PageSourceSearch

https://toot.wales/packs/streaming-D9CrfAiU.js

js toot.wales collected 2026-10-02 04:07:27 UTC 7,706 bytes, 2 lines download raw bytes

1import{o as e,t}from"./chunk-CMxvf4Kt.js";import{f as n}from"./prop-types-BTvjt2rf.js";import{r}from"./locales-BuoYIVCV.js";import{Ei as i,Ln as a,Ti as o,Xn as s,Yi as c,Yn as l,Zn as u,_r as d,bi as f,br as p,ci as m,hr as h,li as g,mi as _,pr as v,vi as y,xi as b,xr as x,yi as S}from"./render-CyxiOTyI.js";var C=t((e=>{Object.defineProperty(e,"__esModule",{value:!0}),e.createBackoff=n;var t={exponential:function(e,t){return Math.floor(Math.random()*2**e*t)},fibonacci:function(e,t){var n=1;if(e>n)for(var r=1,n=2,i=2;i<e;i++){var a=r+n;r=n,n=a}return Math.floor(Math.random()*n*t)}};function n(e,n){return new r(t[e],n)}function r(e,t){this.func=e,this.attempts=0,this.delay=t.initialDelay===void 0?100:t.initialDelay}r.prototype.backoff=function(){setTimeout(this.onReady,this.func(++this.attempts,this.delay))}})),w=t(((e,t)=>{t.exports={}})),T=e(t((e=>{Object.defineProperty(e,"__esModule",{value:!0});var t=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,`value`in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function n(e,t){if(!(e instanceof t))throw TypeError(`Cannot call a class as a function`)}var r=C().createBackoff,i=typeof WebSocket<`u`?WebSocket:w(),a=function(){function e(t,i){var a=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};n(this,e),this.url=t,this.protocols=i,this.reconnectEnabled=!0,this.listeners={},this.backoff=r(a.backoff||`exponential`,a),this.backoff.onReady=this.onBackoffReady.bind(this),(a.connect===void 0||a.connect)&&this.open()}return t(e,[{key:`open`,value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1;this.isReconnect=e;var t=this.ws&&this.ws.binaryType;this.ws=new i(this.url,this.protocols),this.ws.onclose=this.onCloseCallback.bind(this),this.ws.onerror=this.onErrorCallback.bind(this),this.ws.onmessage=this.onMessageCallback.bind(this),this.ws.onopen=this.onOpenCallback.bind(this),t&&(this.ws.binaryType=t)}
1},{key:`onBackoffReady`,value:function(e,t){this.open(!0)}},{key:`onCloseCallback`,value:function(e){!this.isReconnect&&this.listeners.onclose&&this.listeners.onclose.apply(null,arguments),this.reconnectEnabled&&e.code<3e3&&this.backoff.backoff()}},{key:`onErrorCallback`,value:function(){this.listeners.onerror&&this.listeners.onerror.apply(null,arguments)}},{key:`onMessageCallback`,value:function(){this.listeners.onmessage&&this.listeners.onmessage.apply(null,arguments)}},{key:`onOpenCallback`,value:function(){this.listeners.onopen&&this.listeners.onopen.apply(null,arguments),this.isReconnect&&this.listeners.onreconnect&&this.listeners.onreconnect.apply(null,arguments),this.isReconnect=!1}},{key:`close`,value:function(e,t){e===void 0&&(e=1e3),this.reconnectEnabled=!1,this.ws.close(e,t)}},{key:`send`,value:function(e){this.ws.send(e)}},{key:`bufferedAmount`,get:function(){return this.ws.bufferedAmount}},{key:`readyState`,get:function(){return this.ws.readyState}},{key:`binaryType`,get:function(){return this.ws.binaryType},set:function(e){this.ws.binaryType=e}},{key:`extensions`,get:function(){return this.ws.extensions},set:function(e){this.ws.extensions=e}},{key:`protocol`,get:function(){return this.ws.protocol},set:function(e){this.ws.protocol=e}},{key:`onclose`,set:function(e){this.listeners.onclose=e},get:function(){return this.listeners.onclose}},{key:`onerror`,set:function(e){this.listeners.onerror=e},get:function(){return this.listeners.onerror}},{key:`onmessage`,set:function(e){this.listeners.onmessage=e},get:function(){return this.listeners.onmessage}},{key:`onopen`,set:function(e){this.listeners.onopen=e},get:function(){return this.listeners.onopen}},{key:`onreconnect`,set:function(e){this.listeners.onreconnect=e},get:function(){return this.listeners.onreconnect}}]),e}();a.CONNECTING=i.CONNECTING,a.OPEN=i.OPEN,a.CLOSING=i.CLOSING,a.CLOSED=i.CLOSED,e.default=a}))()),E,D=[],O={},k=e=>{D.push(e)},A=e=>{let t=D.indexOf(e);t!==-1&&D.splice(t,1)},j=({channelName:e,params:t,onConnect:n})=>{let r=P(e,t);O[r]=O[r]||0,O[r]===0&&E.send(JSON.stringify({type:`subscribe`,stream:e,...t})),O[r]+=1,n()},M=({channelName:e,params:t,onDisconnect:n})=>{let r=P(e,t);O[r]=O[r]||1,O[r]===1&&E.readyState===T.default.OPEN&&E.send(JSON.stringify({type:`unsubscribe`,stream:e,...t})),--O[r],n()},N={connected(){D.forEach(e=>j(e))},received(e){let{stream:t}=e;D.filter(({channelName:e,params:n})=>{let r=t[0];if(t.length===1)return e===r;let i=t[1];return[`hashtag`,`hashtag:local`].includes(e)?e===r&&n.tag===i:e===`list`?e===r&&n.list===i:!1}).forEach(t=>{t.onReceive(e)})},disconnected(){D.forEach(e=>M(e))},reconnected(){}},P=(e,t)=>Object.keys(t).length===0?e:`${e}&${Object.keys(t).map(e=>`${e}=${t[e]}`).join(`&`)}`,F=(e,t,r)=>(i,a)=>{let o=a().getIn([`meta`,`streaming_api_base_url`]),s=n(),{onConnect:c,onReceive:l,onDisconnect:u}=r(i,a);if(!s)throw Error(`Trying to connect to the streaming server but no access token is available.`);if(!o.startsWith(`ws`)){let n=R(o,s,P(e,t),{connected(){c()},received(e){l(e)},disconnected(){u()},reconnected(){c()}});return()=>{n.close()}}let d={channelName:e,params:t,onConnect:c,onReceive:l,onDisconnect:u};return k(d),E?E.readyState===T.default.OPEN&&j(d):E=R(o,s,``,N),()=>{A(d),M(d)}},I=[`update`,`delete`,`notification`,`conversation`,`filters_changed`,`announcement`,`announcement.delete`,`announcement.reaction`],L=(e,t)=>{t({event:e.type,payload:e.data})},R=(e,t,n,{connected:r,received:i,disconnected:a,reconnected:o})=>{let s=n.split(`&`);if(n=s.shift(),e.startsWith(`ws`)){let n=new T.default(`${e}/api/v1/streaming/?${s.join(`&`)}`,t);return n.onopen=r,n.onmessage=e=>i(JSON.parse(e.data)),n.onclose=a,n.onreconnect=o,n}n=n.replace(/:/g,`/`),n.endsWith(`:media`)&&(n=n.replace(`/media`,``),s.push(`only_media=true`)),s.push(`access_token=${t}`);let c=new EventSource(`${e}/api/v1/streaming/${n}?${s.join(`&`)}`);return c.onopen=()=>{r()},I.forEach(e=>{c.addEventListener(e,e=>L(e,i))}),c.onerror=a,c},z=e=>Math.floor(Math.random()*Math.floor(e)),B=(e,t,n={},l={})=>{let{messages:d}=r(),f=t.startsWith(`public`)||t.startsWith(`hashtag`);return F(t,n,(t,n)=>{let r=n().getIn([`meta`,`locale`]),_,y=async e=>{await e(t,n),_=setTimeout(()=>y(e),2e4+z(2e4))};return{onConnect(){t(m(e)),_&&=(clearTimeout(_),null),l.fillGaps&&t(l.fillGaps())},onDisconnect(){t(i({timeline:e})),l.fallback&&(_=setTimeout(()=>y(l.fallback),z(4e4)))},onReceive(n){switch(n.event){case`update`:t(o(e,JSON.parse(n.payload),{accept:l.accept,bogusQuotePolicy:f}));break;case`status.update`:t(a(JSON.parse(n.payload),{bogusQuotePolicy:f}));break;case`delete`:t(g(n.payload));break;case`notification`:{let e=JSON.parse(n.payload);t(c(e,d,r)),t(s(e));break}case`notifications_merged`:t(u());break;case`conversation`:t(v(JSON.parse(n.payload)));break;case`announcement`:t(p(JSON.parse(n.payload)));break;case`announcement.reaction`:t(x(JSON.parse(n.payload)));break;case`announcement.delete`:t(h(n.payload));break}}}})};async function V(e){await e(_({maxId:void 0}));try{await e(l())}catch{}await e(d())}var H=()=>B(`home`,`user`,{},{fallback:V,fillGaps:S}),U=({onlyMedia:e}={})=>B(`community${e?`:media`:``}`,`public:local${e?`:media`:``}`,{},{fillGaps:()=>y({onlyMedia:e})}),W=({onlyMedia:e,onlyRemote:t}={})=>B(`public${t?`:remote`:``}${e?`:media`:``}`,`public${t?`:remote`:``}${e?`:media`:``}`,{},{fillGaps:()=>b({onlyMedia:e,onlyRemote:t})}),G=(e,t,n,r)=>B(`hashtag:${e}${n?`:local`:``}`,`hashtag${n?`:local`:``}`,{tag:t},{accept:r}),K=()=>B(`direct`,`direct`),q=e=>B(`list:${e}`,`list`,{list:e},{fillGaps:()=>f(e)});export{W as a,q as i,K as n,H as o,G as r,U as t};
2//# sourceMappingURL=streaming-D9CrfAiU.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.