nixamp 0.57.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/dist/guide-rooms.d.ts +42 -0
  2. package/dist/guide-rooms.js +157 -7
  3. package/dist/label-profiles.js +2 -2
  4. package/dist/oauth.d.ts +36 -3
  5. package/dist/oauth.js +107 -7
  6. package/dist/radio-pages.d.ts +2 -2
  7. package/dist/radio-pages.js +4 -4
  8. package/dist/server.js +59 -6
  9. package/package.json +1 -1
  10. package/src/guide-rooms.ts +182 -8
  11. package/src/label-profiles.ts +2 -2
  12. package/src/oauth.ts +119 -6
  13. package/src/radio-pages.ts +4 -4
  14. package/src/server.ts +60 -5
  15. package/web/dist/assets/{ar-d05d_7Df.js → ar-C8G_vLmh.js} +1 -1
  16. package/web/dist/assets/{cs-CclrNwa7.js → cs-7bYMjFS2.js} +1 -1
  17. package/web/dist/assets/{da-C30KTGl1.js → da-DHY5Csp_.js} +1 -1
  18. package/web/dist/assets/{de-D2A2RQwi.js → de-YNBoxnLa.js} +1 -1
  19. package/web/dist/assets/{es-BXFx0WZ5.js → es-9F9kBzzh.js} +1 -1
  20. package/web/dist/assets/{fi-DPA3S8og.js → fi-BqpzsfBb.js} +1 -1
  21. package/web/dist/assets/{fr-D_0wnr4h.js → fr-BKQXRwFk.js} +1 -1
  22. package/web/dist/assets/{hi-EfiCQnb9.js → hi-CGNIGyR-.js} +1 -1
  23. package/web/dist/assets/{hu-CK5rnxKO.js → hu-anYPYX8d.js} +1 -1
  24. package/web/dist/assets/{id-BgTV_4UK.js → id-BW3GasRn.js} +1 -1
  25. package/web/dist/assets/{it-DGefapXn.js → it-C7w2DZ3R.js} +1 -1
  26. package/web/dist/assets/{main-C-tWhTWo.js → main-YkIgU0VD.js} +2 -2
  27. package/web/dist/assets/{nl-Cyst29Bp.js → nl-BNrkTQI2.js} +1 -1
  28. package/web/dist/assets/{radio-CtAne8M1.css → radio-Cmg6GPN2.css} +1 -1
  29. package/web/dist/assets/{radio-yD_-qpS7.js → radio-DV3h4YZS.js} +1 -1
  30. package/web/dist/assets/{ru-D8G6Wynm.js → ru-CnKOo1uk.js} +1 -1
  31. package/web/dist/assets/station-M7G4NiE3.js +3 -0
  32. package/web/dist/assets/{sv-aYnDAFwz.js → sv-BsknKdtx.js} +1 -1
  33. package/web/dist/assets/{uk-BDtew7z3.js → uk-u_igTh6D.js} +1 -1
  34. package/web/dist/assets/{vi-CRlDn2Xh.js → vi-DH0ApTua.js} +1 -1
  35. package/web/dist/assets/watch-Brz-RgjN.js +1 -0
  36. package/web/dist/assets/{zh-BCAIjeQq.js → zh-Bcnk2nIV.js} +1 -1
  37. package/web/dist/index.html +1 -1
  38. package/web/dist/radio.html +2 -2
  39. package/web/dist/station.html +1 -1
  40. package/web/dist/sw.js +23 -23
  41. package/web/dist/watch.html +1 -1
  42. package/web/dist/assets/station-D6sd4DqP.js +0 -3
  43. package/web/dist/assets/watch-Dxsz5gHd.js +0 -1
