webrtc-mock
Advanced tools
Comparing version 1.0.4 to 1.1.0
@@ -1,2 +0,1 @@ | ||
export { default as MediaStreamMock } from './MediaStreamMock'; | ||
export { default as createMediaStreamMock } from './createMediaStreamMock'; | ||
@@ -7,2 +6,3 @@ export { default as doMock } from './doMock'; | ||
export { default as getCanvasMediaStreamMock } from './getCanvasMediaStreamMock'; | ||
export { default as MediaStreamMock } from './MediaStreamMock'; | ||
export { default as MediaStreamTrackMock } from './mediaStreamTrackMock'; | ||
@@ -16,3 +16,4 @@ export { default as resolutionsList } from './resolutionsList'; | ||
export { createAudioContextAudioMediaStreamTrackMock, createAudioMediaStreamTrackMock, createCanvasVideoMediaStreamTrackMock, createVideoMediaStreamTrackMock, } from './createMediaStreamTrackMock'; | ||
export { resetCapabilities, setCapabilities, setMaxHeightCapabilities, setMaxWidthCapabilities, setMinHeightCapabilities, setMinWidthCapabilities, } from './mediaStreamTrackMock'; | ||
export { getAvailableDevices } from './devicesMock'; | ||
export { type TGlobal } from './types'; |
@@ -1,8 +0,8 @@ | ||
var x = Object.defineProperty; | ||
var P = (t, e, i) => e in t ? x(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; | ||
var s = (t, e, i) => (P(t, typeof e != "symbol" ? e + "" : e, i), i); | ||
import C from "events-constructor"; | ||
const g = "ended", L = "mute", Y = "isolationchange", F = "overconstrained", j = "unmute", _ = "devicechange", f = "addtrack", A = "removetrack", $ = [f, A]; | ||
let V = 0; | ||
const K = () => (V += 1, `identifier-${V}`); | ||
var L = Object.defineProperty; | ||
var Y = (t, e, i) => e in t ? L(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i; | ||
var s = (t, e, i) => (Y(t, typeof e != "symbol" ? e + "" : e, i), i); | ||
import m from "events-constructor"; | ||
const _ = "ended", F = "mute", j = "isolationchange", H = "overconstrained", W = "unmute", b = "devicechange", p = "addtrack", f = "removetrack", $ = [p, f]; | ||
let M = 0; | ||
const K = () => (M += 1, `identifier-${M}`); | ||
class S { | ||
@@ -21,4 +21,4 @@ constructor(e = []) { | ||
this.tracks = [...this.tracks, e]; | ||
const i = { ...new Event(f), track: e }; | ||
return this.events.trigger(f, i), this.onaddtrack && this.onaddtrack(i), this; | ||
const i = { ...new Event(p), track: e }; | ||
return this.events.trigger(p, i), this.onaddtrack && this.onaddtrack(i), this; | ||
}); | ||
@@ -31,8 +31,8 @@ s(this, "addEventListener", (e, i) => { | ||
}); | ||
this.id = K(), this.tracks = e, this.events = new C($), this.onaddtrack = null, this.onremovetrack = null; | ||
this.id = K(), this.tracks = e, this.events = new m($), this.onaddtrack = null, this.onremovetrack = null; | ||
} | ||
removeTrack(e) { | ||
this.tracks = this.tracks.filter((r) => r.id !== e.id); | ||
const i = { ...new Event(A), track: e }; | ||
return this.events.trigger(A, i), this.onremovetrack && this.onremovetrack(i), this; | ||
const i = { ...new Event(f), track: e }; | ||
return this.events.trigger(f, i), this.onremovetrack && this.onremovetrack(i), this; | ||
} | ||
@@ -50,4 +50,46 @@ dispatchEvent(e) { | ||
} | ||
const H = [g, L, j, Y, F]; | ||
class O { | ||
const G = 352, J = 4096, X = 288, q = 2160, O = { | ||
width: { min: G, max: J }, | ||
height: { min: X, max: q } | ||
}; | ||
class z { | ||
constructor() { | ||
s(this, "_capabilities", O); | ||
} | ||
get capabilities() { | ||
return this._capabilities; | ||
} | ||
setCapabilities(e) { | ||
this._capabilities = e; | ||
} | ||
resetCapabilities() { | ||
this.setCapabilities(O); | ||
} | ||
setMinWidth(e) { | ||
this._capabilities.width.min = e; | ||
} | ||
setMaxWidth(e) { | ||
this._capabilities.width.max = e; | ||
} | ||
setMinHeight(e) { | ||
this._capabilities.height.min = e; | ||
} | ||
setMaxHeight(e) { | ||
this._capabilities.height.max = e; | ||
} | ||
} | ||
const Q = [_, F, W, j, H], E = new z(), We = (t) => { | ||
E.setCapabilities(t); | ||
}, $e = () => { | ||
E.resetCapabilities(); | ||
}, Ke = (t) => { | ||
E.setMinWidth(t); | ||
}, Ge = (t) => { | ||
E.setMaxWidth(t); | ||
}, Je = (t) => { | ||
E.setMinHeight(t); | ||
}, Xe = (t) => { | ||
E.setMaxHeight(t); | ||
}; | ||
class T { | ||
constructor(e, { id: i = "identifier", constraints: r = {} } = {}) { | ||
@@ -70,4 +112,4 @@ s(this, "events"); | ||
s(this, "stop", () => { | ||
const e = { ...new Event(g) }; | ||
this.events.trigger(g, e), this.readyState = g, this.onended && this.onended(e); | ||
const e = { ...new Event(_) }; | ||
this.events.trigger(_, e), this.readyState = _, this.onended && this.onended(e); | ||
}); | ||
@@ -80,3 +122,3 @@ s(this, "addEventListener", (e, i) => { | ||
}); | ||
this.id = `${i}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new C(H); | ||
this.id = `${i}-${e}-track`, this.kind = e, this.enabled = !0, this.constraints = { ...r }, this.events = new m(Q); | ||
} | ||
@@ -87,6 +129,3 @@ clone() { | ||
getCapabilities() { | ||
return { | ||
width: { min: 352, max: 4096 }, | ||
height: { min: 288, max: 2160 } | ||
}; | ||
return E.capabilities; | ||
} | ||
@@ -108,6 +147,6 @@ getSettings() { | ||
} | ||
const T = (t) => new O("audio", t), k = (t) => new O("video", t), N = () => T({ id: "fromAudioContext", constraints: {} }), b = () => k({ id: "fromCanvas", constraints: {} }), J = (t, e = {}) => { | ||
const { fromCanvas: i, fromAudioContext: r } = e, c = []; | ||
typeof t.audio == "object" && r !== !0 && c.push( | ||
T({ | ||
const k = (t) => new T("audio", t), w = (t) => new T("video", t), C = () => k({ id: "fromAudioContext", constraints: {} }), A = () => w({ id: "fromCanvas", constraints: {} }), Z = (t, e = {}) => { | ||
const { fromCanvas: i, fromAudioContext: r } = e, a = []; | ||
typeof t.audio == "object" && r !== !0 && a.push( | ||
k({ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error | ||
@@ -121,4 +160,4 @@ // @ts-ignore | ||
}) | ||
), typeof t.video == "object" && i !== !0 && c.push( | ||
k({ | ||
), typeof t.video == "object" && i !== !0 && a.push( | ||
w({ | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment, @typescript-eslint/prefer-ts-expect-error | ||
@@ -133,45 +172,45 @@ // @ts-ignore | ||
); | ||
let d = new S(c); | ||
let d = new S(a); | ||
return i === !0 && r === !0 ? d = new S([ | ||
b(), | ||
N() | ||
]) : i === !0 ? d.addTrack(b()) : r === !0 && d.addTrack(N()), d; | ||
}, W = "CIF", G = "360p", X = "720p", q = "1080p", z = { | ||
id: W, | ||
A(), | ||
C() | ||
]) : i === !0 ? d.addTrack(A()) : r === !0 && d.addTrack(C()), d; | ||
}, ee = "CIF", te = "360p", ie = "720p", se = "1080p", oe = { | ||
id: ee, | ||
width: 352, | ||
height: 288, | ||
aspectRatio: 4 / 3 | ||
}, Q = { | ||
id: G, | ||
}, re = { | ||
id: te, | ||
width: 640, | ||
height: 360, | ||
aspectRatio: 16 / 9 | ||
}, Z = { | ||
id: X, | ||
}, ne = { | ||
id: ie, | ||
width: 1280, | ||
height: 720, | ||
aspectRatio: 16 / 9 | ||
}, ee = { | ||
id: q, | ||
}, ae = { | ||
id: se, | ||
width: 1920, | ||
height: 1080, | ||
aspectRatio: 16 / 9 | ||
}, p = [z, Q, Z, ee], o = "videoinput", a = "audioinput", E = "audiooutput", te = "DeviceId", D = ({ | ||
}, N = [oe, re, ne, ae], o = "videoinput", c = "audioinput", v = "audiooutput", ce = "DeviceId", I = ({ | ||
prefix: t, | ||
postfix: e = te, | ||
postfix: e = ce, | ||
index: i | ||
}) => `${t}${e}${i ?? ""}`, ie = (t) => { | ||
}) => `${t}${e}${i ?? ""}`, de = (t) => { | ||
global.DEVICES_BUSY[o].includes(t) || global.DEVICES_BUSY[o].push(t); | ||
}, se = (t) => { | ||
}, le = (t) => { | ||
global.DEVICES_BUSY[o] = global.DEVICES_BUSY[o].filter((e) => e !== t); | ||
}, oe = (t) => global.DEVICES_BUSY[o].includes(t), re = (t) => { | ||
}, ue = (t) => global.DEVICES_BUSY[o].includes(t), he = (t) => { | ||
global.DEVICES_NOT_FOUND[o].includes(t) || global.DEVICES_NOT_FOUND[o].push(t); | ||
}, ne = (t) => { | ||
}, ve = (t) => { | ||
global.DEVICES_NOT_FOUND[o] = global.DEVICES_NOT_FOUND[o].filter((e) => e !== t); | ||
}, ce = (t) => global.DEVICES_NOT_FOUND[o].includes(t), ae = (t) => { | ||
}, Ee = (t) => global.DEVICES_NOT_FOUND[o].includes(t), De = (t) => { | ||
global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o].includes(t) || global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o].push(t); | ||
}, de = (t) => { | ||
}, Ie = (t) => { | ||
global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o] = global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o].filter((e) => e !== t); | ||
}, ue = (t) => global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o].includes(t); | ||
class m { | ||
}, ge = (t) => global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o].includes(t); | ||
class y { | ||
constructor(e, i) { | ||
@@ -182,3 +221,3 @@ s(this, "deviceId"); | ||
s(this, "label"); | ||
this.kind = e, this.deviceId = D({ index: i, prefix: e }), this.groupId = D({ index: i, prefix: "groupId", postfix: e }), this.label = D({ index: i, prefix: "label ", postfix: e }); | ||
this.kind = e, this.deviceId = I({ index: i, prefix: e }), this.groupId = I({ index: i, prefix: "groupId", postfix: e }), this.label = I({ index: i, prefix: "label ", postfix: e }); | ||
} | ||
@@ -189,7 +228,7 @@ toJSON() { | ||
} | ||
const I = (t) => { | ||
const g = (t) => { | ||
const e = t.toLowerCase(); | ||
let i = !1; | ||
return e.includes(o) ? i = global.DEVICES_USER_NOT_ACCESS[o] : e.includes(a) ? i = global.DEVICES_USER_NOT_ACCESS[a] : e.includes(E) && (i = global.DEVICES_USER_NOT_ACCESS[E]), i; | ||
}, y = (t) => ({ ...t }), u = (t) => y(new m(o, t)), l = (t) => y(new m(a, t)), v = (t) => y(new m(E, t)), le = () => { | ||
return e.includes(o) ? i = global.DEVICES_USER_NOT_ACCESS[o] : e.includes(c) ? i = global.DEVICES_USER_NOT_ACCESS[c] : e.includes(v) && (i = global.DEVICES_USER_NOT_ACCESS[v]), i; | ||
}, V = (t) => ({ ...t }), l = (t) => V(new y(o, t)), u = (t) => V(new y(c, t)), h = (t) => V(new y(v, t)), Se = () => { | ||
switch (global.COUNT_DEVICES_AVAILABLE[o]) { | ||
@@ -199,76 +238,76 @@ case 0: | ||
case 1: | ||
return [u()]; | ||
return [l()]; | ||
case 2: | ||
return [u(), u(2)]; | ||
return [l(), l(2)]; | ||
case 3: | ||
return [u(), u(2), u(3)]; | ||
return [l(), l(2), l(3)]; | ||
default: | ||
return [u()]; | ||
return [l()]; | ||
} | ||
}, ve = () => { | ||
switch (global.COUNT_DEVICES_AVAILABLE[a]) { | ||
}, _e = () => { | ||
switch (global.COUNT_DEVICES_AVAILABLE[c]) { | ||
case 0: | ||
return []; | ||
case 1: | ||
return [l()]; | ||
return [u()]; | ||
case 2: | ||
return [l(), l(2)]; | ||
return [u(), u(2)]; | ||
case 3: | ||
return [l(), l(2), l(3)]; | ||
return [u(), u(2), u(3)]; | ||
default: | ||
return [l()]; | ||
return [u()]; | ||
} | ||
}, Ee = () => { | ||
switch (global.COUNT_DEVICES_AVAILABLE[E]) { | ||
}, be = () => { | ||
switch (global.COUNT_DEVICES_AVAILABLE[v]) { | ||
case 0: | ||
return []; | ||
case 1: | ||
return [v()]; | ||
return [h()]; | ||
case 2: | ||
return [v(), v(2)]; | ||
return [h(), h(2)]; | ||
case 3: | ||
return [v(), v(2), v(3)]; | ||
return [h(), h(2), h(3)]; | ||
default: | ||
return [v()]; | ||
return [h()]; | ||
} | ||
}, h = () => [...le(), ...ve(), ...Ee()], M = (t) => { | ||
}, D = () => [...Se(), ..._e(), ...be()], R = (t) => { | ||
global.DEVICES_USER_NOT_ACCESS[o] = t; | ||
}, R = (t) => { | ||
global.DEVICES_USER_NOT_ACCESS[a] = t; | ||
}, U = (t) => { | ||
R(t), M(t); | ||
}, he = () => { | ||
global.DEVICES_BUSY[o] = [], global.DEVICES_NOT_FOUND[o] = [], global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o] = [], U(!1); | ||
}, De = (t = 1) => { | ||
global.DEVICES_USER_NOT_ACCESS[c] = t; | ||
}, x = (t) => { | ||
U(t), R(t); | ||
}, pe = () => { | ||
global.DEVICES_BUSY[o] = [], global.DEVICES_NOT_FOUND[o] = [], global.DEVICES_PERMISSION_DENIED_BY_SYSTEM[o] = [], x(!1); | ||
}, fe = (t = 1) => { | ||
global.COUNT_DEVICES_AVAILABLE[o] = t; | ||
}, Ie = (t = 1) => { | ||
global.COUNT_DEVICES_AVAILABLE[a] = t; | ||
}, Se = (t = 1) => { | ||
global.COUNT_DEVICES_AVAILABLE[E] = t; | ||
}, ge = p.filter(({ id: t }) => t !== "1080p"), w = { | ||
[D({ | ||
}, Ce = (t = 1) => { | ||
global.COUNT_DEVICES_AVAILABLE[c] = t; | ||
}, Ae = (t = 1) => { | ||
global.COUNT_DEVICES_AVAILABLE[v] = t; | ||
}, Ne = N.filter(({ id: t }) => t !== "1080p"), B = { | ||
[I({ | ||
prefix: o | ||
})]: p, | ||
[D({ | ||
})]: N, | ||
[I({ | ||
prefix: o, | ||
index: 1 | ||
})]: p, | ||
[D({ | ||
})]: N, | ||
[I({ | ||
prefix: o, | ||
index: 2 | ||
})]: ge | ||
}, _e = ({ | ||
})]: Ne | ||
}, me = ({ | ||
deviceId: t, | ||
exactHeight: e | ||
}) => { | ||
const i = w[t]; | ||
const i = B[t]; | ||
return i ? i.some(({ height: r }) => r === e) : !0; | ||
}, fe = (t) => w[t], Ae = "NotReadableError", Ne = "NotFoundError", be = "Could not start video source", pe = "Permission denied by system", Ce = "Permission denied", me = () => { | ||
const t = new Error(be); | ||
return t.name = Ae, t; | ||
}, ye = () => { | ||
}, ye = (t) => B[t], Ve = "NotReadableError", Me = "NotFoundError", Oe = "Could not start video source", Te = "Permission denied by system", ke = "Permission denied", we = () => { | ||
const t = new Error(Oe); | ||
return t.name = Ve, t; | ||
}, Re = () => { | ||
const t = new Error("Not found"); | ||
return t.name = Ne, t; | ||
}, Ve = () => new Error(Ce), Oe = () => new Error(pe), Te = [_]; | ||
class ke { | ||
return t.name = Me, t; | ||
}, Ue = () => new Error(ke), xe = () => new Error(Te), Be = [b]; | ||
class Pe { | ||
constructor() { | ||
@@ -278,5 +317,5 @@ s(this, "events"); | ||
s(this, "getUserMedia", async (e) => { | ||
var c, d; | ||
var a, d; | ||
let i, r; | ||
if (typeof e == "object" && typeof e.video == "object" && typeof e.video.deviceId == "object" && !Array.isArray(e.video.deviceId) ? i = e.video.deviceId.exact : typeof e == "object" && e.video === !0 && h().some(({ kind: n }) => n === o) ? (i = (c = h().find(({ kind: n }) => n === o)) == null ? void 0 : c.deviceId, e.video = { | ||
if (typeof e == "object" && typeof e.video == "object" && typeof e.video.deviceId == "object" && !Array.isArray(e.video.deviceId) ? i = e.video.deviceId.exact : typeof e == "object" && e.video === !0 && D().some(({ kind: n }) => n === o) ? (i = (a = D().find(({ kind: n }) => n === o)) == null ? void 0 : a.deviceId, e.video = { | ||
deviceId: { | ||
@@ -289,3 +328,3 @@ exact: i | ||
} | ||
}), typeof e == "object" && typeof e.audio == "object" && typeof e.audio.deviceId == "object" && !Array.isArray(e.audio.deviceId) ? r = e.audio.deviceId.exact : typeof e == "object" && e.audio === !0 && h().some(({ kind: n }) => n === a) ? (r = (d = h().find(({ kind: n }) => n === a)) == null ? void 0 : d.deviceId, e.audio = { | ||
}), typeof e == "object" && typeof e.audio == "object" && typeof e.audio.deviceId == "object" && !Array.isArray(e.audio.deviceId) ? r = e.audio.deviceId.exact : typeof e == "object" && e.audio === !0 && D().some(({ kind: n }) => n === c) ? (r = (d = D().find(({ kind: n }) => n === c)) == null ? void 0 : d.deviceId, e.audio = { | ||
deviceId: { | ||
@@ -298,25 +337,25 @@ exact: r | ||
} | ||
}), i && typeof i == "string" && oe(i)) | ||
throw me(); | ||
}), i && typeof i == "string" && ue(i)) | ||
throw we(); | ||
if ( | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
i && typeof i == "string" && ue(i) | ||
i && typeof i == "string" && ge(i) | ||
) | ||
throw Oe(); | ||
throw xe(); | ||
if ( | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
i && typeof i == "string" && ce(i) | ||
i && typeof i == "string" && Ee(i) | ||
) | ||
throw ye(); | ||
throw Re(); | ||
if ( | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
i && typeof i == "string" && // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | ||
I(i) || // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
r && typeof r == "string" && I(r) | ||
g(i) || // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
r && typeof r == "string" && g(r) | ||
) | ||
throw Ve(); | ||
throw Ue(); | ||
if ( | ||
// eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
i && typeof i == "string" && typeof e.video == "object" && typeof e.video.height == "object" && typeof e.video.height == "object" && // eslint-disable-next-line @typescript-eslint/strict-boolean-expressions | ||
e.video.height.exact && !_e({ | ||
e.video.height.exact && !me({ | ||
deviceId: i, | ||
@@ -329,7 +368,7 @@ exactHeight: e.video.height.exact | ||
); | ||
return J(e); | ||
return Z(e); | ||
}); | ||
s(this, "enumerateDevices", async () => new Promise((e) => { | ||
setTimeout(() => { | ||
const i = h(); | ||
const i = D(); | ||
e(i); | ||
@@ -345,52 +384,52 @@ }, 100); | ||
s(this, "setCountVideoDevicesAvailable", (e) => { | ||
De(e), this.events.trigger(_, {}); | ||
fe(e), this.events.trigger(b, {}); | ||
}); | ||
s(this, "setCountAudioInDevicesAvailable", (e) => { | ||
Ie(e), this.events.trigger(_, {}); | ||
Ce(e), this.events.trigger(b, {}); | ||
}); | ||
s(this, "setCountAudioOutDevicesAvailable", (e) => { | ||
Se(e), this.events.trigger(_, {}); | ||
Ae(e), this.events.trigger(b, {}); | ||
}); | ||
s(this, "setBusyVideoDevice", (e) => { | ||
ie(e); | ||
de(e); | ||
}); | ||
s(this, "setNotFoundVideoDevice", (e) => { | ||
re(e); | ||
he(e); | ||
}); | ||
s(this, "setPermissionDeniedBySystem", (e) => { | ||
ae(e); | ||
De(e); | ||
}); | ||
s(this, "setUserNotAccessVideo", (e = !0) => { | ||
M(e); | ||
R(e); | ||
}); | ||
s(this, "setUserNotAccessAudioIn", (e = !0) => { | ||
R(e); | ||
U(e); | ||
}); | ||
s(this, "setUserNotAccessAll", (e = !0) => { | ||
U(e); | ||
x(e); | ||
}); | ||
s(this, "unsetAllRestrictions", () => { | ||
he(); | ||
pe(); | ||
}); | ||
s(this, "unsetBusyVideoDevice", (e) => { | ||
se(e); | ||
le(e); | ||
}); | ||
s(this, "unsetNotFoundVideoDevice", (e) => { | ||
ne(e); | ||
ve(e); | ||
}); | ||
s(this, "unsetPermissionDeniedBySystem", (e) => { | ||
de(e); | ||
Ie(e); | ||
}); | ||
this.events = new C(Te), this.getDisplayMedia = this.getUserMedia; | ||
this.events = new m(Be), this.getDisplayMedia = this.getUserMedia; | ||
} | ||
} | ||
const xe = () => { | ||
global.MediaStream = S, global.navigator.mediaDevices = new ke(), global.COUNT_DEVICES_AVAILABLE = { | ||
const qe = () => { | ||
global.MediaStream = S, global.navigator.mediaDevices = new Pe(), global.COUNT_DEVICES_AVAILABLE = { | ||
[o]: 1, | ||
[a]: 1, | ||
[E]: 1 | ||
[c]: 1, | ||
[v]: 1 | ||
}, global.DEVICES_USER_NOT_ACCESS = { | ||
[o]: !1, | ||
[a]: !1, | ||
[E]: !1 | ||
[c]: !1, | ||
[v]: !1 | ||
}, global.DEVICES_BUSY = { | ||
@@ -403,17 +442,17 @@ [o]: [] | ||
}; | ||
}, Pe = async () => new S([N()]), Le = ({ hasAccessDeviceAudioOutput: t = !1 } = {}) => h().map((i) => { | ||
}, ze = async () => new S([C()]), Qe = ({ hasAccessDeviceAudioOutput: t = !1 } = {}) => D().map((i) => { | ||
let r; | ||
return i.kind === "videoinput" ? r = { | ||
resolutions: I(i.deviceId) ? [] : fe(i.deviceId), | ||
hasAccess: !I(i.deviceId), | ||
resolutions: g(i.deviceId) ? [] : ye(i.deviceId), | ||
hasAccess: !g(i.deviceId), | ||
...i | ||
} : i.kind === "audioinput" ? r = { hasAccess: !I(i.deviceId), ...i } : t ? r = { hasAccess: !0, ...i } : r = { ...i }, r; | ||
}), Ye = async () => new S([b()]), B = (t) => JSON.parse(JSON.stringify(t)), Me = (t) => (i) => { | ||
const r = i.map((c) => B(c)); | ||
return r.sort((c, d) => Number.parseFloat(c[t]) - Number.parseFloat(d[t])), r; | ||
}, Re = Me("id"), Ue = (t) => B({ | ||
} : i.kind === "audioinput" ? r = { hasAccess: !g(i.deviceId), ...i } : t ? r = { hasAccess: !0, ...i } : r = { ...i }, r; | ||
}), Ze = async () => new S([A()]), P = (t) => JSON.parse(JSON.stringify(t)), Le = (t) => (i) => { | ||
const r = i.map((a) => P(a)); | ||
return r.sort((a, d) => Number.parseFloat(a[t]) - Number.parseFloat(d[t])), r; | ||
}, Ye = Le("id"), Fe = (t) => P({ | ||
...t, | ||
tracks: Re(t.getTracks()) | ||
}), Fe = (t) => { | ||
const e = Ue(t); | ||
tracks: Ye(t.getTracks()) | ||
}), et = (t) => { | ||
const e = Fe(t); | ||
return delete e.id, e; | ||
@@ -423,19 +462,25 @@ }; | ||
S as MediaStreamMock, | ||
O as MediaStreamTrackMock, | ||
N as createAudioContextAudioMediaStreamTrackMock, | ||
T as createAudioMediaStreamTrackMock, | ||
b as createCanvasVideoMediaStreamTrackMock, | ||
J as createMediaStreamMock, | ||
k as createVideoMediaStreamTrackMock, | ||
xe as doMock, | ||
Pe as getAudioContextMediaStreamMock, | ||
h as getAvailableDevices, | ||
Le as getAvailableDevicesWithResolutions, | ||
Ye as getCanvasMediaStreamMock, | ||
Ue as parseMediaStream, | ||
Fe as parseMediaStreamWithoutId, | ||
B as parseObject, | ||
Re as parseTracks, | ||
p as resolutionsList, | ||
Me as resolveParseArray | ||
T as MediaStreamTrackMock, | ||
C as createAudioContextAudioMediaStreamTrackMock, | ||
k as createAudioMediaStreamTrackMock, | ||
A as createCanvasVideoMediaStreamTrackMock, | ||
Z as createMediaStreamMock, | ||
w as createVideoMediaStreamTrackMock, | ||
qe as doMock, | ||
ze as getAudioContextMediaStreamMock, | ||
D as getAvailableDevices, | ||
Qe as getAvailableDevicesWithResolutions, | ||
Ze as getCanvasMediaStreamMock, | ||
Fe as parseMediaStream, | ||
et as parseMediaStreamWithoutId, | ||
P as parseObject, | ||
Ye as parseTracks, | ||
$e as resetCapabilities, | ||
N as resolutionsList, | ||
Le as resolveParseArray, | ||
We as setCapabilities, | ||
Xe as setMaxHeightCapabilities, | ||
Ge as setMaxWidthCapabilities, | ||
Je as setMinHeightCapabilities, | ||
Ke as setMinWidthCapabilities | ||
}; |
@@ -0,1 +1,3 @@ | ||
import { TCapabilities } from './Capabilities'; | ||
declare const eventsNames: readonly ["ended", "mute", "unmute", "isolationchange", "overconstrained"]; | ||
@@ -5,2 +7,8 @@ type TEventNames = typeof eventsNames; | ||
type THandler = (event: Event) => void; | ||
export declare const setCapabilities: (value: TCapabilities) => void; | ||
export declare const resetCapabilities: () => void; | ||
export declare const setMinWidthCapabilities: (value: number) => void; | ||
export declare const setMaxWidthCapabilities: (value: number) => void; | ||
export declare const setMinHeightCapabilities: (value: number) => void; | ||
export declare const setMaxHeightCapabilities: (value: number) => void; | ||
export type TOptions = { | ||
@@ -7,0 +15,0 @@ id?: string; |
{ | ||
"name": "webrtc-mock", | ||
"version": "1.0.4", | ||
"version": "1.1.0", | ||
"description": "Classes and functions mock webrtc api for tests", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
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
45834
27
823