shaka-video-element 0.7.0 → 0.7.2
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/dist/shaka-video-element.js +69 -36
- package/package.json +3 -3
|
@@ -31918,6 +31918,7 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
31918
31918
|
#nativeEl = null;
|
|
31919
31919
|
#childMap = /* @__PURE__ */ new Map();
|
|
31920
31920
|
#childObserver;
|
|
31921
|
+
#slotChangeHandler;
|
|
31921
31922
|
get;
|
|
31922
31923
|
set;
|
|
31923
31924
|
call;
|
|
@@ -31967,11 +31968,15 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
31967
31968
|
for (const prop of nativeElProps) {
|
|
31968
31969
|
this.#upgradeProperty(prop);
|
|
31969
31970
|
}
|
|
31971
|
+
this.#setupListeners();
|
|
31972
|
+
}
|
|
31973
|
+
#setupListeners() {
|
|
31970
31974
|
this.#childObserver = new MutationObserver(this.#syncMediaChildAttribute.bind(this));
|
|
31971
|
-
this
|
|
31975
|
+
this.#slotChangeHandler = () => this.#syncMediaChildren();
|
|
31976
|
+
this.shadowRoot?.addEventListener("slotchange", this.#slotChangeHandler);
|
|
31972
31977
|
this.#syncMediaChildren();
|
|
31973
31978
|
for (const type of this.constructor.Events) {
|
|
31974
|
-
this.shadowRoot
|
|
31979
|
+
this.shadowRoot?.addEventListener(type, this, true);
|
|
31975
31980
|
}
|
|
31976
31981
|
}
|
|
31977
31982
|
handleEvent(event) {
|
|
@@ -32040,6 +32045,23 @@ function CustomMediaMixin(superclass, { tag, is }) {
|
|
|
32040
32045
|
}
|
|
32041
32046
|
connectedCallback() {
|
|
32042
32047
|
this.#init();
|
|
32048
|
+
if (!this.#slotChangeHandler) {
|
|
32049
|
+
this.#setupListeners();
|
|
32050
|
+
}
|
|
32051
|
+
}
|
|
32052
|
+
disconnectedCallback() {
|
|
32053
|
+
this.#childObserver?.disconnect();
|
|
32054
|
+
this.#childObserver = void 0;
|
|
32055
|
+
if (this.#slotChangeHandler) {
|
|
32056
|
+
this.shadowRoot?.removeEventListener("slotchange", this.#slotChangeHandler);
|
|
32057
|
+
this.#slotChangeHandler = void 0;
|
|
32058
|
+
}
|
|
32059
|
+
for (const type of this.constructor.Events) {
|
|
32060
|
+
this.shadowRoot?.removeEventListener(type, this, true);
|
|
32061
|
+
}
|
|
32062
|
+
this.#childMap.forEach((clone) => clone.remove());
|
|
32063
|
+
this.#childMap.clear();
|
|
32064
|
+
this.#nativeEl = null;
|
|
32043
32065
|
}
|
|
32044
32066
|
};
|
|
32045
32067
|
}
|
|
@@ -32056,11 +32078,14 @@ function serializeAttributes(attrs) {
|
|
|
32056
32078
|
for (const key in attrs) {
|
|
32057
32079
|
if (!Attributes.includes(key)) continue;
|
|
32058
32080
|
const value = attrs[key];
|
|
32059
|
-
if (value === "") html += ` ${key}`;
|
|
32060
|
-
else html += ` ${key}="${value}"`;
|
|
32081
|
+
if (value === "") html += ` ${escapeHtml(key)}`;
|
|
32082
|
+
else html += ` ${escapeHtml(key)}="${escapeHtml(`${value}`)}"`;
|
|
32061
32083
|
}
|
|
32062
32084
|
return html;
|
|
32063
32085
|
}
|
|
32086
|
+
function escapeHtml(str) {
|
|
32087
|
+
return str.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'").replace(/`/g, "`");
|
|
32088
|
+
}
|
|
32064
32089
|
function namedNodeMapToObject(namedNodeMap) {
|
|
32065
32090
|
const obj = {};
|
|
32066
32091
|
for (const attr of namedNodeMap) {
|
|
@@ -32100,7 +32125,7 @@ function setPrivate(instance, props) {
|
|
|
32100
32125
|
// ../media-tracks/dist/video-track-list.js
|
|
32101
32126
|
function addVideoTrack(media, track) {
|
|
32102
32127
|
const trackList = media.videoTracks;
|
|
32103
|
-
getPrivate(track).media = media;
|
|
32128
|
+
getPrivate(track).media = new WeakRef(media);
|
|
32104
32129
|
if (!getPrivate(track).renditionSet) {
|
|
32105
32130
|
getPrivate(track).renditionSet = /* @__PURE__ */ new Set();
|
|
32106
32131
|
}
|
|
@@ -32119,7 +32144,7 @@ function addVideoTrack(media, track) {
|
|
|
32119
32144
|
});
|
|
32120
32145
|
}
|
|
32121
32146
|
function removeVideoTrack(track) {
|
|
32122
|
-
const trackList = getPrivate(track).media?.videoTracks;
|
|
32147
|
+
const trackList = getPrivate(track).media?.deref()?.videoTracks;
|
|
32123
32148
|
if (!trackList) return;
|
|
32124
32149
|
const trackSet = getPrivate(trackList).trackSet;
|
|
32125
32150
|
trackSet.delete(track);
|
|
@@ -32128,7 +32153,7 @@ function removeVideoTrack(track) {
|
|
|
32128
32153
|
});
|
|
32129
32154
|
}
|
|
32130
32155
|
function selectedChanged(selected) {
|
|
32131
|
-
const trackList = getPrivate(selected).media
|
|
32156
|
+
const trackList = getPrivate(selected).media?.deref()?.videoTracks ?? [];
|
|
32132
32157
|
let hasUnselected = false;
|
|
32133
32158
|
for (const track of trackList) {
|
|
32134
32159
|
if (track === selected) continue;
|
|
@@ -32219,7 +32244,7 @@ var RenditionEvent = class extends Event {
|
|
|
32219
32244
|
|
|
32220
32245
|
// ../media-tracks/dist/video-rendition-list.js
|
|
32221
32246
|
function addRendition(track, rendition) {
|
|
32222
|
-
const renditionList = getPrivate(track).media
|
|
32247
|
+
const renditionList = getPrivate(track).media?.deref()?.videoRenditions;
|
|
32223
32248
|
getPrivate(rendition).media = getPrivate(track).media;
|
|
32224
32249
|
getPrivate(rendition).track = track;
|
|
32225
32250
|
const renditionSet = getPrivate(track).renditionSet;
|
|
@@ -32233,23 +32258,23 @@ function addRendition(track, rendition) {
|
|
|
32233
32258
|
});
|
|
32234
32259
|
}
|
|
32235
32260
|
queueMicrotask(() => {
|
|
32236
|
-
if (!track.selected) return;
|
|
32261
|
+
if (!renditionList || !track.selected) return;
|
|
32237
32262
|
renditionList.dispatchEvent(new RenditionEvent("addrendition", { rendition }));
|
|
32238
32263
|
});
|
|
32239
32264
|
}
|
|
32240
32265
|
function removeRendition(rendition) {
|
|
32241
|
-
const renditionList = getPrivate(rendition).media
|
|
32266
|
+
const renditionList = getPrivate(rendition).media?.deref()?.videoRenditions;
|
|
32242
32267
|
const track = getPrivate(rendition).track;
|
|
32243
32268
|
const renditionSet = getPrivate(track).renditionSet;
|
|
32244
32269
|
renditionSet.delete(rendition);
|
|
32245
32270
|
queueMicrotask(() => {
|
|
32246
32271
|
const track2 = getPrivate(rendition).track;
|
|
32247
|
-
if (!track2.selected) return;
|
|
32272
|
+
if (!renditionList || !track2.selected) return;
|
|
32248
32273
|
renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition }));
|
|
32249
32274
|
});
|
|
32250
32275
|
}
|
|
32251
32276
|
function selectedChanged2(rendition) {
|
|
32252
|
-
const renditionList = getPrivate(rendition).media
|
|
32277
|
+
const renditionList = getPrivate(rendition).media?.deref()?.videoRenditions;
|
|
32253
32278
|
if (!renditionList || getPrivate(renditionList).changeRequested) return;
|
|
32254
32279
|
getPrivate(renditionList).changeRequested = true;
|
|
32255
32280
|
queueMicrotask(() => {
|
|
@@ -32260,7 +32285,8 @@ function selectedChanged2(rendition) {
|
|
|
32260
32285
|
});
|
|
32261
32286
|
}
|
|
32262
32287
|
function getCurrentRenditions(renditionList) {
|
|
32263
|
-
const media = getPrivate(renditionList).media;
|
|
32288
|
+
const media = getPrivate(renditionList).media?.deref();
|
|
32289
|
+
if (!media) return [];
|
|
32264
32290
|
return [...media.videoTracks].filter((track) => track.selected).flatMap((track) => [...getPrivate(track).renditionSet]);
|
|
32265
32291
|
}
|
|
32266
32292
|
var VideoRenditionList = class extends EventTarget {
|
|
@@ -32380,7 +32406,7 @@ var VideoTrack = class {
|
|
|
32380
32406
|
|
|
32381
32407
|
// ../media-tracks/dist/audio-rendition-list.js
|
|
32382
32408
|
function addRendition2(track, rendition) {
|
|
32383
|
-
const renditionList = getPrivate(track).media
|
|
32409
|
+
const renditionList = getPrivate(track).media?.deref()?.audioRenditions;
|
|
32384
32410
|
getPrivate(rendition).media = getPrivate(track).media;
|
|
32385
32411
|
getPrivate(rendition).track = track;
|
|
32386
32412
|
const renditionSet = getPrivate(track).renditionSet;
|
|
@@ -32394,23 +32420,23 @@ function addRendition2(track, rendition) {
|
|
|
32394
32420
|
});
|
|
32395
32421
|
}
|
|
32396
32422
|
queueMicrotask(() => {
|
|
32397
|
-
if (!track.enabled) return;
|
|
32423
|
+
if (!renditionList || !track.enabled) return;
|
|
32398
32424
|
renditionList.dispatchEvent(new RenditionEvent("addrendition", { rendition }));
|
|
32399
32425
|
});
|
|
32400
32426
|
}
|
|
32401
32427
|
function removeRendition2(rendition) {
|
|
32402
|
-
const renditionList = getPrivate(rendition).media
|
|
32428
|
+
const renditionList = getPrivate(rendition).media?.deref()?.audioRenditions;
|
|
32403
32429
|
const track = getPrivate(rendition).track;
|
|
32404
32430
|
const renditionSet = getPrivate(track).renditionSet;
|
|
32405
32431
|
renditionSet.delete(rendition);
|
|
32406
32432
|
queueMicrotask(() => {
|
|
32407
32433
|
const track2 = getPrivate(rendition).track;
|
|
32408
|
-
if (!track2.enabled) return;
|
|
32434
|
+
if (!renditionList || !track2.enabled) return;
|
|
32409
32435
|
renditionList.dispatchEvent(new RenditionEvent("removerendition", { rendition }));
|
|
32410
32436
|
});
|
|
32411
32437
|
}
|
|
32412
32438
|
function selectedChanged3(rendition) {
|
|
32413
|
-
const renditionList = getPrivate(rendition).media
|
|
32439
|
+
const renditionList = getPrivate(rendition).media?.deref()?.audioRenditions;
|
|
32414
32440
|
if (!renditionList || getPrivate(renditionList).changeRequested) return;
|
|
32415
32441
|
getPrivate(renditionList).changeRequested = true;
|
|
32416
32442
|
queueMicrotask(() => {
|
|
@@ -32421,7 +32447,8 @@ function selectedChanged3(rendition) {
|
|
|
32421
32447
|
});
|
|
32422
32448
|
}
|
|
32423
32449
|
function getCurrentRenditions2(renditionList) {
|
|
32424
|
-
const media = getPrivate(renditionList).media;
|
|
32450
|
+
const media = getPrivate(renditionList).media?.deref();
|
|
32451
|
+
if (!media) return [];
|
|
32425
32452
|
return [...media.audioTracks].filter((track) => track.enabled).flatMap((track) => [...getPrivate(track).renditionSet]);
|
|
32426
32453
|
}
|
|
32427
32454
|
var AudioRenditionList = class extends EventTarget {
|
|
@@ -32506,7 +32533,7 @@ var AudioRendition = class {
|
|
|
32506
32533
|
// ../media-tracks/dist/audio-track-list.js
|
|
32507
32534
|
function addAudioTrack(media, track) {
|
|
32508
32535
|
const trackList = media.audioTracks;
|
|
32509
|
-
getPrivate(track).media = media;
|
|
32536
|
+
getPrivate(track).media = new WeakRef(media);
|
|
32510
32537
|
if (!getPrivate(track).renditionSet) {
|
|
32511
32538
|
getPrivate(track).renditionSet = /* @__PURE__ */ new Set();
|
|
32512
32539
|
}
|
|
@@ -32525,7 +32552,7 @@ function addAudioTrack(media, track) {
|
|
|
32525
32552
|
});
|
|
32526
32553
|
}
|
|
32527
32554
|
function removeAudioTrack(track) {
|
|
32528
|
-
const trackList = getPrivate(track).media?.audioTracks;
|
|
32555
|
+
const trackList = getPrivate(track).media?.deref()?.audioTracks;
|
|
32529
32556
|
if (!trackList) return;
|
|
32530
32557
|
const trackSet = getPrivate(trackList).trackSet;
|
|
32531
32558
|
trackSet.delete(track);
|
|
@@ -32534,7 +32561,7 @@ function removeAudioTrack(track) {
|
|
|
32534
32561
|
});
|
|
32535
32562
|
}
|
|
32536
32563
|
function enabledChanged(track) {
|
|
32537
|
-
const trackList = getPrivate(track).media
|
|
32564
|
+
const trackList = getPrivate(track).media?.deref()?.audioTracks;
|
|
32538
32565
|
if (!trackList || getPrivate(trackList).changeRequested) return;
|
|
32539
32566
|
getPrivate(trackList).changeRequested = true;
|
|
32540
32567
|
queueMicrotask(() => {
|
|
@@ -32690,7 +32717,7 @@ function MediaTracksMixin(MediaElementClass) {
|
|
|
32690
32717
|
let renditions = getPrivate(media).videoRenditions;
|
|
32691
32718
|
if (!renditions) {
|
|
32692
32719
|
renditions = new VideoRenditionList();
|
|
32693
|
-
getPrivate(renditions).media = media;
|
|
32720
|
+
getPrivate(renditions).media = new WeakRef(media);
|
|
32694
32721
|
getPrivate(media).videoRenditions = renditions;
|
|
32695
32722
|
}
|
|
32696
32723
|
return renditions;
|
|
@@ -32706,7 +32733,7 @@ function MediaTracksMixin(MediaElementClass) {
|
|
|
32706
32733
|
let renditions = getPrivate(media).audioRenditions;
|
|
32707
32734
|
if (!renditions) {
|
|
32708
32735
|
renditions = new AudioRenditionList();
|
|
32709
|
-
getPrivate(renditions).media = media;
|
|
32736
|
+
getPrivate(renditions).media = new WeakRef(media);
|
|
32710
32737
|
getPrivate(media).audioRenditions = renditions;
|
|
32711
32738
|
}
|
|
32712
32739
|
return renditions;
|
|
@@ -32728,10 +32755,10 @@ function getVideoTracks(media) {
|
|
|
32728
32755
|
for (const nativeTrack of nativeTracks) {
|
|
32729
32756
|
addVideoTrack(media, nativeTrack);
|
|
32730
32757
|
}
|
|
32731
|
-
|
|
32758
|
+
const onChange = () => {
|
|
32732
32759
|
tracks.dispatchEvent(new Event("change"));
|
|
32733
|
-
}
|
|
32734
|
-
|
|
32760
|
+
};
|
|
32761
|
+
const onAddTrack = (event) => {
|
|
32735
32762
|
if ([...tracks].some((t) => t instanceof VideoTrack)) {
|
|
32736
32763
|
for (const nativeTrack of nativeTracks) {
|
|
32737
32764
|
removeVideoTrack(nativeTrack);
|
|
@@ -32739,10 +32766,13 @@ function getVideoTracks(media) {
|
|
|
32739
32766
|
return;
|
|
32740
32767
|
}
|
|
32741
32768
|
addVideoTrack(media, event.track);
|
|
32742
|
-
}
|
|
32743
|
-
|
|
32769
|
+
};
|
|
32770
|
+
const onRemoveTrack = (event) => {
|
|
32744
32771
|
removeVideoTrack(event.track);
|
|
32745
|
-
}
|
|
32772
|
+
};
|
|
32773
|
+
nativeTracks.addEventListener("change", onChange);
|
|
32774
|
+
nativeTracks.addEventListener("addtrack", onAddTrack);
|
|
32775
|
+
nativeTracks.addEventListener("removetrack", onRemoveTrack);
|
|
32746
32776
|
}
|
|
32747
32777
|
}
|
|
32748
32778
|
return tracks;
|
|
@@ -32757,10 +32787,10 @@ function getAudioTracks(media) {
|
|
|
32757
32787
|
for (const nativeTrack of nativeTracks) {
|
|
32758
32788
|
addAudioTrack(media, nativeTrack);
|
|
32759
32789
|
}
|
|
32760
|
-
|
|
32790
|
+
const onChange = () => {
|
|
32761
32791
|
tracks.dispatchEvent(new Event("change"));
|
|
32762
|
-
}
|
|
32763
|
-
|
|
32792
|
+
};
|
|
32793
|
+
const onAddTrack = (event) => {
|
|
32764
32794
|
if ([...tracks].some((t) => t instanceof AudioTrack)) {
|
|
32765
32795
|
for (const nativeTrack of nativeTracks) {
|
|
32766
32796
|
removeAudioTrack(nativeTrack);
|
|
@@ -32768,10 +32798,13 @@ function getAudioTracks(media) {
|
|
|
32768
32798
|
return;
|
|
32769
32799
|
}
|
|
32770
32800
|
addAudioTrack(media, event.track);
|
|
32771
|
-
}
|
|
32772
|
-
|
|
32801
|
+
};
|
|
32802
|
+
const onRemoveTrack = (event) => {
|
|
32773
32803
|
removeAudioTrack(event.track);
|
|
32774
|
-
}
|
|
32804
|
+
};
|
|
32805
|
+
nativeTracks.addEventListener("change", onChange);
|
|
32806
|
+
nativeTracks.addEventListener("addtrack", onAddTrack);
|
|
32807
|
+
nativeTracks.addEventListener("removetrack", onRemoveTrack);
|
|
32775
32808
|
}
|
|
32776
32809
|
}
|
|
32777
32810
|
return tracks;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "shaka-video-element",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "Custom element (web component) for Shaka Player",
|
|
5
5
|
"author": "@muxinc",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"build": "run-s build:*"
|
|
53
53
|
},
|
|
54
54
|
"dependencies": {
|
|
55
|
-
"custom-media-element": "^1.4.
|
|
56
|
-
"media-tracks": "^0.3.
|
|
55
|
+
"custom-media-element": "^1.4.7",
|
|
56
|
+
"media-tracks": "^0.3.5",
|
|
57
57
|
"shaka-player": "~4.15.4"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|