<commit_before>/**
 * anzu-js-sdk
 * anzu-js-sdk
 * @version 0.3.0
 * @author Shiguredo Inc.
 * @license MIT
 */
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Anzu=n()}}(function(){var n;return function e(n,t,r){function o(a,s){if(!t[a]){if(!n[a]){var c="function"==typeof require&&require;if(!s&&c)return c(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var f=t[a]={exports:{}};n[a][0].call(f.exports,function(e){var t=n[a][1][e];return o(t?t:e)},f,f.exports,e,n,t,r)}return t[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(n,e,t){"use strict";function r(n){return n&&n.__esModule?n:{"default":n}}function o(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var i=function(){function n(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),a=n("sora-js-sdk"),s=r(a),c=window.mozRTCPeerConnection||window.webkitRTCPeerConnection,u=window.RTCSessionDescription||window.mozRTCSessionDescription;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var f=function(){function n(e){var t=arguments.length<=1||void 0===arguments[1]?{anzuUrl:null,signalingUrl:null}:arguments[1];if(o(this,n),this.anzuUrl=null===t.anzuUrl?"https://anzu.shiguredo.jp/api/":t.anzuUrl,this.signalingUrl=null===t.signalingUrl?"wss://anzu.shiguredo.jp/signaling":t.signalingUrl,"upstream"!==e&&"downstream"!==e){var r=new Error("Role "+e+" is not defined");throw r}this.role=e}return i(n,[{key:"start",value:function(n,e){var t=arguments.length<=2||void 0===arguments[2]?null:arguments[2];if("upstream"===this.role){var r=null===t?{video:!0,audio:!0}:t;return this._startUpstream(n,e,r)}return"downstream"===this.role?this._startDownstream(n,e):void 0}},{key:"_startUpstream",value:function(n,e,t){var r=this,o=function(n){return new Promise(function(e,t){navigator.getUserMedia?navigator.getUserMedia(n,function(n){r.stream=n,e({stream:n})},function(n){t(n)}):t()})},i=function(){return r.sora=new s["default"](r.signalingUrl).connection(),r.sora.connect({role:"upstream",channelId:n,accessToken:e})},a=function(n){return r.sdplog("Upstream Offer",n),new Promise(function(e,t){r.clientId=n.clientId,r.pc=new c({iceServers:n.iceServers}),r.pc.addStream(r.stream),e(n)})},f=function(n){return new Promise(function(e,t){r.pc.setRemoteDescription(new u(n),function(){r.pc.createAnswer(function(o){r.sdplog("Upstream answer",n),r.pc.setLocalDescription(o,function(){r.sora.answer(o.sdp),r.pc.onicecandidate=function(n){null!==n.candidate&&(console.info("====== candidate ======"),console.info(n.candidate),r.sora.candidate(n.candidate))},e({clientId:r.clientId,stream:r.stream})},function(n){t(n)})},function(n){t(n)})},function(n){t(n)})})};return o(t).then(i).then(a).then(f)}},{key:"_startDownstream",value:function(n,e){var t=this,r=function(){return t.sora=new s["default"](t.signalingUrl).connection(),t.sora.connect({role:"downstream",channelId:n,accessToken:e})},o=function(n){return t.sdplog("Downstream offer",n),new Promise(function(e,r){t.clientId=n.clientId,t.pc=new c({iceServers:n.iceServers}),e(n)})},i=function(n){var e=void 0!==navigator.mozGetUserMedia;return new Promise(function(r,o){e||(t.pc.onaddstream=function(n){t.stream=n.stream}),t.pc.setRemoteDescription(new u(n),function(){t.pc.createAnswer(function(i){t.sdplog("Downstream answer",n),t.pc.setLocalDescription(i,function(){t.sora.answer(i.sdp),t.sendanswer=!0,e?t.pc.onaddstream=function(n){t.stream=n.stream,r({clientId:t.clientId,stream:t.stream})}:r({clientId:t.clientId,stream:t.stream}),t.pc.onicecandidate=function(n){null!==n.candidate&&(console.info("====== candidate ======"),console.info(n.candidate),t.sora.candidate(n.candidate))}},function(n){o(n)})},function(n){o(n)})},function(n){o(n)})})};return r().then(o).then(i)}},{key:"sdplog",value:function(n,e){console.info("========== "+n+" ==========");for(var t in e)console.info(t+":"),console.info(e[t])}}]),n}();e.exports=f},{"sora-js-sdk":2}],2:[function(e,t,r){(function(o){!function(e){if("object"==typeof r&&"undefined"!=typeof t)t.exports=e();else if("function"==typeof n&&n.amd)n([],e);else{var i;i="undefined"!=typeof window?window:"undefined"!=typeof o?o:"undefined"!=typeof self?self:this,i.Sora=e()}}(function(){return function n(t,r,o){function i(s,c){if(!r[s]){if(!t[s]){var u="function"==typeof e&&e;if(!c&&u)return u(s,!0);if(a)return a(s,!0);var f=new Error("Cannot find module '"+s+"'");throw f.code="MODULE_NOT_FOUND",f}var l=r[s]={exports:{}};t[s][0].call(l.exports,function(n){var e=t[s][1][n];return i(e?e:n)},l,l.exports,n,t,r,o)}return r[s].exports}for(var a="function"==typeof e&&e,s=0;s<o.length;s++)i(o[s]);return i}({1:[function(n,e,t){"use strict";function r(n,e){if(!(n instanceof e))throw new TypeError("Cannot call a class as a function")}var o=function(){function n(n,e){for(var t=0;t<e.length;t++){var r=e[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(n,r.key,r)}}return function(e,t,r){return t&&n(e.prototype,t),r&&n(e,r),e}}(),i=function(){function n(e){r(this,n),this.url=e||""}return o(n,[{key:"connection",value:function(){return new a(this.url)}}]),n}(),a=function(){function n(e){r(this,n),this._ws=null,this._url=e}return o(n,[{key:"connect",value:function(n){var e=this;return new Promise(function(t,r){null===e._ws&&(e._ws=new WebSocket(e._url)),e._ws.onopen=function(){var t=JSON.stringify({type:"connect",role:n.role,channelId:n.channelId,accessToken:n.accessToken});e._ws.send(t)},e._ws.onclose=function(n){4401===n.code&&r(n)},e._ws.onmessage=function(n){var r=JSON.parse(n.data);"offer"==r.type?t(r):"ping"==r.type&&e._ws.send(JSON.stringify({type:"pong"}))}})}},{key:"answer",value:function(n){this._ws.send(JSON.stringify({type:"answer",sdp:n}))}},{key:"candidate",value:function(n){var e=n.toJSON();e.type="candidate",this._ws.send(JSON.stringify(e))}}]),n}();e.exports=i},{}]},{},[1])(1)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}]},{},[1])(1)});<commit_msg>get recent anzu-js-sdk<commit_after>/*!
 * anzu-js-sdk
 * WebRTC SFU as a Service Anzu Library
 * @version 0.5.2
 * @author <NAME>.
 * @license MIT
 */
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.Anzu=e()}}(function(){var e;return function n(e,t,o){function i(c,a){if(!t[c]){if(!e[c]){var s="function"==typeof require&&require;if(!a&&s)return s(c,!0);if(r)return r(c,!0);var u=new Error("Cannot find module '"+c+"'");throw u.code="MODULE_NOT_FOUND",u}var f=t[c]={exports:{}};e[c][0].call(f.exports,function(n){var t=e[c][1][n];return i(t?t:n)},f,f.exports,n,e,t,o)}return t[c].exports}for(var r="function"==typeof require&&require,c=0;c<o.length;c++)i(o[c]);return i}({1:[function(n,t,o){(function(i){/*!
 * sora-js-sdk
 * WebRTC SFU Sora Signaling Library
 * @version 0.4.1
 * @author Shiguredo Inc.
 * @license MIT
 */
!function(n){if("object"==typeof o&&"undefined"!=typeof t)t.exports=n();else if("function"==typeof e&&e.amd)e([],n);else{var r;r="undefined"!=typeof window?window:"undefined"!=typeof i?i:"undefined"!=typeof self?self:this,r.Sora=n()}}(function(){return function e(t,o,i){function r(a,s){if(!o[a]){if(!t[a]){var u="function"==typeof n&&n;if(!s&&u)return u(a,!0);if(c)return c(a,!0);var f=new Error("Cannot find module '"+a+"'");throw f.code="MODULE_NOT_FOUND",f}var d=o[a]={exports:{}};t[a][0].call(d.exports,function(e){var n=t[a][1][e];return r(n?n:e)},d,d.exports,e,t,o,i)}return o[a].exports}for(var c="function"==typeof n&&n,a=0;a<i.length;a++)r(i[a]);return r}({1:[function(e,n,t){"use strict";function o(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var i=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}(),r=function(){function e(n){o(this,e),this.url=n||""}return i(e,[{key:"connection",value:function(){return new a(this.url)}}]),e}(),c=["VP8","VP9","H264"],a=function(){function e(n){o(this,e),this._ws=null,this._url=n,this._onerror=function(){},this._onclose=function(){}}return i(e,[{key:"connect",value:function(e){var n=this;return new Promise(function(t,o){null===n._ws&&(n._ws=new WebSocket(n._url)),n._ws.onopen=function(){var t={type:"connect",role:e.role,channelId:e.channelId,accessToken:e.accessToken},o=c.indexOf(e.codecType);o>=0&&(t.video={codecType:c[o]}),n._ws.send(JSON.stringify(t))},n._ws.onclose=function(e){/440\d$/.test(e.code)?o(e):n._onclose(e)},n._ws.onerror=function(e){n._onerror(e)},n._ws.onmessage=function(e){var o=JSON.parse(e.data);"offer"==o.type?t(o):"ping"==o.type&&n._ws.send(JSON.stringify({type:"pong"}))}})}},{key:"answer",value:function(e){this._ws.send(JSON.stringify({type:"answer",sdp:e}))}},{key:"candidate",value:function(e){var n=e.toJSON();n.type="candidate",this._ws.send(JSON.stringify(n))}},{key:"onError",value:function(e){this._onerror=e}},{key:"onDisconnect",value:function(e){this._onclose=e}},{key:"disconnect",value:function(){this._ws.close(),this._ws=null}}]),e}();n.exports=r},{}]},{},[1])(1)})}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,n,t){"use strict";function o(e){return e&&e.__esModule?e:{"default":e}}function i(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},c=function(){function e(e,n){for(var t=0;t<n.length;t++){var o=n[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(n,t,o){return t&&e(n.prototype,t),o&&e(n,o),n}}(),a=e("sora-js-sdk"),s=o(a),u=window.mozRTCPeerConnection||window.webkitRTCPeerConnection,f=window.RTCSessionDescription||window.mozRTCSessionDescription;navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;var d=function(){function e(n){var t=arguments.length<=1||void 0===arguments[1]?{anzuUrl:null,signalingUrl:null}:arguments[1];if(i(this,e),this.anzuUrl=null===t.anzuUrl?"https://anzu.shiguredo.jp/api/":t.anzuUrl,this.signalingUrl=null===t.signalingUrl?"wss://anzu.shiguredo.jp/signaling":t.signalingUrl,"upstream"!==n&&"downstream"!==n){var o=new Error("Role "+n+" is not defined");throw o}this.role=n,this._onError=function(){},this._onDisconnect=function(){}}return c(e,[{key:"start",value:function(e,n){var t=arguments.length<=2||void 0===arguments[2]?null:arguments[2],o=arguments.length<=3||void 0===arguments[3]?"VP8":arguments[3];if("upstream"===this.role){var i=null===t?{video:!0,audio:!0}:t;return this._startUpstream(e,n,i,o)}return"downstream"===this.role?this._startDownstream(e,n,o):void 0}},{key:"_startUpstream",value:function(e,n,t,o){var i=this,r=function(e){return new Promise(function(n,t){navigator.getUserMedia?navigator.getUserMedia(e,function(t){i.trace("Upstream getUserMedia constraints",e),i.stream=t,n({stream:t})},function(e){t(e)}):t()})},c=function(){return i.sora=new s["default"](i.signalingUrl).connection(),i.sora.onError(i._onError),i.sora.onDisconnect(i._onDisconnect),i.sora.connect({role:"upstream",channelId:e,accessToken:n,codecType:o})},a=function(e){return i.trace("Upstream Offer sdp",e.sdp),i.trace("Upstream Offer clientId",e.clientId),i.trace("Upstream Offer iceServers",e.metadata.iceServers),new Promise(function(n,t){i.clientId=e.clientId,i.pc=new u({iceServers:e.metadata.iceServers}),i.pc.addStream(i.stream),n(e)})},d=function(e){return new Promise(function(n,t){i.pc.oniceconnectionstatechange=function(e){switch(i.trace("Upstream oniceconnectionstatechange",{iceConnectionState:i.pc.iceConnectionState,iceGatheringState:i.pc.iceGatheringState}),i.pc.iceConnectionState){case"connected":case"completed":n({clientId:i.clientId,stream:i.stream});break;case"failed":t(e)}},i.pc.onicecandidate=function(e){i.trace("Upstream onicecandidate",{candidate:e.candidate,iceConnectionState:i.pc.iceConnectionState,iceGatheringState:i.pc.iceGatheringState}),null!==e.candidate&&i.sora.candidate(e.candidate)},i.pc.setRemoteDescription(new f(e),function(){i.pc.createAnswer(function(e){i.trace("Upstream answer sdp",e.sdp),i.pc.setLocalDescription(e,function(){i.sora.answer(e.sdp)},function(e){t(e)})},function(e){t(e)})},function(e){t(e)})})};return r(t).then(c).then(a).then(d)["catch"](function(e){return i.disconnect(),Promise.reject(e)})}},{key:"_startDownstream",value:function(e,n,t){var o=this,i=function(){return o.sora=new s["default"](o.signalingUrl).connection(),o.sora.onError(o._onError),o.sora.onDisconnect(o._onDisconnect),o.sora.connect({role:"downstream",channelId:e,accessToken:n,codecType:t})},r=function(e){return o.trace("Downstream offer sdp",e.sdp),o.trace("Downstream offer clientId",e.clientId),o.trace("Downstream offer iceServers",e.metadata.iceServers),new Promise(function(n,t){o.clientId=e.clientId,o.pc=new u({iceServers:e.metadata.iceServers}),n(e)})},c=function(e){return o.icecandidateConnected=!1,o.addstreamCompleted=!1,new Promise(function(n,t){o.pc.onaddstream=function(e){o.addstreamCompleted=!0,o.stream=e.stream,o.trace("Downstream onaddstream",e.stream.id),o.icecandidateConnected&&n({clientId:o.clientId,stream:o.stream})},o.pc.oniceconnectionstatechange=function(e){switch(o.trace("Downstream oniceconnectionstatechange",{iceConnectionState:o.pc.iceConnectionState,iceGatheringState:o.pc.iceGatheringState}),o.pc.iceConnectionState){case"connected":case"completed":o.icecandidateConnected=!0,o.addstreamCompleted&&n({clientId:o.clientId,stream:o.stream});break;case"failed":t(e)}},o.pc.onicecandidate=function(e){o.trace("Downstream onicecandidate",{candidate:e.candidate,iceConnectionState:o.pc.iceConnectionState,iceGatheringState:o.pc.iceGatheringState}),null!==e.candidate&&o.sora.candidate(e.candidate)},o.pc.setRemoteDescription(new f(e),function(){o.pc.createAnswer(function(e){o.trace("Downstream answer sdp",e.sdp),o.pc.setLocalDescription(e,function(){o.sora.answer(e.sdp)},function(e){t(e)})},function(e){t(e)})},function(e){t(e)})})};return i().then(r).then(c)["catch"](function(e){return o.disconnect(),Promise.reject(e)})}},{key:"trace",value:function(e,n){var t="";window.performance&&(t=(window.performance.now()/1e3).toFixed(3)+": "),"object"===("undefined"==typeof n?"undefined":r(n))&&null!==n?console.info(t+e+"\n"+JSON.stringify(n,null,2)):console.info(t+e+"\n"+n)}},{key:"disconnect",value:function(){this.stream&&this.stream.getTracks().forEach(function(e){e.stop()}),this.stream=null,this.sora&&this.sora.disconnect(),this.sora=null,this.pc&&"closed"!==this.pc.signalingState&&(this.pc.oniceconnectionstatechange=null,this.pc.close()),this.pc=null}},{key:"onError",value:function(e){this._onError=e,this.sora&&this.sora.onError(e)}},{key:"onDisconnect",value:function(e){this._onDisconnect=e,this.sora&&this.sora.onDisconnect(e)}}]),e}();n.exports=d},{"sora-js-sdk":1}]},{},[2])(2)});
{'fraction_non_alphanumeric': 0.25733861336350494, 'fraction_numerical': 0.006977182726758438, 'mean_word_length': 15.402061855670103, 'pattern_counts': {'":': 19, '<': 17, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1014154', 'n_tokens_mistral': 6250, 'n_tokens_neox': 6148, 'n_words': 397}