media-tracks
Advanced tools
Comparing version 0.2.0 to 0.2.1
@@ -5,9 +5,7 @@ import { RenditionEvent } from "./rendition-event.js"; | ||
const renditionList = getPrivate(track).media.audioRenditions; | ||
if (!getPrivate(rendition).list) { | ||
getPrivate(rendition).list = renditionList; | ||
getPrivate(rendition).track = track; | ||
} | ||
const { collection } = getPrivate(renditionList); | ||
collection.add(rendition); | ||
const index = collection.size - 1; | ||
getPrivate(rendition).media = getPrivate(track).media; | ||
getPrivate(rendition).track = track; | ||
const renditionSet = getPrivate(track).renditionSet; | ||
renditionSet.add(rendition); | ||
const index = renditionSet.size - 1; | ||
if (!(index in AudioRenditionList.prototype)) { | ||
@@ -27,8 +25,9 @@ Object.defineProperty(AudioRenditionList.prototype, index, { | ||
function removeRendition(rendition) { | ||
const renditionList = getPrivate(rendition).list; | ||
const collection = getPrivate(renditionList).collection; | ||
collection.delete(rendition); | ||
const renditionList = getPrivate(rendition).media.audioRenditions; | ||
const track = getPrivate(rendition).track; | ||
const renditionSet = getPrivate(track).renditionSet; | ||
renditionSet.delete(rendition); | ||
queueMicrotask(() => { | ||
const track = getPrivate(rendition).track; | ||
if (!track.enabled) | ||
const track2 = getPrivate(rendition).track; | ||
if (!track2.enabled) | ||
return; | ||
@@ -39,3 +38,3 @@ renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition })); | ||
function selectedChanged(rendition) { | ||
const renditionList = getPrivate(rendition).list; | ||
const renditionList = getPrivate(rendition).media.audioRenditions; | ||
if (!renditionList || getPrivate(renditionList).changeRequested) | ||
@@ -53,5 +52,4 @@ return; | ||
function getCurrentRenditions(renditionList) { | ||
return [...getPrivate(renditionList).collection].filter((rendition) => { | ||
return getPrivate(rendition).track.enabled; | ||
}); | ||
const media = getPrivate(renditionList).media; | ||
return [...media.audioTracks].filter((track) => track.enabled).flatMap((track) => [...getPrivate(track).renditionSet]); | ||
} | ||
@@ -62,6 +60,2 @@ class AudioRenditionList extends EventTarget { | ||
#changeCallback; | ||
constructor() { | ||
super(); | ||
getPrivate(this).collection = /* @__PURE__ */ new Set(); | ||
} | ||
[Symbol.iterator]() { | ||
@@ -68,0 +62,0 @@ return getCurrentRenditions(this).values(); |
@@ -5,13 +5,13 @@ import { TrackEvent } from "./track-event.js"; | ||
const trackList = media.audioTracks; | ||
if (!getPrivate(track).list) { | ||
getPrivate(track).list = trackList; | ||
getPrivate(track).media = media; | ||
getPrivate(track).media = media; | ||
if (!getPrivate(track).renditionSet) { | ||
getPrivate(track).renditionSet = /* @__PURE__ */ new Set(); | ||
} | ||
const { collection } = getPrivate(trackList); | ||
collection.add(track); | ||
const index = collection.size - 1; | ||
const trackSet = getPrivate(trackList).trackSet; | ||
trackSet.add(track); | ||
const index = trackSet.size - 1; | ||
if (!(index in AudioTrackList.prototype)) { | ||
Object.defineProperty(AudioTrackList.prototype, index, { | ||
get() { | ||
return [...collection][index]; | ||
return [...getPrivate(this).trackSet][index]; | ||
} | ||
@@ -25,5 +25,5 @@ }); | ||
function removeAudioTrack(track) { | ||
const trackList = getPrivate(track).list; | ||
const collection = getPrivate(trackList).collection; | ||
collection.delete(track); | ||
const trackList = getPrivate(track).media.audioTracks; | ||
const trackSet = getPrivate(trackList).trackSet; | ||
trackSet.delete(track); | ||
queueMicrotask(() => { | ||
@@ -34,3 +34,3 @@ trackList.dispatchEvent(new TrackEvent("removetrack", { track })); | ||
function enabledChanged(track) { | ||
const trackList = getPrivate(track).list; | ||
const trackList = getPrivate(track).media.audioTracks; | ||
if (!trackList || getPrivate(trackList).changeRequested) | ||
@@ -50,6 +50,6 @@ return; | ||
super(); | ||
getPrivate(this).collection = /* @__PURE__ */ new Set(); | ||
getPrivate(this).trackSet = /* @__PURE__ */ new Set(); | ||
} | ||
get #tracks() { | ||
return getPrivate(this).collection; | ||
return getPrivate(this).trackSet; | ||
} | ||
@@ -56,0 +56,0 @@ [Symbol.iterator]() { |
@@ -121,2 +121,3 @@ import { VideoTrack } from "./video-track.js"; | ||
renditions = new VideoRenditionList(); | ||
getPrivate(renditions).media = media; | ||
getPrivate(media).videoRenditions = renditions; | ||
@@ -137,2 +138,3 @@ } | ||
renditions = new AudioRenditionList(); | ||
getPrivate(renditions).media = media; | ||
getPrivate(media).audioRenditions = renditions; | ||
@@ -139,0 +141,0 @@ } |
@@ -9,3 +9,2 @@ import type { AudioTrack } from './audio-track.js'; | ||
[index: number]: AudioRendition; | ||
constructor(); | ||
[Symbol.iterator](): IterableIterator<AudioRendition>; | ||
@@ -12,0 +11,0 @@ get length(): number; |
@@ -9,3 +9,2 @@ import type { VideoTrack } from './video-track.js'; | ||
[index: number]: VideoRendition; | ||
constructor(); | ||
[Symbol.iterator](): IterableIterator<VideoRendition>; | ||
@@ -12,0 +11,0 @@ get length(): number; |
@@ -5,9 +5,7 @@ import { RenditionEvent } from "./rendition-event.js"; | ||
const renditionList = getPrivate(track).media.videoRenditions; | ||
if (!getPrivate(rendition).list) { | ||
getPrivate(rendition).list = renditionList; | ||
getPrivate(rendition).track = track; | ||
} | ||
const { collection } = getPrivate(renditionList); | ||
collection.add(rendition); | ||
const index = collection.size - 1; | ||
getPrivate(rendition).media = getPrivate(track).media; | ||
getPrivate(rendition).track = track; | ||
const renditionSet = getPrivate(track).renditionSet; | ||
renditionSet.add(rendition); | ||
const index = renditionSet.size - 1; | ||
if (!(index in VideoRenditionList.prototype)) { | ||
@@ -27,8 +25,9 @@ Object.defineProperty(VideoRenditionList.prototype, index, { | ||
function removeRendition(rendition) { | ||
const renditionList = getPrivate(rendition).list; | ||
const collection = getPrivate(renditionList).collection; | ||
collection.delete(rendition); | ||
const renditionList = getPrivate(rendition).media.videoRenditions; | ||
const track = getPrivate(rendition).track; | ||
const renditionSet = getPrivate(track).renditionSet; | ||
renditionSet.delete(rendition); | ||
queueMicrotask(() => { | ||
const track = getPrivate(rendition).track; | ||
if (!track.selected) | ||
const track2 = getPrivate(rendition).track; | ||
if (!track2.selected) | ||
return; | ||
@@ -39,3 +38,3 @@ renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition })); | ||
function selectedChanged(rendition) { | ||
const renditionList = getPrivate(rendition).list; | ||
const renditionList = getPrivate(rendition).media.videoRenditions; | ||
if (!renditionList || getPrivate(renditionList).changeRequested) | ||
@@ -53,5 +52,4 @@ return; | ||
function getCurrentRenditions(renditionList) { | ||
return [...getPrivate(renditionList).collection].filter((rendition) => { | ||
return getPrivate(rendition).track.selected; | ||
}); | ||
const media = getPrivate(renditionList).media; | ||
return [...media.videoTracks].filter((track) => track.selected).flatMap((track) => [...getPrivate(track).renditionSet]); | ||
} | ||
@@ -62,6 +60,2 @@ class VideoRenditionList extends EventTarget { | ||
#changeCallback; | ||
constructor() { | ||
super(); | ||
getPrivate(this).collection = /* @__PURE__ */ new Set(); | ||
} | ||
[Symbol.iterator]() { | ||
@@ -68,0 +62,0 @@ return getCurrentRenditions(this).values(); |
@@ -5,13 +5,13 @@ import { TrackEvent } from "./track-event.js"; | ||
const trackList = media.videoTracks; | ||
if (!getPrivate(track).list) { | ||
getPrivate(track).list = trackList; | ||
getPrivate(track).media = media; | ||
getPrivate(track).media = media; | ||
if (!getPrivate(track).renditionSet) { | ||
getPrivate(track).renditionSet = /* @__PURE__ */ new Set(); | ||
} | ||
const { collection } = getPrivate(trackList); | ||
collection.add(track); | ||
const index = collection.size - 1; | ||
const trackSet = getPrivate(trackList).trackSet; | ||
trackSet.add(track); | ||
const index = trackSet.size - 1; | ||
if (!(index in VideoTrackList.prototype)) { | ||
Object.defineProperty(VideoTrackList.prototype, index, { | ||
get() { | ||
return [...collection][index]; | ||
return [...getPrivate(this).trackSet][index]; | ||
} | ||
@@ -25,5 +25,5 @@ }); | ||
function removeVideoTrack(track) { | ||
const trackList = getPrivate(track).list; | ||
const collection = getPrivate(trackList).collection; | ||
collection.delete(track); | ||
const trackList = getPrivate(track).media.videoTracks; | ||
const trackSet = getPrivate(trackList).trackSet; | ||
trackSet.delete(track); | ||
queueMicrotask(() => { | ||
@@ -34,3 +34,3 @@ trackList.dispatchEvent(new TrackEvent("removetrack", { track })); | ||
function selectedChanged(selected) { | ||
const trackList = getPrivate(selected).list ?? []; | ||
const trackList = getPrivate(selected).media.videoTracks ?? []; | ||
let hasUnselected = false; | ||
@@ -59,6 +59,6 @@ for (const track of trackList) { | ||
super(); | ||
getPrivate(this).collection = /* @__PURE__ */ new Set(); | ||
getPrivate(this).trackSet = /* @__PURE__ */ new Set(); | ||
} | ||
get #tracks() { | ||
return getPrivate(this).collection; | ||
return getPrivate(this).trackSet; | ||
} | ||
@@ -65,0 +65,0 @@ [Symbol.iterator]() { |
{ | ||
"name": "media-tracks", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"description": "Polyfill audio and video tracks with renditions.", | ||
@@ -17,4 +17,3 @@ "type": "module", | ||
"lint": "npx eslint src/*.ts", | ||
"pretest": "esbuild src/*.ts --format=esm --outdir=dist", | ||
"test": "web-test-runner --config test/web-test-runner.config.js", | ||
"test": "web-test-runner --coverage --config test/web-test-runner.config.js", | ||
"dev": "esbuild src/*.ts --format=esm --outdir=dist --servedir=.", | ||
@@ -29,8 +28,9 @@ "build": "rm -rf dist && esbuild src/*.ts --format=esm --outdir=dist", | ||
"@open-wc/testing": "^3.2.0", | ||
"@typescript-eslint/eslint-plugin": "^5.59.9", | ||
"@typescript-eslint/parser": "^5.59.9", | ||
"@web/test-runner": "^0.16.1", | ||
"esbuild": "^0.17.19", | ||
"eslint": "^8.42.0", | ||
"typescript": "5.0.4" | ||
"@typescript-eslint/eslint-plugin": "^6.0.0", | ||
"@typescript-eslint/parser": "^6.0.0", | ||
"@web/dev-server-esbuild": "^0.4.1", | ||
"@web/test-runner": "^0.17.0", | ||
"esbuild": "^0.18.12", | ||
"eslint": "^8.44.0", | ||
"typescript": "5.1.6" | ||
}, | ||
@@ -37,0 +37,0 @@ "eslintConfig": { |
@@ -5,2 +5,3 @@ # Media Tracks | ||
[![Badge size](https://img.badgesize.io/https://cdn.jsdelivr.net/npm/media-tracks/+esm?compression=gzip&label=gzip&style=flat-square)](https://cdn.jsdelivr.net/npm/media-tracks/+esm) | ||
![Codecov](https://img.shields.io/codecov/c/github/muxinc/media-tracks?style=flat-square) | ||
@@ -7,0 +8,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40083
159
8
1029