@vitoyucepi/audioplayer-deploy 0.4.5-master-cb79e769.98 → 0.4.5

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/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta content="width=device-width,initial-scale=1" name="viewport"/><title>Player</title><script defer="defer" src="/runtime.ab179b0cf6be596ac8ee.js"></script><script defer="defer" src="/vendors.6236ffbf0a07bb9f36ad.js"></script><script defer="defer" src="/main.708da1466b88e613fd4d.js"></script><link href="/main.dd8d7d5658d80557ec57.css" rel="stylesheet"></head><body></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta content="width=device-width,initial-scale=1" name="viewport"/><title>Player</title><script defer="defer" src="/runtime.ab179b0cf6be596ac8ee.js"></script><script defer="defer" src="/vendors.6236ffbf0a07bb9f36ad.js"></script><script defer="defer" src="/main.41cbd15ee6630d7223a1.js"></script><link href="/main.dd8d7d5658d80557ec57.css" rel="stylesheet"></head><body></body></html>
@@ -1 +1 @@
1
- "use strict";(self.webpackChunk_vitoyucepi_audioplayer_deploy=self.webpackChunk_vitoyucepi_audioplayer_deploy||[]).push([[792],{709:(t,e,n)=>{var r,i,a,o=n(181),s=n(78),u=n(300),l=n(608),c=n(313),d=n(808),h=n(819);r="https://anon.fm/state.txt",i="https://anon.fm/streams/radio",a=[{source:"https://anon.fm/streams/radio",bitrate:192,name:"High",default:!0},{source:"https://anon.fm/streams/radio.ogg",bitrate:112,name:"Medium"},{source:"https://anon.fm/streams/radio-low",bitrate:64,name:"Low"},{source:"https://anon.fm/streams/radio.aac",bitrate:12,name:"UltraLow"}];var f="Radio Anonymous",p=[function(t){t.on("@init",function(){var t=a.find(function(t){return t.default})||a[0];return{audioSources:a,currentSource:t}}),t.on("quality/set",function(t,e){return{currentSource:t.audioSources.find(function(t){return t.name===e})||t.currentSource}})},function(t){t.on("@init",function(){return{playStatus:"stop"}}),t.on("play/set",function(t,e){return void 0===e?{}:{playStatus:e}})},function(t){t.on("@init",function(){return{volume:50}}),t.on("volume/set",function(t,e){return e>100?{volume:100}:e<0?{volume:0}:{volume:e}})},function(t){t.on("@init",function(){return{tags:{title:f}}}),t.on("metadata/set",function(t,e){return{tags:e}})}],v=(0,d.g)((0,l.fX)((0,l.fX)([],["currentSource"],!0),["volume"],!0),{key:"player"}),m=(0,h.a)({filter:function(t){return function(t){return"volume/set"===t}(t)||function(t){return"quality/set"===t}(t)},key:"playerCT"}),y=(0,c.x)((0,l.fX)((0,l.fX)([],p,!0),[v,m],!1)),E=n(146),S=n.n(E),T=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,e)||this;return n.name="UtilsError",n}return(0,l.C6)(e,t),e}(Error),g=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Failed to fetch. ".concat(e).trim())||this;return n.name="FailedToFetchError",n}return(0,l.C6)(e,t),e}(T),I=function(t){function e(e){var n=t.call(this,"Fetch timeout. Fetch did not finish in ".concat(e.timeout," msecs"))||this;return n.name="FetchTimeoutError",n}return(0,l.C6)(e,t),e}(T),A=n(683);function _(t,e){void 0===e&&(e={});var n=e.timeout,r=void 0===n?C:n,i=new AbortController,a=setTimeout(function(){return i.abort()},r);return A.EN.fromPromise(fetch(t,(0,l.Cl)({signal:i.signal},e)),function(t){var e=t;return"AbortError"===e.name?new I({timeout:r}):new g(e.message)}).andThen(function(t){return clearTimeout(a),t.status===b&&t.ok?(0,A.ok)(t):(0,A._q)(new g(t.statusText))})}var b=200,C=1e4;function R(t){console.error("[".concat(t.name,"]: ").concat(t.message))}function H(t,e){var n=t.length;if(n!==e.length)return!1;for(var r=0,i=0;i<n;i++)t[i]===e[i]&&r++;return r===n}var w=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,e)||this;return n.name="MetadataError",n}return(0,l.C6)(e,t),e}(Error),D=function(t){function e(){var e=t.call(this,"Metadata download failed.")||this;return e.name="FailedToLoadMetadataError",e}return(0,l.C6)(e,t),e}(w),L=function(t){function e(e){var n=t.call(this,"Stream ended before enough bytes received. ".concat(e.bytesReceived," of ").concat(e.bytesExpected))||this;return n.name="UnderflowStreamError",n}return(0,l.C6)(e,t),e}(w),k=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Meta headers don't present in stream. ".concat(e).trim())||this;return n.name="NoMetaHeadersError",n}return(0,l.C6)(e,t),e}(w),O=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Failed to split block. ".concat(e).trim())||this;return n.name="FailedToSplitBlock",n}return(0,l.C6)(e,t),e}(w),M=function(){function t(){}return t.split=function(t){var e=function(t,e,n){void 0===n&&(n=0);for(var r=!1,i=!1,a=n;!r&&!i;)-1===(a=t.indexOf(e[0],a))?r=!0:H(t.slice(a,a+e.length),e)?i=!0:a++;return a}(t,this.HEADER_SEPARATOR);if(-1===e)return(0,A._q)(new O("Cannot find split sequence '".concat(this.HEADER_SEPARATOR.toString(),"' in block")));var n=t.subarray(0,e),r=t.subarray(e+4);return(0,A.ok)({headerBlock:n,bodyBlock:r})},t.parseHeader=function(t){var e=this,n=new TextDecoder("utf-8").decode(t).split("\r\n");if(n[0]!==this.ICY_STATUS_OK)return(0,A._q)(new g("Icy status not ok. ".concat(n[0])));n.shift();var r={};return n.map(function(t){return t.split(":")}).map(function(t){var e=t[0],n=t[1];return[e.trim().toUpperCase(),n.trim()]}).filter(function(t){return t[0].startsWith("ICY")}).filter(function(t){var n=t[0];return!e.EXCLUDED_HTTP_HEADERS.includes(n)}).forEach(function(t){var e=t[0],n=t[1];r[e]=n}),(0,A.ok)(r)},t.parseHttpHeaders=function(t){var e=this,n={};return t.forEach(function(t,r){var i=r.trim().toUpperCase(),a=t.trim();i.startsWith("ICY")&&!e.EXCLUDED_HTTP_HEADERS.includes(i)&&(n[i]=a)}),(0,A.ok)(n)},t.parseBody=function(t,e){var n=t[e]*this.METAINT_MULTIPLIER,r=t.subarray(e+1,e+n+1),i=new TextDecoder("utf-8").decode(r).split(";");i.pop();var a={};return i.filter(function(t){return t}).map(function(t){return t.split("=")}).filter(function(t){var e=t[0],n=t[1];return e&&n}).map(function(t){var e=t[0],n=t[1];return[e.trim().toUpperCase(),n.trim().slice(1,-1).trim()]}).filter(function(t){var e=t[0],n=t[1];return e.length>0&&n.length>0}).forEach(function(t){var e=t[0],n=t[1];a[e]=n}),(0,A.ok)(a)},t.HEADER_SEPARATOR=function(t){for(var e=new Uint8Array(t.length),n=0,r=t.length;n<r;n++)e[n]=t.charCodeAt(n);return e}("\r\n\r\n"),t.EXCLUDED_HTTP_HEADERS=["ICY-PUB","ICY-AUDIO-INFO","ICY-BR","ICY-URL"],t.ICY_STATUS_OK="ICY 200 OK",t.METAINT_MULTIPLIER=16,t}(),x=function(){function t(){}return t.parseText=function(t){for(var e=this,n=t.split("\n").filter(function(t){return t}),r=[];n.length;){var i=n.splice(-2),a=i[0],o=i[1];r.push([a,o])}var s={};return r.filter(function(t){var n=t[0];return-1===e.USELESS_KEYS.indexOf(n)}).filter(function(t){var n=t[1];return!e.FORBIDDEN_SYMBOLS.some(function(t){return n.indexOf(t)>-1})}).map(function(t){var e=t[0],n=t[1];return[e.toUpperCase().trim(),n.trim()]}).filter(function(t){var e=t[0],n=t[1];return e.length>0&&n.length>0}).forEach(function(t){var e=t[0],n=t[1];s[e]=n}),(0,A.ok)(s)},t.FORBIDDEN_SYMBOLS=["�"],t.USELESS_KEYS=["FILE","COVER","POS","ID","ISVIDEO"],t}(),U=function(){function t(t){this.source=t}return t.prototype.getTags=function(){return(0,l.sH)(this,void 0,void 0,function(){var t,e,n;return(0,l.YH)(this,function(r){switch(r.label){case 0:return[4,_(this.source)];case 1:return(t=r.sent()).isErr()?(R(t.error),[2,(0,A._q)(new D)]):[4,t.value.text()];case 2:return e=r.sent(),(n=x.parseText(e)).isErr()?[2,(0,A._q)(n.error)]:[2,(0,A.ok)(this.extractGenericTags(n.value))]}})})},t.prototype.extractGenericTags=function(t){var e=t.TITLE,n=t.ARTIST,r=t.ALBUMARTIST,i=t.COMPOSER,a=t.NAME,o={};switch(t.ISLIVE){case"0":o.isLive=!1;break;case"1":o.isLive=!0}if(o.artist=n||r||i,e)if(o.artist)o.title=e;else{var s=e.indexOf(" - ");s>-1&&e.lastIndexOf(" - ")?(o.artist=e.slice(0,s),o.title=e.slice(s+3)):o.title=e}return a&&(o.name=a),o},t}(),Y=function(){function t(t){this.source=t}return t.fetchBlock=function(e){return(0,l.sH)(this,void 0,void 0,function(){var n,r,i,a,o,s;return(0,l.YH)(this,function(u){switch(u.label){case 0:n=0,r=!1,i=[],u.label=1;case 1:return n<t.HEADER_SIZE&&!r?[4,e.read()]:[3,3];case 2:return a=u.sent(),r=a.done,void 0===(o=a.value)?[2,(0,A._q)(new L({bytesReceived:n,bytesExpected:t.HEADER_SIZE}))]:(n+=o.length,i.push(o),[3,1]);case 3:return e.cancel().catch(function(){}),n<t.HEADER_SIZE?[2,(0,A._q)(new L({bytesReceived:n,bytesExpected:t.HEADER_SIZE}))]:(s=function(t,e){void 0===e&&(e=0);var n=t.reduce(function(t,e){return t+e.length},0),r=new Uint8Array(n);return t.reduce(function(t,e){return r.set(e,t),t+e.length},0),r.slice(0,e)}(i,t.HEADER_SIZE),[2,(0,A.ok)(s)])}})})},t.prototype.getTags=function(){return(0,l.sH)(this,void 0,void 0,function(){var e,n,r,i,a,o;return(0,l.YH)(this,function(s){switch(s.label){case 0:return[4,_(this.source,{headers:t.FETCH_HEADERS})];case 1:return(e=s.sent()).isErr()?(R(e.error),[2,(0,A._q)(new D)]):null===e.value.body?[2,(0,A._q)(new D)]:(n=e.value.body.getReader(),[4,t.fetchBlock(n)]);case 2:if((r=s.sent()).isErr())return[2,(0,A._q)(r.error)];if(e.value.headers.has("icy-metaint"))i=M.parseHttpHeaders(e.value.headers),a=(0,A.ok)({headerBlock:new Uint8Array(0),bodyBlock:r.value});else{if((a=M.split(r.value)).isErr())return[2,(0,A._q)(a.error)];i=M.parseHeader(a.value.headerBlock)}return i.isErr()?(R(i.error),[2,(0,A._q)(new D)]):i.value["ICY-METAINT"]?(o=M.parseBody(a.value.bodyBlock,parseInt(i.value["ICY-METAINT"],10))).isErr()?[2,(0,A._q)(o.error)]:[2,(0,A.ok)(this.extractGenericTags((0,l.Cl)((0,l.Cl)({},i.value),o.value)))]:[2,(0,A._q)(new k)]}})})},t.prototype.extractGenericTags=function(t){var e=t["ICY-NAME"],n=t.STREAMTITLE,r={};if(e&&(r.name=e),n){var i=n.indexOf(" - ");i>-1&&i===n.lastIndexOf(" - ")?(r.artist=n.slice(0,i),r.title=n.slice(i+3)):r.title=n}return r},t.HEADER_SIZE=16*Math.pow(2,10),t.FETCH_HEADERS={"Icy-Metadata":"1"},t}(),P=function(){function t(){this.stateTxt=new U(r),this.mp3=new Y(i),this.isInitialized=!1}return t.fixTags=function(t){var e,n,r,i=/^ ?-|- ?$/g;return t.artist=null===(e=t.artist)||void 0===e?void 0:e.replaceAll(i,"").trim(),t.name=null===(n=t.name)||void 0===n?void 0:n.replaceAll(i,"").trim(),t.title=null===(r=t.title)||void 0===r?void 0:r.replaceAll(i,"").trim(),t},t.prototype.init=function(e){return(0,l.sH)(this,void 0,void 0,function(){var n,r,i,a=this;return(0,l.YH)(this,function(o){switch(o.label){case 0:return this.isInitialized?[2]:(this.isInitialized=!0,r=(n=e).dispatch,i=["metadata/set"],[4,this.getTags()]);case 1:return r.apply(n,i.concat([o.sent()])),setInterval(function(){a.getTags().then(function(t){S()(e.get().tags,t)||e.dispatch("metadata/set",t)}).catch(function(){})},t.DATA_FETCH_INTERVAL),[2]}})})},t.prototype.getTags=function(){return(0,l.sH)(this,void 0,void 0,function(){var e,n,r,i;return(0,l.YH)(this,function(a){switch(a.label){case 0:e=this.dataSourceGenerator(),n=e.next(),r={},a.label=1;case 1:return n.done?[3,3]:[4,n.value.getTags()];case 2:if((i=a.sent()).isOk()){if((r=t.fixTags((0,l.Cl)((0,l.Cl)({},i.value),r))).name||r.title)return[2,r]}else R(i.error);return n=e.next(),[3,1];case 3:return[2,r]}})})},t.prototype.dataSourceGenerator=function(){return(0,l.YH)(this,function(t){switch(t.label){case 0:return[4,this.stateTxt];case 1:return t.sent(),[4,this.mp3];case 2:return t.sent(),[2]}})},t.DATA_FETCH_INTERVAL=1e4,t}(),q=new P,F=function(){function t(){this.isInitialized=!1,this.stream=new Audio,this.stream.preload="none"}return t.prototype.init=function(t){var e=this;this.isInitialized||(this.isInitialized=!0,this.setSource(t.get().currentSource),this.setVolume(t.get().volume),this.setPlayStatus(t.get().playStatus),t.on("@changed",function(t,n){e.onStoreChanged(t,n)}),this.handleStreamEvents(t))},t.prototype.onStoreChanged=function(t,e){var n=e.playStatus,r=e.volume,i=e.currentSource;void 0!==n&&this.setPlayStatus(n),void 0!==r&&this.setVolume(r),void 0!==i&&(this.setSource(i),this.setPlayStatus(t.playStatus))},t.prototype.handleStreamEvents=function(t){var e=this;this.isInitialized&&(this.stream.addEventListener("ended",function(){t.dispatch("play/set","stop")}),this.stream.addEventListener("stalled",function(){e.handleStreamStalled(t)}),this.stream.addEventListener("canplay",function(){e.resetRetryTimer(),e.resetStopTimer()}))},t.prototype.handleStreamStalled=function(e){var n=this;this.isInitialized&&(void 0===this.stalledRetryTimer&&(this.stalledRetryTimer=setInterval(function(){e.get().playStatus?(n.setPlayStatus("stop"),n.setPlayStatus("play")):(n.resetRetryTimer(),n.resetStopTimer())},t.STALLED_RETRY_TIMEOUT)),void 0===this.stalledStopTimer&&(this.stalledStopTimer=setTimeout(function(){e.dispatch("play/set","stop"),n.resetRetryTimer()},t.STALLED_STOP_TIMEOUT)))},t.prototype.resetRetryTimer=function(){void 0!==this.stalledRetryTimer&&(clearInterval(this.stalledRetryTimer),this.stalledRetryTimer=void 0)},t.prototype.resetStopTimer=function(){void 0!==this.stalledStopTimer&&(clearTimeout(this.stalledStopTimer),this.stalledStopTimer=void 0)},t.prototype.setSource=function(t){this.stream.src=t.source},t.volumeTransformFunction=function(t){return Math.pow(t,2)},t.prototype.setVolume=function(e){this.stream.volume=t.volumeTransformFunction(e/100)},t.prototype.setPlayStatus=function(t){"play"===t?this.startStream():"pause"===t?this.pauseStream():this.stopStream()},t.prototype.startStream=function(){var t;this.stream.paused&&4===this.stream.readyState&&this.stopStream(),null===(t=this.stream.play())||void 0===t||t.catch(function(){})},t.prototype.pauseStream=function(){this.stream.pause(),this.stream.currentTime=0},t.prototype.stopStream=function(){var t=this.stream.src;this.stream.src="",this.stream.src=t},t.STALLED_RETRY_TIMEOUT=1e4,t.STALLED_STOP_TIMEOUT=3e4,t}(),B=new F,z=function(){function t(){this.isInitialized=!1,this.isActionHandlersInit=!1}return t.setTags=function(e){if(t.isMediaSessionAvailable()){var n=e.name,r=e.artist,i=e.title,a={};void 0!==i?(a.title=i,void 0!==r&&(a.artist=r)):a.title=void 0!==n?n:f,navigator.mediaSession.metadata=new MediaMetadata(a)}},t.prototype.initActionHandlers=function(){var t=this;if(!this.isActionHandlersInit){this.isActionHandlersInit=!0;var e=navigator.mediaSession;e.setActionHandler("play",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","play")}),e.setActionHandler("pause",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","pause")}),e.setActionHandler("stop",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","stop")})}},t.prototype.onStoreChanged=function(e){"play"!==e.playStatus&&"pause"!==e.playStatus||(this.initActionHandlers(),t.setTags(e.tags))},t.isMediaSessionAvailable=function(){return void 0!==navigator.mediaSession||(console.warn("MediaSession is not available."),!1)},t.prototype.init=function(e){var n=this;this.isInitialized||(this.isInitialized=!0,t.isMediaSessionAvailable()&&(this.store=e,e.on("@changed",function(t){n.onStoreChanged(t)})))},t}(),N=new z,X=function(){return(0,o.h)("div",{class:"player-logo"},(0,o.h)("div",{class:"player-logo-image"}),(0,o.h)("div",{class:"player-logo-text"},"Anon.fm"))},G=n(817),V=n(314),K=function(){var t=(0,s.SE)("playStatus"),e=t.dispatch,n=t.playStatus,r=(0,G.hb)(function(){e("play/set","play"===n?"stop":"play")},[e,n]);return(0,o.h)("button",{class:"player-play-button",onClick:r},"play"===n?(0,o.h)(V.eGh,null):(0,o.h)(V.XKH,null))},Z=function(){var t,e=(0,s.SE)("tags").tags;return t=e.title?e.artist?"".concat(e.artist," - ").concat(e.title):e.name?"".concat(e.name," - ").concat(e.title):e.title:e.name?e.name:f,(0,o.h)("div",{class:"player-title"},t)},W=function(){var t=(0,s.SE)("volume"),e=t.volume,n=t.dispatch,r=(0,G.hb)(function(t){t.preventDefault(),t.deltaY<0?n("volume/set",e+5):t.deltaY>0&&n("volume/set",e-5)},[n,e]),i=(0,G.hb)(function(t){var e=t.currentTarget.value;n("volume/set",Number(e))},[n]),a=(0,o.h)(V.FFb,null);return e>j?a=(0,o.h)(V.guq,null):e>$?a=(0,o.h)(V.ahh,null):e>0&&(a=(0,o.h)(V.fGm,null)),(0,o.h)("div",{class:"player-volume-dropdown",onWheel:r},(0,o.h)("button",{class:"player-volume-button"},a),(0,o.h)("div",{class:"player-volume-dropdown-content"},(0,o.h)("div",{class:"player-volume-input-icon"},(0,o.h)(V.fGm,{size:"75%"})),(0,o.h)("input",{class:"player-volume-input-range",type:"range",min:"0",max:"100",value:e,onInput:i,onChange:i}),(0,o.h)("div",{class:"player-volume-input-icon"},(0,o.h)(V.guq,{size:"75%"}))))},$=33,j=66,J=function(){var t=(0,s.SE)("audioSources","currentSource"),e=t.dispatch,n=t.audioSources,r=t.currentSource,i=(0,G.hb)(function(t){var n=t.target;e("quality/set",n.value)},[e]),a=n.map(function(t){return(0,o.h)("option",{class:"quality-selector-option",key:t.name,value:t.name},t.name)});return(0,o.h)("select",{class:"player-quality-selector",value:r.name,onChange:i},a)},Q=function(){return(0,o.h)("div",{class:"player-controls-component"},(0,o.h)(K,null),(0,o.h)(Z,null),(0,o.h)(W,null),(0,o.h)(J,null))};q.init(y).catch(function(){}),B.init(y),N.init(y),(0,o.XX)((0,o.h)("div",{id:"player-root"},(0,o.h)(u.Vx.Provider,{value:{size:"100%"}},(0,o.h)(s.Pd.Provider,{value:y},(0,o.h)(function(){return(0,o.h)("div",{class:"player-main-frame"},(0,o.h)(X,null),(0,o.h)(Q,null))},null)))),document.body)}},t=>{t.O(0,[96],()=>{return e=709,t(t.s=e);var e});t.O()}]);
1
+ "use strict";(self.webpackChunk_vitoyucepi_audioplayer_deploy=self.webpackChunk_vitoyucepi_audioplayer_deploy||[]).push([[792],{709:(t,e,n)=>{var r,i,a,o=n(181),s=n(78),u=n(300),c=n(608),l=n(313),d=n(808),h=n(819);r="https://anon.fm/state.txt",i="https://icecast.anon.fm/radio",a=[{source:"https://icecast.anon.fm/radio",bitrate:192,name:"High",default:!0},{source:"https://icecast.anon.fm/radio.ogg",bitrate:112,name:"Medium"},{source:"https://icecast.anon.fm/radio-low",bitrate:64,name:"Low"},{source:"https://icecast.anon.fm/radio.aac",bitrate:12,name:"UltraLow"}];var f="Radio Anonymous",p=[function(t){t.on("@init",function(){var t=a.find(function(t){return t.default})||a[0];return{audioSources:a,currentSource:t}}),t.on("quality/set",function(t,e){return{currentSource:t.audioSources.find(function(t){return t.name===e})||t.currentSource}})},function(t){t.on("@init",function(){return{playStatus:"stop"}}),t.on("play/set",function(t,e){return void 0===e?{}:{playStatus:e}})},function(t){t.on("@init",function(){return{volume:50}}),t.on("volume/set",function(t,e){return e>100?{volume:100}:e<0?{volume:0}:{volume:e}})},function(t){t.on("@init",function(){return{tags:{title:f}}}),t.on("metadata/set",function(t,e){return{tags:e}})}],v=(0,d.g)((0,c.fX)((0,c.fX)([],["currentSource"],!0),["volume"],!0),{key:"player"}),m=(0,h.a)({filter:function(t){return function(t){return"volume/set"===t}(t)||function(t){return"quality/set"===t}(t)},key:"playerCT"}),y=(0,l.x)((0,c.fX)((0,c.fX)([],p,!0),[v,m],!1)),E=n(146),S=n.n(E),T=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,e)||this;return n.name="UtilsError",n}return(0,c.C6)(e,t),e}(Error),g=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Failed to fetch. ".concat(e).trim())||this;return n.name="FailedToFetchError",n}return(0,c.C6)(e,t),e}(T),I=function(t){function e(e){var n=t.call(this,"Fetch timeout. Fetch did not finish in ".concat(e.timeout," msecs"))||this;return n.name="FetchTimeoutError",n}return(0,c.C6)(e,t),e}(T),A=n(683);function _(t,e){void 0===e&&(e={});var n=e.timeout,r=void 0===n?C:n,i=new AbortController,a=setTimeout(function(){return i.abort()},r);return A.EN.fromPromise(fetch(t,(0,c.Cl)({signal:i.signal},e)),function(t){var e=t;return"AbortError"===e.name?new I({timeout:r}):new g(e.message)}).andThen(function(t){return clearTimeout(a),t.status===b&&t.ok?(0,A.ok)(t):(0,A._q)(new g(t.statusText))})}var b=200,C=1e4;function R(t){console.error("[".concat(t.name,"]: ").concat(t.message))}function H(t,e){var n=t.length;if(n!==e.length)return!1;for(var r=0,i=0;i<n;i++)t[i]===e[i]&&r++;return r===n}var w=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,e)||this;return n.name="MetadataError",n}return(0,c.C6)(e,t),e}(Error),D=function(t){function e(){var e=t.call(this,"Metadata download failed.")||this;return e.name="FailedToLoadMetadataError",e}return(0,c.C6)(e,t),e}(w),L=function(t){function e(e){var n=t.call(this,"Stream ended before enough bytes received. ".concat(e.bytesReceived," of ").concat(e.bytesExpected))||this;return n.name="UnderflowStreamError",n}return(0,c.C6)(e,t),e}(w),k=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Meta headers don't present in stream. ".concat(e).trim())||this;return n.name="NoMetaHeadersError",n}return(0,c.C6)(e,t),e}(w),O=function(t){function e(e){void 0===e&&(e="");var n=t.call(this,"Failed to split block. ".concat(e).trim())||this;return n.name="FailedToSplitBlock",n}return(0,c.C6)(e,t),e}(w),M=function(){function t(){}return t.split=function(t){var e=function(t,e,n){void 0===n&&(n=0);for(var r=!1,i=!1,a=n;!r&&!i;)-1===(a=t.indexOf(e[0],a))?r=!0:H(t.slice(a,a+e.length),e)?i=!0:a++;return a}(t,this.HEADER_SEPARATOR);if(-1===e)return(0,A._q)(new O("Cannot find split sequence '".concat(this.HEADER_SEPARATOR.toString(),"' in block")));var n=t.subarray(0,e),r=t.subarray(e+4);return(0,A.ok)({headerBlock:n,bodyBlock:r})},t.parseHeader=function(t){var e=this,n=new TextDecoder("utf-8").decode(t).split("\r\n");if(n[0]!==this.ICY_STATUS_OK)return(0,A._q)(new g("Icy status not ok. ".concat(n[0])));n.shift();var r={};return n.map(function(t){return t.split(":")}).map(function(t){var e=t[0],n=t[1];return[e.trim().toUpperCase(),n.trim()]}).filter(function(t){return t[0].startsWith("ICY")}).filter(function(t){var n=t[0];return!e.EXCLUDED_HTTP_HEADERS.includes(n)}).forEach(function(t){var e=t[0],n=t[1];r[e]=n}),(0,A.ok)(r)},t.parseHttpHeaders=function(t){var e=this,n={};return t.forEach(function(t,r){var i=r.trim().toUpperCase(),a=t.trim();i.startsWith("ICY")&&!e.EXCLUDED_HTTP_HEADERS.includes(i)&&(n[i]=a)}),(0,A.ok)(n)},t.parseBody=function(t,e){var n=t[e]*this.METAINT_MULTIPLIER,r=t.subarray(e+1,e+n+1),i=new TextDecoder("utf-8").decode(r).split(";");i.pop();var a={};return i.filter(function(t){return t}).map(function(t){return t.split("=")}).filter(function(t){var e=t[0],n=t[1];return e&&n}).map(function(t){var e=t[0],n=t[1];return[e.trim().toUpperCase(),n.trim().slice(1,-1).trim()]}).filter(function(t){var e=t[0],n=t[1];return e.length>0&&n.length>0}).forEach(function(t){var e=t[0],n=t[1];a[e]=n}),(0,A.ok)(a)},t.HEADER_SEPARATOR=function(t){for(var e=new Uint8Array(t.length),n=0,r=t.length;n<r;n++)e[n]=t.charCodeAt(n);return e}("\r\n\r\n"),t.EXCLUDED_HTTP_HEADERS=["ICY-PUB","ICY-AUDIO-INFO","ICY-BR","ICY-URL"],t.ICY_STATUS_OK="ICY 200 OK",t.METAINT_MULTIPLIER=16,t}(),x=function(){function t(){}return t.parseText=function(t){for(var e=this,n=t.split("\n").filter(function(t){return t}),r=[];n.length;){var i=n.splice(-2),a=i[0],o=i[1];r.push([a,o])}var s={};return r.filter(function(t){var n=t[0];return-1===e.USELESS_KEYS.indexOf(n)}).filter(function(t){var n=t[1];return!e.FORBIDDEN_SYMBOLS.some(function(t){return n.indexOf(t)>-1})}).map(function(t){var e=t[0],n=t[1];return[e.toUpperCase().trim(),n.trim()]}).filter(function(t){var e=t[0],n=t[1];return e.length>0&&n.length>0}).forEach(function(t){var e=t[0],n=t[1];s[e]=n}),(0,A.ok)(s)},t.FORBIDDEN_SYMBOLS=["�"],t.USELESS_KEYS=["FILE","COVER","POS","ID","ISVIDEO"],t}(),U=function(){function t(t){this.source=t}return t.prototype.getTags=function(){return(0,c.sH)(this,void 0,void 0,function(){var t,e,n;return(0,c.YH)(this,function(r){switch(r.label){case 0:return[4,_(this.source)];case 1:return(t=r.sent()).isErr()?(R(t.error),[2,(0,A._q)(new D)]):[4,t.value.text()];case 2:return e=r.sent(),(n=x.parseText(e)).isErr()?[2,(0,A._q)(n.error)]:[2,(0,A.ok)(this.extractGenericTags(n.value))]}})})},t.prototype.extractGenericTags=function(t){var e=t.TITLE,n=t.ARTIST,r=t.ALBUMARTIST,i=t.COMPOSER,a=t.NAME,o={};switch(t.ISLIVE){case"0":o.isLive=!1;break;case"1":o.isLive=!0}if(o.artist=n||r||i,e)if(o.artist)o.title=e;else{var s=e.indexOf(" - ");s>-1&&e.lastIndexOf(" - ")?(o.artist=e.slice(0,s),o.title=e.slice(s+3)):o.title=e}return a&&(o.name=a),o},t}(),Y=function(){function t(t){this.source=t}return t.fetchBlock=function(e){return(0,c.sH)(this,void 0,void 0,function(){var n,r,i,a,o,s;return(0,c.YH)(this,function(u){switch(u.label){case 0:n=0,r=!1,i=[],u.label=1;case 1:return n<t.HEADER_SIZE&&!r?[4,e.read()]:[3,3];case 2:return a=u.sent(),r=a.done,void 0===(o=a.value)?[2,(0,A._q)(new L({bytesReceived:n,bytesExpected:t.HEADER_SIZE}))]:(n+=o.length,i.push(o),[3,1]);case 3:return e.cancel().catch(function(){}),n<t.HEADER_SIZE?[2,(0,A._q)(new L({bytesReceived:n,bytesExpected:t.HEADER_SIZE}))]:(s=function(t,e){void 0===e&&(e=0);var n=t.reduce(function(t,e){return t+e.length},0),r=new Uint8Array(n);return t.reduce(function(t,e){return r.set(e,t),t+e.length},0),r.slice(0,e)}(i,t.HEADER_SIZE),[2,(0,A.ok)(s)])}})})},t.prototype.getTags=function(){return(0,c.sH)(this,void 0,void 0,function(){var e,n,r,i,a,o;return(0,c.YH)(this,function(s){switch(s.label){case 0:return[4,_(this.source,{headers:t.FETCH_HEADERS})];case 1:return(e=s.sent()).isErr()?(R(e.error),[2,(0,A._q)(new D)]):null===e.value.body?[2,(0,A._q)(new D)]:(n=e.value.body.getReader(),[4,t.fetchBlock(n)]);case 2:if((r=s.sent()).isErr())return[2,(0,A._q)(r.error)];if(e.value.headers.has("icy-metaint"))i=M.parseHttpHeaders(e.value.headers),a=(0,A.ok)({headerBlock:new Uint8Array(0),bodyBlock:r.value});else{if((a=M.split(r.value)).isErr())return[2,(0,A._q)(a.error)];i=M.parseHeader(a.value.headerBlock)}return i.isErr()?(R(i.error),[2,(0,A._q)(new D)]):i.value["ICY-METAINT"]?(o=M.parseBody(a.value.bodyBlock,parseInt(i.value["ICY-METAINT"],10))).isErr()?[2,(0,A._q)(o.error)]:[2,(0,A.ok)(this.extractGenericTags((0,c.Cl)((0,c.Cl)({},i.value),o.value)))]:[2,(0,A._q)(new k)]}})})},t.prototype.extractGenericTags=function(t){var e=t["ICY-NAME"],n=t.STREAMTITLE,r={};if(e&&(r.name=e),n){var i=n.indexOf(" - ");i>-1&&i===n.lastIndexOf(" - ")?(r.artist=n.slice(0,i),r.title=n.slice(i+3)):r.title=n}return r},t.HEADER_SIZE=16*Math.pow(2,10),t.FETCH_HEADERS={"Icy-Metadata":"1"},t}(),P=function(){function t(){this.stateTxt=new U(r),this.mp3=new Y(i),this.isInitialized=!1}return t.fixTags=function(t){var e,n,r,i=/^ ?-|- ?$/g;return t.artist=null===(e=t.artist)||void 0===e?void 0:e.replaceAll(i,"").trim(),t.name=null===(n=t.name)||void 0===n?void 0:n.replaceAll(i,"").trim(),t.title=null===(r=t.title)||void 0===r?void 0:r.replaceAll(i,"").trim(),t},t.prototype.init=function(e){return(0,c.sH)(this,void 0,void 0,function(){var n,r,i,a=this;return(0,c.YH)(this,function(o){switch(o.label){case 0:return this.isInitialized?[2]:(this.isInitialized=!0,r=(n=e).dispatch,i=["metadata/set"],[4,this.getTags()]);case 1:return r.apply(n,i.concat([o.sent()])),setInterval(function(){a.getTags().then(function(t){S()(e.get().tags,t)||e.dispatch("metadata/set",t)}).catch(function(){})},t.DATA_FETCH_INTERVAL),[2]}})})},t.prototype.getTags=function(){return(0,c.sH)(this,void 0,void 0,function(){var e,n,r,i;return(0,c.YH)(this,function(a){switch(a.label){case 0:e=this.dataSourceGenerator(),n=e.next(),r={},a.label=1;case 1:return n.done?[3,3]:[4,n.value.getTags()];case 2:if((i=a.sent()).isOk()){if((r=t.fixTags((0,c.Cl)((0,c.Cl)({},i.value),r))).name||r.title)return[2,r]}else R(i.error);return n=e.next(),[3,1];case 3:return[2,r]}})})},t.prototype.dataSourceGenerator=function(){return(0,c.YH)(this,function(t){switch(t.label){case 0:return[4,this.stateTxt];case 1:return t.sent(),[4,this.mp3];case 2:return t.sent(),[2]}})},t.DATA_FETCH_INTERVAL=1e4,t}(),q=new P,F=function(){function t(){this.isInitialized=!1,this.stream=new Audio,this.stream.preload="none"}return t.prototype.init=function(t){var e=this;this.isInitialized||(this.isInitialized=!0,this.setSource(t.get().currentSource),this.setVolume(t.get().volume),this.setPlayStatus(t.get().playStatus),t.on("@changed",function(t,n){e.onStoreChanged(t,n)}),this.handleStreamEvents(t))},t.prototype.onStoreChanged=function(t,e){var n=e.playStatus,r=e.volume,i=e.currentSource;void 0!==n&&this.setPlayStatus(n),void 0!==r&&this.setVolume(r),void 0!==i&&(this.setSource(i),this.setPlayStatus(t.playStatus))},t.prototype.handleStreamEvents=function(t){var e=this;this.isInitialized&&(this.stream.addEventListener("ended",function(){t.dispatch("play/set","stop")}),this.stream.addEventListener("stalled",function(){e.handleStreamStalled(t)}),this.stream.addEventListener("canplay",function(){e.resetRetryTimer(),e.resetStopTimer()}))},t.prototype.handleStreamStalled=function(e){var n=this;this.isInitialized&&(void 0===this.stalledRetryTimer&&(this.stalledRetryTimer=setInterval(function(){e.get().playStatus?(n.setPlayStatus("stop"),n.setPlayStatus("play")):(n.resetRetryTimer(),n.resetStopTimer())},t.STALLED_RETRY_TIMEOUT)),void 0===this.stalledStopTimer&&(this.stalledStopTimer=setTimeout(function(){e.dispatch("play/set","stop"),n.resetRetryTimer()},t.STALLED_STOP_TIMEOUT)))},t.prototype.resetRetryTimer=function(){void 0!==this.stalledRetryTimer&&(clearInterval(this.stalledRetryTimer),this.stalledRetryTimer=void 0)},t.prototype.resetStopTimer=function(){void 0!==this.stalledStopTimer&&(clearTimeout(this.stalledStopTimer),this.stalledStopTimer=void 0)},t.prototype.setSource=function(t){this.stream.src=t.source},t.volumeTransformFunction=function(t){return Math.pow(t,2)},t.prototype.setVolume=function(e){this.stream.volume=t.volumeTransformFunction(e/100)},t.prototype.setPlayStatus=function(t){"play"===t?this.startStream():"pause"===t?this.pauseStream():this.stopStream()},t.prototype.startStream=function(){var t;this.stream.paused&&4===this.stream.readyState&&this.stopStream(),null===(t=this.stream.play())||void 0===t||t.catch(function(){})},t.prototype.pauseStream=function(){this.stream.pause(),this.stream.currentTime=0},t.prototype.stopStream=function(){var t=this.stream.src;this.stream.src="",this.stream.src=t},t.STALLED_RETRY_TIMEOUT=1e4,t.STALLED_STOP_TIMEOUT=3e4,t}(),B=new F,z=function(){function t(){this.isInitialized=!1,this.isActionHandlersInit=!1}return t.setTags=function(e){if(t.isMediaSessionAvailable()){var n=e.name,r=e.artist,i=e.title,a={};void 0!==i?(a.title=i,void 0!==r&&(a.artist=r)):a.title=void 0!==n?n:f,navigator.mediaSession.metadata=new MediaMetadata(a)}},t.prototype.initActionHandlers=function(){var t=this;if(!this.isActionHandlersInit){this.isActionHandlersInit=!0;var e=navigator.mediaSession;e.setActionHandler("play",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","play")}),e.setActionHandler("pause",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","pause")}),e.setActionHandler("stop",function(){var e;null===(e=t.store)||void 0===e||e.dispatch("play/set","stop")})}},t.prototype.onStoreChanged=function(e){"play"!==e.playStatus&&"pause"!==e.playStatus||(this.initActionHandlers(),t.setTags(e.tags))},t.isMediaSessionAvailable=function(){return void 0!==navigator.mediaSession||(console.warn("MediaSession is not available."),!1)},t.prototype.init=function(e){var n=this;this.isInitialized||(this.isInitialized=!0,t.isMediaSessionAvailable()&&(this.store=e,e.on("@changed",function(t){n.onStoreChanged(t)})))},t}(),N=new z,X=function(){return(0,o.h)("div",{class:"player-logo"},(0,o.h)("div",{class:"player-logo-image"}),(0,o.h)("div",{class:"player-logo-text"},"Anon.fm"))},G=n(817),V=n(314),K=function(){var t=(0,s.SE)("playStatus"),e=t.dispatch,n=t.playStatus,r=(0,G.hb)(function(){e("play/set","play"===n?"stop":"play")},[e,n]);return(0,o.h)("button",{class:"player-play-button",onClick:r},"play"===n?(0,o.h)(V.eGh,null):(0,o.h)(V.XKH,null))},Z=function(){var t,e=(0,s.SE)("tags").tags;return t=e.title?e.artist?"".concat(e.artist," - ").concat(e.title):e.name?"".concat(e.name," - ").concat(e.title):e.title:e.name?e.name:f,(0,o.h)("div",{class:"player-title"},t)},W=function(){var t=(0,s.SE)("volume"),e=t.volume,n=t.dispatch,r=(0,G.hb)(function(t){t.preventDefault(),t.deltaY<0?n("volume/set",e+5):t.deltaY>0&&n("volume/set",e-5)},[n,e]),i=(0,G.hb)(function(t){var e=t.currentTarget.value;n("volume/set",Number(e))},[n]),a=(0,o.h)(V.FFb,null);return e>j?a=(0,o.h)(V.guq,null):e>$?a=(0,o.h)(V.ahh,null):e>0&&(a=(0,o.h)(V.fGm,null)),(0,o.h)("div",{class:"player-volume-dropdown",onWheel:r},(0,o.h)("button",{class:"player-volume-button"},a),(0,o.h)("div",{class:"player-volume-dropdown-content"},(0,o.h)("div",{class:"player-volume-input-icon"},(0,o.h)(V.fGm,{size:"75%"})),(0,o.h)("input",{class:"player-volume-input-range",type:"range",min:"0",max:"100",value:e,onInput:i,onChange:i}),(0,o.h)("div",{class:"player-volume-input-icon"},(0,o.h)(V.guq,{size:"75%"}))))},$=33,j=66,J=function(){var t=(0,s.SE)("audioSources","currentSource"),e=t.dispatch,n=t.audioSources,r=t.currentSource,i=(0,G.hb)(function(t){var n=t.target;e("quality/set",n.value)},[e]),a=n.map(function(t){return(0,o.h)("option",{class:"quality-selector-option",key:t.name,value:t.name},t.name)});return(0,o.h)("select",{class:"player-quality-selector",value:r.name,onChange:i},a)},Q=function(){return(0,o.h)("div",{class:"player-controls-component"},(0,o.h)(K,null),(0,o.h)(Z,null),(0,o.h)(W,null),(0,o.h)(J,null))};q.init(y).catch(function(){}),B.init(y),N.init(y),(0,o.XX)((0,o.h)("div",{id:"player-root"},(0,o.h)(u.Vx.Provider,{value:{size:"100%"}},(0,o.h)(s.Pd.Provider,{value:y},(0,o.h)(function(){return(0,o.h)("div",{class:"player-main-frame"},(0,o.h)(X,null),(0,o.h)(Q,null))},null)))),document.body)}},t=>{t.O(0,[96],()=>{return e=709,t(t.s=e);var e});t.O()}]);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitoyucepi/audioplayer-deploy",
3
- "version": "0.4.5-master-cb79e769.98+cb79e76",
3
+ "version": "0.4.5",
4
4
  "description": "AudioPlayer for anon.fm. Deploy package.",
5
5
  "scripts": {},
6
6
  "author": "Vitoyucepi",
@@ -16,5 +16,5 @@
16
16
  "publishConfig": {
17
17
  "access": "public"
18
18
  },
19
- "gitHead": "cb79e769bffd2a01badf60c9f995e854a9c9c85d"
19
+ "gitHead": "a95a6012a83200d6a8e47906e8b60af25fa170ad"
20
20
  }