railwatch 0.3.4 → 0.3.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +32 -0
- data/app/jobs/railwatch/prune_telemetry_job.rb +20 -1
- data/app/models/railwatch/telemetry_record.rb +48 -0
- data/db/railwatch_telemetry_migrate/20260903000000_enable_incremental_vacuum.rb +62 -0
- data/docs/embedded.md +47 -1
- data/lib/railwatch/version.rb +1 -1
- data/lib/tasks/railwatch_tasks.rake +161 -0
- data/public/railwatch/assets/{app-layout-yh-sPWgK.js → app-layout-CdJ5Qjms.js} +1 -1
- data/public/railwatch/assets/{app-wordmark-nbjkzxwQ.js → app-wordmark-B-0yZiDb.js} +1 -1
- data/public/railwatch/assets/{appearance-CDuRvQTB.js → appearance-CU28GBf1.js} +1 -1
- data/public/railwatch/assets/application-CwshqwM6.css +1 -0
- data/public/railwatch/assets/{arrow-up-DVtOGdVA.js → arrow-up-DY1fS0tD.js} +1 -1
- data/public/railwatch/assets/{auth-layout-TCwPpS1K.js → auth-layout-C3FKuUJz.js} +1 -1
- data/public/railwatch/assets/{badge-Daw4Hvr8.js → badge-DKvItdlb.js} +1 -1
- data/public/railwatch/assets/{braces-DhFbHPsz.js → braces-Bse5Gh3K.js} +1 -1
- data/public/railwatch/assets/{card-BX_3HXcJ.js → card-C9j_ffR9.js} +1 -1
- data/public/railwatch/assets/{chart-B14-N9g7.js → chart-Cmh6JEww.js} +1 -1
- data/public/railwatch/assets/{chart-hover-Vy52H4uD.js → chart-hover-B0SjyWFy.js} +1 -1
- data/public/railwatch/assets/{chart-panel-Cb4S_ej_.js → chart-panel-DKNxoauI.js} +1 -1
- data/public/railwatch/assets/{checkbox-D3aRSsBj.js → checkbox-BsBkRg5n.js} +1 -1
- data/public/railwatch/assets/{code-KvW8k7Jr.js → code-C879Qwgg.js} +1 -1
- data/public/railwatch/assets/{copy-block-BKFGd11J.js → copy-block-DtO_3esq.js} +1 -1
- data/public/railwatch/assets/{copy-id-Djks1fXB.js → copy-id-SeLCKsW2.js} +1 -1
- data/public/railwatch/assets/{cursor-load-more-BXV0f1D_.js → cursor-load-more-OpHbe_kE.js} +1 -1
- data/public/railwatch/assets/{data-table-iv1bdF6u.js → data-table-Bc3ZRnpb.js} +1 -1
- data/public/railwatch/assets/{edit-__9yJlO3.js → edit-BMpgcQhU.js} +1 -1
- data/public/railwatch/assets/{edit-DMKUF8Zi.js → edit-CTD1jSWh.js} +1 -1
- data/public/railwatch/assets/{edit-BZc_Iawe.js → edit-DDvf9mkq.js} +1 -1
- data/public/railwatch/assets/{empty-state-6j_0AaQQ.js → empty-state-CkPROZB0.js} +1 -1
- data/public/railwatch/assets/env-layout-aGQgTZRg.js +1 -0
- data/public/railwatch/assets/{execution-path-CzgBUi5e.js → execution-path-BX5NcXUZ.js} +1 -1
- data/public/railwatch/assets/{filter-bar-9SU5NrzX.js → filter-bar-C0O2rJVr.js} +1 -1
- data/public/railwatch/assets/{flamegraph-qcekju8V.js → flamegraph-Vj4QSAlT.js} +1 -1
- data/public/railwatch/assets/{frames-Cyu7KMxZ.js → frames-CTiGwm4E.js} +1 -1
- data/public/railwatch/assets/{google-sign-in-button-DsTSfmzY.js → google-sign-in-button-BzogBGeF.js} +1 -1
- data/public/railwatch/assets/index-B-kuWp-m.js +1 -0
- data/public/railwatch/assets/{index-1ol1-QWI.js → index-B2_QluAw.js} +1 -1
- data/public/railwatch/assets/index-B69Iad2U.js +1 -0
- data/public/railwatch/assets/index-BCLvKVhP.js +1 -0
- data/public/railwatch/assets/index-BKgAm-w2.js +1 -0
- data/public/railwatch/assets/index-BRN_bXV_.js +1 -0
- data/public/railwatch/assets/index-Ble4RoA3.js +1 -0
- data/public/railwatch/assets/index-Bvy021Vv.js +1 -0
- data/public/railwatch/assets/index-CCLMaY9k.js +1 -0
- data/public/railwatch/assets/index-CD4HIHq0.js +1 -0
- data/public/railwatch/assets/{index-Cmlwy1-V.js → index-CPQKOQxV.js} +1 -1
- data/public/railwatch/assets/{index-CeYKnapu.js → index-CY6lbwAC.js} +1 -1
- data/public/railwatch/assets/index-C__S10ze.js +1 -0
- data/public/railwatch/assets/index-ChQ1_u8u.js +1 -0
- data/public/railwatch/assets/index-CtT4T6kp.js +1 -0
- data/public/railwatch/assets/index-CxU1Jj35.js +1 -0
- data/public/railwatch/assets/index-D3Axxkk2.js +1 -0
- data/public/railwatch/assets/index-D5YVcrqR.js +1 -0
- data/public/railwatch/assets/index-D9cV-IQr.js +1 -0
- data/public/railwatch/assets/index-DbyRgbzQ.js +1 -0
- data/public/railwatch/assets/index-Dcxd_H-U.js +1 -0
- data/public/railwatch/assets/index-Dep2XomH.js +1 -0
- data/public/railwatch/assets/{index-DlumCsWY.js → index-DepurF6s.js} +2 -2
- data/public/railwatch/assets/{index-BRiq3SNR.js → index-DigUOHQ8.js} +1 -1
- data/public/railwatch/assets/index-DkgImCOg.js +1 -0
- data/public/railwatch/assets/{index-DU9F5b5d.js → index-DxuDLoTc.js} +1 -1
- data/public/railwatch/assets/{index-OqI59zPb.js → index-Dy7Wg880.js} +1 -1
- data/public/railwatch/assets/index-FgpFDA1Z.js +1 -0
- data/public/railwatch/assets/index-LaTKDe0-.js +1 -0
- data/public/railwatch/assets/index-Wb_U2_hz.js +1 -0
- data/public/railwatch/assets/index-chS28dvS.js +1 -0
- data/public/railwatch/assets/index-jSEU_Yp7.js +1 -0
- data/public/railwatch/assets/index-uuKg6Zqn.js +1 -0
- data/public/railwatch/assets/index-y2c8xKzI.js +1 -0
- data/public/railwatch/assets/index-z2YfKBJl.js +1 -0
- data/public/railwatch/assets/{inertia-TViv6kNv.js → inertia-CgBdJDaE.js} +2 -2
- data/public/railwatch/assets/{input-error-LxImUkxv.js → input-error-DfpIawjl.js} +1 -1
- data/public/railwatch/assets/{json-viewer-Ar4cjPDW.js → json-viewer-CH7nEIUs.js} +1 -1
- data/public/railwatch/assets/klass-BTg1l2AO.js +1 -0
- data/public/railwatch/assets/{label-COUKWqE_.js → label-BWgQzHCO.js} +1 -1
- data/public/railwatch/assets/{layout-DNSLAkw_.js → layout-neknbxn-.js} +1 -1
- data/public/railwatch/assets/{live-dot-ChfUtY3p.js → live-dot-Bejk0a5o.js} +1 -1
- data/public/railwatch/assets/{nav-CNnDqPlm.js → nav-C1M8941-.js} +1 -1
- data/public/railwatch/assets/{new-D4uewYC8.js → new-B8CzyoMu.js} +1 -1
- data/public/railwatch/assets/{new-Be55nmt9.js → new-BnGIYM37.js} +1 -1
- data/public/railwatch/assets/{new-Bi_xQiIb.js → new-DElC-JCS.js} +1 -1
- data/public/railwatch/assets/{new-D05SajFR.js → new-DGYPcz7w.js} +1 -1
- data/public/railwatch/assets/{new-84S8ZJq9.js → new-DLgCLBiW.js} +1 -1
- data/public/railwatch/assets/{new-BvCT8TMg.js → new-bBwawsEg.js} +1 -1
- data/public/railwatch/assets/{onboarding-CYZi5Cqc.js → onboarding-CW0jUhHT.js} +1 -1
- data/public/railwatch/assets/{origin-identity-6q1-CBts.js → origin-identity-bJMxeEHB.js} +1 -1
- data/public/railwatch/assets/{percentile-picker-gFZCXtdb.js → percentile-picker-DLAnTKY3.js} +1 -1
- data/public/railwatch/assets/{relative-time-IOOgl5n2.js → relative-time-BHbJh8HW.js} +1 -1
- data/public/railwatch/assets/release-health-2O1GRclB.js +1 -0
- data/public/railwatch/assets/route-DSw8aIZa.js +1 -0
- data/public/railwatch/assets/{segmented-h1VdDTqE.js → segmented-Dg8CES94.js} +1 -1
- data/public/railwatch/assets/{select-_AJsUa7X.js → select-CqKpvI98.js} +1 -1
- data/public/railwatch/assets/{separator-BwwTYtCF.js → separator-BOp2LHw3.js} +1 -1
- data/public/railwatch/assets/{series-chart-DaFPefku.js → series-chart-COEtj3PY.js} +1 -1
- data/public/railwatch/assets/show-B40560ZT.js +1 -0
- data/public/railwatch/assets/{show-C4Ltf5i9.js → show-B7Zqjlqc.js} +1 -1
- data/public/railwatch/assets/{show-CeTL4B37.js → show-BAxMoNvw.js} +2 -2
- data/public/railwatch/assets/show-B_QVoqKE.js +1 -0
- data/public/railwatch/assets/show-Bbs1i46N.js +1 -0
- data/public/railwatch/assets/{show-DACku6AD.js → show-C-xpDkoj.js} +3 -3
- data/public/railwatch/assets/{show-DgSIoRvA.js → show-C9Y1To9_.js} +1 -1
- data/public/railwatch/assets/show-CGv85sRo.js +1 -0
- data/public/railwatch/assets/{show-BM6X2Mpo.js → show-CPh-7VGL.js} +1 -1
- data/public/railwatch/assets/show-C_9M2nLy.js +1 -0
- data/public/railwatch/assets/{show-DIOSGcXV.js → show-DFlP1ktM.js} +2 -2
- data/public/railwatch/assets/show-DqtE0LI6.js +1 -0
- data/public/railwatch/assets/{show-C8sHalnw.js → show-DrhEDGPn.js} +1 -1
- data/public/railwatch/assets/{show-JxFtB4eK.js → show-HjjzcKRq.js} +2 -2
- data/public/railwatch/assets/show-Zr2xV4OD.js +1 -0
- data/public/railwatch/assets/show-dRDz8OVu.js +1 -0
- data/public/railwatch/assets/{show-DYteoYWW.js → show-pbkvGRER.js} +1 -1
- data/public/railwatch/assets/{sort-header-DpFzXblu.js → sort-header-DBxQ_KFX.js} +1 -1
- data/public/railwatch/assets/{sparkline-cell-C3-5vFkP.js → sparkline-cell-BbfXw3kA.js} +1 -1
- data/public/railwatch/assets/stat-Cd8QaTGw.js +1 -0
- data/public/railwatch/assets/{status-badge-8jVV-LA4.js → status-badge-Ys4b0fcG.js} +1 -1
- data/public/railwatch/assets/{tenant-path-G-6u9A-o.js → tenant-path-CQWzaNYR.js} +1 -1
- data/public/railwatch/assets/{text-link-DfsiaCcP.js → text-link-BY8FY-CJ.js} +1 -1
- data/public/railwatch/assets/{textarea-Dye72uP7.js → textarea-Bq2jjOMC.js} +1 -1
- data/public/railwatch/assets/{timeline-CD7WHnbo.js → timeline-SxStCFO2.js} +1 -1
- data/public/railwatch/assets/{transition-B_AW8rMK.js → transition-CQ9yvfPa.js} +1 -1
- data/public/railwatch/assets/{use-clipboard-ColgLyQ2.js → use-clipboard-3hTXU91g.js} +1 -1
- data/public/railwatch/assets/use-live-LwJStJvD.js +1 -0
- data/public/railwatch/manifest.json +1289 -1236
- metadata +117 -115
- data/public/railwatch/assets/application-DD4nJA5I.css +0 -1
- data/public/railwatch/assets/env-layout-DrT8rO6P.js +0 -1
- data/public/railwatch/assets/index-5jI4aFzC.js +0 -1
- data/public/railwatch/assets/index-9KTrVnrc.js +0 -1
- data/public/railwatch/assets/index-B0-8lcTp.js +0 -1
- data/public/railwatch/assets/index-B7jjfNfO.js +0 -1
- data/public/railwatch/assets/index-BBchRy0M.js +0 -1
- data/public/railwatch/assets/index-BgKj9xhr.js +0 -1
- data/public/railwatch/assets/index-BkTZqqOu.js +0 -1
- data/public/railwatch/assets/index-BprKx8QO.js +0 -1
- data/public/railwatch/assets/index-C3jzvPs3.js +0 -1
- data/public/railwatch/assets/index-Cbs6gGyQ.js +0 -1
- data/public/railwatch/assets/index-CdRZ6AWF.js +0 -1
- data/public/railwatch/assets/index-Cwx6058d.js +0 -1
- data/public/railwatch/assets/index-D4CSdbHv.js +0 -1
- data/public/railwatch/assets/index-DEFMSkdG.js +0 -1
- data/public/railwatch/assets/index-DFiHEBSh.js +0 -1
- data/public/railwatch/assets/index-DL4vWdWJ.js +0 -1
- data/public/railwatch/assets/index-DaXgPcGL.js +0 -1
- data/public/railwatch/assets/index-DbtaU-EE.js +0 -1
- data/public/railwatch/assets/index-DeOe83F4.js +0 -1
- data/public/railwatch/assets/index-DiucHN4B.js +0 -1
- data/public/railwatch/assets/index-DlnR_l9o.js +0 -1
- data/public/railwatch/assets/index-DmRd7aIG.js +0 -1
- data/public/railwatch/assets/index-DxSh2UpM.js +0 -1
- data/public/railwatch/assets/index-MIMGuFNt.js +0 -1
- data/public/railwatch/assets/index-P4rC7IlX.js +0 -1
- data/public/railwatch/assets/index-gpPOcFWq.js +0 -1
- data/public/railwatch/assets/index-oVkururr.js +0 -1
- data/public/railwatch/assets/index-p9puqVge.js +0 -1
- data/public/railwatch/assets/klass-CJ-J4INB.js +0 -1
- data/public/railwatch/assets/release-health-DC8oc7uw.js +0 -1
- data/public/railwatch/assets/route-Dv6LAWvT.js +0 -1
- data/public/railwatch/assets/show-B7NCgkEo.js +0 -1
- data/public/railwatch/assets/show-BKqyKjBK.js +0 -1
- data/public/railwatch/assets/show-BNw4tN5q.js +0 -1
- data/public/railwatch/assets/show-BO3bnG5h.js +0 -1
- data/public/railwatch/assets/show-BhrAVAEA.js +0 -1
- data/public/railwatch/assets/show-CpfgV1jP.js +0 -1
- data/public/railwatch/assets/show-DQp_1n-B.js +0 -1
- data/public/railwatch/assets/show-DVNz46RI.js +0 -1
- data/public/railwatch/assets/stat-s4RpOS9w.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as c,c as nt,e as it}from"./inertia-CgBdJDaE.js";var C={logger:typeof console<"u"?console:void 0,WebSocket:typeof WebSocket<"u"?WebSocket:void 0},i={log(...n){this.enabled&&(n.push(Date.now()),C.logger.log("[ActionCable]",...n))}};const g=()=>new Date().getTime(),k=n=>(g()-n)/1e3;class x{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=g(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),i.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=g(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),i.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordMessage(){this.pingedAt=g()}recordConnect(){this.reconnectAttempts=0,delete this.disconnectedAt,i.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=g(),i.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout((()=>{this.reconnectIfStale(),this.poll()}),this.getPollInterval())}getPollInterval(){const{staleThreshold:t,reconnectionBackoffRate:e}=this.constructor,s=Math.pow(1+e,Math.min(this.reconnectAttempts,10)),r=(this.reconnectAttempts===0?1:e)*Math.random();return t*1e3*s*(1+r)}reconnectIfStale(){this.connectionIsStale()&&(i.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${k(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?i.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${k(this.disconnectedAt)} s`):(i.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return k(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&k(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout((()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(i.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())}),200)}}x.staleThreshold=6;x.reconnectionBackoffRate=.15;var V={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]};const{message_types:p,protocols:W}=V,st=W.slice(0,W.length-1),F=[].indexOf;class j{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new x(this),this.disconnected=!0}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){if(this.isActive())return i.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{const t=[...W,...this.consumer.subprotocols||[]];return i.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${t}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new C.WebSocket(this.consumer.url,t),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(i.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){i.log("Failed to reopen WebSocket",t)}finally{i.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return F.call(st,this.getProtocol())>=0}isState(...t){return F.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in C.WebSocket)if(C.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){const e=this.events[t].bind(this);this.webSocket[`on${t}`]=e}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){}}}j.reopenDelay=500;j.prototype.events={message(n){if(!this.isProtocolSupported())return;const{identifier:t,message:e,reason:s,reconnect:o,type:r}=JSON.parse(n.data);switch(this.monitor.recordMessage(),r){case p.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case p.disconnect:return i.log(`Disconnecting. Reason: ${s}`),this.close({allowReconnect:o});case p.ping:return null;case p.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case p.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",e)}},open(){if(i.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return i.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(n){if(i.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){i.log("WebSocket onerror event")}};const ot=function(n,t){if(t!=null)for(let e in t){const s=t[e];n[e]=s}return n};class rt{constructor(t,e={},s){this.consumer=t,this.identifier=JSON.stringify(e),ot(this,s)}perform(t,e={}){return e.action=t,this.send(e)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}class ct{constructor(t){this.subscriptions=t,this.pendingSubscriptions=[]}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(i.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):i.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing()}forget(t){i.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter((e=>e!==t))}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout((()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map((t=>{i.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t)}))}),500)}}class lt{constructor(t){this.consumer=t,this.guarantor=new ct(this),this.subscriptions=[]}create(t,e){const s=t,o=typeof s=="object"?s:{channel:s},r=new rt(this.consumer,o,e);return this.add(r)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map((e=>(this.forget(e),this.notify(e,"rejected"),e)))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter((e=>e!==t)),t}findAll(t){return this.subscriptions.filter((e=>e.identifier===t))}reload(){return this.subscriptions.map((t=>this.subscribe(t)))}notifyAll(t,...e){return this.subscriptions.map((s=>this.notify(s,t,...e)))}notify(t,e,...s){let o;return typeof t=="string"?o=this.findAll(t):o=[t],o.map((r=>typeof r[e]=="function"?r[e](...s):void 0))}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t)}confirmSubscription(t){i.log(`Subscription confirmed ${t}`),this.findAll(t).map((e=>this.guarantor.forget(e)))}sendCommand(t,e){const{identifier:s}=t;return this.consumer.send({command:e,identifier:s})}}class ut{constructor(t){this._url=t,this.subscriptions=new lt(this),this.connection=new j(this),this.subprotocols=[]}get url(){return at(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(t){this.subprotocols=[...this.subprotocols,t]}}function at(n){if(typeof n=="function"&&(n=n()),n&&!/^wss?:/i.test(n)){const t=document.createElement("a");return t.href=n,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return n}function ht(n=dt("url")||V.default_mount_path){return new ut(n)}function dt(n){const t=document.head.querySelector(`meta[name='action-cable-${n}']`);if(t)return t.getAttribute("content")}let U;function ft(){return U??=ht(),U}const pt=5e3,q="railwatch:live-paused";let L=!1;const O=new Set;function z(n){if(L!==n){L=n;for(const t of O)t()}}function gt(n){return O.add(n),()=>{O.delete(n)}}function Rt(){return c.useSyncExternalStore(gt,bt,mt)}function mt(){return!1}function bt(){return L}function kt(n,t){const e=nt.c(19);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{only:o,onEvent:r}=s,[u,T]=c.useState(!1),[E,G]=c.useState(null),[_,N]=c.useState(null),[K,Y]=c.useState(n);K!==n&&(Y(n),T(!1),G(null),N(null));const[l,Q]=c.useState(At),I=c.useRef(o),H=c.useRef(r),$=c.useRef(l);let m;e[2]!==r||e[3]!==o||e[4]!==l?(m=()=>{I.current=o,H.current=r,$.current=l},e[2]=r,e[3]=o,e[4]=l,e[5]=m):m=e[5],c.useEffect(m);const P=c.useRef(vt);let b,S;e[6]!==u||e[7]!==l?(b=()=>(z(u&&!l),yt),S=[u,l],e[6]=u,e[7]=l,e[8]=b,e[9]=S):(b=e[8],S=e[9]),c.useEffect(b,S);let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=function(h){$.current=h,localStorage.setItem(q,h?"1":"0"),Q(h),P.current()},e[10]=y):y=e[10];const X=y;let v,A;e[11]!==n?(v=()=>{let a=!1,h=!1,D=!1,J=-1/0,R,M;const Z=function(){h=!1,D=!0,J=Date.now(),it.reload({only:I.current,onCancelToken:et=>{M=()=>et.cancel()},onSuccess:()=>{a||N(Date.now())},onFinish:()=>{M=void 0,D=!1,f()}})};function f(){if(clearTimeout(R),R=void 0,a||!h||D||$.current||document.visibilityState!=="visible")return;const d=pt-(Date.now()-J);d>0?R=setTimeout(f,d):Z()}const B=function(){f()};document.addEventListener("visibilitychange",B),P.current=f;const tt=ft().subscriptions.create({channel:"EnvironmentChannel",id:n},{connected:()=>{a||T(!0)},disconnected:()=>{a||T(!1)},received:d=>{a||(G(Date.now()),H.current?.(d),h=!0,f())}});return()=>{a=!0,M?.(),clearTimeout(R),P.current=St,document.removeEventListener("visibilitychange",B),tt.unsubscribe()}},A=[n],e[11]=n,e[12]=v,e[13]=A):(v=e[12],A=e[13]),c.useEffect(v,A);let w;return e[14]!==u||e[15]!==E||e[16]!==_||e[17]!==l?(w={connected:u,lastEventAt:E,lastRefreshedAt:_,paused:l,setPaused:X},e[14]=u,e[15]=E,e[16]=_,e[17]=l,e[18]=w):w=e[18],w}function St(){}function yt(){return z(!1)}function vt(){}function At(){return typeof window>"u"?!1:localStorage.getItem(q)==="1"}export{Rt as a,kt as u};
|