webrtc-mock
Advanced tools
Comparing version 0.0.4 to 0.0.5
@@ -69,4 +69,4 @@ "use strict"; | ||
this.deviceId = (0, exports.generateDeviceId)({ index, prefix: kind }); | ||
this.groupId = `groupId ${kind}`; | ||
this.label = `label ${kind}`; | ||
this.groupId = `groupId ${kind} ${index}`; | ||
this.label = `label ${kind} ${index}`; | ||
} | ||
@@ -73,0 +73,0 @@ // eslint-disable-next-line class-methods-use-this |
@@ -1,2 +0,2 @@ | ||
import e from"lodash/flow";import t from"lodash/curryRight";import i from"lodash/map";import o from"lodash/sortBy";import s from"lodash/property";import n from"events-constructor";class d{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}const r=e=>new d("audio",e),a=e=>new d("video",e),c=()=>r({id:"fromAudioContext",constraints:{}}),l=()=>a({id:"fromCanvas",constraints:{}}),u=[{id:"CIF",width:352,height:288,aspectRatio:4/3},{id:"360p",width:640,height:360,aspectRatio:16/9},{id:"720p",width:1280,height:720,aspectRatio:16/9},{id:"1080p",width:1920,height:1080,aspectRatio:16/9}],h="videoinput",v=({prefix:e,postfix:t="DeviceId",index:i})=>`${e}${t}${void 0===i?"":i}`;class E{constructor(e,t){this.kind=e,this.deviceId=v({index:t,prefix:e}),this.groupId=`groupId ${e}`,this.label=`label ${e}`}toJSON(){throw new Error("Method not implemented.")}}const p=e=>{const t=e.toLowerCase();let i=!1;return t.includes(h)?i=!0===global.DEVICES_USER_NOT_ACCESS.videoinput:t.includes("audioinput")?i=!0===global.DEVICES_USER_NOT_ACCESS.audioinput:t.includes("audiooutput")&&(i=!0===global.DEVICES_USER_NOT_ACCESS.audiooutput),i},S=e=>Object.assign({},e),g=e=>S(new E(h,e)),I=e=>S(new E("audioinput",e)),_=e=>S(new E("audiooutput",e)),b=()=>{switch(global.COUNT_DEVICES_AVAILABLE.videoinput){case 0:return[];case 1:return[g()];case 2:return[g(),g(2)];case 3:return[g(),g(2),g(3)];default:return[g()]}},m=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audioinput){case 0:return[];case 1:return[I()];case 2:return[I(),I(2)];case 3:return[I(),I(2),I(3)];default:return[I()]}},D=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audiooutput){case 0:return[];case 1:return[_()];case 2:return[_(),_(2)];case 3:return[_(),_(2),_(3)];default:return[_()]}},C=()=>[...b(),...m(),...D()],f=e=>{global.DEVICES_USER_NOT_ACCESS.videoinput=e},A=e=>{global.DEVICES_USER_NOT_ACCESS.audioinput=e},N=e=>{A(e),f(e)},O=u.filter((({id:e})=>"1080p"!==e)),V={[v({prefix:h})]:u,[v({prefix:h,index:1})]:u,[v({prefix:h,index:2})]:O};class w{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}let y=0;class T{constructor(e=[]){this.active=!0,this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.getTracks=()=>this.tracks,this.getAudioTracks=()=>this.tracks.filter((({kind:e})=>"audio"===e)),this.getVideoTracks=()=>this.tracks.filter((({kind:e})=>"video"===e)),this.addTrack=e=>(this.tracks=[...this.tracks,e],this),this.id=(y+=1,`identifier-${y}`),this.tracks=e}}const j=()=>Promise.resolve(new T([c()])),U=()=>Promise.resolve(new T([l()])),k=(e,t={})=>{const{fromCanvas:i,fromAudioContext:o}=t,s=[];e.audio&&!o&&s.push(r({id:e.audio.deviceId.exact,deviceId:e.audio.deviceId,constraints:e.audio})),e.video&&!i&&s.push(a({id:e.video.deviceId.exact,deviceId:e.video.deviceId,constraints:e.video}));const n=new T(s);return i&&o?n.tracks=[l(),c()]:i?(n.addTrack(l()),delete n.video):o&&n.addTrack(c()),n},x=e=>JSON.parse(JSON.stringify(e)),B=n=>e(x,(e=>o(e,s(n))),t(i)(x)),M=B("id"),P=e=>x(Object.assign(Object.assign({},e),{tracks:M(e.tracks)})),L=e=>{const t=P(e);return delete t.id,t},R=({hasAccessDeviceAudioOutput:e=!1}={})=>C().map((t=>{let i;var o;return i="videoinput"===t.kind?Object.assign({resolutions:p(t.deviceId)?[]:(o=t.deviceId,V[o]),hasAccess:!p(t.deviceId)},t):"audioinput"===t.kind?Object.assign({hasAccess:!p(t.deviceId)},t):e?Object.assign({hasAccess:!0},t):Object.assign({},t),i})),Y=["devicechange"];class ${constructor(){this.getUserMedia=e=>{var t,i;let o,s;if(e&&e.video&&"object"==typeof e.video&&"object"==typeof e.video.deviceId&&!Array.isArray(e.video.deviceId)?o=e.video.deviceId.exact:e&&!0===e.video&&C().find((({kind:e})=>e===h))?(o=null===(t=C().find((({kind:e})=>e===h)))||void 0===t?void 0:t.deviceId,e.video={deviceId:{exact:o}}):e&&!0===e.video&&(e.video={deviceId:{exact:"notAvailableDevice"}}),e&&e.audio&&"object"==typeof e.audio&&"object"==typeof e.audio.deviceId&&!Array.isArray(e.audio.deviceId)?s=e.audio.deviceId.exact:e&&!0===e.audio&&C().find((({kind:e})=>"audioinput"===e))?(s=null===(i=C().find((({kind:e})=>"audioinput"===e)))||void 0===i?void 0:i.deviceId,e.audio={deviceId:{exact:s}}):e&&!0===e.audio&&(e.audio={deviceId:{exact:"notAvailableDevice"}}),o&&"string"==typeof o&&p(o))return Promise.reject(new Error(`Video DeviceId is not available: ${o}`));if(o&&"string"==typeof o&&(n=o,global.DEVICES_BUSY.videoinput.includes(n))){const e=(()=>{const e=new Error("Could not start video source");return e.name="NotReadableError",e})();return Promise.reject(e)}var n;if(o&&"string"==typeof o&&(e=>global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e))(o)){const e=new Error("Permission denied by system");return Promise.reject(e)}if(o&&"string"==typeof o&&(e=>global.DEVICES_NOT_FOUND.videoinput.includes(e))(o)){const e=(()=>{const e=new Error;return e.name="NotFoundError",e})();return Promise.reject(e)}if(o&&"string"==typeof o&&p(o)){const e=new Error("Permission denied");return Promise.reject(e)}return o&&"string"==typeof o&&"object"==typeof e.video&&"object"==typeof e.video.height&&"object"==typeof e.video.height&&e.video.height&&e.video.height.exact&&!(({deviceId:e,exactHeight:t})=>{const i=V[e];return!i||0!==i.filter((({height:e})=>e===t)).length})({deviceId:o,exactHeight:e.video.height.exact})?Promise.reject(new Error(`Resolution height:${e.video.height.exact} is not available: ${o}`)):s&&"string"==typeof s&&p(s)?Promise.reject(new Error(`Audio DeviceId is not available: ${s}`)):Promise.resolve(k(e))},this.enumerateDevices=()=>new Promise((e=>setTimeout((()=>e(C())),100))),this.addEventListener=(e,t)=>{this._events.on(e,t)},this.removeEventListener=(e,t)=>{this._events.off(e,t)},this.setCountVideoDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.videoinput=e})(e),this._events.trigger("devicechange",void 0)},this.setCountAudioInDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audioinput=e})(e),this._events.trigger("devicechange",void 0)},this.setCountAudioOutDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audiooutput=e})(e),this._events.trigger("devicechange",void 0)},this.setBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput.includes(e)||global.DEVICES_BUSY.videoinput.push(e)})(e)},this.setNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput.includes(e)||global.DEVICES_NOT_FOUND.videoinput.push(e)})(e)},this.setPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e)||global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.push(e)})(e)},this.setUserNotAccessVideo=(e=!0)=>{f(e)},this.setUserNotAccessAudioIn=(e=!0)=>{A(e)},this.setUserNotAccessAll=(e=!0)=>{N(e)},this.unsetAllRestrictions=()=>{global.DEVICES_BUSY.videoinput=[],global.DEVICES_NOT_FOUND.videoinput=[],global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=[],N(!1)},this.unsetBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput=global.DEVICES_BUSY.videoinput.filter((t=>t!==e))})(e)},this.unsetNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput=global.DEVICES_NOT_FOUND.videoinput.filter((t=>t!==e))})(e)},this.unsetPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.filter((t=>t!==e))})(e)},this._events=new n(Y)}}const F=()=>{global.MediaStream=T,global.navigator.mediaDevices=new $,global.COUNT_DEVICES_AVAILABLE={[h]:1,audioinput:1,audiooutput:1},global.DEVICES_USER_NOT_ACCESS={[h]:!1,audioinput:!1,audiooutput:!1},global.DEVICES_BUSY={[h]:[]},global.DEVICES_NOT_FOUND={[h]:[]},global.DEVICES_PERMISSION_DENIED_BY_SYSTEM={[h]:[]}};export{T as MediaStreamMock,w as MediaStreamTrackMock,c as createAudioContextAudioMediaStreamTrackMock,r as createAudioMediaStreamTrackMock,l as createCanvasVideoMediaStreamTrackMock,k as createMediaStreamMock,a as createVideoMediaStreamTrackMock,F as doMock,j as getAudioContextMediaStreamMock,C as getAvailableDevices,R as getAvailableDevicesWithResolutions,U as getCanvasMediaStreamMock,P as parseMediaStream,L as parseMediaStreamWithoutId,x as parseObject,M as parseTracks,u as resolutionsList,B as resolveParseArray}; | ||
import e from"lodash/flow";import t from"lodash/curryRight";import i from"lodash/map";import o from"lodash/sortBy";import s from"lodash/property";import n from"events-constructor";class d{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}const r=e=>new d("audio",e),a=e=>new d("video",e),c=()=>r({id:"fromAudioContext",constraints:{}}),l=()=>a({id:"fromCanvas",constraints:{}}),u=[{id:"CIF",width:352,height:288,aspectRatio:4/3},{id:"360p",width:640,height:360,aspectRatio:16/9},{id:"720p",width:1280,height:720,aspectRatio:16/9},{id:"1080p",width:1920,height:1080,aspectRatio:16/9}],h="videoinput",v=({prefix:e,postfix:t="DeviceId",index:i})=>`${e}${t}${void 0===i?"":i}`;class E{constructor(e,t){this.kind=e,this.deviceId=v({index:t,prefix:e}),this.groupId=`groupId ${e} ${t}`,this.label=`label ${e} ${t}`}toJSON(){throw new Error("Method not implemented.")}}const p=e=>{const t=e.toLowerCase();let i=!1;return t.includes(h)?i=!0===global.DEVICES_USER_NOT_ACCESS.videoinput:t.includes("audioinput")?i=!0===global.DEVICES_USER_NOT_ACCESS.audioinput:t.includes("audiooutput")&&(i=!0===global.DEVICES_USER_NOT_ACCESS.audiooutput),i},S=e=>Object.assign({},e),g=e=>S(new E(h,e)),I=e=>S(new E("audioinput",e)),_=e=>S(new E("audiooutput",e)),b=()=>{switch(global.COUNT_DEVICES_AVAILABLE.videoinput){case 0:return[];case 1:return[g()];case 2:return[g(),g(2)];case 3:return[g(),g(2),g(3)];default:return[g()]}},m=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audioinput){case 0:return[];case 1:return[I()];case 2:return[I(),I(2)];case 3:return[I(),I(2),I(3)];default:return[I()]}},D=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audiooutput){case 0:return[];case 1:return[_()];case 2:return[_(),_(2)];case 3:return[_(),_(2),_(3)];default:return[_()]}},C=()=>[...b(),...m(),...D()],f=e=>{global.DEVICES_USER_NOT_ACCESS.videoinput=e},A=e=>{global.DEVICES_USER_NOT_ACCESS.audioinput=e},N=e=>{A(e),f(e)},O=u.filter((({id:e})=>"1080p"!==e)),V={[v({prefix:h})]:u,[v({prefix:h,index:1})]:u,[v({prefix:h,index:2})]:O};class w{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}let y=0;class T{constructor(e=[]){this.active=!0,this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.getTracks=()=>this.tracks,this.getAudioTracks=()=>this.tracks.filter((({kind:e})=>"audio"===e)),this.getVideoTracks=()=>this.tracks.filter((({kind:e})=>"video"===e)),this.addTrack=e=>(this.tracks=[...this.tracks,e],this),this.id=(y+=1,`identifier-${y}`),this.tracks=e}}const j=()=>Promise.resolve(new T([c()])),U=()=>Promise.resolve(new T([l()])),k=(e,t={})=>{const{fromCanvas:i,fromAudioContext:o}=t,s=[];e.audio&&!o&&s.push(r({id:e.audio.deviceId.exact,deviceId:e.audio.deviceId,constraints:e.audio})),e.video&&!i&&s.push(a({id:e.video.deviceId.exact,deviceId:e.video.deviceId,constraints:e.video}));const n=new T(s);return i&&o?n.tracks=[l(),c()]:i?(n.addTrack(l()),delete n.video):o&&n.addTrack(c()),n},x=e=>JSON.parse(JSON.stringify(e)),B=n=>e(x,(e=>o(e,s(n))),t(i)(x)),M=B("id"),P=e=>x(Object.assign(Object.assign({},e),{tracks:M(e.tracks)})),L=e=>{const t=P(e);return delete t.id,t},R=({hasAccessDeviceAudioOutput:e=!1}={})=>C().map((t=>{let i;var o;return i="videoinput"===t.kind?Object.assign({resolutions:p(t.deviceId)?[]:(o=t.deviceId,V[o]),hasAccess:!p(t.deviceId)},t):"audioinput"===t.kind?Object.assign({hasAccess:!p(t.deviceId)},t):e?Object.assign({hasAccess:!0},t):Object.assign({},t),i})),Y=["devicechange"];class ${constructor(){this.getUserMedia=e=>{var t,i;let o,s;if(e&&e.video&&"object"==typeof e.video&&"object"==typeof e.video.deviceId&&!Array.isArray(e.video.deviceId)?o=e.video.deviceId.exact:e&&!0===e.video&&C().find((({kind:e})=>e===h))?(o=null===(t=C().find((({kind:e})=>e===h)))||void 0===t?void 0:t.deviceId,e.video={deviceId:{exact:o}}):e&&!0===e.video&&(e.video={deviceId:{exact:"notAvailableDevice"}}),e&&e.audio&&"object"==typeof e.audio&&"object"==typeof e.audio.deviceId&&!Array.isArray(e.audio.deviceId)?s=e.audio.deviceId.exact:e&&!0===e.audio&&C().find((({kind:e})=>"audioinput"===e))?(s=null===(i=C().find((({kind:e})=>"audioinput"===e)))||void 0===i?void 0:i.deviceId,e.audio={deviceId:{exact:s}}):e&&!0===e.audio&&(e.audio={deviceId:{exact:"notAvailableDevice"}}),o&&"string"==typeof o&&p(o))return Promise.reject(new Error(`Video DeviceId is not available: ${o}`));if(o&&"string"==typeof o&&(n=o,global.DEVICES_BUSY.videoinput.includes(n))){const e=(()=>{const e=new Error("Could not start video source");return e.name="NotReadableError",e})();return Promise.reject(e)}var n;if(o&&"string"==typeof o&&(e=>global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e))(o)){const e=new Error("Permission denied by system");return Promise.reject(e)}if(o&&"string"==typeof o&&(e=>global.DEVICES_NOT_FOUND.videoinput.includes(e))(o)){const e=(()=>{const e=new Error;return e.name="NotFoundError",e})();return Promise.reject(e)}if(o&&"string"==typeof o&&p(o)){const e=new Error("Permission denied");return Promise.reject(e)}return o&&"string"==typeof o&&"object"==typeof e.video&&"object"==typeof e.video.height&&"object"==typeof e.video.height&&e.video.height&&e.video.height.exact&&!(({deviceId:e,exactHeight:t})=>{const i=V[e];return!i||0!==i.filter((({height:e})=>e===t)).length})({deviceId:o,exactHeight:e.video.height.exact})?Promise.reject(new Error(`Resolution height:${e.video.height.exact} is not available: ${o}`)):s&&"string"==typeof s&&p(s)?Promise.reject(new Error(`Audio DeviceId is not available: ${s}`)):Promise.resolve(k(e))},this.enumerateDevices=()=>new Promise((e=>setTimeout((()=>e(C())),100))),this.addEventListener=(e,t)=>{this._events.on(e,t)},this.removeEventListener=(e,t)=>{this._events.off(e,t)},this.setCountVideoDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.videoinput=e})(e),this._events.trigger("devicechange",void 0)},this.setCountAudioInDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audioinput=e})(e),this._events.trigger("devicechange",void 0)},this.setCountAudioOutDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audiooutput=e})(e),this._events.trigger("devicechange",void 0)},this.setBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput.includes(e)||global.DEVICES_BUSY.videoinput.push(e)})(e)},this.setNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput.includes(e)||global.DEVICES_NOT_FOUND.videoinput.push(e)})(e)},this.setPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e)||global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.push(e)})(e)},this.setUserNotAccessVideo=(e=!0)=>{f(e)},this.setUserNotAccessAudioIn=(e=!0)=>{A(e)},this.setUserNotAccessAll=(e=!0)=>{N(e)},this.unsetAllRestrictions=()=>{global.DEVICES_BUSY.videoinput=[],global.DEVICES_NOT_FOUND.videoinput=[],global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=[],N(!1)},this.unsetBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput=global.DEVICES_BUSY.videoinput.filter((t=>t!==e))})(e)},this.unsetNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput=global.DEVICES_NOT_FOUND.videoinput.filter((t=>t!==e))})(e)},this.unsetPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.filter((t=>t!==e))})(e)},this._events=new n(Y)}}const F=()=>{global.MediaStream=T,global.navigator.mediaDevices=new $,global.COUNT_DEVICES_AVAILABLE={[h]:1,audioinput:1,audiooutput:1},global.DEVICES_USER_NOT_ACCESS={[h]:!1,audioinput:!1,audiooutput:!1},global.DEVICES_BUSY={[h]:[]},global.DEVICES_NOT_FOUND={[h]:[]},global.DEVICES_PERMISSION_DENIED_BY_SYSTEM={[h]:[]}};export{T as MediaStreamMock,w as MediaStreamTrackMock,c as createAudioContextAudioMediaStreamTrackMock,r as createAudioMediaStreamTrackMock,l as createCanvasVideoMediaStreamTrackMock,k as createMediaStreamMock,a as createVideoMediaStreamTrackMock,F as doMock,j as getAudioContextMediaStreamMock,C as getAvailableDevices,R as getAvailableDevicesWithResolutions,U as getCanvasMediaStreamMock,P as parseMediaStream,L as parseMediaStreamWithoutId,x as parseObject,M as parseTracks,u as resolutionsList,B as resolveParseArray}; | ||
//# sourceMappingURL=index.es5.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash/flow"),require("lodash/curryRight"),require("lodash/map"),require("lodash/sortBy"),require("lodash/property"),require("events-constructor")):"function"==typeof define&&define.amd?define(["exports","lodash/flow","lodash/curryRight","lodash/map","lodash/sortBy","lodash/property","events-constructor"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).webrtcMock={},e.flow,e.curryRight,e.map,e.sortBy,e.property,e.Events)}(this,(function(e,t,i,o,s,n,r){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=d(t),c=d(i),l=d(o),u=d(s),h=d(n),v=d(r);class E{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}const p=e=>new E("audio",e),S=e=>new E("video",e),g=()=>p({id:"fromAudioContext",constraints:{}}),I=()=>S({id:"fromCanvas",constraints:{}}),_=[{id:"CIF",width:352,height:288,aspectRatio:4/3},{id:"360p",width:640,height:360,aspectRatio:16/9},{id:"720p",width:1280,height:720,aspectRatio:16/9},{id:"1080p",width:1920,height:1080,aspectRatio:16/9}],f="videoinput",b="audioinput",m="audiooutput",D=({prefix:e,postfix:t="DeviceId",index:i})=>`${e}${t}${void 0===i?"":i}`;class C{constructor(e,t){this.kind=e,this.deviceId=D({index:t,prefix:e}),this.groupId=`groupId ${e}`,this.label=`label ${e}`}toJSON(){throw new Error("Method not implemented.")}}const A=e=>{const t=e.toLowerCase();let i=!1;return t.includes(f)?i=!0===global.DEVICES_USER_NOT_ACCESS.videoinput:t.includes(b)?i=!0===global.DEVICES_USER_NOT_ACCESS.audioinput:t.includes(m)&&(i=!0===global.DEVICES_USER_NOT_ACCESS.audiooutput),i},O=e=>Object.assign({},e),N=e=>O(new C(f,e)),V=e=>O(new C(b,e)),y=e=>O(new C(m,e)),w=()=>{switch(global.COUNT_DEVICES_AVAILABLE.videoinput){case 0:return[];case 1:return[N()];case 2:return[N(),N(2)];case 3:return[N(),N(2),N(3)];default:return[N()]}},M=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audioinput){case 0:return[];case 1:return[V()];case 2:return[V(),V(2)];case 3:return[V(),V(2),V(3)];default:return[V()]}},k=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audiooutput){case 0:return[];case 1:return[y()];case 2:return[y(),y(2)];case 3:return[y(),y(2),y(3)];default:return[y()]}},T=()=>[...w(),...M(),...k()],j=e=>{global.DEVICES_USER_NOT_ACCESS.videoinput=e},U=e=>{global.DEVICES_USER_NOT_ACCESS.audioinput=e},x=e=>{U(e),j(e)},B=_.filter((({id:e})=>"1080p"!==e)),P={[D({prefix:f})]:_,[D({prefix:f,index:1})]:_,[D({prefix:f,index:2})]:B};let L=0;class R{constructor(e=[]){this.active=!0,this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.getTracks=()=>this.tracks,this.getAudioTracks=()=>this.tracks.filter((({kind:e})=>"audio"===e)),this.getVideoTracks=()=>this.tracks.filter((({kind:e})=>"video"===e)),this.addTrack=e=>(this.tracks=[...this.tracks,e],this),this.id=(L+=1,`identifier-${L}`),this.tracks=e}}const Y=(e,t={})=>{const{fromCanvas:i,fromAudioContext:o}=t,s=[];e.audio&&!o&&s.push(p({id:e.audio.deviceId.exact,deviceId:e.audio.deviceId,constraints:e.audio})),e.video&&!i&&s.push(S({id:e.video.deviceId.exact,deviceId:e.video.deviceId,constraints:e.video}));const n=new R(s);return i&&o?n.tracks=[I(),g()]:i?(n.addTrack(I()),delete n.video):o&&n.addTrack(g()),n},$=e=>JSON.parse(JSON.stringify(e)),F=e=>a.default($,(t=>u.default(t,h.default(e))),c.default(l.default)($)),q=F("id"),H=e=>$(Object.assign(Object.assign({},e),{tracks:q(e.tracks)})),J="devicechange",W=[J];class z{constructor(){this.getUserMedia=e=>{var t,i;let o,s;if(e&&e.video&&"object"==typeof e.video&&"object"==typeof e.video.deviceId&&!Array.isArray(e.video.deviceId)?o=e.video.deviceId.exact:e&&!0===e.video&&T().find((({kind:e})=>e===f))?(o=null===(t=T().find((({kind:e})=>e===f)))||void 0===t?void 0:t.deviceId,e.video={deviceId:{exact:o}}):e&&!0===e.video&&(e.video={deviceId:{exact:"notAvailableDevice"}}),e&&e.audio&&"object"==typeof e.audio&&"object"==typeof e.audio.deviceId&&!Array.isArray(e.audio.deviceId)?s=e.audio.deviceId.exact:e&&!0===e.audio&&T().find((({kind:e})=>e===b))?(s=null===(i=T().find((({kind:e})=>e===b)))||void 0===i?void 0:i.deviceId,e.audio={deviceId:{exact:s}}):e&&!0===e.audio&&(e.audio={deviceId:{exact:"notAvailableDevice"}}),o&&"string"==typeof o&&A(o))return Promise.reject(new Error(`Video DeviceId is not available: ${o}`));if(o&&"string"==typeof o&&(n=o,global.DEVICES_BUSY.videoinput.includes(n))){const e=(()=>{const e=new Error("Could not start video source");return e.name="NotReadableError",e})();return Promise.reject(e)}var n;if(o&&"string"==typeof o&&(e=>global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e))(o)){const e=new Error("Permission denied by system");return Promise.reject(e)}if(o&&"string"==typeof o&&(e=>global.DEVICES_NOT_FOUND.videoinput.includes(e))(o)){const e=(()=>{const e=new Error;return e.name="NotFoundError",e})();return Promise.reject(e)}if(o&&"string"==typeof o&&A(o)){const e=new Error("Permission denied");return Promise.reject(e)}return o&&"string"==typeof o&&"object"==typeof e.video&&"object"==typeof e.video.height&&"object"==typeof e.video.height&&e.video.height&&e.video.height.exact&&!(({deviceId:e,exactHeight:t})=>{const i=P[e];return!i||0!==i.filter((({height:e})=>e===t)).length})({deviceId:o,exactHeight:e.video.height.exact})?Promise.reject(new Error(`Resolution height:${e.video.height.exact} is not available: ${o}`)):s&&"string"==typeof s&&A(s)?Promise.reject(new Error(`Audio DeviceId is not available: ${s}`)):Promise.resolve(Y(e))},this.enumerateDevices=()=>new Promise((e=>setTimeout((()=>e(T())),100))),this.addEventListener=(e,t)=>{this._events.on(e,t)},this.removeEventListener=(e,t)=>{this._events.off(e,t)},this.setCountVideoDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.videoinput=e})(e),this._events.trigger(J,void 0)},this.setCountAudioInDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audioinput=e})(e),this._events.trigger(J,void 0)},this.setCountAudioOutDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audiooutput=e})(e),this._events.trigger(J,void 0)},this.setBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput.includes(e)||global.DEVICES_BUSY.videoinput.push(e)})(e)},this.setNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput.includes(e)||global.DEVICES_NOT_FOUND.videoinput.push(e)})(e)},this.setPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e)||global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.push(e)})(e)},this.setUserNotAccessVideo=(e=!0)=>{j(e)},this.setUserNotAccessAudioIn=(e=!0)=>{U(e)},this.setUserNotAccessAll=(e=!0)=>{x(e)},this.unsetAllRestrictions=()=>{global.DEVICES_BUSY.videoinput=[],global.DEVICES_NOT_FOUND.videoinput=[],global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=[],x(!1)},this.unsetBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput=global.DEVICES_BUSY.videoinput.filter((t=>t!==e))})(e)},this.unsetNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput=global.DEVICES_NOT_FOUND.videoinput.filter((t=>t!==e))})(e)},this.unsetPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.filter((t=>t!==e))})(e)},this._events=new v.default(W)}}e.MediaStreamMock=R,e.MediaStreamTrackMock=class{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}},e.createAudioContextAudioMediaStreamTrackMock=g,e.createAudioMediaStreamTrackMock=p,e.createCanvasVideoMediaStreamTrackMock=I,e.createMediaStreamMock=Y,e.createVideoMediaStreamTrackMock=S,e.doMock=()=>{global.MediaStream=R,global.navigator.mediaDevices=new z,global.COUNT_DEVICES_AVAILABLE={[f]:1,[b]:1,[m]:1},global.DEVICES_USER_NOT_ACCESS={[f]:!1,[b]:!1,[m]:!1},global.DEVICES_BUSY={[f]:[]},global.DEVICES_NOT_FOUND={[f]:[]},global.DEVICES_PERMISSION_DENIED_BY_SYSTEM={[f]:[]}},e.getAudioContextMediaStreamMock=()=>Promise.resolve(new R([g()])),e.getAvailableDevices=T,e.getAvailableDevicesWithResolutions=({hasAccessDeviceAudioOutput:e=!1}={})=>T().map((t=>{let i;var o;return i="videoinput"===t.kind?Object.assign({resolutions:A(t.deviceId)?[]:(o=t.deviceId,P[o]),hasAccess:!A(t.deviceId)},t):"audioinput"===t.kind?Object.assign({hasAccess:!A(t.deviceId)},t):e?Object.assign({hasAccess:!0},t):Object.assign({},t),i})),e.getCanvasMediaStreamMock=()=>Promise.resolve(new R([I()])),e.parseMediaStream=H,e.parseMediaStreamWithoutId=e=>{const t=H(e);return delete t.id,t},e.parseObject=$,e.parseTracks=q,e.resolutionsList=_,e.resolveParseArray=F,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash/flow"),require("lodash/curryRight"),require("lodash/map"),require("lodash/sortBy"),require("lodash/property"),require("events-constructor")):"function"==typeof define&&define.amd?define(["exports","lodash/flow","lodash/curryRight","lodash/map","lodash/sortBy","lodash/property","events-constructor"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).webrtcMock={},e.flow,e.curryRight,e.map,e.sortBy,e.property,e.Events)}(this,(function(e,t,i,o,s,n,r){"use strict";function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=d(t),c=d(i),l=d(o),u=d(s),h=d(n),v=d(r);class E{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}}const p=e=>new E("audio",e),S=e=>new E("video",e),g=()=>p({id:"fromAudioContext",constraints:{}}),I=()=>S({id:"fromCanvas",constraints:{}}),_=[{id:"CIF",width:352,height:288,aspectRatio:4/3},{id:"360p",width:640,height:360,aspectRatio:16/9},{id:"720p",width:1280,height:720,aspectRatio:16/9},{id:"1080p",width:1920,height:1080,aspectRatio:16/9}],f="videoinput",b="audioinput",m="audiooutput",D=({prefix:e,postfix:t="DeviceId",index:i})=>`${e}${t}${void 0===i?"":i}`;class C{constructor(e,t){this.kind=e,this.deviceId=D({index:t,prefix:e}),this.groupId=`groupId ${e} ${t}`,this.label=`label ${e} ${t}`}toJSON(){throw new Error("Method not implemented.")}}const A=e=>{const t=e.toLowerCase();let i=!1;return t.includes(f)?i=!0===global.DEVICES_USER_NOT_ACCESS.videoinput:t.includes(b)?i=!0===global.DEVICES_USER_NOT_ACCESS.audioinput:t.includes(m)&&(i=!0===global.DEVICES_USER_NOT_ACCESS.audiooutput),i},O=e=>Object.assign({},e),N=e=>O(new C(f,e)),V=e=>O(new C(b,e)),y=e=>O(new C(m,e)),w=()=>{switch(global.COUNT_DEVICES_AVAILABLE.videoinput){case 0:return[];case 1:return[N()];case 2:return[N(),N(2)];case 3:return[N(),N(2),N(3)];default:return[N()]}},M=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audioinput){case 0:return[];case 1:return[V()];case 2:return[V(),V(2)];case 3:return[V(),V(2),V(3)];default:return[V()]}},k=()=>{switch(global.COUNT_DEVICES_AVAILABLE.audiooutput){case 0:return[];case 1:return[y()];case 2:return[y(),y(2)];case 3:return[y(),y(2),y(3)];default:return[y()]}},T=()=>[...w(),...M(),...k()],j=e=>{global.DEVICES_USER_NOT_ACCESS.videoinput=e},U=e=>{global.DEVICES_USER_NOT_ACCESS.audioinput=e},x=e=>{U(e),j(e)},B=_.filter((({id:e})=>"1080p"!==e)),P={[D({prefix:f})]:_,[D({prefix:f,index:1})]:_,[D({prefix:f,index:2})]:B};let L=0;class R{constructor(e=[]){this.active=!0,this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.getTracks=()=>this.tracks,this.getAudioTracks=()=>this.tracks.filter((({kind:e})=>"audio"===e)),this.getVideoTracks=()=>this.tracks.filter((({kind:e})=>"video"===e)),this.addTrack=e=>(this.tracks=[...this.tracks,e],this),this.id=(L+=1,`identifier-${L}`),this.tracks=e}}const Y=(e,t={})=>{const{fromCanvas:i,fromAudioContext:o}=t,s=[];e.audio&&!o&&s.push(p({id:e.audio.deviceId.exact,deviceId:e.audio.deviceId,constraints:e.audio})),e.video&&!i&&s.push(S({id:e.video.deviceId.exact,deviceId:e.video.deviceId,constraints:e.video}));const n=new R(s);return i&&o?n.tracks=[I(),g()]:i?(n.addTrack(I()),delete n.video):o&&n.addTrack(g()),n},$=e=>JSON.parse(JSON.stringify(e)),F=e=>a.default($,(t=>u.default(t,h.default(e))),c.default(l.default)($)),q=F("id"),H=e=>$(Object.assign(Object.assign({},e),{tracks:q(e.tracks)})),J="devicechange",W=[J];class z{constructor(){this.getUserMedia=e=>{var t,i;let o,s;if(e&&e.video&&"object"==typeof e.video&&"object"==typeof e.video.deviceId&&!Array.isArray(e.video.deviceId)?o=e.video.deviceId.exact:e&&!0===e.video&&T().find((({kind:e})=>e===f))?(o=null===(t=T().find((({kind:e})=>e===f)))||void 0===t?void 0:t.deviceId,e.video={deviceId:{exact:o}}):e&&!0===e.video&&(e.video={deviceId:{exact:"notAvailableDevice"}}),e&&e.audio&&"object"==typeof e.audio&&"object"==typeof e.audio.deviceId&&!Array.isArray(e.audio.deviceId)?s=e.audio.deviceId.exact:e&&!0===e.audio&&T().find((({kind:e})=>e===b))?(s=null===(i=T().find((({kind:e})=>e===b)))||void 0===i?void 0:i.deviceId,e.audio={deviceId:{exact:s}}):e&&!0===e.audio&&(e.audio={deviceId:{exact:"notAvailableDevice"}}),o&&"string"==typeof o&&A(o))return Promise.reject(new Error(`Video DeviceId is not available: ${o}`));if(o&&"string"==typeof o&&(n=o,global.DEVICES_BUSY.videoinput.includes(n))){const e=(()=>{const e=new Error("Could not start video source");return e.name="NotReadableError",e})();return Promise.reject(e)}var n;if(o&&"string"==typeof o&&(e=>global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e))(o)){const e=new Error("Permission denied by system");return Promise.reject(e)}if(o&&"string"==typeof o&&(e=>global.DEVICES_NOT_FOUND.videoinput.includes(e))(o)){const e=(()=>{const e=new Error;return e.name="NotFoundError",e})();return Promise.reject(e)}if(o&&"string"==typeof o&&A(o)){const e=new Error("Permission denied");return Promise.reject(e)}return o&&"string"==typeof o&&"object"==typeof e.video&&"object"==typeof e.video.height&&"object"==typeof e.video.height&&e.video.height&&e.video.height.exact&&!(({deviceId:e,exactHeight:t})=>{const i=P[e];return!i||0!==i.filter((({height:e})=>e===t)).length})({deviceId:o,exactHeight:e.video.height.exact})?Promise.reject(new Error(`Resolution height:${e.video.height.exact} is not available: ${o}`)):s&&"string"==typeof s&&A(s)?Promise.reject(new Error(`Audio DeviceId is not available: ${s}`)):Promise.resolve(Y(e))},this.enumerateDevices=()=>new Promise((e=>setTimeout((()=>e(T())),100))),this.addEventListener=(e,t)=>{this._events.on(e,t)},this.removeEventListener=(e,t)=>{this._events.off(e,t)},this.setCountVideoDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.videoinput=e})(e),this._events.trigger(J,void 0)},this.setCountAudioInDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audioinput=e})(e),this._events.trigger(J,void 0)},this.setCountAudioOutDevicesAvailable=e=>{((e=1)=>{global.COUNT_DEVICES_AVAILABLE.audiooutput=e})(e),this._events.trigger(J,void 0)},this.setBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput.includes(e)||global.DEVICES_BUSY.videoinput.push(e)})(e)},this.setNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput.includes(e)||global.DEVICES_NOT_FOUND.videoinput.push(e)})(e)},this.setPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.includes(e)||global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.push(e)})(e)},this.setUserNotAccessVideo=(e=!0)=>{j(e)},this.setUserNotAccessAudioIn=(e=!0)=>{U(e)},this.setUserNotAccessAll=(e=!0)=>{x(e)},this.unsetAllRestrictions=()=>{global.DEVICES_BUSY.videoinput=[],global.DEVICES_NOT_FOUND.videoinput=[],global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=[],x(!1)},this.unsetBusyVideoDevice=e=>{(e=>{global.DEVICES_BUSY.videoinput=global.DEVICES_BUSY.videoinput.filter((t=>t!==e))})(e)},this.unsetNotFoundVideoDevice=e=>{(e=>{global.DEVICES_NOT_FOUND.videoinput=global.DEVICES_NOT_FOUND.videoinput.filter((t=>t!==e))})(e)},this.unsetPermissionDeniedBySystem=e=>{(e=>{global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput=global.DEVICES_PERMISSION_DENIED_BY_SYSTEM.videoinput.filter((t=>t!==e))})(e)},this._events=new v.default(W)}}e.MediaStreamMock=R,e.MediaStreamTrackMock=class{constructor(e,{id:t="identifier",constraints:i={}}={}){this.contentHint="",this.readyState="live",this.isolated=!1,this.label="",this.muted=!1,this.onended=null,this.onisolationchange=null,this.onmute=null,this.onunmute=null,this.getConstraints=()=>this.constraints,this.stop=()=>{this.readyState="ended"},this.addEventListener=jest.fn(),this.removeEventListener=jest.fn(),this.id=`${t}-${e}-track`,this.kind=e,this.enabled=!0,this.constraints=Object.assign({},i)}clone(){throw new Error("Method not implemented.")}getCapabilities(){throw new Error("Method not implemented.")}getSettings(){throw new Error("Method not implemented.")}dispatchEvent(e){throw new Error("Method not implemented.")}applyConstraints(e){return this.constraints=Object.assign({},e),Promise.resolve()}},e.createAudioContextAudioMediaStreamTrackMock=g,e.createAudioMediaStreamTrackMock=p,e.createCanvasVideoMediaStreamTrackMock=I,e.createMediaStreamMock=Y,e.createVideoMediaStreamTrackMock=S,e.doMock=()=>{global.MediaStream=R,global.navigator.mediaDevices=new z,global.COUNT_DEVICES_AVAILABLE={[f]:1,[b]:1,[m]:1},global.DEVICES_USER_NOT_ACCESS={[f]:!1,[b]:!1,[m]:!1},global.DEVICES_BUSY={[f]:[]},global.DEVICES_NOT_FOUND={[f]:[]},global.DEVICES_PERMISSION_DENIED_BY_SYSTEM={[f]:[]}},e.getAudioContextMediaStreamMock=()=>Promise.resolve(new R([g()])),e.getAvailableDevices=T,e.getAvailableDevicesWithResolutions=({hasAccessDeviceAudioOutput:e=!1}={})=>T().map((t=>{let i;var o;return i="videoinput"===t.kind?Object.assign({resolutions:A(t.deviceId)?[]:(o=t.deviceId,P[o]),hasAccess:!A(t.deviceId)},t):"audioinput"===t.kind?Object.assign({hasAccess:!A(t.deviceId)},t):e?Object.assign({hasAccess:!0},t):Object.assign({},t),i})),e.getCanvasMediaStreamMock=()=>Promise.resolve(new R([I()])),e.parseMediaStream=H,e.parseMediaStreamWithoutId=e=>{const t=H(e);return delete t.id,t},e.parseObject=$,e.parseTracks=q,e.resolutionsList=_,e.resolveParseArray=F,Object.defineProperty(e,"__esModule",{value:!0})})); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "webrtc-mock", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Classes and functions mock webrtc api for tests", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
190528