@tidal-music/player-web-components 0.1.1 → 0.2.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/dist/basePlayer-C5QIyqfj-Dxhlf4BZ.js +528 -0
- package/dist/{browserPlayer-oNOpDVm6-UW0N6pFH.js → browserPlayer-HE2uqs17-DJrIq6Jp.js} +44 -55
- package/dist/{index-tM9JvbA8.js → index-vp_MoGvy.js} +1204 -1054
- package/dist/index.d.ts +3 -0
- package/dist/index.js +9 -8
- package/dist/{nativePlayer-U375Dfm5-hUK7oXzY.js → nativePlayer-B3eHKegV-DdXsvi0F.js} +65 -104
- package/dist/output-devices-Jno8Kp5B-CAnEAv_Z.js +224 -0
- package/dist/shakaPlayer-CCJQsypf-DHT2kwDp.js +24411 -0
- package/package.json +16 -18
- package/dist/basePlayer-a-avZASH-Ux-6s9Ex.js +0 -579
- package/dist/output-devices-NXuo75MQ-_vYYuqUm.js +0 -236
- package/dist/shakaPlayer-izGFLVQr--XUsjgT2.js +0 -24740
- package/dist/worker-qh_9Fyf6-Li0uY2-a.js +0 -89
- /package/dist/{_commonjsHelpers-f3sTPFkQ-YKQV-mq1.js → _commonjsHelpers-DaMA6jEr-DtILRGNx.js} +0 -0
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { h as V, y as S, l as b, g as T } from "./index-tM9JvbA8.js";
|
|
2
|
-
import { l as W } from "./_commonjsHelpers-f3sTPFkQ-YKQV-mq1.js";
|
|
3
|
-
var q = function() {
|
|
4
|
-
function s(e, t, n, i, a) {
|
|
5
|
-
return e < t || n < t ? e > n ? n + 1 : e + 1 : i === a ? t : t + 1;
|
|
6
|
-
}
|
|
7
|
-
return function(e, t) {
|
|
8
|
-
if (e === t)
|
|
9
|
-
return 0;
|
|
10
|
-
if (e.length > t.length) {
|
|
11
|
-
var n = e;
|
|
12
|
-
e = t, t = n;
|
|
13
|
-
}
|
|
14
|
-
for (var i = e.length, a = t.length; i > 0 && e.charCodeAt(i - 1) === t.charCodeAt(a - 1); )
|
|
15
|
-
i--, a--;
|
|
16
|
-
for (var c = 0; c < i && e.charCodeAt(c) === t.charCodeAt(c); )
|
|
17
|
-
c++;
|
|
18
|
-
if (i -= c, a -= c, i === 0 || a < 3)
|
|
19
|
-
return a;
|
|
20
|
-
var o = 0, r, d, h, l, f, v, m, p, D, C, E, A, u = [];
|
|
21
|
-
for (r = 0; r < i; r++)
|
|
22
|
-
u.push(r + 1), u.push(e.charCodeAt(c + r));
|
|
23
|
-
for (var P = u.length - 1; o < a - 3; )
|
|
24
|
-
for (D = t.charCodeAt(c + (d = o)), C = t.charCodeAt(c + (h = o + 1)), E = t.charCodeAt(c + (l = o + 2)), A = t.charCodeAt(c + (f = o + 3)), v = o += 4, r = 0; r < P; r += 2)
|
|
25
|
-
m = u[r], p = u[r + 1], d = s(m, d, h, D, p), h = s(d, h, l, C, p), l = s(h, l, f, E, p), v = s(l, f, v, A, p), u[r] = v, f = l, l = h, h = d, d = m;
|
|
26
|
-
for (; o < a; )
|
|
27
|
-
for (D = t.charCodeAt(c + (d = o)), v = ++o, r = 0; r < P; r += 2)
|
|
28
|
-
m = u[r], u[r] = v = s(m, d, v, D, u[r + 1]), d = m;
|
|
29
|
-
return v;
|
|
30
|
-
};
|
|
31
|
-
}();
|
|
32
|
-
const O = /* @__PURE__ */ W(q);
|
|
33
|
-
function M(s) {
|
|
34
|
-
return new CustomEvent("device-change", {
|
|
35
|
-
detail: {
|
|
36
|
-
devices: s
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
const g = V.parse(navigator.userAgent);
|
|
41
|
-
class w {
|
|
42
|
-
controllableVolume;
|
|
43
|
-
id;
|
|
44
|
-
name;
|
|
45
|
-
nativeDeviceId;
|
|
46
|
-
type;
|
|
47
|
-
webDeviceId;
|
|
48
|
-
constructor({
|
|
49
|
-
controllableVolume: e,
|
|
50
|
-
name: t,
|
|
51
|
-
nativeDeviceId: n,
|
|
52
|
-
type: i,
|
|
53
|
-
webDeviceId: a
|
|
54
|
-
}) {
|
|
55
|
-
this.name = t, this.id = n === "default" && a === "default" ? "default" : T(), this.nativeDeviceId = n, this.webDeviceId = a, this.type = i, this.controllableVolume = e !== !1;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function y(s) {
|
|
59
|
-
if (B(s))
|
|
60
|
-
return "windowsCommunication";
|
|
61
|
-
if ("id" in s && s.id === "BuiltInSpeakerDevice")
|
|
62
|
-
return "builtIn";
|
|
63
|
-
if ("type" in s) {
|
|
64
|
-
if (s.type === "airplay")
|
|
65
|
-
return "airplay";
|
|
66
|
-
if (s.type === "mqa")
|
|
67
|
-
return "mqa";
|
|
68
|
-
}
|
|
69
|
-
if ("label" in s) {
|
|
70
|
-
const e = s.label.toLowerCase();
|
|
71
|
-
if (e.includes("bluetooth"))
|
|
72
|
-
return "bluetooth";
|
|
73
|
-
if (e.includes("displayport"))
|
|
74
|
-
return "displayPort";
|
|
75
|
-
if (e.includes("hdmi"))
|
|
76
|
-
return "hdmi";
|
|
77
|
-
if (e.includes("usb"))
|
|
78
|
-
return "usb";
|
|
79
|
-
if (e.includes("built-in"))
|
|
80
|
-
return "builtIn";
|
|
81
|
-
if (e.includes("airplay"))
|
|
82
|
-
return "airplay";
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function I(s, e) {
|
|
86
|
-
const t = e.toLowerCase();
|
|
87
|
-
let n = s;
|
|
88
|
-
return t.includes("mac") && (n = s.split("(")[0].trim()), n;
|
|
89
|
-
}
|
|
90
|
-
function B(s) {
|
|
91
|
-
let e;
|
|
92
|
-
return "label" in s && (e = s.label), "name" in s && (e = s.name), e !== void 0 && e.startsWith("Communications");
|
|
93
|
-
}
|
|
94
|
-
function L(s, e) {
|
|
95
|
-
if (e = I(e, g.os.name || ""), [...s].length === 0 || e === "")
|
|
96
|
-
return;
|
|
97
|
-
const t = [...s].filter((i) => i.name === e)[0];
|
|
98
|
-
if (t)
|
|
99
|
-
return t;
|
|
100
|
-
const n = [...s].filter((i) => e.includes(i.name) || i.name.includes(e)).map((i) => ({
|
|
101
|
-
device: i,
|
|
102
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
103
|
-
distance: O(i.name, e)
|
|
104
|
-
})).sort((i, a) => i.distance - a.distance).reverse();
|
|
105
|
-
if (n.length > 0) {
|
|
106
|
-
const i = n.pop();
|
|
107
|
-
if (i && i.distance <= 16)
|
|
108
|
-
return i.device;
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
class N {
|
|
112
|
-
#i;
|
|
113
|
-
#s;
|
|
114
|
-
#n = "shared";
|
|
115
|
-
#e;
|
|
116
|
-
#t;
|
|
117
|
-
#a = void 0;
|
|
118
|
-
#r;
|
|
119
|
-
outputDevices;
|
|
120
|
-
constructor() {
|
|
121
|
-
this.#t = /* @__PURE__ */ new Set(), this.#r = /* @__PURE__ */ new Set(), this.#e = new EventTarget(), this.#s = new w({
|
|
122
|
-
name: "System Default",
|
|
123
|
-
nativeDeviceId: "default",
|
|
124
|
-
type: "systemDefault",
|
|
125
|
-
webDeviceId: "default"
|
|
126
|
-
}), this.#i = this.#s, this.outputDevices = /* @__PURE__ */ new Set([this.#s]), this.hydrateWebDevices().then().catch(console.error), navigator.mediaDevices.addEventListener("devicechange", () => {
|
|
127
|
-
this.hydrateWebDevices().then().catch(console.error);
|
|
128
|
-
}), this.#e.addEventListener("native-devices", (e) => {
|
|
129
|
-
this.#t = new Set(e.detail), this.queueUpdate().then().catch(console.error);
|
|
130
|
-
}), this.#e.addEventListener("web-devices", (e) => {
|
|
131
|
-
this.#r = new Set(e.detail), this.queueUpdate().then().catch(console.error);
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
addNativeDevices(e) {
|
|
135
|
-
this.#e.dispatchEvent(
|
|
136
|
-
new CustomEvent("native-devices", {
|
|
137
|
-
detail: e
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
addWebDevices(e) {
|
|
142
|
-
e = e.filter((t) => t.deviceId !== "default"), this.#e.dispatchEvent(
|
|
143
|
-
new CustomEvent("web-devices", {
|
|
144
|
-
detail: e
|
|
145
|
-
})
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
emitDeviceChange() {
|
|
149
|
-
S.dispatchEvent(M([...this.outputDevices]));
|
|
150
|
-
}
|
|
151
|
-
getNativeDevice(e) {
|
|
152
|
-
return [...this.#t].find((t) => t.id === e);
|
|
153
|
-
}
|
|
154
|
-
async hydrateWebDevices() {
|
|
155
|
-
const e = (await navigator.mediaDevices.enumerateDevices()).filter((t) => t.kind === "audiooutput");
|
|
156
|
-
this.addWebDevices(e);
|
|
157
|
-
}
|
|
158
|
-
mergeDevices() {
|
|
159
|
-
[...this.outputDevices].filter((e) => e.id !== "default").forEach((e) => {
|
|
160
|
-
e.nativeDeviceId = void 0, e.webDeviceId = void 0;
|
|
161
|
-
}), this.#t.forEach((e) => {
|
|
162
|
-
const t = L(this.outputDevices, e.name);
|
|
163
|
-
t ? (t.nativeDeviceId = e.id, t.controllableVolume = e.controllableVolume, t.type = y(e) || t.type) : this.outputDevices.add(
|
|
164
|
-
new w({
|
|
165
|
-
controllableVolume: e.controllableVolume,
|
|
166
|
-
name: I(e.name, g.os.name || ""),
|
|
167
|
-
nativeDeviceId: e.id,
|
|
168
|
-
type: y(e)
|
|
169
|
-
})
|
|
170
|
-
);
|
|
171
|
-
}), this.#r.forEach((e) => {
|
|
172
|
-
const t = L(this.outputDevices, e.label);
|
|
173
|
-
t ? (t.webDeviceId = e.deviceId, t.type = y(e) || t.type) : this.outputDevices.add(
|
|
174
|
-
new w({
|
|
175
|
-
name: I(e.label, g.os.name || ""),
|
|
176
|
-
type: y(e),
|
|
177
|
-
webDeviceId: e.deviceId
|
|
178
|
-
})
|
|
179
|
-
);
|
|
180
|
-
}), [...this.outputDevices].filter(
|
|
181
|
-
(e) => e.webDeviceId === void 0 && e.nativeDeviceId === void 0 || e.type === "airplay" || e.type === "windowsCommunication"
|
|
182
|
-
).forEach((e) => this.outputDevices.delete(e));
|
|
183
|
-
}
|
|
184
|
-
async queueUpdate() {
|
|
185
|
-
const e = new Promise(
|
|
186
|
-
(i) => this.#e.addEventListener(
|
|
187
|
-
"native-devices",
|
|
188
|
-
(a) => i(a.detail),
|
|
189
|
-
{ once: !0 }
|
|
190
|
-
)
|
|
191
|
-
), t = new Promise(
|
|
192
|
-
(i) => this.#e.addEventListener(
|
|
193
|
-
"web-devices",
|
|
194
|
-
(a) => i(a.detail),
|
|
195
|
-
{ once: !0 }
|
|
196
|
-
)
|
|
197
|
-
), n = (i) => new Promise((a) => setTimeout(() => a(), i));
|
|
198
|
-
await Promise.any([e, t, n(1e3)]), this.mergeDevices(), this.emitDeviceChange();
|
|
199
|
-
}
|
|
200
|
-
set activeDevice(e) {
|
|
201
|
-
this.#i = e, this.#a = !1, this.#n = "shared", b.activePlayer?.updateOutputDevice()?.catch(console.error);
|
|
202
|
-
}
|
|
203
|
-
get activeDevice() {
|
|
204
|
-
return this.#i;
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Set the current device mode for the output device.
|
|
208
|
-
*/
|
|
209
|
-
set deviceMode(e) {
|
|
210
|
-
const { activeDevice: t } = this, { activePlayer: n } = b;
|
|
211
|
-
t && n && n.name === "nativePlayer" && this.deviceMode !== e && (this.#n = e, n.updateDeviceMode());
|
|
212
|
-
}
|
|
213
|
-
get deviceMode() {
|
|
214
|
-
return this.#n;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Set to true to disable software MQA decoder.
|
|
218
|
-
*/
|
|
219
|
-
set passThrough(e) {
|
|
220
|
-
const { activeDevice: t } = this, { activePlayer: n } = b;
|
|
221
|
-
t && n && n.name === "nativePlayer" && this.passThrough !== e && (this.#a = e, n.updatePassThrough());
|
|
222
|
-
}
|
|
223
|
-
get passThrough() {
|
|
224
|
-
return !!this.#a;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
const $ = new N();
|
|
228
|
-
export {
|
|
229
|
-
w as OutputDevice,
|
|
230
|
-
N as OutputDevices,
|
|
231
|
-
y as findOutputType,
|
|
232
|
-
L as getOutputDeviceByName,
|
|
233
|
-
B as isWindowsCommunicationsDevice,
|
|
234
|
-
I as marshalLabel,
|
|
235
|
-
$ as outputDevices
|
|
236
|
-
};
|