@locpd/vidstack 1.12.14
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/LICENSE +21 -0
- package/README.md +22 -0
- package/analyze.json.d.ts +8 -0
- package/bundle.d.ts +1 -0
- package/cdn/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/chunks/vidstack-BYgY9wmd.js +1 -0
- package/cdn/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/chunks/vidstack-Bjo5esRp.js +1 -0
- package/cdn/chunks/vidstack-BuL67v3q.js +1 -0
- package/cdn/chunks/vidstack-C0msPRTd.js +3 -0
- package/cdn/chunks/vidstack-CJNLoJPa.js +1 -0
- package/cdn/chunks/vidstack-CQSpZ7X8.js +16 -0
- package/cdn/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/chunks/vidstack-CioT3Yw2.js +1 -0
- package/cdn/chunks/vidstack-CrqkytHl.js +1 -0
- package/cdn/chunks/vidstack-D0M8R0ZU.js +1 -0
- package/cdn/chunks/vidstack-D40FSa5B.js +3 -0
- package/cdn/chunks/vidstack-DD2JwFVU.js +1 -0
- package/cdn/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/chunks/vidstack-DfDZuHNP.js +1 -0
- package/cdn/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/chunks/vidstack-xjJ-ui_l.js +1 -0
- package/cdn/providers/vidstack-audio-2Dt_Ivbp.js +1 -0
- package/cdn/providers/vidstack-dash-CUtD4e6q.js +1 -0
- package/cdn/providers/vidstack-google-cast-BdORATUX.js +1 -0
- package/cdn/providers/vidstack-hls-R25Kb6DP.js +1 -0
- package/cdn/providers/vidstack-html-DaAUJYsD.js +1 -0
- package/cdn/providers/vidstack-video-Csvox7SO.js +1 -0
- package/cdn/providers/vidstack-vimeo-D4Z96kg2.js +1 -0
- package/cdn/providers/vidstack-youtube-DiND6h3s.js +1 -0
- package/cdn/vidstack.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-2f5gzOW6.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-45yH5los.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BBVMdOnf.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BB_ulI_T.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BcAewM33.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-BfBBPhXV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Bxv1Qnxe.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C2ZbG62f.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-CCYIOKgL.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CL6PeIO1.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-C_AxqLKV.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-CifDkwDH.js +795 -0
- package/cdn/with-layouts/chunks/vidstack-Cry7aD59.js +3 -0
- package/cdn/with-layouts/chunks/vidstack-D065okCn.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DGuMoXmI.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DRH_1tFW.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DVBs1XoQ.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-Dge3KT8k.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-DiNS2Vx5.js +1 -0
- package/cdn/with-layouts/chunks/vidstack-HvYfJoen.js +1 -0
- package/cdn/with-layouts/providers/vidstack-audio-DE5vKIzW.js +1 -0
- package/cdn/with-layouts/providers/vidstack-dash-CA2agUuZ.js +1 -0
- package/cdn/with-layouts/providers/vidstack-google-cast-CGs-t8HM.js +1 -0
- package/cdn/with-layouts/providers/vidstack-hls-BHMbMFFR.js +1 -0
- package/cdn/with-layouts/providers/vidstack-html-Dm9gmNk6.js +1 -0
- package/cdn/with-layouts/providers/vidstack-video-C5it_Lbl.js +1 -0
- package/cdn/with-layouts/providers/vidstack-vimeo-BabLn9sy.js +1 -0
- package/cdn/with-layouts/providers/vidstack-youtube-D8UlccUL.js +1 -0
- package/cdn/with-layouts/vidstack.js +1 -0
- package/dev/chunks/vidstack-B7Zi3v_O.js +104 -0
- package/dev/chunks/vidstack-BFg1ZqiG.js +91 -0
- package/dev/chunks/vidstack-BGB2pa9s.js +58 -0
- package/dev/chunks/vidstack-BaIbHZE3.js +1519 -0
- package/dev/chunks/vidstack-Bb2rASIc.js +5188 -0
- package/dev/chunks/vidstack-Bcmx8pmK.js +224 -0
- package/dev/chunks/vidstack-Bl4b0Nen.js +29 -0
- package/dev/chunks/vidstack-Bo5OTJ06.js +58 -0
- package/dev/chunks/vidstack-BoAGnlRt.js +58 -0
- package/dev/chunks/vidstack-Bpr4fI4n.js +7 -0
- package/dev/chunks/vidstack-Bt8MP2DK.js +204 -0
- package/dev/chunks/vidstack-Bu2kfzUd.js +1637 -0
- package/dev/chunks/vidstack-C-ffXlSV.js +2995 -0
- package/dev/chunks/vidstack-C-ztJq-f.js +109 -0
- package/dev/chunks/vidstack-CFNlaVTR.js +55 -0
- package/dev/chunks/vidstack-C_l97D5j.js +254 -0
- package/dev/chunks/vidstack-CjhKISI0.js +114 -0
- package/dev/chunks/vidstack-CofXIJAy.js +57 -0
- package/dev/chunks/vidstack-CwTj4H1w.js +18 -0
- package/dev/chunks/vidstack-DDwbYVHV.js +66 -0
- package/dev/chunks/vidstack-DFImIcIL.js +11 -0
- package/dev/chunks/vidstack-DGDvUbvO.js +33 -0
- package/dev/chunks/vidstack-DO0kqA99.js +107 -0
- package/dev/chunks/vidstack-DXxIKXmd.js +50 -0
- package/dev/chunks/vidstack-DajrMUR0.js +297 -0
- package/dev/chunks/vidstack-DbBJlz7I.js +10 -0
- package/dev/chunks/vidstack-Dihypf8P.js +11 -0
- package/dev/chunks/vidstack-DlAhl87f.js +1193 -0
- package/dev/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/dev/chunks/vidstack-Dv_LIPFu.js +14 -0
- package/dev/chunks/vidstack-igYn0Apa.js +254 -0
- package/dev/chunks/vidstack-krOAtKMi.js +32 -0
- package/dev/chunks/vidstack-qh1N5_f_.js +26 -0
- package/dev/chunks/vidstack-rB-wqXw1.js +107 -0
- package/dev/chunks/vidstack-zG6PIeGg.js +66 -0
- package/dev/define/plyr-layout.js +51 -0
- package/dev/define/templates/plyr-layout.js +571 -0
- package/dev/define/templates/vidstack-audio-layout.js +167 -0
- package/dev/define/templates/vidstack-video-layout.js +390 -0
- package/dev/define/vidstack-icons.js +1 -0
- package/dev/define/vidstack-player-default-layout.js +21 -0
- package/dev/define/vidstack-player-layouts.js +25 -0
- package/dev/define/vidstack-player-ui.js +70 -0
- package/dev/define/vidstack-player.js +19 -0
- package/dev/global/plyr.js +501 -0
- package/dev/global/vidstack-player.js +129 -0
- package/dev/providers/vidstack-audio.js +35 -0
- package/dev/providers/vidstack-dash.js +516 -0
- package/dev/providers/vidstack-google-cast.js +474 -0
- package/dev/providers/vidstack-hls.js +408 -0
- package/dev/providers/vidstack-html.js +567 -0
- package/dev/providers/vidstack-video.js +207 -0
- package/dev/providers/vidstack-vimeo.js +554 -0
- package/dev/providers/vidstack-youtube.js +286 -0
- package/dev/vidstack-elements.js +36 -0
- package/dev/vidstack.js +91 -0
- package/dom.d.ts +91 -0
- package/elements.d.ts +1433 -0
- package/empty.vtt +1 -0
- package/global/player.d.ts +52 -0
- package/global/plyr.d.ts +343 -0
- package/google-cast.d.ts +1422 -0
- package/icons.d.ts +1 -0
- package/index.d.ts +402 -0
- package/package.json +199 -0
- package/player/index.d.ts +3 -0
- package/player/layouts/default.d.ts +3 -0
- package/player/layouts/index.d.ts +3 -0
- package/player/layouts/plyr.d.ts +3 -0
- package/player/styles/base.css +153 -0
- package/player/styles/default/buffering.css +55 -0
- package/player/styles/default/buttons.css +175 -0
- package/player/styles/default/captions.css +181 -0
- package/player/styles/default/chapter-title.css +26 -0
- package/player/styles/default/controls.css +56 -0
- package/player/styles/default/gestures.css +19 -0
- package/player/styles/default/icons.css +6 -0
- package/player/styles/default/keyboard.css +148 -0
- package/player/styles/default/layouts/audio.css +417 -0
- package/player/styles/default/layouts/video.css +590 -0
- package/player/styles/default/menus.css +959 -0
- package/player/styles/default/poster.css +52 -0
- package/player/styles/default/sliders.css +391 -0
- package/player/styles/default/theme.css +2461 -0
- package/player/styles/default/thumbnail.css +40 -0
- package/player/styles/default/time.css +45 -0
- package/player/styles/default/tooltips.css +141 -0
- package/player/styles/plyr/theme.css +1237 -0
- package/player/ui.d.ts +3 -0
- package/plugins.d.ts +19 -0
- package/plugins.js +13 -0
- package/prod/chunks/vidstack-B01xzxC4.js +7 -0
- package/prod/chunks/vidstack-BCeb7ryV.js +201 -0
- package/prod/chunks/vidstack-BGSTndAW.js +1590 -0
- package/prod/chunks/vidstack-BPitBBjh.js +1519 -0
- package/prod/chunks/vidstack-BQlOPwOu.js +45 -0
- package/prod/chunks/vidstack-BSDzlwxO.js +4778 -0
- package/prod/chunks/vidstack-BT0m6zEi.js +109 -0
- package/prod/chunks/vidstack-BTigPj2h.js +55 -0
- package/prod/chunks/vidstack-BiyXcJ_M.js +107 -0
- package/prod/chunks/vidstack-BoVf5n1M.js +2985 -0
- package/prod/chunks/vidstack-Bq6c3Bam.js +58 -0
- package/prod/chunks/vidstack-ByLCIBtB.js +297 -0
- package/prod/chunks/vidstack-C2US-gSO.js +248 -0
- package/prod/chunks/vidstack-C9vIqaYT.js +10 -0
- package/prod/chunks/vidstack-CF6fixCQ.js +1193 -0
- package/prod/chunks/vidstack-CTojmhKq.js +66 -0
- package/prod/chunks/vidstack-ChQTHmIQ.js +77 -0
- package/prod/chunks/vidstack-Cm6_unwd.js +246 -0
- package/prod/chunks/vidstack-CwTj4H1w.js +18 -0
- package/prod/chunks/vidstack-D3ltXc3a.js +33 -0
- package/prod/chunks/vidstack-D5EzK014.js +14 -0
- package/prod/chunks/vidstack-DDXt6fpN.js +58 -0
- package/prod/chunks/vidstack-DJDnh4xT.js +11 -0
- package/prod/chunks/vidstack-DXxIKXmd.js +50 -0
- package/prod/chunks/vidstack-D_-9AA6_.js +29 -0
- package/prod/chunks/vidstack-DbkZGjSn.js +107 -0
- package/prod/chunks/vidstack-Dihypf8P.js +11 -0
- package/prod/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/prod/chunks/vidstack-Dq5Yu0Vr.js +205 -0
- package/prod/chunks/vidstack-DqAw8m9J.js +26 -0
- package/prod/chunks/vidstack-DsPOyKtl.js +57 -0
- package/prod/chunks/vidstack-krOAtKMi.js +32 -0
- package/prod/chunks/vidstack-nLyr4NEP.js +58 -0
- package/prod/chunks/vidstack-xMS8dnYq.js +114 -0
- package/prod/chunks/vidstack-yEGTpgeA.js +104 -0
- package/prod/define/plyr-layout.js +51 -0
- package/prod/define/templates/plyr-layout.js +571 -0
- package/prod/define/templates/vidstack-audio-layout.js +167 -0
- package/prod/define/templates/vidstack-video-layout.js +390 -0
- package/prod/define/vidstack-icons.js +1 -0
- package/prod/define/vidstack-player-default-layout.js +21 -0
- package/prod/define/vidstack-player-layouts.js +25 -0
- package/prod/define/vidstack-player-ui.js +70 -0
- package/prod/define/vidstack-player.js +19 -0
- package/prod/global/plyr.js +493 -0
- package/prod/global/vidstack-player.js +129 -0
- package/prod/providers/vidstack-audio.js +35 -0
- package/prod/providers/vidstack-dash.js +501 -0
- package/prod/providers/vidstack-google-cast.js +468 -0
- package/prod/providers/vidstack-hls.js +393 -0
- package/prod/providers/vidstack-html.js +555 -0
- package/prod/providers/vidstack-video.js +204 -0
- package/prod/providers/vidstack-vimeo.js +548 -0
- package/prod/providers/vidstack-youtube.js +286 -0
- package/prod/vidstack-elements.js +36 -0
- package/prod/vidstack.js +158 -0
- package/server/chunks/vidstack-6juFdkKy.js +29 -0
- package/server/chunks/vidstack-B7iHmv7_.js +307 -0
- package/server/chunks/vidstack-BmxyML9v.js +1619 -0
- package/server/chunks/vidstack-BskfxwD3.js +566 -0
- package/server/chunks/vidstack-BvLV0SMz.js +4642 -0
- package/server/chunks/vidstack-BvWwluXZ.js +205 -0
- package/server/chunks/vidstack-C-413dj2.js +8 -0
- package/server/chunks/vidstack-C26K8z_-.js +55 -0
- package/server/chunks/vidstack-CJJiksDz.js +107 -0
- package/server/chunks/vidstack-CUNv52x1.js +141 -0
- package/server/chunks/vidstack-CqyBCODe.js +295 -0
- package/server/chunks/vidstack-CwTj4H1w.js +18 -0
- package/server/chunks/vidstack-DHAyGSOl.js +1502 -0
- package/server/chunks/vidstack-DLU3cjcp.js +381 -0
- package/server/chunks/vidstack-DXxIKXmd.js +50 -0
- package/server/chunks/vidstack-DbtDXDS2.js +104 -0
- package/server/chunks/vidstack-Dm1xEU9Q.js +34 -0
- package/server/chunks/vidstack-DzTHw_bw.js +207 -0
- package/server/chunks/vidstack-Wn3NH5Sg.js +1566 -0
- package/server/chunks/vidstack-krOAtKMi.js +32 -0
- package/server/chunks/vidstack-wNViAkr4.js +3045 -0
- package/server/define/plyr-layout.js +16 -0
- package/server/define/vidstack-icons.js +1 -0
- package/server/define/vidstack-player-default-layout.js +13 -0
- package/server/define/vidstack-player-layouts.js +16 -0
- package/server/define/vidstack-player-ui.js +11 -0
- package/server/define/vidstack-player.js +6 -0
- package/server/global/plyr.js +322 -0
- package/server/global/vidstack-player.js +58 -0
- package/server/vidstack-elements.js +46 -0
- package/server/vidstack.js +148 -0
- package/tailwind.cjs +101 -0
- package/tailwind.d.cts +15 -0
- package/types/vidstack-BOvzfZjK.d.ts +1269 -0
- package/types/vidstack-Cttpg6GU.d.ts +7474 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { signal, effect, listenEvent, EventsController } from './vidstack-BGSTndAW.js';
|
|
2
|
+
import './vidstack-xMS8dnYq.js';
|
|
3
|
+
|
|
4
|
+
class HTMLRemotePlaybackAdapter {
|
|
5
|
+
#media;
|
|
6
|
+
#ctx;
|
|
7
|
+
#state;
|
|
8
|
+
#supported = signal(false);
|
|
9
|
+
get supported() {
|
|
10
|
+
return this.#supported();
|
|
11
|
+
}
|
|
12
|
+
constructor(media, ctx) {
|
|
13
|
+
this.#media = media;
|
|
14
|
+
this.#ctx = ctx;
|
|
15
|
+
this.#setup();
|
|
16
|
+
}
|
|
17
|
+
#setup() {
|
|
18
|
+
if (!this.#media?.remote || !this.canPrompt) return;
|
|
19
|
+
this.#media.remote.watchAvailability((available) => {
|
|
20
|
+
this.#supported.set(available);
|
|
21
|
+
}).catch(() => {
|
|
22
|
+
this.#supported.set(false);
|
|
23
|
+
});
|
|
24
|
+
effect(this.#watchSupported.bind(this));
|
|
25
|
+
}
|
|
26
|
+
#watchSupported() {
|
|
27
|
+
if (!this.#supported()) return;
|
|
28
|
+
const events = ["connecting", "connect", "disconnect"], onStateChange = this.#onStateChange.bind(this);
|
|
29
|
+
onStateChange();
|
|
30
|
+
listenEvent(this.#media, "playing", onStateChange);
|
|
31
|
+
const remoteEvents = new EventsController(this.#media.remote);
|
|
32
|
+
for (const type of events) {
|
|
33
|
+
remoteEvents.add(type, onStateChange);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
async prompt() {
|
|
37
|
+
if (!this.supported) throw Error("Not supported on this platform.");
|
|
38
|
+
if (this.type === "airplay" && this.#media.webkitShowPlaybackTargetPicker) {
|
|
39
|
+
return this.#media.webkitShowPlaybackTargetPicker();
|
|
40
|
+
}
|
|
41
|
+
return this.#media.remote.prompt();
|
|
42
|
+
}
|
|
43
|
+
#onStateChange(event) {
|
|
44
|
+
const state = this.#media.remote.state;
|
|
45
|
+
if (state === this.#state) return;
|
|
46
|
+
const detail = { type: this.type, state };
|
|
47
|
+
this.#ctx.notify("remote-playback-change", detail, event);
|
|
48
|
+
this.#state = state;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
class HTMLAirPlayAdapter extends HTMLRemotePlaybackAdapter {
|
|
52
|
+
type = "airplay";
|
|
53
|
+
get canPrompt() {
|
|
54
|
+
return "WebKitPlaybackTargetAvailabilityEvent" in window;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export { HTMLAirPlayAdapter };
|
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { Host, effect, Component, signal, setAttribute, isBoolean, computed, isString, useState } from './vidstack-BGSTndAW.js';
|
|
2
|
+
import { Captions, Gesture, MediaAnnouncer, Controls, ControlsGroup, GoogleCastButton, ToggleButton, Tooltip, TooltipTrigger, TooltipContent, ChaptersRadioGroup, AudioGainRadioGroup, RadioGroup, SliderVideo, AudioGainSlider, SpeedSlider, QualitySlider, SliderChapters } from './vidstack-BPitBBjh.js';
|
|
3
|
+
import { useMediaContext } from './vidstack-DJDnh4xT.js';
|
|
4
|
+
import { watchCueTextChange } from './vidstack-nLyr4NEP.js';
|
|
5
|
+
import { html } from 'lit-html';
|
|
6
|
+
import { requestScopedAnimationFrame, isHTMLElement, cloneTemplateContent, createTemplate, cloneTemplate } from './vidstack-C2US-gSO.js';
|
|
7
|
+
import { LitElement } from './vidstack-CwTj4H1w.js';
|
|
8
|
+
import { MenuPortal, Slider, sliderState } from './vidstack-BoVf5n1M.js';
|
|
9
|
+
import { renderMenuItemsTemplate } from './vidstack-BCeb7ryV.js';
|
|
10
|
+
|
|
11
|
+
class MediaCaptionsElement extends Host(HTMLElement, Captions) {
|
|
12
|
+
static tagName = "media-captions";
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class MediaGestureElement extends Host(HTMLElement, Gesture) {
|
|
16
|
+
static tagName = "media-gesture";
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
class MediaAnnouncerElement extends Host(HTMLElement, MediaAnnouncer) {
|
|
20
|
+
static tagName = "media-announcer";
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
class MediaControlsElement extends Host(HTMLElement, Controls) {
|
|
24
|
+
static tagName = "media-controls";
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
class MediaControlsGroupElement extends Host(HTMLElement, ControlsGroup) {
|
|
28
|
+
static tagName = "media-controls-group";
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
class Title extends Component {
|
|
32
|
+
}
|
|
33
|
+
class MediaTitleElement extends Host(HTMLElement, Title) {
|
|
34
|
+
static tagName = "media-title";
|
|
35
|
+
#media;
|
|
36
|
+
onSetup() {
|
|
37
|
+
this.#media = useMediaContext();
|
|
38
|
+
}
|
|
39
|
+
onConnect() {
|
|
40
|
+
effect(this.#watchTitle.bind(this));
|
|
41
|
+
}
|
|
42
|
+
#watchTitle() {
|
|
43
|
+
const { title } = this.#media.$state;
|
|
44
|
+
this.textContent = title();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
class ChapterTitle extends Component {
|
|
49
|
+
static props = {
|
|
50
|
+
defaultText: ""
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
class MediaChapterTitleElement extends Host(HTMLElement, ChapterTitle) {
|
|
54
|
+
static tagName = "media-chapter-title";
|
|
55
|
+
#media;
|
|
56
|
+
#chapterTitle;
|
|
57
|
+
onSetup() {
|
|
58
|
+
this.#media = useMediaContext();
|
|
59
|
+
this.#chapterTitle = signal("");
|
|
60
|
+
}
|
|
61
|
+
onConnect() {
|
|
62
|
+
const tracks = this.#media.textTracks;
|
|
63
|
+
watchCueTextChange(tracks, "chapters", this.#chapterTitle.set);
|
|
64
|
+
effect(this.#watchChapterTitle.bind(this));
|
|
65
|
+
}
|
|
66
|
+
#watchChapterTitle() {
|
|
67
|
+
const { defaultText } = this.$props;
|
|
68
|
+
this.textContent = this.#chapterTitle() || defaultText();
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
class Spinner extends Component {
|
|
73
|
+
static props = {
|
|
74
|
+
size: 96,
|
|
75
|
+
trackWidth: 8,
|
|
76
|
+
fillPercent: 50
|
|
77
|
+
};
|
|
78
|
+
onConnect(el) {
|
|
79
|
+
requestScopedAnimationFrame(() => {
|
|
80
|
+
if (!this.connectScope) return;
|
|
81
|
+
const root = el.querySelector("svg"), track = root.firstElementChild, trackFill = track.nextElementSibling;
|
|
82
|
+
effect(this.#update.bind(this, root, track, trackFill));
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
#update(root, track, trackFill) {
|
|
86
|
+
const { size, trackWidth, fillPercent } = this.$props;
|
|
87
|
+
setAttribute(root, "width", size());
|
|
88
|
+
setAttribute(root, "height", size());
|
|
89
|
+
setAttribute(track, "stroke-width", trackWidth());
|
|
90
|
+
setAttribute(trackFill, "stroke-width", trackWidth());
|
|
91
|
+
setAttribute(trackFill, "stroke-dashoffset", 100 - fillPercent());
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
class MediaSpinnerElement extends Host(LitElement, Spinner) {
|
|
95
|
+
static tagName = "media-spinner";
|
|
96
|
+
render() {
|
|
97
|
+
return html`
|
|
98
|
+
<svg fill="none" viewBox="0 0 120 120" aria-hidden="true" data-part="root">
|
|
99
|
+
<circle cx="60" cy="60" r="54" stroke="currentColor" data-part="track"></circle>
|
|
100
|
+
<circle
|
|
101
|
+
cx="60"
|
|
102
|
+
cy="60"
|
|
103
|
+
r="54"
|
|
104
|
+
stroke="currentColor"
|
|
105
|
+
pathLength="100"
|
|
106
|
+
stroke-dasharray="100"
|
|
107
|
+
data-part="track-fill"
|
|
108
|
+
></circle>
|
|
109
|
+
</svg>
|
|
110
|
+
`;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
class MediaLayout extends Component {
|
|
115
|
+
static props = {
|
|
116
|
+
when: false
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
class MediaLayoutElement extends Host(HTMLElement, MediaLayout) {
|
|
120
|
+
static tagName = "media-layout";
|
|
121
|
+
#media;
|
|
122
|
+
onSetup() {
|
|
123
|
+
this.#media = useMediaContext();
|
|
124
|
+
}
|
|
125
|
+
onConnect() {
|
|
126
|
+
effect(this.#watchWhen.bind(this));
|
|
127
|
+
}
|
|
128
|
+
#watchWhen() {
|
|
129
|
+
const root = this.firstElementChild, isTemplate = root?.localName === "template", when = this.$props.when(), matches = isBoolean(when) ? when : computed(() => when(this.#media.player.state))();
|
|
130
|
+
if (!matches) {
|
|
131
|
+
if (isTemplate) {
|
|
132
|
+
this.textContent = "";
|
|
133
|
+
this.appendChild(root);
|
|
134
|
+
} else if (isHTMLElement(root)) {
|
|
135
|
+
root.style.display = "none";
|
|
136
|
+
}
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (isTemplate) {
|
|
140
|
+
this.append(root.content.cloneNode(true));
|
|
141
|
+
} else if (isHTMLElement(root)) {
|
|
142
|
+
root.style.display = "";
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
class MediaGoogleCastButtonElement extends Host(HTMLElement, GoogleCastButton) {
|
|
148
|
+
static tagName = "media-google-cast-button";
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
class MediaToggleButtonElement extends Host(HTMLElement, ToggleButton) {
|
|
152
|
+
static tagName = "media-toggle-button";
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
class MediaTooltipElement extends Host(HTMLElement, Tooltip) {
|
|
156
|
+
static tagName = "media-tooltip";
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class MediaTooltipTriggerElement extends Host(HTMLElement, TooltipTrigger) {
|
|
160
|
+
static tagName = "media-tooltip-trigger";
|
|
161
|
+
onConnect() {
|
|
162
|
+
this.style.display = "contents";
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
class MediaTooltipContentElement extends Host(HTMLElement, TooltipContent) {
|
|
167
|
+
static tagName = "media-tooltip-content";
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
class MediaMenuPortalElement extends Host(HTMLElement, MenuPortal) {
|
|
171
|
+
static tagName = "media-menu-portal";
|
|
172
|
+
static attrs = {
|
|
173
|
+
disabled: {
|
|
174
|
+
converter(value) {
|
|
175
|
+
if (isString(value)) return value;
|
|
176
|
+
return value !== null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
class MediaChaptersRadioGroupElement extends Host(HTMLElement, ChaptersRadioGroup) {
|
|
183
|
+
static tagName = "media-chapters-radio-group";
|
|
184
|
+
onConnect() {
|
|
185
|
+
renderMenuItemsTemplate(this, (el, option) => {
|
|
186
|
+
const { cue, startTime, duration } = option, thumbnailEl = el.querySelector(".vds-thumbnail,media-thumbnail"), startEl = el.querySelector('[data-part="start-time"]'), durationEl = el.querySelector('[data-part="duration"]');
|
|
187
|
+
if (startEl) startEl.textContent = startTime;
|
|
188
|
+
if (durationEl) durationEl.textContent = duration;
|
|
189
|
+
if (thumbnailEl) {
|
|
190
|
+
thumbnailEl.setAttribute("time", cue.startTime + "");
|
|
191
|
+
effect(() => {
|
|
192
|
+
const thumbnails = this.$props.thumbnails();
|
|
193
|
+
if ("src" in thumbnailEl) {
|
|
194
|
+
thumbnailEl.src = thumbnails;
|
|
195
|
+
} else if (isString(thumbnails)) {
|
|
196
|
+
thumbnailEl.setAttribute("src", thumbnails);
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
class MediaAudioGainRadioGroupElement extends Host(HTMLElement, AudioGainRadioGroup) {
|
|
205
|
+
static tagName = "media-audio-gain-radio-group";
|
|
206
|
+
onConnect() {
|
|
207
|
+
renderMenuItemsTemplate(this);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
class MediaRadioGroupElement extends Host(HTMLElement, RadioGroup) {
|
|
212
|
+
static tagName = "media-radio-group";
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
class MediaSliderElement extends Host(HTMLElement, Slider) {
|
|
216
|
+
static tagName = "media-slider";
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
const videoTemplate = /* @__PURE__ */ createTemplate(
|
|
220
|
+
`<video muted playsinline preload="none" style="max-width: unset;"></video>`
|
|
221
|
+
);
|
|
222
|
+
class MediaSliderVideoElement extends Host(HTMLElement, SliderVideo) {
|
|
223
|
+
static tagName = "media-slider-video";
|
|
224
|
+
#media;
|
|
225
|
+
#video = this.#createVideo();
|
|
226
|
+
onSetup() {
|
|
227
|
+
this.#media = useMediaContext();
|
|
228
|
+
this.$state.video.set(this.#video);
|
|
229
|
+
}
|
|
230
|
+
onConnect() {
|
|
231
|
+
const { canLoad } = this.#media.$state, { src, crossOrigin } = this.$state;
|
|
232
|
+
if (this.#video.parentNode !== this) {
|
|
233
|
+
this.prepend(this.#video);
|
|
234
|
+
}
|
|
235
|
+
effect(() => {
|
|
236
|
+
setAttribute(this.#video, "crossorigin", crossOrigin());
|
|
237
|
+
setAttribute(this.#video, "preload", canLoad() ? "auto" : "none");
|
|
238
|
+
setAttribute(this.#video, "src", src());
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
#createVideo() {
|
|
242
|
+
return cloneTemplateContent(videoTemplate);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
class MediaAudioGainSliderElement extends Host(HTMLElement, AudioGainSlider) {
|
|
247
|
+
static tagName = "media-audio-gain-slider";
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
class MediaSpeedSliderElement extends Host(HTMLElement, SpeedSlider) {
|
|
251
|
+
static tagName = "media-speed-slider";
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
class MediaQualitySliderElement extends Host(HTMLElement, QualitySlider) {
|
|
255
|
+
static tagName = "media-quality-slider";
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
class MediaSliderChaptersElement extends Host(HTMLElement, SliderChapters) {
|
|
259
|
+
static tagName = "media-slider-chapters";
|
|
260
|
+
#template = null;
|
|
261
|
+
onConnect() {
|
|
262
|
+
requestScopedAnimationFrame(() => {
|
|
263
|
+
if (!this.connectScope) return;
|
|
264
|
+
const template = this.querySelector("template");
|
|
265
|
+
if (template) {
|
|
266
|
+
this.#template = template;
|
|
267
|
+
effect(this.#renderTemplate.bind(this));
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
#renderTemplate() {
|
|
272
|
+
if (!this.#template) return;
|
|
273
|
+
const elements = cloneTemplate(this.#template, this.cues.length || 1);
|
|
274
|
+
this.setRefs(elements);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
class SliderSteps extends Component {
|
|
279
|
+
}
|
|
280
|
+
class MediaSliderStepsElement extends Host(HTMLElement, SliderSteps) {
|
|
281
|
+
static tagName = "media-slider-steps";
|
|
282
|
+
#template = null;
|
|
283
|
+
onConnect(el) {
|
|
284
|
+
requestScopedAnimationFrame(() => {
|
|
285
|
+
if (!this.connectScope) return;
|
|
286
|
+
this.#template = el.querySelector("template");
|
|
287
|
+
if (this.#template) effect(this.#render.bind(this));
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
#render() {
|
|
291
|
+
if (!this.#template) return;
|
|
292
|
+
const { min, max, step } = useState(sliderState), steps = (max() - min()) / step();
|
|
293
|
+
cloneTemplate(this.#template, Math.floor(steps) + 1);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export { MediaAnnouncerElement, MediaAudioGainRadioGroupElement, MediaAudioGainSliderElement, MediaCaptionsElement, MediaChapterTitleElement, MediaChaptersRadioGroupElement, MediaControlsElement, MediaControlsGroupElement, MediaGestureElement, MediaGoogleCastButtonElement, MediaLayoutElement, MediaMenuPortalElement, MediaQualitySliderElement, MediaRadioGroupElement, MediaSliderChaptersElement, MediaSliderElement, MediaSliderStepsElement, MediaSliderVideoElement, MediaSpeedSliderElement, MediaSpinnerElement, MediaTitleElement, MediaToggleButtonElement, MediaTooltipContentElement, MediaTooltipElement, MediaTooltipTriggerElement };
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import { autoUpdate, computePosition, flip, shift } from '@floating-ui/dom';
|
|
2
|
+
import { EventsController, isKeyboardClick, isTouchEvent, scoped, getScope, effect, isFunction, setAttribute, setStyle, isDOMNode, onDispose, toggleClass, animationFrameThrottle, signal, listenEvent, computed } from './vidstack-BGSTndAW.js';
|
|
3
|
+
|
|
4
|
+
function isEventInside(el, event) {
|
|
5
|
+
const target = event.composedPath()[0];
|
|
6
|
+
return isDOMNode(target) && el.contains(target);
|
|
7
|
+
}
|
|
8
|
+
const rafJobs = /* @__PURE__ */ new Set();
|
|
9
|
+
{
|
|
10
|
+
let processJobs = function() {
|
|
11
|
+
for (const job of rafJobs) {
|
|
12
|
+
try {
|
|
13
|
+
job();
|
|
14
|
+
} catch (e) {
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
window.requestAnimationFrame(processJobs);
|
|
18
|
+
};
|
|
19
|
+
processJobs();
|
|
20
|
+
}
|
|
21
|
+
function scheduleRafJob(job) {
|
|
22
|
+
rafJobs.add(job);
|
|
23
|
+
return () => rafJobs.delete(job);
|
|
24
|
+
}
|
|
25
|
+
function setAttributeIfEmpty(target, name, value) {
|
|
26
|
+
if (!target.hasAttribute(name)) target.setAttribute(name, value);
|
|
27
|
+
}
|
|
28
|
+
function setARIALabel(target, $label) {
|
|
29
|
+
if (target.hasAttribute("aria-label") || target.hasAttribute("data-no-label")) return;
|
|
30
|
+
if (!isFunction($label)) {
|
|
31
|
+
setAttribute(target, "aria-label", $label);
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
function updateAriaDescription() {
|
|
35
|
+
setAttribute(target, "aria-label", $label());
|
|
36
|
+
}
|
|
37
|
+
effect(updateAriaDescription);
|
|
38
|
+
}
|
|
39
|
+
function isElementVisible(el) {
|
|
40
|
+
const style = getComputedStyle(el);
|
|
41
|
+
return style.display !== "none" && parseInt(style.opacity) > 0;
|
|
42
|
+
}
|
|
43
|
+
function checkVisibility(el) {
|
|
44
|
+
return !!el && ("checkVisibility" in el ? el.checkVisibility({ checkOpacity: true, checkVisibilityCSS: true }) : isElementVisible(el));
|
|
45
|
+
}
|
|
46
|
+
function observeVisibility(el, callback) {
|
|
47
|
+
return scheduleRafJob(() => callback(checkVisibility(el)));
|
|
48
|
+
}
|
|
49
|
+
function isElementParent(owner, node, test) {
|
|
50
|
+
while (node) {
|
|
51
|
+
if (node === owner) {
|
|
52
|
+
return true;
|
|
53
|
+
} else if (test?.(node)) {
|
|
54
|
+
break;
|
|
55
|
+
} else {
|
|
56
|
+
node = node.parentElement;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
function onPress(target, handler) {
|
|
62
|
+
return new EventsController(target).add("pointerup", (event) => {
|
|
63
|
+
if (event.button === 0 && !event.defaultPrevented) handler(event);
|
|
64
|
+
}).add("keydown", (event) => {
|
|
65
|
+
if (isKeyboardClick(event)) handler(event);
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
function isTouchPinchEvent(event) {
|
|
69
|
+
return isTouchEvent(event) && (event.touches.length > 1 || event.changedTouches.length > 1);
|
|
70
|
+
}
|
|
71
|
+
function requestScopedAnimationFrame(callback) {
|
|
72
|
+
let scope = getScope(), id = window.requestAnimationFrame(() => {
|
|
73
|
+
scoped(callback, scope);
|
|
74
|
+
id = -1;
|
|
75
|
+
});
|
|
76
|
+
return () => void window.cancelAnimationFrame(id);
|
|
77
|
+
}
|
|
78
|
+
function cloneTemplate(template, length, onCreate) {
|
|
79
|
+
let current, prev = template, parent = template.parentElement, content = template.content.firstElementChild, elements = [];
|
|
80
|
+
if (!content && template.firstElementChild) {
|
|
81
|
+
template.innerHTML = template.firstElementChild.outerHTML;
|
|
82
|
+
template.firstElementChild.remove();
|
|
83
|
+
content = template.content.firstElementChild;
|
|
84
|
+
}
|
|
85
|
+
for (let i = 0; i < length; i++) {
|
|
86
|
+
current = document.importNode(content, true);
|
|
87
|
+
onCreate?.(current, i);
|
|
88
|
+
parent.insertBefore(current, prev.nextSibling);
|
|
89
|
+
elements.push(current);
|
|
90
|
+
prev = current;
|
|
91
|
+
}
|
|
92
|
+
onDispose(() => {
|
|
93
|
+
for (let i = 0; i < elements.length; i++) elements[i].remove();
|
|
94
|
+
});
|
|
95
|
+
return elements;
|
|
96
|
+
}
|
|
97
|
+
function createTemplate(content) {
|
|
98
|
+
const template = document.createElement("template");
|
|
99
|
+
template.innerHTML = content;
|
|
100
|
+
return template.content;
|
|
101
|
+
}
|
|
102
|
+
function cloneTemplateContent(content) {
|
|
103
|
+
const fragment = content.cloneNode(true);
|
|
104
|
+
return fragment.firstElementChild;
|
|
105
|
+
}
|
|
106
|
+
function autoPlacement(el, trigger, placement, {
|
|
107
|
+
offsetVarName,
|
|
108
|
+
xOffset,
|
|
109
|
+
yOffset,
|
|
110
|
+
...options
|
|
111
|
+
}) {
|
|
112
|
+
if (!el) return;
|
|
113
|
+
const floatingPlacement = placement.replace(" ", "-").replace("-center", "");
|
|
114
|
+
setStyle(el, "visibility", !trigger ? "hidden" : null);
|
|
115
|
+
if (!trigger) return;
|
|
116
|
+
let isTop = placement.includes("top");
|
|
117
|
+
const negateX = (x) => placement.includes("left") ? `calc(-1 * ${x})` : x, negateY = (y) => isTop ? `calc(-1 * ${y})` : y;
|
|
118
|
+
return autoUpdate(trigger, el, () => {
|
|
119
|
+
computePosition(trigger, el, {
|
|
120
|
+
placement: floatingPlacement,
|
|
121
|
+
middleware: [
|
|
122
|
+
...options.middleware ?? [],
|
|
123
|
+
flip({ fallbackAxisSideDirection: "start", crossAxis: false }),
|
|
124
|
+
shift()
|
|
125
|
+
],
|
|
126
|
+
...options
|
|
127
|
+
}).then(({ x, y, middlewareData }) => {
|
|
128
|
+
const hasFlipped = !!middlewareData.flip?.index;
|
|
129
|
+
isTop = placement.includes(hasFlipped ? "bottom" : "top");
|
|
130
|
+
el.setAttribute(
|
|
131
|
+
"data-placement",
|
|
132
|
+
hasFlipped ? placement.startsWith("top") ? placement.replace("top", "bottom") : placement.replace("bottom", "top") : placement
|
|
133
|
+
);
|
|
134
|
+
Object.assign(el.style, {
|
|
135
|
+
top: `calc(${y + "px"} + ${negateY(
|
|
136
|
+
yOffset ? yOffset + "px" : `var(--${offsetVarName}-y-offset, 0px)`
|
|
137
|
+
)})`,
|
|
138
|
+
left: `calc(${x + "px"} + ${negateX(
|
|
139
|
+
xOffset ? xOffset + "px" : `var(--${offsetVarName}-x-offset, 0px)`
|
|
140
|
+
)})`
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
function hasAnimation(el) {
|
|
146
|
+
const styles = getComputedStyle(el);
|
|
147
|
+
return styles.animationName !== "none";
|
|
148
|
+
}
|
|
149
|
+
function createSlot(name) {
|
|
150
|
+
const slot = document.createElement("slot");
|
|
151
|
+
slot.name = name;
|
|
152
|
+
return slot;
|
|
153
|
+
}
|
|
154
|
+
function useTransitionActive($el) {
|
|
155
|
+
const $active = signal(false);
|
|
156
|
+
effect(() => {
|
|
157
|
+
const el = $el();
|
|
158
|
+
if (!el) return;
|
|
159
|
+
new EventsController(el).add("transitionstart", () => $active.set(true)).add("transitionend", () => $active.set(false));
|
|
160
|
+
});
|
|
161
|
+
return $active;
|
|
162
|
+
}
|
|
163
|
+
function useResizeObserver($el, onResize) {
|
|
164
|
+
function onElementChange() {
|
|
165
|
+
const el = $el();
|
|
166
|
+
if (!el) return;
|
|
167
|
+
onResize();
|
|
168
|
+
const observer = new ResizeObserver(animationFrameThrottle(onResize));
|
|
169
|
+
observer.observe(el);
|
|
170
|
+
return () => observer.disconnect();
|
|
171
|
+
}
|
|
172
|
+
effect(onElementChange);
|
|
173
|
+
}
|
|
174
|
+
function useActive($el) {
|
|
175
|
+
const $isMouseEnter = useMouseEnter($el), $isFocusedIn = useFocusIn($el);
|
|
176
|
+
let prevMouseEnter = false;
|
|
177
|
+
return computed(() => {
|
|
178
|
+
const isMouseEnter = $isMouseEnter();
|
|
179
|
+
if (prevMouseEnter && !isMouseEnter) return false;
|
|
180
|
+
prevMouseEnter = isMouseEnter;
|
|
181
|
+
return isMouseEnter || $isFocusedIn();
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
function useMouseEnter($el) {
|
|
185
|
+
const $isMouseEnter = signal(false);
|
|
186
|
+
effect(() => {
|
|
187
|
+
const el = $el();
|
|
188
|
+
if (!el) {
|
|
189
|
+
$isMouseEnter.set(false);
|
|
190
|
+
return;
|
|
191
|
+
}
|
|
192
|
+
new EventsController(el).add("mouseenter", () => $isMouseEnter.set(true)).add("mouseleave", () => $isMouseEnter.set(false));
|
|
193
|
+
});
|
|
194
|
+
return $isMouseEnter;
|
|
195
|
+
}
|
|
196
|
+
function useFocusIn($el) {
|
|
197
|
+
const $isFocusIn = signal(false);
|
|
198
|
+
effect(() => {
|
|
199
|
+
const el = $el();
|
|
200
|
+
if (!el) {
|
|
201
|
+
$isFocusIn.set(false);
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
new EventsController(el).add("focusin", () => $isFocusIn.set(true)).add("focusout", () => $isFocusIn.set(false));
|
|
205
|
+
});
|
|
206
|
+
return $isFocusIn;
|
|
207
|
+
}
|
|
208
|
+
function isHTMLElement(el) {
|
|
209
|
+
return el instanceof HTMLElement;
|
|
210
|
+
}
|
|
211
|
+
function useColorSchemePreference() {
|
|
212
|
+
const colorScheme = signal("dark");
|
|
213
|
+
const media = window.matchMedia("(prefers-color-scheme: light)");
|
|
214
|
+
function onChange() {
|
|
215
|
+
colorScheme.set(media.matches ? "light" : "dark");
|
|
216
|
+
}
|
|
217
|
+
onChange();
|
|
218
|
+
listenEvent(media, "change", onChange);
|
|
219
|
+
return colorScheme;
|
|
220
|
+
}
|
|
221
|
+
function watchColorScheme(el, colorScheme) {
|
|
222
|
+
effect(() => {
|
|
223
|
+
const scheme = colorScheme();
|
|
224
|
+
if (scheme === "system") {
|
|
225
|
+
const preference = useColorSchemePreference();
|
|
226
|
+
effect(() => updateColorScheme(preference()));
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
updateColorScheme(scheme);
|
|
230
|
+
});
|
|
231
|
+
function updateColorScheme(scheme) {
|
|
232
|
+
toggleClass(el, "light", scheme === "light");
|
|
233
|
+
toggleClass(el, "dark", scheme === "dark");
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function ariaBool(value) {
|
|
238
|
+
return value ? "true" : "false";
|
|
239
|
+
}
|
|
240
|
+
function $ariaBool(signal) {
|
|
241
|
+
return () => ariaBool(signal());
|
|
242
|
+
}
|
|
243
|
+
function prefersReducedMotion() {
|
|
244
|
+
if (typeof window === "undefined") return false;
|
|
245
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export { $ariaBool, autoPlacement, cloneTemplate, cloneTemplateContent, createSlot, createTemplate, hasAnimation, isElementParent, isElementVisible, isEventInside, isHTMLElement, isTouchPinchEvent, observeVisibility, onPress, prefersReducedMotion, requestScopedAnimationFrame, setARIALabel, setAttributeIfEmpty, useActive, useResizeObserver, useTransitionActive, watchColorScheme };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function coerceToError(error) {
|
|
2
|
+
return error instanceof Error ? error : Error(typeof error === "string" ? error : JSON.stringify(error));
|
|
3
|
+
}
|
|
4
|
+
function assert(condition, message) {
|
|
5
|
+
if (!condition) {
|
|
6
|
+
throw Error("Assertion failed.");
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { assert, coerceToError };
|