@@ -1,3 +0,0 @@
1
- import{r as e}from"./chunk-Q2XQMA4B-PTuZPMen.js";/* empty css */var t={þ:`th`,ð:`d`,ø:`o`,æ:`ae`,œ:`oe`,ß:`ss`,đ:`d`,ł:`l`,ı:`i`,"&":` and `};function n(e,n=60){let r=String(e??``).toLowerCase().replace(/[þðøæœßđłı&]/g,e=>t[e]??e).normalize(`NFKD`).replace(/[̀-ͯ]/g,``).replace(/['’`]/g,``).replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``);if(r.length<=n)return r;let i=r.slice(0,n+1),a=i.lastIndexOf(`-`);return(a>8?i.slice(0,a):r.slice(0,n)).replace(/-+$/,``)}var r=e=>n(String(e??``).split(/\s*;\s*/)[0]??``,60),i=(e,t)=>n(`${r(e)} ${t}`,90),a={owned:`owned by the station`,permission:`broadcast with permission`,licensed:`licensed for broadcast`,"creative-commons":`Creative Commons`,"public-domain":`public domain`},o=/^\/radio\/[a-z0-9-]+\/?$/.test(location.pathname),s=location.pathname.split(`/`).filter(Boolean)[1]??``,c=new URLSearchParams(location.search).get(`t`)??``,l=o?``:`?t=`+encodeURIComponent(c),u=o?location.pathname.replace(/\/+$/,``):`/api/v1/stations/`+encodeURIComponent(s),d=(e,t)=>e+(e.includes(`?`)?`&`:`?`)+t,f=e=>e.startsWith(`/api/v1/stations/`)||o&&e.startsWith(u+`/`),p=e=>document.querySelector(e),m=null,h=null,g=null,_=!1,v=0,y=0,b=0,x=!1,S=!1,C=0,w=(e,t)=>{let n=p(`#state`);n.className=`station-chip `+e,n.textContent=t},T=e=>{p(`#announce`).textContent=e},E=e=>{let t=e.nowPlaying;p(`#title`).textContent=t?t.title||`Untitled`:e.state===`live`?`On the air`:``,p(`#by`).textContent=t?[t.artist,t.album].filter(Boolean).join(` · `):``},D=e=>{let t=p(`#facts`);if(!e){t.hidden=!0,N(``);return}let n=[];e.artist&&n.push([`Artist`,e.artist]),e.album&&n.push([`Album`,e.album]),e.year&&n.push([`Year`,e.year]),e.genre&&!/^ai$/i.test(e.genre)&&n.push([`Genre`,e.genre]),n.push([`Made with AI`,e.ai.generated===!0?`Yes, ${e.ai.by}`:e.ai.generated===!1?`No`:`Not stated`]);let s=e.rights.holder,c=e.rights.basis?a[e.rights.basis]??e.rights.basis:``;n.push([`Copyright`,s?`© ${s}`:c?`Not stated (${c})`:`Not stated`]),e.rights.license?n.push([`Licence`,e.rights.license]):e.rights.note&&e.rights.source!==`holder`&&n.push([`Rights`,e.rights.note]);let l=p(`#facts-list`),u=t=>o?t===`Artist`&&r(e.artist)?`/radio/artist/${r(e.artist)}`:t===`Album`&&e.album&&i(e.artist,e.album)?`/radio/album/${i(e.artist,e.album)}`:``:``;l.replaceChildren(...n.flatMap(([e,t])=>{let n=document.createElement(`dt`);n.textContent=e;let r=document.createElement(`dd`),i=u(e);if(i){let e=document.createElement(`a`);e.href=i,e.textContent=t,r.append(e)}else r.textContent=t;return[n,r]}));let d=p(`#cover`),m=typeof e.art==`string`&&f(e.art)?e.art:``;d.hidden=!m,m&&d.getAttribute(`src`)!==m&&(d.src=m,d.alt=`Cover of ${e.title||`this track`}`),`mediaSession`in navigator&&typeof MediaMetadata<`u`&&(navigator.mediaSession.metadata=new MediaMetadata({title:e.title||g?.name||`nixamp`,artist:e.artist,album:e.album||g?.name||``,...m?{artwork:[{src:new URL(m,location.href).href,sizes:`512x512`,type:`image/jpeg`}]}:{}}));let h=p(`#ai-badge`);h.hidden=e.ai.generated!==!0,h.textContent=e.ai.generated===!0?`AI-generated`:``,h.title=e.ai.evidence;let _=p(`#support`),v=e.support?.url??``;_.hidden=!/^https:\/\//.test(v),_.hidden||(_.href=v,_.textContent=`${e.support.label||`Support`} ${e.support.holder}`);let y=e.store&&[e.store.song,e.store.album,e.store.artist].every(e=>/^https:\/\//.test(e)||e.startsWith(`/radio/buy?`))?e.store:null;p(`#buy`).hidden=!y,y&&(p(`#buy-song`).href=y.song,p(`#buy-album`).href=y.album,p(`#buy-album`).textContent=`Album${y.albumTitle?`, ${y.albumTitle}`:``} · $1`,p(`#buy-artist`).href=y.artist,p(`#buy-artist`).textContent=`Everything by ${y.artistName||`them`} · $2`),t.hidden=!1,N(typeof e.lyrics==`string`&&f(e.lyrics)?e.lyrics:``)},O=null,k=(e,t)=>{let n=[],r=[];for(let e of t){let t=document.createElement(`p`);t.className=`lyric-line`;let i=e.words.length?e.words.map((e,t)=>{let n=document.createElement(`span`);return n.className=`lyric-word`,n.textContent=(t?` `:``)+e.text,n}):[];i.length?t.append(...i):t.textContent=e.text,n.push(t),r.push(i)}let i=p(`#lyrics-text`);i.classList.add(`synced`),i.replaceChildren(...n),O={lines:t,els:n,words:r,at:-1},p(`#lyrics-follow-box`).hidden=!1,p(`#lyrics-for`).textContent=e.title?`· ${e.title}`:``,p(`#lyrics-source`).textContent=`Timed to the recording; the line being sung lights up.`,p(`#lyrics`).hidden=!1},A=e=>{if(!O)return;let{lines:t,els:n,words:r}=O,i=-1;for(let n=0;n<t.length;n++)t[n].start<=e+.1&&(i=n);if(i!==O.at){n.forEach((e,t)=>{e.classList.toggle(`now`,t===i),e.classList.toggle(`past`,t<i)}),O.at=i;let e=p(`#lyrics-text`);if(i>=0&&p(`#lyrics-follow`).checked){let t=n[i];e.scrollTop=Math.max(0,t.offsetTop-e.offsetTop-e.clientHeight/2+t.clientHeight/2)}}i>=0&&r[i].forEach((n,r)=>n.classList.toggle(`sung`,t[i].words[r].start<=e))},j=e=>{if(e.synced?.length){k(e,e.synced);return}O=null,p(`#lyrics-text`).classList.remove(`synced`),p(`#lyrics-follow-box`).hidden=!0;let t=e.text.split(`
2
- `),n=[],r=[],i=()=>{if(r.length===0)return;let e=document.createElement(`p`);e.textContent=r.join(`
3
- `),n.push(e),r=[]};for(let e of t)if(/^\s*\[[^\]]{1,160}\]\s*$/.test(e)){i();let t=document.createElement(`p`);t.className=`station-lyrics-section`,t.textContent=e.trim().slice(1,-1),n.push(t)}else e.trim()===``?i():r.push(e);i();let a=p(`#lyrics-text`);a.replaceChildren(...n),a.lang=/^[a-z]{2,3}$/.test(e.language)?e.language:``,p(`#lyrics-for`).textContent=e.title?`· ${e.title}`:``,p(`#lyrics-source`).textContent=e.source===`embedded`?`From the track itself.`:`From nichedb.dev.`,p(`#lyrics`).hidden=!1},M=``,N=async e=>{if(e!==M){if(M=e,!e){p(`#lyrics`).hidden=!0;return}try{let t=await fetch(e,{cache:`no-store`});if(M!==e)return;if(!t.ok){p(`#lyrics`).hidden=!0;return}j((await t.json()).lyrics)}catch{M===e&&(M=``)}}};window.matchMedia?.(`(max-width: 640px)`).matches&&(p(`#lyrics-box`).open=!1);var P=async()=>{try{let e=await fetch(u+`/now`+l,{cache:`no-store`});e.ok&&D((await e.json()).facts)}catch{}},F=()=>{let e=m;m=null,e?.destroy()},I=``,L=(async()=>{let e=location.hostname===`nixamp.com`?``:`https://nixamp.com`;try{let t=await fetch(e+`/api/v1/me/pass`,{credentials:`include`,cache:`no-store`,signal:AbortSignal.timeout(3e3)});t.ok&&(I=String((await t.json()).pass??``))}catch{}})(),R=t=>{F();let n=h===`video`,r=e(p(`#stage`),{src:d(u+`/stream`+l+(I?(l?`&`:`?`)+`pass=`+encodeURIComponent(I):``),`n=`+Date.now()),kind:n?`mp4`:`audio`,audio:!n,live:!0,autoplay:t});m=r;let i=r.media,a=()=>m===r,o=t;i.addEventListener(`volumechange`,()=>{a()&&!o&&(S=i.muted)}),i.addEventListener(`playing`,()=>{a()&&(clearTimeout(C),o&&(o=!1,i.muted=S),v&&T(`Back on`),v=0,g&&U(g))}),i.addEventListener(`error`,()=>{a()&&z()}),i.addEventListener(`ended`,()=>{a()&&z()});let s=Date.now();i.addEventListener(`stalled`,()=>{a()&&i.readyState<3&&Date.now()-s>12e3&&z()}),i.addEventListener(`pause`,()=>{!a()||i.ended||i.error||o||(x=!1,b=Date.now())}),i.addEventListener(`play`,()=>{a()&&(x=!0,b&&Date.now()-b>3e3&&(b=0,R(!0)))}),clearTimeout(C),t&&(C=window.setTimeout(()=>{a()&&i.paused&&(w(`reconnecting`,`Tap play to rejoin`),T(`The station is back. Press play to rejoin.`))},8e3))};function z(){x&&(v+=1,g&&U(g),clearTimeout(y),y=window.setTimeout(()=>R(!0),Math.min(15e3,1e3*2**Math.min(v,4))))}var B=null,V=e=>{let t=Math.max(0,Math.floor(e)),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=String(t%60).padStart(2,`0`);return n?`${n}:${String(r).padStart(2,`0`)}:${i}`:`${r}:${i}`},H=()=>{let e=p(`#progress`);if(!B){e.hidden=!0;return}let t=B.position+(Date.now()-B.at)/1e3-W(),n=Math.min(B.duration,Math.max(0,t)),r=p(`#progress-bar`);r.max=B.duration,r.value=n,r.setAttribute(`aria-valuetext`,`${V(n)} of ${V(B.duration)}`),p(`#progress-time`).textContent=`${V(n)} / ${V(B.duration)}`,e.hidden=!1,A(n)};setInterval(H,500);function U(e){g=e,B=e.progress&&e.progress.duration>0?{...e.progress,at:Date.now()}:null,H(),document.title=e.name+` · nixamp`,p(`#name`).textContent=e.name,p(`#about`).textContent=e.description||``,p(`#about`).hidden=!e.description,_||E(e);let t=e.state===`live`||e.state===`recovering`||e.state===`starting`;v>0?w(`reconnecting`,`Reconnecting`):e.state===`live`?w(`live`,`Live`):e.state===`starting`||e.state===`recovering`?w(`reconnecting`,`Coming back`):e.state===`stopped`?w(`stopped`,`Off the air`):w(`unavailable`,`Unavailable`),p(`#m3u`).href=u+`/listen.m3u`+l,t&&h!==e.kind&&(h=e.kind,L.then(()=>R(x)))}var W=()=>{let e=m?.media;return!e||e.paused||e.buffered.length===0?0:Math.max(0,Math.min(30,e.buffered.end(e.buffered.length-1)-e.currentTime))},G=async()=>{try{let e=await fetch(u+`/state`+l,{cache:`no-store`});if(e.status===404){p(`#name`).textContent=`This station is not available`,w(`unavailable`,`Unavailable`),F(),h=null;return}e.ok&&U(await e.json())}catch{}},K=()=>{if(!window.EventSource)return;let e=new EventSource(u+`/events`+l);e.addEventListener(`hello`,e=>{_=!0;let t=JSON.parse(e.data);setTimeout(()=>{E(t),t.facts===void 0?P():D(t.facts)},W()*1e3)}),e.addEventListener(`now`,e=>{let t=JSON.parse(e.data);setTimeout(()=>{E(t),D(t.facts),T(t.nowPlaying?`Now playing `+(t.nowPlaying.title||``):``)},W()*1e3)}),e.addEventListener(`state`,()=>void G()),e.onerror=()=>{_=!1}};{let e=p(`#lyrics-follow`);try{e.checked=localStorage.getItem(`nixamp.lyrics.follow`)!==`0`}catch{}e.addEventListener(`change`,()=>{try{localStorage.setItem(`nixamp.lyrics.follow`,e.checked?`1`:`0`)}catch{}});let t=()=>{e.checked&&(e.checked=!1,e.dispatchEvent(new Event(`change`)))};for(let e of[`wheel`,`touchmove`])p(`#lyrics-text`).addEventListener(e,t,{passive:!0})}G(),P(),K(),setInterval(()=>void G(),5e3);
@@ -1 +0,0 @@
1
- import{r as e}from"./chunk-Q2XQMA4B-PTuZPMen.js";/* empty css */function t(e){let t;try{t=new URL(e)}catch{return null}if(t.protocol!==`https:`&&!(t.protocol===`http:`&&/^(127\.0\.0\.1|localhost)$/.test(t.hostname)))return null;let n=/^\/api\/channels\/([A-Za-z0-9._~-]{1,120})\/?$/.exec(t.pathname),r=/^\/api\/live\/?$/.test(t.pathname),i=t.searchParams.get(`k`)??``;if(!n&&!r||!/^[A-Za-z0-9_-]{8,128}$/.test(i))return null;let a=n?`/api/channels/${n[1]}`:`/api/live`;return{origin:t.origin,channel:n?n[1]:null,key:i,play:`${t.origin}${a}?k=${i}`}}var n=e=>document.querySelector(e),r=t(new URLSearchParams(location.search).get(`play`)??``),i=null,a=``,o=null,s=!1,c=0,l=0,u=0,d=(e,t)=>{let r=n(`#state`);r.className=`station-chip `+e,r.textContent=t},f=e=>{n(`#announce`).textContent=e},p=()=>typeof MediaSource>`u`&&window.ManagedMediaSource===void 0;function m(e){let t=`&n=${Date.now()}`;return e.kind===`video`&&r.channel!==null&&(p()||e.folder)?{src:`${r.origin}/api/channels/${r.channel}/hls/index.m3u8?k=${r.key}`,kind:`hls`}:{src:r.play+t,kind:e.kind===`video`?`mp4`:`audio`}}function h(){let e=i;i=null,a=``,e?.destroy()}function g(t,r){h();let{src:l,kind:d}=m(t),p=e(n(`#stage`),{src:l,kind:d,audio:t.kind===`audio`,live:!0,autoplay:r});i=p,a=t.kind;let y=p.media,b=()=>i===p;y.addEventListener(`playing`,()=>{b()&&(c&&f(`Back on`),c=0,v())}),y.addEventListener(`error`,()=>{b()&&_()}),y.addEventListener(`ended`,()=>{b()&&_()}),y.addEventListener(`stalled`,()=>{b()&&y.readyState<3&&_()}),y.addEventListener(`pause`,()=>{!b()||y.ended||y.error||(s=!1,u=Date.now())}),y.addEventListener(`play`,()=>{b()&&(s=!0,u&&Date.now()-u>3e3&&o&&(u=0,g(o,!0)))})}function _(){s&&o&&(c+=1,v(),clearTimeout(l),l=window.setTimeout(()=>{o&&g(o,!0)},Math.min(15e3,1e3*2**Math.min(c,4))))}function v(){o&&(document.title=`${o.name} · live`,n(`#name`).textContent=o.name,n(`#title`).textContent=o.title,n(`#by`).textContent=o.by,c>0?d(`reconnecting`,`Reconnecting`):o.live?d(`live`,o.kind===`video`?`Live · TV`:`Live · radio`):d(`stopped`,`Off the air`))}async function y(){if(r.channel!==null){let e=await fetch(`${r.origin}/api/channels?k=${r.key}`,{cache:`no-store`});if(!e.ok)return null;let t=(await e.json()).channels?.find(e=>e.id===r.channel);if(!t)return null;let n=t.codecs?.tags??{};return{name:String(t.name??r.channel).replace(/\/+$/,``),kind:t.kind===`video`?`video`:`audio`,live:t.live!==!1,folder:r.channel.startsWith(`folder-`)||(t.playlist?.length??0)>1,title:String(n.title??``),by:[n.artist,n.album].filter(Boolean).join(` · `)}}let e=new AbortController;try{let t=await fetch(r.play+`&n=${Date.now()}`,{signal:e.signal,cache:`no-store`}),n=t.headers.get(`content-type`)??``;return e.abort(),t.ok?{name:`Live`,kind:n.startsWith(`video/`)?`video`:`audio`,live:!0,folder:!1,title:``,by:``}:null}catch{return null}}async function b(){try{let e=await y();if(!e){n(`#name`).textContent=`This room is not on the air`,d(`unavailable`,`Unavailable`);return}o=e,e.live&&a!==e.kind&&g(e,s),v()}catch{}}r?(n(`#raw`).href=r.play,n(`#nixamp`).href=`https://nixamp.com/?play=${encodeURIComponent(r.play)}`,b(),setInterval(()=>void b(),1e4)):(n(`#name`).textContent=`That is not a room link`,n(`#about`).textContent=`A room link is the address a nixamp Share gives you: https://…/api/channels/<id>?k=…`,n(`#about`).hidden=!1,d(`unavailable`,`Unavailable`));