@norskvideo/moq-watch 0.2.0 → 0.2.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/element.d.ts +10 -2
- package/element.d.ts.map +1 -1
- package/element.js +95 -80
- package/element.js.map +1 -1
- package/index.js +1 -1
- package/package.json +6 -6
- package/{player-C19uf7Dc.js → player-C7Ih0ExN.js} +64 -36
- package/player-C7Ih0ExN.js.map +1 -0
- package/video/renderer.d.ts +10 -1
- package/video/renderer.d.ts.map +1 -1
- package/video/tab-visible.d.ts +28 -0
- package/video/tab-visible.d.ts.map +1 -0
- package/player-C19uf7Dc.js.map +0 -1
|
@@ -1078,7 +1078,7 @@ var Le = [
|
|
|
1078
1078
|
}
|
|
1079
1079
|
if (i === r) return { local: !0 };
|
|
1080
1080
|
let a = e.get(this.in.origin);
|
|
1081
|
-
if (!a || !
|
|
1081
|
+
if (!a || !e.get(this.in.announced) || e.get(a.discovery) === !1 || this.#s(e, i)) return {
|
|
1082
1082
|
local: !1,
|
|
1083
1083
|
path: i
|
|
1084
1084
|
};
|
|
@@ -1815,8 +1815,26 @@ async function tt(e) {
|
|
|
1815
1815
|
}
|
|
1816
1816
|
Object.assign(tt, { [Y]: We });
|
|
1817
1817
|
//#endregion
|
|
1818
|
-
//#region src/video/
|
|
1819
|
-
var nt =
|
|
1818
|
+
//#region src/video/tab-visible.ts
|
|
1819
|
+
var nt = class {
|
|
1820
|
+
visible;
|
|
1821
|
+
#e;
|
|
1822
|
+
#t;
|
|
1823
|
+
#n = new i();
|
|
1824
|
+
constructor(e = {}) {
|
|
1825
|
+
let t = e.doc ?? globalThis.document;
|
|
1826
|
+
this.#e = new a(t?.hidden ?? !1), this.visible = new a(!this.#e.peek()), this.#t = o(e.grace ?? 5e3), t && this.#n.event(t, "visibilitychange", () => this.#e.set(t.hidden)), this.#n.run((e) => {
|
|
1827
|
+
if (!e.get(this.#e)) {
|
|
1828
|
+
this.visible.set(!0);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
e.timer(() => this.visible.set(!1), e.get(this.#t));
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
close() {
|
|
1835
|
+
this.#n.close();
|
|
1836
|
+
}
|
|
1837
|
+
}, rt = .01, it = class {
|
|
1820
1838
|
decoder;
|
|
1821
1839
|
in;
|
|
1822
1840
|
#e = {
|
|
@@ -1827,22 +1845,27 @@ var nt = .01, rt = class {
|
|
|
1827
1845
|
out = s(this.#e);
|
|
1828
1846
|
#t = new a(void 0);
|
|
1829
1847
|
#n = new i();
|
|
1848
|
+
#r;
|
|
1830
1849
|
constructor(e) {
|
|
1831
1850
|
this.decoder = e.decoder, this.in = {
|
|
1832
1851
|
canvas: o(e?.canvas),
|
|
1833
|
-
visible: o(e?.visible ?? "20%")
|
|
1834
|
-
|
|
1852
|
+
visible: o(e?.visible ?? "20%"),
|
|
1853
|
+
hiddenGrace: o(e?.hiddenGrace ?? 5e3)
|
|
1854
|
+
}, this.#r = new nt({
|
|
1855
|
+
doc: e.document,
|
|
1856
|
+
grace: this.in.hiddenGrace
|
|
1857
|
+
}), this.#n.run((e) => {
|
|
1835
1858
|
let t = e.get(this.in.canvas);
|
|
1836
1859
|
this.#t.set(t?.getContext("2d") ?? void 0);
|
|
1837
|
-
}), this.#n.run(this.#
|
|
1860
|
+
}), this.#n.run(this.#a.bind(this)), this.#n.run(this.#o.bind(this)), this.#n.run(this.#i.bind(this));
|
|
1838
1861
|
}
|
|
1839
|
-
#
|
|
1862
|
+
#i(e) {
|
|
1840
1863
|
let t = e.getAll([this.in.canvas, this.decoder.out.display]);
|
|
1841
1864
|
if (!t) return;
|
|
1842
1865
|
let [n, r] = t;
|
|
1843
1866
|
(n.width !== r.width || n.height !== r.height) && (n.width = r.width, n.height = r.height);
|
|
1844
1867
|
}
|
|
1845
|
-
#
|
|
1868
|
+
#a(e) {
|
|
1846
1869
|
let t = e.get(this.in.visible);
|
|
1847
1870
|
if (t === "never") {
|
|
1848
1871
|
this.#e.visible.set(!1);
|
|
@@ -1852,31 +1875,36 @@ var nt = .01, rt = class {
|
|
|
1852
1875
|
this.#e.visible.set(!0), e.cleanup(() => this.#e.visible.set(!1));
|
|
1853
1876
|
return;
|
|
1854
1877
|
}
|
|
1855
|
-
let n = e.get(this.
|
|
1856
|
-
if (
|
|
1878
|
+
let n = e.get(this.#r.visible);
|
|
1879
|
+
if (t === "tab") {
|
|
1880
|
+
this.#e.visible.set(n), e.cleanup(() => this.#e.visible.set(!1));
|
|
1881
|
+
return;
|
|
1882
|
+
}
|
|
1883
|
+
let r = e.get(this.in.canvas);
|
|
1884
|
+
if (!r) {
|
|
1857
1885
|
this.#e.visible.set(!1);
|
|
1858
1886
|
return;
|
|
1859
1887
|
}
|
|
1860
|
-
let
|
|
1861
|
-
this.#e.visible.set(
|
|
1862
|
-
},
|
|
1863
|
-
for (let t of e)
|
|
1864
|
-
},
|
|
1888
|
+
let i = !1, a = () => {
|
|
1889
|
+
this.#e.visible.set(i && n);
|
|
1890
|
+
}, o = (e) => {
|
|
1891
|
+
for (let t of e) i = t.isIntersecting, a();
|
|
1892
|
+
}, s;
|
|
1865
1893
|
try {
|
|
1866
|
-
|
|
1867
|
-
threshold:
|
|
1894
|
+
s = new IntersectionObserver(o, {
|
|
1895
|
+
threshold: rt,
|
|
1868
1896
|
rootMargin: t
|
|
1869
1897
|
});
|
|
1870
1898
|
} catch {
|
|
1871
|
-
console.warn(`moq-watch: invalid visible margin "${t}", using "0px"`),
|
|
1899
|
+
console.warn(`moq-watch: invalid visible margin "${t}", using "0px"`), s = new IntersectionObserver(o, { threshold: rt });
|
|
1872
1900
|
}
|
|
1873
|
-
|
|
1901
|
+
a(), s.observe(r), e.cleanup(() => s.disconnect()), e.cleanup(() => this.#e.visible.set(!1));
|
|
1874
1902
|
}
|
|
1875
|
-
#
|
|
1903
|
+
#o(e) {
|
|
1876
1904
|
let t = e.get(this.#t);
|
|
1877
1905
|
if (!t) return;
|
|
1878
1906
|
let n = e.get(this.decoder.out.frame), i = e.get(this.decoder.source.out.catalog), a = requestAnimationFrame(() => {
|
|
1879
|
-
this.#
|
|
1907
|
+
this.#s(t, n, i), n ? (this.#e.frame.update((e) => (e?.close(), n.clone())), this.#e.timestamp.set(r.Milli.fromMicro(n.timestamp))) : (this.#e.frame.update((e) => {
|
|
1880
1908
|
e?.close();
|
|
1881
1909
|
}), this.#e.timestamp.set(void 0)), a = void 0;
|
|
1882
1910
|
});
|
|
@@ -1884,7 +1912,7 @@ var nt = .01, rt = class {
|
|
|
1884
1912
|
a !== void 0 && cancelAnimationFrame(a);
|
|
1885
1913
|
});
|
|
1886
1914
|
}
|
|
1887
|
-
#
|
|
1915
|
+
#s(e, t, n) {
|
|
1888
1916
|
if (!t) {
|
|
1889
1917
|
e.fillStyle = "#000", e.fillRect(0, 0, e.canvas.width, e.canvas.height);
|
|
1890
1918
|
return;
|
|
@@ -1899,12 +1927,12 @@ var nt = .01, rt = class {
|
|
|
1899
1927
|
close() {
|
|
1900
1928
|
this.#e.frame.update((e) => {
|
|
1901
1929
|
e?.close();
|
|
1902
|
-
}), this.#e.timestamp.set(void 0), this.#n.close();
|
|
1930
|
+
}), this.#e.timestamp.set(void 0), this.#n.close(), this.#r.close();
|
|
1903
1931
|
}
|
|
1904
1932
|
};
|
|
1905
1933
|
//#endregion
|
|
1906
1934
|
//#region src/video/source.ts
|
|
1907
|
-
function
|
|
1935
|
+
function at(e) {
|
|
1908
1936
|
return (t) => {
|
|
1909
1937
|
let n = [], r = [];
|
|
1910
1938
|
for (let [i, a] of t) if (a.codedWidth && a.codedHeight) {
|
|
@@ -1920,7 +1948,7 @@ function it(e) {
|
|
|
1920
1948
|
return n.sort((e, t) => t.size - e.size), n.length > 0 ? n.map((e) => e.name) : r.length > 0 ? (r.sort((e, t) => e.size - t.size), [r[0].name]) : t.map(([e]) => e);
|
|
1921
1949
|
};
|
|
1922
1950
|
}
|
|
1923
|
-
function
|
|
1951
|
+
function ot(e, t) {
|
|
1924
1952
|
return (n) => {
|
|
1925
1953
|
let r = [], i = [];
|
|
1926
1954
|
for (let [a, o] of n) {
|
|
@@ -1950,7 +1978,7 @@ function $(e) {
|
|
|
1950
1978
|
return n.sort((e, t) => t.bitrate - e.bitrate), n.length > 0 ? n.map((e) => e.name) : r.length > 0 ? (r.sort((e, t) => e.bitrate - t.bitrate), [r[0].name]) : t.map(([e]) => e);
|
|
1951
1979
|
};
|
|
1952
1980
|
}
|
|
1953
|
-
function
|
|
1981
|
+
function st(e) {
|
|
1954
1982
|
let t = e[0];
|
|
1955
1983
|
for (let n of e) {
|
|
1956
1984
|
let [, e] = n, [, r] = t, i = (e.codedWidth ?? 0) * (e.codedHeight ?? 0), a = (r.codedWidth ?? 0) * (r.codedHeight ?? 0);
|
|
@@ -1962,15 +1990,15 @@ function ot(e) {
|
|
|
1962
1990
|
}
|
|
1963
1991
|
return t[0];
|
|
1964
1992
|
}
|
|
1965
|
-
function
|
|
1993
|
+
function ct(e) {
|
|
1966
1994
|
let t = Object.entries(e).filter(([, e]) => !e.stalled);
|
|
1967
1995
|
if (t.length > 0) return Object.fromEntries(t);
|
|
1968
1996
|
let n = Object.entries(e);
|
|
1969
1997
|
if (n.length === 0) return {};
|
|
1970
|
-
let r = $(0)(n), i = r.length === 1 ? r[0] :
|
|
1998
|
+
let r = $(0)(n), i = r.length === 1 ? r[0] : ot(0, 0)(n)[0];
|
|
1971
1999
|
return { [i]: e[i] };
|
|
1972
2000
|
}
|
|
1973
|
-
var
|
|
2001
|
+
var lt = class {
|
|
1974
2002
|
in;
|
|
1975
2003
|
#e = {
|
|
1976
2004
|
catalog: new a(void 0),
|
|
@@ -2039,7 +2067,7 @@ var ct = class {
|
|
|
2039
2067
|
e.set(this.#e.track, n.name), e.set(this.#e.config, r);
|
|
2040
2068
|
return;
|
|
2041
2069
|
}
|
|
2042
|
-
let r =
|
|
2070
|
+
let r = ct(t);
|
|
2043
2071
|
if (Object.keys(r).length === 0) return;
|
|
2044
2072
|
let i = n;
|
|
2045
2073
|
if (!n?.bitrate) {
|
|
@@ -2062,7 +2090,7 @@ var ct = class {
|
|
|
2062
2090
|
if (n.length === 0) return;
|
|
2063
2091
|
if (n.length === 1) return n[0][0];
|
|
2064
2092
|
let r = [];
|
|
2065
|
-
if (t?.pixels != null && r.push(
|
|
2093
|
+
if (t?.pixels != null && r.push(at(t.pixels)), (t?.width != null || t?.height != null) && r.push(ot(t.width, t.height)), t?.bitrate != null && r.push($(t.bitrate)), r.length === 0) return st(n);
|
|
2066
2094
|
let i = r.map((e) => e(n)), a = i.map((e) => new Set(e));
|
|
2067
2095
|
for (let e of i[0]) if (a.every((t) => t.has(e))) return e;
|
|
2068
2096
|
console.warn("conflicting rendition filters, no rendition satisfies all criteria");
|
|
@@ -2070,7 +2098,7 @@ var ct = class {
|
|
|
2070
2098
|
close() {
|
|
2071
2099
|
this.#t.close();
|
|
2072
2100
|
}
|
|
2073
|
-
},
|
|
2101
|
+
}, ut = class {
|
|
2074
2102
|
in;
|
|
2075
2103
|
broadcast;
|
|
2076
2104
|
sync;
|
|
@@ -2105,7 +2133,7 @@ var ct = class {
|
|
|
2105
2133
|
audioTarget: o(e.audioTarget),
|
|
2106
2134
|
captions: o(e.captions)
|
|
2107
2135
|
}), this.broadcast = new R(this.in), this.#r.cleanup(() => this.broadcast.close());
|
|
2108
|
-
let t = new
|
|
2136
|
+
let t = new lt({
|
|
2109
2137
|
broadcast: this.broadcast,
|
|
2110
2138
|
target: this.in.target,
|
|
2111
2139
|
supported: Q.supported,
|
|
@@ -2139,7 +2167,7 @@ var ct = class {
|
|
|
2139
2167
|
volume: this.in.volume,
|
|
2140
2168
|
muted: this.in.muted,
|
|
2141
2169
|
paused: this.in.paused
|
|
2142
|
-
}), this.renderer = new
|
|
2170
|
+
}), this.renderer = new it({
|
|
2143
2171
|
decoder: this.video,
|
|
2144
2172
|
canvas: this.in.canvas,
|
|
2145
2173
|
visible: this.in.visible
|
|
@@ -2167,6 +2195,6 @@ var ct = class {
|
|
|
2167
2195
|
}
|
|
2168
2196
|
};
|
|
2169
2197
|
//#endregion
|
|
2170
|
-
export { Ae as _, J as a, G as c, W as d, V as f, N as g, Le as h, Q as i, H as l, R as m,
|
|
2198
|
+
export { Ae as _, J as a, G as c, W as d, V as f, N as g, Le as h, Q as i, H as l, R as m, lt as n, q as o, B as p, it as r, K as s, ut as t, U as u, j as v };
|
|
2171
2199
|
|
|
2172
|
-
//# sourceMappingURL=player-
|
|
2200
|
+
//# sourceMappingURL=player-C7Ih0ExN.js.map
|