1import{app}from"./app.js";import{config}from"./config.js";import{Events}from"../lib/events.js";import{$}from"../lib/util.js";export class AppServiceWorker extends Events{static isEnabled(){return!!navigator.serviceWorker&&config.service_worker_enabled}constructor(){super(),this.onStateChange=this.onStateChange.bind(this),this.registration=null,this.notifyUpdate=!0,navigator.serviceWorker.register(config.service_worker_path,{scope:"/"}).then(t=>this.updateRegistration(t),t=>console.error("Could not register service worker:",t))}update(){if(this.registration)return this.notifyUpdate=!0,this.registration.update().catch(()=>{})}updateInBackground(){if(this.registration)return this.notifyUpdate=!1,this.registration.update().catch(()=>{})}reload(){return this.updateInBackground().then(()=>app.reboot())}updateRegistration(t){this.registration=t,$.on(this.registration,"updatefound",()=>this.onUpdateFound())}onUpdateFound(){this.installingRegistration&&$.off(this.installingRegistration,"statechange",this.onStateChange),this.installingRegistration=this.registration.installing,$.on(this.installingRegistration,"statechange",this.onStateChange)}onStateChange(){this.installingRegistration&&"installed"===this.installingRegistration.state&&navigator.serviceWorker.controller&&(this.installingRegistration=null,this.onUpdateReady())}onUpdateReady(){this.notifyUpdate&&this.trigger("updateready")}}
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.