@hanifhan1f/vidstack-react 1.12.25 → 1.12.30
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-BalWqr4j.js +1422 -0
- package/dev/chunks/vidstack-CKsUl4ll.js +1384 -0
- package/dev/chunks/vidstack-CqNX679o.js +669 -0
- package/dev/chunks/vidstack-D3ZXOE4d.js +643 -0
- package/dev/chunks/vidstack-DjqYvkVp.js +84 -0
- package/dev/chunks/vidstack-DqaqkU4T.js +9 -0
- package/dev/chunks/vidstack-FuCbl228.js +226 -0
- package/dev/chunks/vidstack-PREbBNMG.js +125 -0
- package/dev/chunks/vidstack-gqKBE4xH.js +376 -0
- package/dev/player/vidstack-default-components.js +9 -8
- package/dev/player/vidstack-default-icons.js +1 -1
- package/dev/player/vidstack-default-layout.js +9 -8
- package/dev/player/vidstack-plyr-layout.js +77 -63
- package/dev/player/vidstack-remotion.js +6 -6
- package/dev/vidstack.js +22 -133
- package/package.json +1 -1
- package/prod/chunks/vidstack-BCBskRpc.js +664 -0
- package/prod/chunks/vidstack-BZVrgeRF.js +9 -0
- package/prod/chunks/vidstack-CKapDFwB.js +376 -0
- package/prod/chunks/vidstack-CYK75vJF.js +1382 -0
- package/prod/chunks/vidstack-CtxjO6HG.js +84 -0
- package/prod/chunks/vidstack-D91K36KQ.js +206 -0
- package/prod/chunks/vidstack-DJThTSEm.js +125 -0
- package/prod/chunks/vidstack-DXSNXDnS.js +1384 -0
- package/prod/chunks/vidstack-DdiGCJVp.js +504 -0
- package/prod/player/vidstack-default-components.js +9 -8
- package/prod/player/vidstack-default-icons.js +1 -1
- package/prod/player/vidstack-default-layout.js +9 -8
- package/prod/player/vidstack-plyr-layout.js +77 -63
- package/prod/player/vidstack-remotion.js +6 -6
- package/prod/vidstack.js +22 -204
- package/server/chunks/vidstack-B4rJ1ZKK.js +376 -0
- package/server/chunks/vidstack-BTdEfKqV.js +84 -0
- package/server/chunks/vidstack-D4t_SZbb.js +1416 -0
- package/server/chunks/vidstack-DOIUveQF.js +504 -0
- package/server/chunks/vidstack-DbNoKLjz.js +664 -0
- package/server/chunks/vidstack-DeS67_gx.js +9 -0
- package/server/chunks/vidstack-DiHlnSws.js +1384 -0
- package/server/chunks/vidstack-DnoqxmOs.js +125 -0
- package/server/chunks/vidstack-SkX-mSrw.js +206 -0
- package/server/player/vidstack-default-components.js +9 -8
- package/server/player/vidstack-default-icons.js +1 -1
- package/server/player/vidstack-default-layout.js +9 -8
- package/server/player/vidstack-plyr-layout.js +77 -63
- package/server/player/vidstack-remotion.js +6 -6
- package/server/vidstack.js +22 -204
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { createReactComponent, composeRefs, listenEvent, useReactScope, scoped, computed, signal, effect, EventsController, useSignal } from './vidstack-D4t_SZbb.js';
|
|
5
|
+
import { MediaAnnouncerInstance, Primitive, ControlsInstance, ControlsGroupInstance, TooltipInstance, TooltipTriggerInstance, TooltipContentInstance, GoogleCastButtonInstance, QualitySliderInstance, AudioGainSliderInstance, SpeedSliderInstance, useMediaState, CaptionsInstance } from './vidstack-SkX-mSrw.js';
|
|
6
|
+
import { sliderCallbacks, Preview, Steps, Thumb, Track as Track$1, TrackFill as TrackFill$1, Value, useMediaContext } from './vidstack-DbNoKLjz.js';
|
|
7
|
+
import { watchActiveTextTrack, formatSpokenTime, formatTime } from 'vidstack';
|
|
8
|
+
|
|
9
|
+
const MediaAnnouncerBridge = createReactComponent(MediaAnnouncerInstance, {
|
|
10
|
+
events: ["onChange"]
|
|
11
|
+
});
|
|
12
|
+
const MediaAnnouncer = React.forwardRef(
|
|
13
|
+
({ style, children, ...props }, forwardRef) => {
|
|
14
|
+
return /* @__PURE__ */ React.createElement(MediaAnnouncerBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
15
|
+
Primitive.div,
|
|
16
|
+
{
|
|
17
|
+
...props2,
|
|
18
|
+
style: { display: "contents", ...style },
|
|
19
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
20
|
+
},
|
|
21
|
+
children
|
|
22
|
+
));
|
|
23
|
+
}
|
|
24
|
+
);
|
|
25
|
+
MediaAnnouncer.displayName = "MediaAnnouncer";
|
|
26
|
+
|
|
27
|
+
const ControlsBridge = createReactComponent(ControlsInstance);
|
|
28
|
+
const Root$5 = React.forwardRef(({ children, ...props }, forwardRef) => {
|
|
29
|
+
return /* @__PURE__ */ React.createElement(ControlsBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
30
|
+
Primitive.div,
|
|
31
|
+
{
|
|
32
|
+
...props2,
|
|
33
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
34
|
+
},
|
|
35
|
+
children
|
|
36
|
+
));
|
|
37
|
+
});
|
|
38
|
+
Root$5.displayName = "Controls";
|
|
39
|
+
const ControlsGroupBridge = createReactComponent(ControlsGroupInstance);
|
|
40
|
+
const Group = React.forwardRef(({ children, ...props }, forwardRef) => {
|
|
41
|
+
return /* @__PURE__ */ React.createElement(ControlsGroupBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
42
|
+
Primitive.div,
|
|
43
|
+
{
|
|
44
|
+
...props2,
|
|
45
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
46
|
+
},
|
|
47
|
+
children
|
|
48
|
+
));
|
|
49
|
+
});
|
|
50
|
+
Group.displayName = "ControlsGroup";
|
|
51
|
+
|
|
52
|
+
var controls = /*#__PURE__*/Object.freeze({
|
|
53
|
+
__proto__: null,
|
|
54
|
+
Group: Group,
|
|
55
|
+
Root: Root$5
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
const TooltipBridge = createReactComponent(TooltipInstance);
|
|
59
|
+
function Root$4({ children, ...props }) {
|
|
60
|
+
return /* @__PURE__ */ React.createElement(TooltipBridge, { ...props }, children);
|
|
61
|
+
}
|
|
62
|
+
Root$4.displayName = "Tooltip";
|
|
63
|
+
const TriggerBridge = createReactComponent(TooltipTriggerInstance);
|
|
64
|
+
const Trigger = React.forwardRef(
|
|
65
|
+
({ children, ...props }, forwardRef) => {
|
|
66
|
+
return /* @__PURE__ */ React.createElement(TriggerBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
67
|
+
Primitive.button,
|
|
68
|
+
{
|
|
69
|
+
...props2,
|
|
70
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
71
|
+
},
|
|
72
|
+
children
|
|
73
|
+
));
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
Trigger.displayName = "TooltipTrigger";
|
|
77
|
+
const ContentBridge = createReactComponent(TooltipContentInstance);
|
|
78
|
+
const Content = React.forwardRef(
|
|
79
|
+
({ children, ...props }, forwardRef) => {
|
|
80
|
+
return /* @__PURE__ */ React.createElement(ContentBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
81
|
+
Primitive.div,
|
|
82
|
+
{
|
|
83
|
+
...props2,
|
|
84
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
85
|
+
},
|
|
86
|
+
children
|
|
87
|
+
));
|
|
88
|
+
}
|
|
89
|
+
);
|
|
90
|
+
Content.displayName = "TooltipContent";
|
|
91
|
+
|
|
92
|
+
var tooltip = /*#__PURE__*/Object.freeze({
|
|
93
|
+
__proto__: null,
|
|
94
|
+
Content: Content,
|
|
95
|
+
Root: Root$4,
|
|
96
|
+
Trigger: Trigger
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
const GoogleCastButtonBridge = createReactComponent(GoogleCastButtonInstance, {
|
|
100
|
+
domEventsRegex: /^onMedia/
|
|
101
|
+
});
|
|
102
|
+
const GoogleCastButton = React.forwardRef(
|
|
103
|
+
({ children, ...props }, forwardRef) => {
|
|
104
|
+
return /* @__PURE__ */ React.createElement(GoogleCastButtonBridge, { ...props }, (props2) => /* @__PURE__ */ React.createElement(
|
|
105
|
+
Primitive.button,
|
|
106
|
+
{
|
|
107
|
+
...props2,
|
|
108
|
+
ref: composeRefs(props2.ref, forwardRef)
|
|
109
|
+
},
|
|
110
|
+
children
|
|
111
|
+
));
|
|
112
|
+
}
|
|
113
|
+
);
|
|
114
|
+
GoogleCastButton.displayName = "GoogleCastButton";
|
|
115
|
+
|
|
116
|
+
const QualitySliderBridge = createReactComponent(QualitySliderInstance, {
|
|
117
|
+
events: sliderCallbacks,
|
|
118
|
+
domEventsRegex: /^onMedia/
|
|
119
|
+
});
|
|
120
|
+
const Root$3 = React.forwardRef(
|
|
121
|
+
({ children, ...props }, forwardRef) => {
|
|
122
|
+
return /* @__PURE__ */ React.createElement(QualitySliderBridge, { ...props, ref: forwardRef }, (props2) => /* @__PURE__ */ React.createElement(Primitive.div, { ...props2 }, children));
|
|
123
|
+
}
|
|
124
|
+
);
|
|
125
|
+
Root$3.displayName = "QualitySlider";
|
|
126
|
+
|
|
127
|
+
var qualitySlider = /*#__PURE__*/Object.freeze({
|
|
128
|
+
__proto__: null,
|
|
129
|
+
Preview: Preview,
|
|
130
|
+
Root: Root$3,
|
|
131
|
+
Steps: Steps,
|
|
132
|
+
Thumb: Thumb,
|
|
133
|
+
Track: Track$1,
|
|
134
|
+
TrackFill: TrackFill$1,
|
|
135
|
+
Value: Value
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const AudioGainSliderBridge = createReactComponent(AudioGainSliderInstance, {
|
|
139
|
+
events: sliderCallbacks,
|
|
140
|
+
domEventsRegex: /^onMedia/
|
|
141
|
+
});
|
|
142
|
+
const Root$2 = React.forwardRef(
|
|
143
|
+
({ children, ...props }, forwardRef) => {
|
|
144
|
+
return /* @__PURE__ */ React.createElement(AudioGainSliderBridge, { ...props, ref: forwardRef }, (props2) => /* @__PURE__ */ React.createElement(Primitive.div, { ...props2 }, children));
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
Root$2.displayName = "AudioGainSlider";
|
|
148
|
+
|
|
149
|
+
var audioGainSlider = /*#__PURE__*/Object.freeze({
|
|
150
|
+
__proto__: null,
|
|
151
|
+
Preview: Preview,
|
|
152
|
+
Root: Root$2,
|
|
153
|
+
Steps: Steps,
|
|
154
|
+
Thumb: Thumb,
|
|
155
|
+
Track: Track$1,
|
|
156
|
+
TrackFill: TrackFill$1,
|
|
157
|
+
Value: Value
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
const SpeedSliderBridge = createReactComponent(SpeedSliderInstance, {
|
|
161
|
+
events: sliderCallbacks,
|
|
162
|
+
domEventsRegex: /^onMedia/
|
|
163
|
+
});
|
|
164
|
+
const Root$1 = React.forwardRef(
|
|
165
|
+
({ children, ...props }, forwardRef) => {
|
|
166
|
+
return /* @__PURE__ */ React.createElement(SpeedSliderBridge, { ...props, ref: forwardRef }, (props2) => /* @__PURE__ */ React.createElement(Primitive.div, { ...props2 }, children));
|
|
167
|
+
}
|
|
168
|
+
);
|
|
169
|
+
Root$1.displayName = "SpeedSlider";
|
|
170
|
+
|
|
171
|
+
var speedSlider = /*#__PURE__*/Object.freeze({
|
|
172
|
+
__proto__: null,
|
|
173
|
+
Preview: Preview,
|
|
174
|
+
Root: Root$1,
|
|
175
|
+
Steps: Steps,
|
|
176
|
+
Thumb: Thumb,
|
|
177
|
+
Track: Track$1,
|
|
178
|
+
TrackFill: TrackFill$1,
|
|
179
|
+
Value: Value
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
const Title = React.forwardRef(({ children, ...props }, forwardRef) => {
|
|
183
|
+
const $title = useMediaState("title");
|
|
184
|
+
return /* @__PURE__ */ React.createElement(Primitive.span, { ...props, ref: forwardRef }, $title, children);
|
|
185
|
+
});
|
|
186
|
+
Title.displayName = "Title";
|
|
187
|
+
|
|
188
|
+
function useActiveTextCues(track) {
|
|
189
|
+
const [activeCues, setActiveCues] = React.useState([]);
|
|
190
|
+
React.useEffect(() => {
|
|
191
|
+
if (!track) {
|
|
192
|
+
setActiveCues([]);
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
function onCuesChange() {
|
|
196
|
+
if (track) setActiveCues(track.activeCues);
|
|
197
|
+
}
|
|
198
|
+
onCuesChange();
|
|
199
|
+
return listenEvent(track, "cue-change", onCuesChange);
|
|
200
|
+
}, [track]);
|
|
201
|
+
return activeCues;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function useActiveTextTrack(kind) {
|
|
205
|
+
const media = useMediaContext(), [track, setTrack] = React.useState(null);
|
|
206
|
+
React.useEffect(() => {
|
|
207
|
+
return watchActiveTextTrack(media.textTracks, kind, setTrack);
|
|
208
|
+
}, [kind]);
|
|
209
|
+
return track;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function useChapterTitle() {
|
|
213
|
+
const $track = useActiveTextTrack("chapters"), $cues = useActiveTextCues($track);
|
|
214
|
+
return $cues[0]?.text || "";
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const ChapterTitle = React.forwardRef(
|
|
218
|
+
({ defaultText = "", children, ...props }, forwardRef) => {
|
|
219
|
+
const $chapterTitle = useChapterTitle();
|
|
220
|
+
return /* @__PURE__ */ React.createElement(Primitive.span, { ...props, ref: forwardRef }, $chapterTitle || defaultText, children);
|
|
221
|
+
}
|
|
222
|
+
);
|
|
223
|
+
ChapterTitle.displayName = "ChapterTitle";
|
|
224
|
+
|
|
225
|
+
const CaptionsBridge = createReactComponent(CaptionsInstance);
|
|
226
|
+
const Captions = React.forwardRef(
|
|
227
|
+
({ children, ...props }, forwardRef) => {
|
|
228
|
+
return /* @__PURE__ */ React.createElement(CaptionsBridge, { ...props, ref: forwardRef }, (props2) => /* @__PURE__ */ React.createElement(Primitive.div, { ...props2 }, children));
|
|
229
|
+
}
|
|
230
|
+
);
|
|
231
|
+
Captions.displayName = "Captions";
|
|
232
|
+
|
|
233
|
+
const Root = React.forwardRef(
|
|
234
|
+
({ size = 96, children, ...props }, forwardRef) => {
|
|
235
|
+
return /* @__PURE__ */ React.createElement(
|
|
236
|
+
"svg",
|
|
237
|
+
{
|
|
238
|
+
width: size,
|
|
239
|
+
height: size,
|
|
240
|
+
fill: "none",
|
|
241
|
+
viewBox: "0 0 120 120",
|
|
242
|
+
"aria-hidden": "true",
|
|
243
|
+
"data-part": "root",
|
|
244
|
+
...props,
|
|
245
|
+
ref: forwardRef
|
|
246
|
+
},
|
|
247
|
+
children
|
|
248
|
+
);
|
|
249
|
+
}
|
|
250
|
+
);
|
|
251
|
+
const Track = React.forwardRef(
|
|
252
|
+
({ width = 8, children, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
253
|
+
"circle",
|
|
254
|
+
{
|
|
255
|
+
cx: "60",
|
|
256
|
+
cy: "60",
|
|
257
|
+
r: "54",
|
|
258
|
+
stroke: "currentColor",
|
|
259
|
+
strokeWidth: width,
|
|
260
|
+
"data-part": "track",
|
|
261
|
+
...props,
|
|
262
|
+
ref
|
|
263
|
+
},
|
|
264
|
+
children
|
|
265
|
+
)
|
|
266
|
+
);
|
|
267
|
+
const TrackFill = React.forwardRef(
|
|
268
|
+
({ width = 8, fillPercent = 50, children, ...props }, ref) => /* @__PURE__ */ React.createElement(
|
|
269
|
+
"circle",
|
|
270
|
+
{
|
|
271
|
+
cx: "60",
|
|
272
|
+
cy: "60",
|
|
273
|
+
r: "54",
|
|
274
|
+
stroke: "currentColor",
|
|
275
|
+
pathLength: "100",
|
|
276
|
+
strokeWidth: width,
|
|
277
|
+
strokeDasharray: 100,
|
|
278
|
+
strokeDashoffset: 100 - fillPercent,
|
|
279
|
+
"data-part": "track-fill",
|
|
280
|
+
...props,
|
|
281
|
+
ref
|
|
282
|
+
},
|
|
283
|
+
children
|
|
284
|
+
)
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
var spinner = /*#__PURE__*/Object.freeze({
|
|
288
|
+
__proto__: null,
|
|
289
|
+
Root: Root,
|
|
290
|
+
Track: Track,
|
|
291
|
+
TrackFill: TrackFill
|
|
292
|
+
});
|
|
293
|
+
|
|
294
|
+
function createSignal(initialValue, deps = []) {
|
|
295
|
+
const scope = useReactScope();
|
|
296
|
+
return React.useMemo(() => scoped(() => signal(initialValue), scope), [scope, ...deps]);
|
|
297
|
+
}
|
|
298
|
+
function createComputed(compute, deps = []) {
|
|
299
|
+
const scope = useReactScope();
|
|
300
|
+
return React.useMemo(() => scoped(() => computed(compute), scope), [scope, ...deps]);
|
|
301
|
+
}
|
|
302
|
+
function createEffect(compute, deps = []) {
|
|
303
|
+
const scope = useReactScope();
|
|
304
|
+
React.useEffect(() => scoped(() => effect(compute), scope), [scope, ...deps]);
|
|
305
|
+
}
|
|
306
|
+
function useScoped(compute) {
|
|
307
|
+
const scope = useReactScope();
|
|
308
|
+
return React.useMemo(() => scoped(compute, scope), [scope]);
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function useTextCues(track) {
|
|
312
|
+
const [cues, setCues] = React.useState([]);
|
|
313
|
+
React.useEffect(() => {
|
|
314
|
+
if (!track) return;
|
|
315
|
+
function onCuesChange() {
|
|
316
|
+
if (track) setCues([...track.cues]);
|
|
317
|
+
}
|
|
318
|
+
const events = new EventsController(track).add("add-cue", onCuesChange).add("remove-cue", onCuesChange);
|
|
319
|
+
onCuesChange();
|
|
320
|
+
return () => {
|
|
321
|
+
setCues([]);
|
|
322
|
+
events.abort();
|
|
323
|
+
};
|
|
324
|
+
}, [track]);
|
|
325
|
+
return cues;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function useChapterOptions() {
|
|
329
|
+
const media = useMediaContext(), track = useActiveTextTrack("chapters"), cues = useTextCues(track), $startTime = useSignal(media.$state.seekableStart), $endTime = useSignal(media.$state.seekableEnd);
|
|
330
|
+
useActiveTextCues(track);
|
|
331
|
+
return React.useMemo(() => {
|
|
332
|
+
const options = track ? cues.filter((cue) => cue.startTime <= $endTime && cue.endTime >= $startTime).map((cue, i) => {
|
|
333
|
+
let currentRef = null, stopProgressEffect;
|
|
334
|
+
return {
|
|
335
|
+
cue,
|
|
336
|
+
label: cue.text,
|
|
337
|
+
value: i.toString(),
|
|
338
|
+
startTimeText: formatTime(Math.max(0, cue.startTime - $startTime)),
|
|
339
|
+
durationText: formatSpokenTime(
|
|
340
|
+
Math.min($endTime, cue.endTime) - Math.max($startTime, cue.startTime)
|
|
341
|
+
),
|
|
342
|
+
get selected() {
|
|
343
|
+
return cue === track.activeCues[0];
|
|
344
|
+
},
|
|
345
|
+
setProgressVar(ref) {
|
|
346
|
+
if (!ref || cue !== track.activeCues[0]) {
|
|
347
|
+
stopProgressEffect?.();
|
|
348
|
+
stopProgressEffect = void 0;
|
|
349
|
+
ref?.style.setProperty("--progress", "0%");
|
|
350
|
+
currentRef = null;
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
if (currentRef === ref) return;
|
|
354
|
+
currentRef = ref;
|
|
355
|
+
stopProgressEffect?.();
|
|
356
|
+
stopProgressEffect = effect(() => {
|
|
357
|
+
const { realCurrentTime } = media.$state, time = realCurrentTime(), cueStartTime = Math.max($startTime, cue.startTime), duration = Math.min($endTime, cue.endTime) - cueStartTime, progress = Math.max(0, time - cueStartTime) / duration * 100;
|
|
358
|
+
ref.style.setProperty("--progress", progress.toFixed(3) + "%");
|
|
359
|
+
});
|
|
360
|
+
},
|
|
361
|
+
select(trigger) {
|
|
362
|
+
media.remote.seek(cue.startTime - $startTime, trigger);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
}) : [];
|
|
366
|
+
Object.defineProperty(options, "selectedValue", {
|
|
367
|
+
get() {
|
|
368
|
+
const index = options.findIndex((option) => option.selected);
|
|
369
|
+
return (index >= 0 ? index : 0).toString();
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
return options;
|
|
373
|
+
}, [cues, $startTime, $endTime]);
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
export { Captions, ChapterTitle, Content, GoogleCastButton, Group, MediaAnnouncer, Root$4 as Root, Root$2 as Root$1, Root$1 as Root$2, Root$3, Root$5 as Root$4, Root as Root$5, Title, Track, TrackFill, Trigger, audioGainSlider, controls, createComputed, createEffect, createSignal, qualitySlider, speedSlider, spinner, tooltip, useActiveTextCues, useActiveTextTrack, useChapterOptions, useChapterTitle, useScoped, useTextCues };
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use client"
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { listenEvent, EventsController, animationFrameThrottle, effect } from './vidstack-D4t_SZbb.js';
|
|
5
|
+
import { useMediaPlayer } from './vidstack-DbNoKLjz.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 };
|