- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
100 lines
2.7 KiB
JavaScript
100 lines
2.7 KiB
JavaScript
import * as PropertySymbol from '../../PropertySymbol.js';
|
|
import Crypto from 'crypto';
|
|
import EventTarget from '../../event/EventTarget.js';
|
|
import MediaStreamTrackEvent from '../../event/events/MediaStreamTrackEvent.js';
|
|
/**
|
|
* MediaStream.
|
|
*
|
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/MediaStream
|
|
*/
|
|
export default class MediaStream extends EventTarget {
|
|
// Public properties
|
|
active = true;
|
|
id = Crypto.randomUUID();
|
|
// Events
|
|
onaddtrack = null;
|
|
onremovetrack = null;
|
|
// Internal properties
|
|
[PropertySymbol.tracks] = [];
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param [streamOrTracks] Stream or tracks.
|
|
*/
|
|
constructor(streamOrTracks) {
|
|
super();
|
|
if (!this[PropertySymbol.window]) {
|
|
throw new TypeError(`Failed to construct '${this.constructor.name}': '${this.constructor.name}' was constructed outside a Window context.`);
|
|
}
|
|
if (streamOrTracks !== undefined) {
|
|
this[PropertySymbol.tracks] =
|
|
streamOrTracks instanceof MediaStream
|
|
? streamOrTracks[PropertySymbol.tracks].slice()
|
|
: streamOrTracks;
|
|
}
|
|
}
|
|
/**
|
|
* Adds a track.
|
|
*
|
|
* @param track Track.
|
|
*/
|
|
addTrack(track) {
|
|
if (this[PropertySymbol.tracks].includes(track)) {
|
|
return;
|
|
}
|
|
this[PropertySymbol.tracks].push(track);
|
|
this.dispatchEvent(new MediaStreamTrackEvent('addtrack', { track }));
|
|
}
|
|
/**
|
|
* Returns a clone.
|
|
*
|
|
* @returns Clone.
|
|
*/
|
|
clone() {
|
|
return new this.constructor(this);
|
|
}
|
|
/**
|
|
* Returns audio tracks.
|
|
*
|
|
* @returns Audio tracks.
|
|
*/
|
|
getAudioTracks() {
|
|
return this[PropertySymbol.tracks].filter((track) => track.kind === 'audio');
|
|
}
|
|
/**
|
|
* Returns track by id.
|
|
*
|
|
* @param id Id.
|
|
* @returns Track.
|
|
*/
|
|
getTrackById(id) {
|
|
for (const track of this[PropertySymbol.tracks]) {
|
|
if (track.id === id) {
|
|
return track;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
/**
|
|
* Returns video tracks.
|
|
*
|
|
* @returns Video tracks.
|
|
*/
|
|
getVideoTracks() {
|
|
return this[PropertySymbol.tracks].filter((track) => track.kind === 'video');
|
|
}
|
|
/**
|
|
* Removes a track.
|
|
*
|
|
* @param track Track.
|
|
*/
|
|
removeTrack(track) {
|
|
const index = this[PropertySymbol.tracks].indexOf(track);
|
|
if (index === -1) {
|
|
return;
|
|
}
|
|
this[PropertySymbol.tracks].splice(index, 1);
|
|
this.dispatchEvent(new MediaStreamTrackEvent('removetrack', { track }));
|
|
}
|
|
}
|
|
//# sourceMappingURL=MediaStream.js.map
|