@thalassic/ui 22.20.0 → 22.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fesm2022/thalassic-ui-media.mjs +1194 -0
- package/fesm2022/thalassic-ui-media.mjs.map +1 -0
- package/fesm2022/thalassic-ui.mjs +7514 -2411
- package/fesm2022/thalassic-ui.mjs.map +1 -1
- package/package.json +5 -1
- package/types/thalassic-ui-media.d.ts +300 -0
- package/types/thalassic-ui.d.ts +2065 -116
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thalassic/ui",
|
|
3
|
-
"version": "22.
|
|
3
|
+
"version": "22.21.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"@angular/aria": "^22.0.0",
|
|
@@ -80,6 +80,10 @@
|
|
|
80
80
|
"types": "./types/thalassic-ui-fontawesome.d.ts",
|
|
81
81
|
"default": "./fesm2022/thalassic-ui-fontawesome.mjs"
|
|
82
82
|
},
|
|
83
|
+
"./media": {
|
|
84
|
+
"types": "./types/thalassic-ui-media.d.ts",
|
|
85
|
+
"default": "./fesm2022/thalassic-ui-media.mjs"
|
|
86
|
+
},
|
|
83
87
|
"./rich-text-editor": {
|
|
84
88
|
"types": "./types/thalassic-ui-rich-text-editor.d.ts",
|
|
85
89
|
"default": "./fesm2022/thalassic-ui-rich-text-editor.mjs"
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import * as i0 from '@angular/core';
|
|
2
|
+
import { InjectionToken, Signal, InputSignal, InputSignalWithTransform, EnvironmentProviders } from '@angular/core';
|
|
3
|
+
import * as _thalassic_ui_media from '@thalassic/ui/media';
|
|
4
|
+
import { systemIcon } from '@thalassic/ui';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Lifecycle of an attached media element, collapsed to the single state the
|
|
8
|
+
* chrome renders: exactly one of poster, spinner, playing surface, replay
|
|
9
|
+
* affordance, or error panel is showing at a time.
|
|
10
|
+
*/
|
|
11
|
+
type mediaState = 'idle' | 'loading' | 'ready' | 'playing' | 'ended' | 'error';
|
|
12
|
+
/** One contiguous buffered span of the media timeline, in seconds. */
|
|
13
|
+
interface TimeRange {
|
|
14
|
+
start: number;
|
|
15
|
+
end: number;
|
|
16
|
+
}
|
|
17
|
+
/** A text track of the media element, projected for the captions menu. */
|
|
18
|
+
interface MediaTextTrack {
|
|
19
|
+
id: string;
|
|
20
|
+
label: string;
|
|
21
|
+
language: string;
|
|
22
|
+
active: boolean;
|
|
23
|
+
}
|
|
24
|
+
/** A selectable quality rendition reported by a {@link MediaSourceEngine}. */
|
|
25
|
+
interface MediaLevel {
|
|
26
|
+
id: string;
|
|
27
|
+
height: number;
|
|
28
|
+
bitrate: number;
|
|
29
|
+
label: string;
|
|
30
|
+
}
|
|
31
|
+
/** A captions/subtitles source rendered as a `<track>` element. */
|
|
32
|
+
interface MediaCaptionSource {
|
|
33
|
+
src: string;
|
|
34
|
+
srclang: string;
|
|
35
|
+
label: string;
|
|
36
|
+
default?: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Accessible names and visible copy of the player chrome, overridable for i18n. */
|
|
40
|
+
interface MediaPlayerLabels {
|
|
41
|
+
play: string;
|
|
42
|
+
pause: string;
|
|
43
|
+
replay: string;
|
|
44
|
+
mute: string;
|
|
45
|
+
unmute: string;
|
|
46
|
+
volume: string;
|
|
47
|
+
seek: string;
|
|
48
|
+
/** Joins current and total time in the scrubber's `aria-valuetext`, e.g. "1:23 {timeSeparator} 4:05". */
|
|
49
|
+
timeSeparator: string;
|
|
50
|
+
settings: string;
|
|
51
|
+
captions: string;
|
|
52
|
+
captionsOff: string;
|
|
53
|
+
playbackRate: string;
|
|
54
|
+
quality: string;
|
|
55
|
+
fullscreen: string;
|
|
56
|
+
exitFullscreen: string;
|
|
57
|
+
pictureInPicture: string;
|
|
58
|
+
errorMessage: string;
|
|
59
|
+
retry: string;
|
|
60
|
+
}
|
|
61
|
+
interface MediaPlayerConfig {
|
|
62
|
+
seekStep: number;
|
|
63
|
+
rateOptions: number[];
|
|
64
|
+
controlsHideDelay: number;
|
|
65
|
+
preload: 'none' | 'metadata' | 'auto';
|
|
66
|
+
labels: MediaPlayerLabels;
|
|
67
|
+
}
|
|
68
|
+
declare const DEFAULT_MEDIA_PLAYER_CONFIG: MediaPlayerConfig;
|
|
69
|
+
|
|
70
|
+
declare const MEDIA_PLAYER_CONFIG: InjectionToken<MediaPlayerConfig>;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Headless playback state over one `HTMLMediaElement`. Provided per player
|
|
74
|
+
* instance; the single place in the feature that touches the element. All
|
|
75
|
+
* signals are written exclusively from element events (plus one eager sync at
|
|
76
|
+
* attach, since a cached or autoplaying source can already be past
|
|
77
|
+
* `loadedmetadata` and will not re-fire it).
|
|
78
|
+
*/
|
|
79
|
+
declare class MediaController {
|
|
80
|
+
private readonly _destroyRef;
|
|
81
|
+
private readonly _engine;
|
|
82
|
+
private readonly _config;
|
|
83
|
+
private _media;
|
|
84
|
+
private _detachRegistered;
|
|
85
|
+
private readonly _playing;
|
|
86
|
+
private readonly _currentTime;
|
|
87
|
+
private readonly _duration;
|
|
88
|
+
private readonly _buffered;
|
|
89
|
+
private readonly _volume;
|
|
90
|
+
private readonly _muted;
|
|
91
|
+
private readonly _rate;
|
|
92
|
+
private readonly _state;
|
|
93
|
+
private readonly _error;
|
|
94
|
+
private readonly _textTracks;
|
|
95
|
+
private readonly _scrubbing;
|
|
96
|
+
private readonly _scrubTime;
|
|
97
|
+
readonly playing: Signal<boolean>;
|
|
98
|
+
readonly currentTime: Signal<number>;
|
|
99
|
+
readonly duration: Signal<number>;
|
|
100
|
+
readonly buffered: Signal<TimeRange[]>;
|
|
101
|
+
readonly volume: Signal<number>;
|
|
102
|
+
readonly muted: Signal<boolean>;
|
|
103
|
+
readonly rate: Signal<number>;
|
|
104
|
+
readonly state: Signal<mediaState>;
|
|
105
|
+
readonly error: Signal<MediaError | null>;
|
|
106
|
+
readonly textTracks: Signal<MediaTextTrack[]>;
|
|
107
|
+
attach(media: HTMLMediaElement): void;
|
|
108
|
+
play(): Promise<void>;
|
|
109
|
+
pause(): void;
|
|
110
|
+
togglePlay(): void;
|
|
111
|
+
seek(seconds: number): void;
|
|
112
|
+
seekBy(delta: number): void;
|
|
113
|
+
beginScrub(): void;
|
|
114
|
+
scrubTo(seconds: number): void;
|
|
115
|
+
endScrub(): void;
|
|
116
|
+
setVolume(volume: number): void;
|
|
117
|
+
toggleMute(): void;
|
|
118
|
+
setRate(rate: number): void;
|
|
119
|
+
setSource(source: string): void;
|
|
120
|
+
selectTextTrack(id: string | null): void;
|
|
121
|
+
setMetadata(metadata: {
|
|
122
|
+
title?: string;
|
|
123
|
+
artist?: string;
|
|
124
|
+
artwork?: {
|
|
125
|
+
src: string;
|
|
126
|
+
}[];
|
|
127
|
+
}): void;
|
|
128
|
+
private _requireMedia;
|
|
129
|
+
private _clampTime;
|
|
130
|
+
private _registerMediaSession;
|
|
131
|
+
private _listen;
|
|
132
|
+
private _syncInitial;
|
|
133
|
+
private _syncTime;
|
|
134
|
+
private _syncDuration;
|
|
135
|
+
private _syncBuffered;
|
|
136
|
+
private _syncTextTracks;
|
|
137
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MediaController, never>;
|
|
138
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MediaController>;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Attaches non-progressive sources (MSE-based streaming such as HLS or DASH)
|
|
143
|
+
* to a media element. The library ships no implementation; an application
|
|
144
|
+
* provides one and the controller delegates whenever `canPlay` accepts the
|
|
145
|
+
* source, otherwise it assigns `media.src` directly.
|
|
146
|
+
*/
|
|
147
|
+
interface MediaSourceEngine {
|
|
148
|
+
canPlay(source: string): boolean;
|
|
149
|
+
attach(media: HTMLMediaElement, source: string): void;
|
|
150
|
+
detach(): void;
|
|
151
|
+
/** Quality renditions of the attached source; the settings menu renders them when non-empty. */
|
|
152
|
+
levels?: Signal<MediaLevel[]>;
|
|
153
|
+
}
|
|
154
|
+
declare const MEDIA_SOURCE_ENGINE: InjectionToken<MediaSourceEngine>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Fullscreen and Picture-in-Picture state for a video player: fullscreen is
|
|
158
|
+
* requested on the player container (so the chrome stays visible), PiP on the
|
|
159
|
+
* video element itself. Feature support is detected per element at attach, so
|
|
160
|
+
* the chrome can hide unavailable buttons.
|
|
161
|
+
*/
|
|
162
|
+
declare class FullscreenController {
|
|
163
|
+
private readonly _document;
|
|
164
|
+
private readonly _destroyRef;
|
|
165
|
+
private _container;
|
|
166
|
+
private _video;
|
|
167
|
+
private readonly _fullscreen;
|
|
168
|
+
private readonly _pictureInPicture;
|
|
169
|
+
private readonly _fullscreenSupported;
|
|
170
|
+
private readonly _pictureInPictureSupported;
|
|
171
|
+
readonly fullscreen: Signal<boolean>;
|
|
172
|
+
readonly pictureInPicture: Signal<boolean>;
|
|
173
|
+
readonly fullscreenSupported: Signal<boolean>;
|
|
174
|
+
readonly pictureInPictureSupported: Signal<boolean>;
|
|
175
|
+
attach(container: HTMLElement, video: HTMLVideoElement): void;
|
|
176
|
+
toggleFullscreen(): Promise<void>;
|
|
177
|
+
togglePictureInPicture(): Promise<void>;
|
|
178
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<FullscreenController, never>;
|
|
179
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<FullscreenController>;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Audio playback surface assembling the headless {@link MediaController} with
|
|
184
|
+
* the feature's control set — play toggle, time display, scrubber, volume and
|
|
185
|
+
* settings — behind a `role="group"` host. The single place in the feature
|
|
186
|
+
* that owns an `<audio>` element and attaches the controller to it.
|
|
187
|
+
*/
|
|
188
|
+
declare class AudioPlayer {
|
|
189
|
+
private readonly _controller;
|
|
190
|
+
private readonly _config;
|
|
191
|
+
readonly source: InputSignal<string>;
|
|
192
|
+
readonly title: InputSignal<string | undefined>;
|
|
193
|
+
/**
|
|
194
|
+
* Requests playback as soon as the source can play. Browsers only honor
|
|
195
|
+
* autoplay when the element is also muted — an unmuted request is silently
|
|
196
|
+
* rejected, and the rejection is not surfaced as an error; the player falls
|
|
197
|
+
* back to the ordinary play affordance so the user can start playback (with
|
|
198
|
+
* sound) explicitly.
|
|
199
|
+
*/
|
|
200
|
+
readonly autoplay: InputSignalWithTransform<boolean, unknown>;
|
|
201
|
+
readonly loop: InputSignalWithTransform<boolean, unknown>;
|
|
202
|
+
readonly preload: InputSignal<'none' | 'metadata' | 'auto'>;
|
|
203
|
+
readonly ariaLabel: InputSignal<string | undefined>;
|
|
204
|
+
readonly ariaLabelledby: InputSignal<string | undefined>;
|
|
205
|
+
readonly ended: i0.OutputEmitterRef<void>;
|
|
206
|
+
readonly playingChange: i0.OutputEmitterRef<boolean>;
|
|
207
|
+
private readonly _audioElement;
|
|
208
|
+
private readonly _attached;
|
|
209
|
+
private _skipInitialPlayingChange;
|
|
210
|
+
constructor();
|
|
211
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<AudioPlayer, never>;
|
|
212
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<AudioPlayer, "tls-audio-player", never, { "source": { "alias": "source"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "autoplay": { "alias": "autoplay"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "preload": { "alias": "preload"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; }, { "ended": "ended"; "playingChange": "playingChange"; }, never, never, true, never>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Video playback surface assembling the headless {@link MediaController} and
|
|
217
|
+
* {@link FullscreenController} with the feature's control set behind a
|
|
218
|
+
* `role="group"` host. The single place in the feature that owns a `<video>`
|
|
219
|
+
* element, attaches both controllers to it, and maps player-level keyboard
|
|
220
|
+
* shortcuts (space/k play, arrow seek/volume, m mute, f fullscreen, c
|
|
221
|
+
* captions, Home/End) to controller calls. Controls fade out during playback
|
|
222
|
+
* once the pointer has been idle for the configured delay, and reappear on
|
|
223
|
+
* pointer activity, keyboard focus, or while the settings menu is open.
|
|
224
|
+
*/
|
|
225
|
+
declare class VideoPlayer {
|
|
226
|
+
private readonly _controller;
|
|
227
|
+
private readonly _fullscreenController;
|
|
228
|
+
private readonly _config;
|
|
229
|
+
private readonly _directionality;
|
|
230
|
+
private readonly _host;
|
|
231
|
+
private readonly _destroyRef;
|
|
232
|
+
readonly source: InputSignal<string>;
|
|
233
|
+
readonly title: InputSignal<string | undefined>;
|
|
234
|
+
readonly poster: InputSignal<string | undefined>;
|
|
235
|
+
readonly captions: InputSignal<MediaCaptionSource[]>;
|
|
236
|
+
/**
|
|
237
|
+
* Requests playback as soon as the source can play. Browsers only honor
|
|
238
|
+
* autoplay when the element is also muted — an unmuted request is silently
|
|
239
|
+
* rejected, and the rejection is not surfaced as an error; the player falls
|
|
240
|
+
* back to its poster with the ordinary play affordance so the user can start
|
|
241
|
+
* playback (with sound) explicitly.
|
|
242
|
+
*/
|
|
243
|
+
readonly autoplay: InputSignalWithTransform<boolean, unknown>;
|
|
244
|
+
readonly loop: InputSignalWithTransform<boolean, unknown>;
|
|
245
|
+
readonly muted: InputSignalWithTransform<boolean, unknown>;
|
|
246
|
+
readonly preload: InputSignal<'none' | 'metadata' | 'auto'>;
|
|
247
|
+
readonly ariaLabel: InputSignal<string | undefined>;
|
|
248
|
+
readonly ariaLabelledby: InputSignal<string | undefined>;
|
|
249
|
+
readonly ended: i0.OutputEmitterRef<void>;
|
|
250
|
+
readonly playingChange: i0.OutputEmitterRef<boolean>;
|
|
251
|
+
private readonly _videoElement;
|
|
252
|
+
private readonly _settingsMenu;
|
|
253
|
+
private readonly _pointerIdle;
|
|
254
|
+
private readonly _focusWithin;
|
|
255
|
+
private readonly _attached;
|
|
256
|
+
/** Accumulated signed seconds of the in-flight keyboard-seek feedback badge, `null` when hidden. */
|
|
257
|
+
protected readonly seekFeedback: i0.WritableSignal<number | null>;
|
|
258
|
+
private _hideTimer;
|
|
259
|
+
private _seekFeedbackTimer;
|
|
260
|
+
private _skipInitialPlayingChange;
|
|
261
|
+
protected readonly labels: _thalassic_ui_media.MediaPlayerLabels;
|
|
262
|
+
protected readonly state: Signal<mediaState>;
|
|
263
|
+
protected readonly fullscreen: Signal<boolean>;
|
|
264
|
+
protected readonly fullscreenSupported: Signal<boolean>;
|
|
265
|
+
protected readonly pictureInPictureSupported: Signal<boolean>;
|
|
266
|
+
private readonly _menuOpen;
|
|
267
|
+
protected readonly controlsHidden: Signal<boolean>;
|
|
268
|
+
protected readonly seekFeedbackText: Signal<string>;
|
|
269
|
+
/** Chevrons pointing in the physical direction the playhead moved; forward points left under RTL. */
|
|
270
|
+
protected readonly seekFeedbackIcon: Signal<systemIcon>;
|
|
271
|
+
constructor();
|
|
272
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
273
|
+
protected onPointerActivity(): void;
|
|
274
|
+
protected onFocusIn(): void;
|
|
275
|
+
protected onFocusOut(event: FocusEvent): void;
|
|
276
|
+
protected onSurfaceClick(): void;
|
|
277
|
+
protected togglePictureInPicture(): void;
|
|
278
|
+
protected toggleFullscreen(): void;
|
|
279
|
+
protected retry(): void;
|
|
280
|
+
private _toggleCaptions;
|
|
281
|
+
private _armHideTimer;
|
|
282
|
+
private _cancelHideTimer;
|
|
283
|
+
/**
|
|
284
|
+
* Seeks and surfaces the transient feedback badge. Presses within the badge's
|
|
285
|
+
* lifetime accumulate into one running total; a press in the opposite
|
|
286
|
+
* direction restarts the count from its own step.
|
|
287
|
+
*/
|
|
288
|
+
private _seekWithFeedback;
|
|
289
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<VideoPlayer, never>;
|
|
290
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<VideoPlayer, "tls-video-player", never, { "source": { "alias": "source"; "required": true; "isSignal": true; }; "title": { "alias": "title"; "required": false; "isSignal": true; }; "poster": { "alias": "poster"; "required": false; "isSignal": true; }; "captions": { "alias": "captions"; "required": false; "isSignal": true; }; "autoplay": { "alias": "autoplay"; "required": false; "isSignal": true; }; "loop": { "alias": "loop"; "required": false; "isSignal": true; }; "muted": { "alias": "muted"; "required": false; "isSignal": true; }; "preload": { "alias": "preload"; "required": false; "isSignal": true; }; "ariaLabel": { "alias": "ariaLabel"; "required": false; "isSignal": true; }; "ariaLabelledby": { "alias": "ariaLabelledby"; "required": false; "isSignal": true; }; }, { "ended": "ended"; "playingChange": "playingChange"; }, never, never, true, never>;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
/** Consumer-facing override shape: every field optional, `labels` deep-partial. */
|
|
294
|
+
interface MediaPlayerConfigOverride extends Partial<Omit<MediaPlayerConfig, 'labels'>> {
|
|
295
|
+
labels?: Partial<MediaPlayerLabels>;
|
|
296
|
+
}
|
|
297
|
+
declare const provideThalassicMediaConfig: (config?: MediaPlayerConfigOverride) => EnvironmentProviders;
|
|
298
|
+
|
|
299
|
+
export { AudioPlayer, DEFAULT_MEDIA_PLAYER_CONFIG, FullscreenController, MEDIA_PLAYER_CONFIG, MEDIA_SOURCE_ENGINE, MediaController, VideoPlayer, provideThalassicMediaConfig };
|
|
300
|
+
export type { MediaCaptionSource, MediaLevel, MediaPlayerConfig, MediaPlayerConfigOverride, MediaPlayerLabels, MediaSourceEngine, MediaTextTrack, TimeRange, mediaState };
|