2024-04-05 23:53:36 +13:00
( ( ) => { var vi = Object . create ; var tt = Object . defineProperty ; var bi = Object . getOwnPropertyDescriptor ; var yi = Object . getOwnPropertyNames , xe = Object . getOwnPropertySymbols , wi = Object . getPrototypeOf , it = Object . prototype . hasOwnProperty , Tt = Object . prototype . propertyIsEnumerable ; var _t = ( e , t , i ) => t in e ? tt ( e , t , { enumerable : ! 0 , configurable : ! 0 , writable : ! 0 , value : i } ) : e [ t ] = i , j = ( e , t ) => { for ( var i in t || ( t = { } ) ) it . call ( t , i ) && _t ( e , i , t [ i ] ) ; if ( xe ) for ( var i of xe ( t ) ) Tt . call ( t , i ) && _t ( e , i , t [ i ] ) ; return e } ; var Rt = ( e , t ) => { var i = { } ; for ( var s in e ) it . call ( e , s ) && t . indexOf ( s ) < 0 && ( i [ s ] = e [ s ] ) ; if ( e != null && xe ) for ( var s of xe ( e ) ) t . indexOf ( s ) < 0 && Tt . call ( e , s ) && ( i [ s ] = e [ s ] ) ; return i } ; var Ai = ( e , t ) => ( ) => ( t || e ( ( t = { exports : { } } ) . exports , t ) , t . exports ) ; var ki = ( e , t , i , s ) => { if ( t && typeof t == "object" || typeof t == "function" ) for ( let n of yi ( t ) ) ! it . call ( e , n ) && n !== i && tt ( e , n , { get : ( ) => t [ n ] , enumerable : ! ( s = bi ( t , n ) ) || s . enumerable } ) ; return e } ; var Si = ( e , t , i ) => ( i = e != null ? vi ( wi ( e ) ) : { } , ki ( t || ! e || ! e . _ _esModule ? tt ( i , "default" , { value : e , enumerable : ! 0 } ) : i , e ) ) ; var Lt = Ai ( ( It , De ) => { ( function ( e , t ) { "use strict" ; ( function ( ) { for ( var f = 0 , m = [ "ms" , "moz" , "webkit" , "o" ] , v = 0 ; v < m . length && ! e . requestAnimationFrame ; ++ v ) e . requestAnimationFrame = e [ m [ v ] + "RequestAnimationFrame" ] , e . cancelAnimationFrame = e [ m [ v ] + "CancelAnimationFrame" ] || e [ m [ v ] + "CancelRequestAnimationFrame" ] ; e . requestAnimationFrame || ( e . requestAnimationFrame = function ( C , R ) { var T = new Date ( ) . getTime ( ) , x = Math . max ( 0 , 16 - ( T - f ) ) , I = e . setTimeout ( function ( ) { C ( T + x ) } , x ) ; return f = T + x , I } ) , e . cancelAnimationFrame || ( e . cancelAnimationFrame = function ( C ) { clearTimeout ( C ) } ) } ) ( ) ; var i , s , n , r = null , o = null , a = null , l = function ( f , m , v ) { f . addEventListener ? f . addEventListener ( m , v , ! 1 ) : f . attachEvent ? f . attachEvent ( "on" + m , v ) : f [ "on" + m ] = v } , h = { autoRun : ! 0 , barThickness : 3 , barColors : { 0 : "rgba(26, 188, 156, .9)" , ".25" : "rgba(52, 152, 219, .9)" , ".50" : "rgba(241, 196, 15, .9)" , ".75" : "rgba(230, 126, 34, .9)" , "1.0" : "rgba(211, 84, 0, .9)" } , shadowBlur : 10 , shadowColor : "rgba(0, 0, 0, .6)" , className : null } , c = function ( ) { i . width = e . innerWidth , i . height = h . barThickness * 5 ; var f = i . getContext ( "2d" ) ; f . shadowBlur = h . shadowBlur , f . shadowColor = h . shadowColor ; var m = f . createLinearGradient ( 0 , 0 , i . width , 0 ) ; for ( var v in h . barColors ) m . addColorStop ( v , h . barColors [ v ] ) ; f . lineWidth = h . barThickness , f . beginPath ( ) , f . moveTo ( 0 , h . barThickness / 2 ) , f . lineTo ( Math . ceil ( s * i . width ) , h . barThickness / 2 ) , f . strokeStyle = m , f . stroke ( ) } , g = function ( ) { i = t . createElement ( "canvas" ) ; var f = i . style ; f . position = "fixed" , f . top = f . left = f . right = f . margin = f . padding = 0 , f . zIndex = 100001 , f . display = "none" , h . className && i . classList . add ( h . className ) , t . body . appendChild ( i ) , l ( e , "resize" , c ) } , p = { config : function ( f ) { for ( var m in f ) h . hasOwnProperty ( m ) && ( h [ m ] = f [ m ] ) } , show : function ( f ) { if ( ! n ) if ( f ) { if ( a ) return ; a = setTimeout ( ( ) => p . show ( ) , f ) } else n = ! 0 , o !== null && e . cancelAnimationFrame ( o ) , i || g ( ) , i . style . opacity = 1 , i . style . display = "block" , p . progress ( 0 ) , h . autoRun && function m ( ) { r = e . requestAnimationFrame ( m ) , p . progress ( "+" + . 05 * Math . pow ( 1 - Math . sqrt ( s ) , 2 ) ) } ( ) } , progress : function ( f ) { return typeof f == "undefined" || ( typeof f == "string" && ( f = ( f . indexOf ( "+" ) >= 0 || f . indexOf ( "-" ) >= 0 ? s : 0 ) + parseFloat ( f ) ) , s = f > 1 ? 1 : f , c ( ) ) , s } , hide : function ( ) { clearTimeout ( a ) , a = null , n && ( n = ! 1 , r != null && ( e . cancelAnimationFrame ( r ) , r = null ) , function f ( ) { if ( p . progress ( "+.1" ) >= 1 && ( i . style . opacity -= . 05 , i . style . opacity <= . 05 ) ) { i . style . display = "none" , o = null ; return } o = e . requestAnimationFrame ( f ) } ( ) ) } } ; typeof De == "object" && typeof De . exports == "object" ? De . exports = p : typeof define == "function" && define . amd ? define ( function ( ) { return p } ) : this . topbar = p } ) . call ( It , window , document ) } ) ; ( function ( ) { var e = t ( ) ; function t ( ) { if ( typeof window . CustomEvent == "function" ) return window . CustomEvent ; function n ( r , o ) { o = o || { bubbles : ! 1 , cancelable : ! 1 , detail : void 0 } ; var a = document . createEvent ( "CustomEvent" ) ; return a . initCustomEvent ( r , o . bubbles , o . cancelable , o . detail ) , a } return n . prototype = window . Event . prototype , n } function i ( n , r ) { var o = document . createElement ( "input" ) ; return o . type = "hidden" , o . name = n , o . value = r , o } function s ( n , r ) { var o = n . getAttribute ( "data-to" ) , a = i ( "_method" , n . getAttribute ( "data-method" ) ) , l = i ( "_csrf_token" , n . getAttribute ( "data-csrf" ) ) , h = document . createElement ( "form" ) , c = document . createElement
` ),()=>this.onerror("timeout"),t=>{this.awaitingBatchAck=!1,!t||t.status!==200?(this.onerror(t&&t.status),this.closeAndRetry(1011,"internal server error",!1)):this.batchBuffer.length>0&&(this.batchSend(this.batchBuffer),this.batchBuffer=[])})}close(e,t,i){for(let n of this.reqs)n.abort();this.readyState=B.closed;let s=Object.assign({code:1e3,reason:void 0,wasClean:!0},{code:e,reason:t,wasClean:i});this.batchBuffer=[],clearTimeout(this.currentBatchTimer),this.currentBatchTimer=null,typeof CloseEvent!="undefined"?this.onclose(new CloseEvent("close",s)):this.onclose(s)}ajax(e,t,i,s,n){let r,o=()=>{this.reqs.delete(r),s()};r=Oe.request(e,this.endpointURL(),t,i,this.timeout,o,a=>{this.reqs.delete(r),this.isActive()&&n(a)}),this.reqs.add(r)}};var Le={HEADER_LENGTH:1,META_LENGTH:4,KINDS:{push:0,reply:1,broadcast:2},encode(e,t){if(e.payload.constructor===ArrayBuffer)return t(this.binaryEncode(e));{let i=[e.join_ref,e.ref,e.topic,e.event,e.payload];return t(JSON.stringify(i))}},decode(e,t){if(e.constructor===ArrayBuffer)return t(this.binaryDecode(e));{let[i,s,n,r,o]=JSON.parse(e);return t({join_ref:i,ref:s,topic:n,event:r,payload:o})}},binaryEncode(e){let{join_ref:t,ref:i,event:s,topic:n,payload:r}=e,o=this.META_LENGTH+t.length+i.length+n.length+s.length,a=new ArrayBuffer(this.HEADER_LENGTH+o),l=new DataView(a),h=0;l.setUint8(h++,this.KINDS.push),l.setUint8(h++,t.length),l.setUint8(h++,i.length),l.setUint8(h++,n.length),l.setUint8(h++,s.length),Array.from(t,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(i,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(n,g=>l.setUint8(h++,g.charCodeAt(0))),Array.from(s,g=>l.setUint8(h++,g.charCodeAt(0)));var c=new Uint8Array(a.byteLength+r.byteLength);return c.set(new Uint8Array(a),0),c.set(new Uint8Array(r),a.byteLength),c.buffer},binaryDecode(e){let t=new DataView(e),i=t.getUint8(0),s=new TextDecoder;switch(i){case this.KINDS.push:return this.decodePush(e,t,s);case this.KINDS.reply:return this.decodeReply(e,t,s);case this.KINDS.broadcast:return this.decodeBroadcast(e,t,s)}},decodePush(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=this.HEADER_LENGTH+this.META_LENGTH-1,a=i.decode(e.slice(o,o+s));o=o+s;let l=i.decode(e.slice(o,o+n));o=o+n;let h=i.decode(e.slice(o,o+r));o=o+r;let c=e.slice(o,e.byteLength);return{join_ref:a,ref:null,topic:l,event:h,payload:c}},decodeReply(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=t.getUint8(3),o=t.getUint8(4),a=this.HEADER_LENGTH+this.META_LENGTH,l=i.decode(e.slice(a,a+s));a=a+s;let h=i.decode(e.slice(a,a+n));a=a+n;let c=i.decode(e.slice(a,a+r));a=a+r;let g=i.decode(e.slice(a,a+o));a=a+o;let p=e.slice(a,e.byteLength),f={status:g,response:p};return{join_ref:l,ref:h,topic:c,event:z.reply,payload:f}},decodeBroadcast(e,t,i){let s=t.getUint8(1),n=t.getUint8(2),r=this.HEADER_LENGTH+2,o=i.decode(e.slice(r,r+s));r=r+s;let a=i.decode(e.slice(r,r+n));r=r+n;let l=e.slice(r,e.byteLength);return{join_ref:null,ref:null,topic:o,event:a,payload:l}}},xt=class{constructor(e,t={}){this.stateChangeCallbacks={open:[],close:[],error:[],message:[]},this.channels=[],this.sendBuffer=[],this.ref=0,this.timeout=t.timeout||_i,this.transport=t.transport||he.WebSocket||ge,this.longPollFallbackMs=t.longPollFallbackMs,this.fallbackTimer=null,this.sessionStore=t.sessionStorage||he.sessionStorage,this.establishedConnections=0,this.defaultEncoder=Le.encode.bind(Le),this.defaultDecoder=Le.decode.bind(Le),this.closeWasClean=!1,this.binaryType=t.binaryType||"arraybuffer",this.connectClock=1,this.transport!==ge?(this.encode=t.encode||this.defaultEncoder,this.decode=t.decode||this.defaultDecoder):(this.encode=this.defaultEncoder,this.decode=this.defaultDecoder);let i=null;ve&&ve.addEventListener&&(ve.addEventListener("pagehide",s=>{this.conn&&(this.disconnect(),i=this.connectClock)}),ve.addEventListener("pageshow",s=>{i===this.connectClock&&(i=null,this.connect())})),this.heartbeatIntervalMs=t.heartbeatIntervalMs||3e4,this.rejoinAfterMs=s=>t.rejoinAfterMs?t.rejoinAfterMs(s):[1e3,2e3,5e3][s-1]||1e4,this.reconnectAfterMs=s=>t.reconnectAfterMs?t.reconnectAfterMs(s):[10,50,100,150,200,250,50
[ name = "${t}[]" ] ,
[ $ { i } = "${t}" ] ` ,n=!1;return $ .all(e,s,r=>{(this.private(r,vt)||this.private(r,Ke))&&(n=!0)}),!n},feedbackSelector(e,t,i){let s= ` [ $ { t } = "${e.name}" ] ,
[ $ { t } = "${e.name.replace(/\[\]$/," ")}" ] ` ;return e.getAttribute(i)&&(s+= ` , [ $ { t } = "${e.getAttribute(i)}" ] ` ),s},resetForm(e,t,i){Array.from(e.elements).forEach(s=>{let n=this.feedbackSelector(s,t,i);this.deletePrivate(s,vt),this.deletePrivate(s,Ke),this.all(document,n,r=>{L.addOrRemoveClasses(r,[He],[])})})},showError(e,t,i){if(e.name){let s=this.feedbackSelector(e,t,i);this.all(document,s,n=>{L.addOrRemoveClasses(n,[],[He])})}},isPhxChild(e){return e.getAttribute&&e.getAttribute(ue)},isPhxSticky(e){return e.getAttribute&&e.getAttribute(Mt)!==null},isChildOfAny(e,t){return!!t.find(i=>i.contains(e))},firstPhxChild(e){return this.isPhxChild(e)?e:this.all(e, ` [ $ { ue } ] ` )[0]},dispatchEvent(e,t,i={}){let s=!0;e.nodeName==="INPUT"&&e.type==="file"&&t==="click"&&(s=!1);let o={bubbles:i.bubbles===void 0?s:!!i.bubbles,cancelable:!0,detail:i.detail||{}},a=t==="click"?new MouseEvent("click",o):new CustomEvent(t,o);e.dispatchEvent(a)},cloneNode(e,t){if(typeof t=="undefined")return e.cloneNode(!0);{let i=e.cloneNode(!1);return i.innerHTML=t,i}},mergeAttrs(e,t,i={}){let s=new Set(i.exclude||[]),n=i.isIgnored,r=t.attributes;for(let a=r.length-1;a>=0;a--){let l=r[a].name;if(s.has(l))l==="value"&&e.value===t.value&&e.setAttribute("value",t.getAttribute(l));else{let h=t.getAttribute(l);e.getAttribute(l)!==h&&(!n||n&&l.startsWith("data-"))&&e.setAttribute(l,h)}}let o=e.attributes;for(let a=o.length-1;a>=0;a--){let l=o[a].name;n?l.startsWith("data-")&&!t.hasAttribute(l)&&![N,te].includes(l)&&e.removeAttribute(l):t.hasAttribute(l)||e.removeAttribute(l)}},mergeFocusedInput(e,t){e instanceof HTMLSelectElement|| $ .mergeAttrs(e,t,{exclude:["value"]}),t.readOnly?e.setAttribute("readonly",!0):e.removeAttribute("readonly")},hasSelectionRange(e){return e.setSelectionRange&&(e.type==="text"||e.type==="textarea")},restoreFocus(e,t,i){if(e instanceof HTMLSelectElement&&e.focus(),! $ .isTextualInput(e))return;let s=e.matches(":focus");e.readOnly&&e.blur(),s||e.focus(),this.hasSelectionRange(e)&&e.setSelectionRange(t,i)},isFormInput(e){return/^(?:input|select|textarea) $ /i.test(e.tagName)&&e.type!=="button"},syncAttrsToProps(e){e instanceof HTMLInputElement&&hi.indexOf(e.type.toLocaleLowerCase())>=0&&(e.checked=e.getAttribute("checked")!==null)},isTextualInput(e){return $ i.indexOf(e.type)>=0},isNowTriggerFormExternal(e,t){return e.getAttribute&&e.getAttribute(t)!==null},syncPendingRef(e,t,i){let s=e.getAttribute(N);if(s===null)return!0;let n=e.getAttribute(te);return $ .isFormInput(e)||e.getAttribute(i)!==null?( $ .isUploadInput(e)&& $ .mergeAttrs(e,t,{isIgnored:!0}), $ .putPrivate(e,N,t),!1):(ri.forEach(r=>{e.classList.contains(r)&&t.classList.add(r)}),t.setAttribute(N,s),t.setAttribute(te,n),!0)},cleanChildNodes(e,t){if( $ .isPhxUpdate(e,t,["append","prepend"])){let i=[];e.childNodes.forEach(s=>{s.id||(s.nodeType===Node.TEXT_NODE&&s.nodeValue.trim()===""||M( ` only HTML element tags with an id are allowed inside containers with phx - update .
2023-08-02 01:16:31 +12:00
2024-04-05 23:53:36 +13:00
removing illegal node : "${(s.outerHTML||s.nodeValue).trim()}"
2023-08-02 01:16:31 +12:00
2024-04-05 23:53:36 +13:00
` ),i.push(s))}),i.forEach(s=>s.remove())}},replaceRootContainer(e,t,i){let s=new Set(["id",se,_e,wt,pe]);if(e.tagName.toLowerCase()===t.toLowerCase())return Array.from(e.attributes).filter(n=>!s.has(n.name.toLowerCase())).forEach(n=>e.removeAttribute(n.name)),Object.keys(i).filter(n=>!s.has(n.toLowerCase())).forEach(n=>e.setAttribute(n,i[n])),e;{let n=document.createElement(t);return Object.keys(i).forEach(r=>n.setAttribute(r,i[r])),s.forEach(r=>n.setAttribute(r,e.getAttribute(r))),n.innerHTML=e.innerHTML,e.replaceWith(n),n}},getSticky(e,t,i){let s=( $ .private(e,"sticky")||[]).find(([n])=>t===n);if(s){let[n,r,o]=s;return o}else return typeof i=="function"?i():i},deleteSticky(e,t){this.updatePrivate(e,"sticky",[],i=>i.filter(([s,n])=>s!==t))},putSticky(e,t,i){let s=i(e);this.updatePrivate(e,"sticky",[],n=>{let r=n.findIndex(([o])=>t===o);return r>=0?n[r]=[t,i,s]:n.push([t,i,s]),n})},applyStickyOperations(e){let t= $ .private(e,"sticky");t&&t.forEach(([i,s,n])=>this.putSticky(e,i,s))}},d= $ ,Se=class{static isActive(e,t){let i=t._phxRef===void 0,n=e.getAttribute(pt).split(",").indexOf(_.genFileRef(t))>=0;return t.size>0&&(i||n)}static isPreflighted(e,t){return e.getAttribute(yt).split(",").indexOf(_.genFileRef(t))>=0&&this.isActive(e,t)}static isPreflightInProgress(e){return e._preflightInProgress===!0}static markPreflightInProgress(e){e._preflightInProgress=!0}constructor(e,t,i,s){this.ref=_.genFileRef(t),this.fileEl=e,this.file=t,this.view=i,this.meta=null,this._isCancelled=!1,this._isDone=!1,this._progress=0,this._lastProgressSent=-1,this._onDone=function(){},this._onElUpdated=this.onElUpdated.bind(this),this.fileEl.addEventListener(qe,this._onElUpdated),this.autoUpload=s}metadata(){return this.meta}progress(e){this._progress=Math.floor(e),this._progress>this._lastProgressSent&&(this._progress>=100?(this._progress=100,this._lastProgressSent=100,this._isDone=!0,this.view.pushFileProgress(this.fileEl,this.ref,100,()=>{_.untrackFile(this.fileEl,this.file),this._onDone()})):(this._lastProgressSent=this._progress,this.view.pushFileProgress(this.fileEl,this.ref,this._progress)))}isCancelled(){return this._isCancelled}cancel(){this.file._preflightInProgress=!1,this._isCancelled=!0,this._isDone=!0,this._onDone()}isDone(){return this._isDone}error(e="failed"){this.fileEl.removeEventListener(qe,this._onElUpdated),this.view.pushFileProgress(this.fileEl,this.ref,{error:e}),this.isAutoUpload()||_.clearFiles(this.fileEl)}isAutoUpload(){return this.autoUpload}onDone(e){this._onDone=()=>{this.fileEl.removeEventListener(qe,this._onElUpdated),e()}}onElUpdated(){this.fileEl.getAttribute(pt).split(",").indexOf(this.ref)===-1&&(_.untrackFile(this.fileEl,this.file),this.cancel())}toPreflightPayload(){return{last_modified:this.file.lastModified,name:this.file.name,relative_path:this.file.webkitRelativePath,size:this.file.size,type:this.file.type,ref:this.ref,meta:typeof this.file.meta=="function"?this.file.meta():void 0}}uploader(e){if(this.meta.uploader){let t=e[this.meta.uploader]||M( ` no uploader configured for $ { this . meta . uploader } ` );return{name:this.meta.uploader,callback:t}}else return{name:"channel",callback:es}}zipPostFlight(e){this.meta=e.entries[this.ref],this.meta||M( ` no preflight upload response returned with ref $ { this . ref } ` ,{input:this.fileEl,response:e})}},ss=0,_=class{static genFileRef(e){let t=e._phxRef;return t!==void 0?t:(e._phxRef=(ss++).toString(),e._phxRef)}static getEntryDataURL(e,t,i){let s=this.activeFiles(e).find(n=>this.genFileRef(n)===t);i(URL.createObjectURL(s))}static hasUploadsInProgress(e){let t=0;return d.findUploadInputs(e).forEach(i=>{i.getAttribute(yt)!==i.getAttribute(Ni)&&t++}),t>0}static serializeUploads(e){let t=this.activeFiles(e),i={};return t.forEach(s=>{let n={path:e.name},r=e.getAttribute(Y);i[r]=i[r]||[],n.ref=this.genFileRef(s),n.last_modified=s.lastModified,n.name=s.name||n.ref,n.relative_path=s.webkitRelativePath,n.type=s.type,n.size=s.size,typeof s.meta=="function"&&(n.meta=s.meta()),i[r].push(n)}),i}static clearFiles(e){e.value=null,e.removeAttribute(Y),d.putPrivate(e,"files",[])}static untrackFil
2023-08-02 01:16:31 +12:00
a phoenix Socket must be provided as the second argument to the LiveSocket constructor . For example :
import { Socket } from "phoenix"
import { LiveSocket } from "phoenix_live_view"
let liveSocket = new LiveSocket ( "/live" , Socket , { ... } )
2024-04-09 00:20:53 +12:00
` );this.socket=new t(e,i),this.bindingPrefix=i.bindingPrefix||Xi,this.opts=i,this.params=ut(i.params||{}),this.viewLogger=i.viewLogger,this.metadataCallbacks=i.metadata||{},this.defaults=Object.assign(Xe(zi),i.defaults||{}),this.activeElement=null,this.prevActive=null,this.silenced=!1,this.main=null,this.outgoingMainEl=null,this.clickStartedAtTarget=null,this.linkRef=1,this.roots={},this.href=window.location.href,this.pendingLink=null,this.currentLocation=Xe(window.location),this.hooks=i.hooks||{},this.uploaders=i.uploaders||{},this.loaderTimeout=i.loaderTimeout||Vi,this.reloadWithJitterTimer=null,this.maxReloads=i.maxReloads||Ii,this.reloadJitterMin=i.reloadJitterMin||Li,this.reloadJitterMax=i.reloadJitterMax||Oi,this.failsafeJitter=i.failsafeJitter||Di,this.localStorage=i.localStorage||window.localStorage,this.sessionStorage=i.sessionStorage||window.sessionStorage,this.boundTopLevelEvents=!1,this.domCallbacks=Object.assign({onNodeAdded:ut(),onBeforeElUpdated:ut()},i.dom||{}),this.transitions=new Es,window.addEventListener("pagehide",s=>{this.unloaded=!0}),this.socket.onOpen(()=>{this.isUnloaded()&&window.location.reload()})}isProfileEnabled(){return this.sessionStorage.getItem(ht)==="true"}isDebugEnabled(){return this.sessionStorage.getItem(Me)==="true"}isDebugDisabled(){return this.sessionStorage.getItem(Me)==="false"}enableDebug(){this.sessionStorage.setItem(Me,"true")}enableProfiling(){this.sessionStorage.setItem(ht,"true")}disableDebug(){this.sessionStorage.setItem(Me,"false")}disableProfiling(){this.sessionStorage.removeItem(ht)}enableLatencySim(e){this.enableDebug(),console.log("latency simulator enabled for the duration of this browser session. Call disableLatencySim() to disable"),this.sessionStorage.setItem(dt,e)}disableLatencySim(){this.sessionStorage.removeItem(dt)}getLatencySim(){let e=this.sessionStorage.getItem(dt);return e?parseInt(e):null}getSocket(){return this.socket}connect(){window.location.hostname==="localhost"&&!this.isDebugDisabled()&&this.enableDebug();let e=()=>{this.joinRootViews()?(this.bindTopLevelEvents(),this.socket.connect()):this.main?this.socket.connect():this.bindTopLevelEvents({dead:!0}),this.joinDeadView()};["complete","loaded","interactive"].indexOf(document.readyState)>=0?e():document.addEventListener("DOMContentLoaded",()=>e())}disconnect(e){clearTimeout(this.reloadWithJitterTimer),this.socket.disconnect(e)}replaceTransport(e){clearTimeout(this.reloadWithJitterTimer),this.socket.replaceTransport(e),this.connect()}execJS(e,t,i=null){this.owner(e,s=>L.exec(i,t,s,e))}execJSHookPush(e,t,i,s){this.withinOwners(e,n=>{L.exec("hook",t,n,e,["push",{data:i,callback:s}])})}unload(){this.unloaded||(this.main&&this.isConnected()&&this.log(this.main,"socket",()=>["disconnect for page nav"]),this.unloaded=!0,this.destroyAllViews(),this.disconnect())}triggerDOM(e,t){this.domCallbacks[e](...t)}time(e,t){if(!this.isProfileEnabled()||!console.time)return t();console.time(e);let i=t();return console.timeEnd(e),i}log(e,t,i){if(this.viewLogger){let[s,n]=i();this.viewLogger(e,t,s,n)}else if(this.isDebugEnabled()){let[s,n]=i();Qi(e,t,s,n)}}requestDOMUpdate(e){this.transitions.after(e)}transition(e,t,i=function(){}){this.transitions.addTransition(e,t,i)}onChannel(e,t,i){e.on(t,s=>{let n=this.getLatencySim();n?setTimeout(()=>i(s),n):i(s)})}wrapPush(e,t,i){let s=this.getLatencySim(),n=e.joinCount;if(!s)return this.isConnected()&&t.timeout?i().receive("timeout",()=>{e.joinCount===n&&!e.isDestroyed()&&this.reloadWithJitter(e,()=>{this.log(e,"timeout",()=>["received timeout while communicating with server. Falling back to hard refresh for recovery"])})}):i();let r={receives:[],receive(o,a){this.receives.push([o,a])}};return setTimeout(()=>{e.isDestroyed()||r.receives.reduce((o,[a,l])=>o.receive(a,l),i())},s),r}reloadWithJitter(e,t){clearTimeout(this.reloadWithJitterTimer),this.disconnect();let i=this.reloadJitterMin,s=this.reloadJitterMax,n=Math.floor(Math.random()*(s-i+1))+i,r=q.updateLocal(this.localStorage,window.location.pathname,ni,0,o=>o+1);r>this.maxReloads&&(n=this.failsafeJitter),this.reloadWi
2023-08-02 01:16:31 +12:00
/ * *
* @ license MIT
* topbar 2.0 . 0 , 2023 - 02 - 04
* https : //buunguyen.github.io/topbar
* Copyright ( c ) 2021 Buu Nguyen
* /