web-mojo 2.2.65 → 2.2.67

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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/admin.cjs.js +1 -1
  3. package/dist/admin.cjs.js.map +1 -1
  4. package/dist/admin.es.js +1 -1
  5. package/dist/admin.es.js.map +1 -1
  6. package/dist/auth.cjs.js +1 -1
  7. package/dist/auth.es.js +1 -1
  8. package/dist/charts.cjs.js +1 -1
  9. package/dist/charts.es.js +1 -1
  10. package/dist/chunks/ChatView-Cfe0ZGvr.js +2 -0
  11. package/dist/chunks/ChatView-Cfe0ZGvr.js.map +1 -0
  12. package/dist/chunks/ChatView-DuQVFrCY.js +2 -0
  13. package/dist/chunks/ChatView-DuQVFrCY.js.map +1 -0
  14. package/dist/chunks/{Collection-1sPoIFvQ.js → Collection-BWKmydl5.js} +2 -2
  15. package/dist/chunks/{Collection-1sPoIFvQ.js.map → Collection-BWKmydl5.js.map} +1 -1
  16. package/dist/chunks/{Collection-DSBRXpwK.js → Collection-CmjTsmrP.js} +2 -2
  17. package/dist/chunks/{Collection-DSBRXpwK.js.map → Collection-CmjTsmrP.js.map} +1 -1
  18. package/dist/chunks/ContextMenu-8vTiZZQV.js +2 -0
  19. package/dist/chunks/ContextMenu-8vTiZZQV.js.map +1 -0
  20. package/dist/chunks/ContextMenu-DBw0WMTO.js +2 -0
  21. package/dist/chunks/ContextMenu-DBw0WMTO.js.map +1 -0
  22. package/dist/chunks/{DataView--nUWtq6r.js → DataView-BEovBggn.js} +2 -2
  23. package/dist/chunks/{DataView--nUWtq6r.js.map → DataView-BEovBggn.js.map} +1 -1
  24. package/dist/chunks/{DataView-CK3Z0TJH.js → DataView-DyJKgOn3.js} +2 -2
  25. package/dist/chunks/{DataView-CK3Z0TJH.js.map → DataView-DyJKgOn3.js.map} +1 -1
  26. package/dist/chunks/{Dialog-VoLlToMl.js → Dialog-DW7PHzUc.js} +2 -2
  27. package/dist/chunks/{Dialog-wBhTkeWg.js.map → Dialog-DW7PHzUc.js.map} +1 -1
  28. package/dist/chunks/{Dialog-wBhTkeWg.js → Dialog-jfBsXy5X.js} +2 -2
  29. package/dist/chunks/{Dialog-VoLlToMl.js.map → Dialog-jfBsXy5X.js.map} +1 -1
  30. package/dist/chunks/Files-C-ChBvr5.js +2 -0
  31. package/dist/chunks/Files-C-ChBvr5.js.map +1 -0
  32. package/dist/chunks/Files-DNbHDy43.js +2 -0
  33. package/dist/chunks/Files-DNbHDy43.js.map +1 -0
  34. package/dist/chunks/FormView-EoB_ZdIB.js +3 -0
  35. package/dist/chunks/FormView-EoB_ZdIB.js.map +1 -0
  36. package/dist/chunks/FormView-Q_lFA0nr.js +3 -0
  37. package/dist/chunks/FormView-Q_lFA0nr.js.map +1 -0
  38. package/dist/chunks/{ListView-6JQ6tRXs.js → ListView-BLFFK_Ir.js} +2 -2
  39. package/dist/chunks/{ListView-6JQ6tRXs.js.map → ListView-BLFFK_Ir.js.map} +1 -1
  40. package/dist/chunks/{ListView-DVStKiMi.js → ListView-CMZpwyyC.js} +2 -2
  41. package/dist/chunks/{ListView-DVStKiMi.js.map → ListView-CMZpwyyC.js.map} +1 -1
  42. package/dist/chunks/{MetricsCountryMapView-CnAEbUw_.js → MetricsCountryMapView-B0kWK-Js.js} +2 -2
  43. package/dist/chunks/{MetricsCountryMapView-CnAEbUw_.js.map → MetricsCountryMapView-B0kWK-Js.js.map} +1 -1
  44. package/dist/chunks/{MetricsCountryMapView-J067qrrt.js → MetricsCountryMapView-DuBKO7gz.js} +2 -2
  45. package/dist/chunks/{MetricsCountryMapView-J067qrrt.js.map → MetricsCountryMapView-DuBKO7gz.js.map} +1 -1
  46. package/dist/chunks/{MetricsMiniChartWidget-DtWq2_YJ.js → MetricsMiniChartWidget-BkMjI-gz.js} +2 -2
  47. package/dist/chunks/{MetricsMiniChartWidget-DtWq2_YJ.js.map → MetricsMiniChartWidget-BkMjI-gz.js.map} +1 -1
  48. package/dist/chunks/{MetricsMiniChartWidget-CtCN1rtt.js → MetricsMiniChartWidget-ChC5GGm6.js} +2 -2
  49. package/dist/chunks/{MetricsMiniChartWidget-CtCN1rtt.js.map → MetricsMiniChartWidget-ChC5GGm6.js.map} +1 -1
  50. package/dist/chunks/{PDFViewer-BNCyDElg.js → PDFViewer-iOqYpg-6.js} +2 -2
  51. package/dist/chunks/{PDFViewer-BNCyDElg.js.map → PDFViewer-iOqYpg-6.js.map} +1 -1
  52. package/dist/chunks/{PDFViewer-Di4OHAkv.js → PDFViewer-sFoyopz3.js} +2 -2
  53. package/dist/chunks/{PDFViewer-Di4OHAkv.js.map → PDFViewer-sFoyopz3.js.map} +1 -1
  54. package/dist/chunks/{Rest-Ds9e8tN8.js → Rest-B1eUyLX5.js} +2 -2
  55. package/dist/chunks/{Rest-Ds9e8tN8.js.map → Rest-B1eUyLX5.js.map} +1 -1
  56. package/dist/chunks/{Rest-DHbszkuP.js → Rest-BJ3Mvx1L.js} +2 -2
  57. package/dist/chunks/{Rest-DHbszkuP.js.map → Rest-BJ3Mvx1L.js.map} +1 -1
  58. package/dist/chunks/TokenManager-BYMKH_aW.js +2 -0
  59. package/dist/chunks/{TokenManager-D-9tqubS.js.map → TokenManager-BYMKH_aW.js.map} +1 -1
  60. package/dist/chunks/TokenManager-DhDUKmaw.js +2 -0
  61. package/dist/chunks/{TokenManager-8JM2qj_1.js.map → TokenManager-DhDUKmaw.js.map} +1 -1
  62. package/dist/chunks/User-BnlvMG5J.js +3 -0
  63. package/dist/chunks/User-BnlvMG5J.js.map +1 -0
  64. package/dist/chunks/User-DSqcOwPL.js +3 -0
  65. package/dist/chunks/User-DSqcOwPL.js.map +1 -0
  66. package/dist/chunks/{WebApp-JJAK0eNM.js → WebApp-B0m6JCjO.js} +2 -2
  67. package/dist/chunks/{WebApp-JJAK0eNM.js.map → WebApp-B0m6JCjO.js.map} +1 -1
  68. package/dist/chunks/{WebApp-BdJA4Uup.js → WebApp-Bsic6FPo.js} +2 -2
  69. package/dist/chunks/{WebApp-BdJA4Uup.js.map → WebApp-Bsic6FPo.js.map} +1 -1
  70. package/dist/chunks/{WebSocketClient-BoF7TV7i.js → WebSocketClient-Bh0Mmtje.js} +2 -2
  71. package/dist/chunks/{WebSocketClient-BoF7TV7i.js.map → WebSocketClient-Bh0Mmtje.js.map} +1 -1
  72. package/dist/chunks/{WebSocketClient-BxL2M7p0.js → WebSocketClient-CLgYPxWX.js} +2 -2
  73. package/dist/chunks/{WebSocketClient-BxL2M7p0.js.map → WebSocketClient-CLgYPxWX.js.map} +1 -1
  74. package/dist/chunks/{version-kTtMlfsq.js → version-BY7AsEkb.js} +2 -2
  75. package/dist/chunks/{version-kTtMlfsq.js.map → version-BY7AsEkb.js.map} +1 -1
  76. package/dist/chunks/{version-Cn26llLs.js → version-BdfRyQDm.js} +2 -2
  77. package/dist/chunks/{version-Cn26llLs.js.map → version-BdfRyQDm.js.map} +1 -1
  78. package/dist/css/web-mojo.css +1 -1
  79. package/dist/docit.cjs.js +1 -1
  80. package/dist/docit.cjs.js.map +1 -1
  81. package/dist/docit.es.js +1 -1
  82. package/dist/docit.es.js.map +1 -1
  83. package/dist/index.cjs.js +1 -1
  84. package/dist/index.cjs.js.map +1 -1
  85. package/dist/index.es.js +1 -1
  86. package/dist/index.es.js.map +1 -1
  87. package/dist/lightbox.cjs.js +1 -1
  88. package/dist/lightbox.cjs.js.map +1 -1
  89. package/dist/lightbox.es.js +1 -1
  90. package/dist/lightbox.es.js.map +1 -1
  91. package/dist/map.cjs.js +1 -1
  92. package/dist/map.es.js +1 -1
  93. package/dist/timeline.cjs.js +1 -1
  94. package/dist/timeline.es.js +1 -1
  95. package/dist/web-mojo.lite.iife.js +1230 -2
  96. package/dist/web-mojo.lite.iife.js.map +1 -1
  97. package/dist/web-mojo.lite.iife.min.js +95 -74
  98. package/dist/web-mojo.lite.iife.min.js.map +1 -1
  99. package/package.json +8 -7
  100. package/dist/chunks/ChatView-D1-ev2qA.js +0 -2
  101. package/dist/chunks/ChatView-D1-ev2qA.js.map +0 -1
  102. package/dist/chunks/ChatView-DesGp57e.js +0 -2
  103. package/dist/chunks/ChatView-DesGp57e.js.map +0 -1
  104. package/dist/chunks/ContextMenu-CsQGpSrv.js +0 -3
  105. package/dist/chunks/ContextMenu-CsQGpSrv.js.map +0 -1
  106. package/dist/chunks/ContextMenu-dqFxitXY.js +0 -3
  107. package/dist/chunks/ContextMenu-dqFxitXY.js.map +0 -1
  108. package/dist/chunks/FormView-BQnvMheR.js +0 -3
  109. package/dist/chunks/FormView-BQnvMheR.js.map +0 -1
  110. package/dist/chunks/FormView-C7FnbmEI.js +0 -3
  111. package/dist/chunks/FormView-C7FnbmEI.js.map +0 -1
  112. package/dist/chunks/TokenManager-8JM2qj_1.js +0 -2
  113. package/dist/chunks/TokenManager-D-9tqubS.js +0 -2
@@ -1,2 +1,2 @@
1
- "use strict";const t=require("./Rest-Ds9e8tN8.js");class WebSocketClient{constructor(t={}){this.url=t.url,this.socket=null,this.isConnected=!1,this.isConnecting=!1,this.getToken=t.getToken||null,this.tokenPrefix=t.tokenPrefix||"bearer",this.autoReconnect=!1!==t.autoReconnect,this._intentionalDisconnect=!1,this.reconnectInterval=t.reconnectInterval||2e3,this.reconnectBackoff=t.reconnectBackoff||1.5,this.maxReconnectDelay=t.maxReconnectDelay||3e4,this.reconnectJitter=!1!==t.reconnectJitter,this.reconnectAttempts=0,this.reconnectTimer=null,this.pingInterval=t.pingInterval||3e4,this.pongTimeout=t.pongTimeout||1e4,this.pingTimer=null,this.pongTimer=null,this._app=t.app||null,this.debug=t.debug||!1,this._onVisibilityChange=this._handleVisibilityChange.bind(this),this._onWindowFocus=this._handleWindowFocus.bind(this),this._setupVisibilityHandlers(),this._setupAppFocusHandler()}async connect(t=null){if(t&&(this.url=t),!this.url)throw new Error("WebSocket URL is required");if(this._intentionalDisconnect=!1,!this.isConnected&&!this.isConnecting)return this._doConnect()}disconnect(){this._intentionalDisconnect=!0,this._clearTimers(),this.socket&&(this._log("Disconnecting (intentional)"),this.socket.close(1e3,"Client disconnect"),this.socket=null),this.isConnected=!1,this.isConnecting=!1}send(t){if(!this.isConnected||!this.socket)throw new Error("WebSocket not connected");const e="string"==typeof t?t:JSON.stringify(t);this.socket.send(e),this._log("Sent:",e)}destroy(){this.disconnect(),this._teardownVisibilityHandlers(),this._teardownAppFocusHandler()}_doConnect(){return this.isConnected||this.isConnecting?Promise.resolve():(this.isConnecting=!0,this._log("Connecting to:",this.url),new Promise((t,e)=>{let n=!1;const i=(t,e)=>{n||(n=!0,t(e))};try{const n=new WebSocket(this.url);this.socket=n,n.onopen=()=>{this._log("Connected"),this.isConnected=!0,this.isConnecting=!1,this.reconnectAttempts=0,this._authenticate(),this._startHeartbeat(),this.emit("connected"),i(t,void 0)},n.onmessage=t=>this._handleMessage(t),n.onerror=t=>{this._log("Socket error:",t),this.emit("error",t),this.isConnected||i(e,new Error("WebSocket connection failed"))},n.onclose=t=>this._handleClose(t,i.bind(null,e))}catch(s){this.isConnecting=!1,this.socket=null,i(e,s),this._scheduleReconnect()}}))}_authenticate(){const t=this.getToken?this.getToken():null;t?this.send({type:"authenticate",token:t,prefix:this.tokenPrefix}):console.warn("[WebSocket] No token available — skipping authentication")}_handleMessage(t){let e;this._log("Received:",t.data);try{e=JSON.parse(t.data)}catch{e=t.data}"pong"!==e?.type?(e?.type&&this.emit(`message:${e.type}`,e),this.emit("message",e)):this._clearPongTimeout()}_handleClose(t,e){this._log("Closed:",t.code,t.reason);const n=this.isConnecting;this.isConnected=!1,this.isConnecting=!1,this._clearTimers(),this.socket=null,this.emit("disconnected",{code:t.code,reason:t.reason,wasClean:t.wasClean}),n&&"function"==typeof e&&e(new Error(`WebSocket closed before connecting (code ${t.code})`)),!this._intentionalDisconnect&&this.autoReconnect&&this._scheduleReconnect()}_scheduleReconnect(){if(this._intentionalDisconnect||!this.autoReconnect)return;if(null!==this.reconnectTimer)return;this.reconnectAttempts++;let t=Math.min(this.reconnectInterval*Math.pow(this.reconnectBackoff,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectJitter&&(t*=.8+.4*Math.random()),t=Math.round(t),this._log(`Reconnecting in ${t}ms (attempt ${this.reconnectAttempts})`),this.emit("reconnecting",{attempt:this.reconnectAttempts,delay:t}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,!this._intentionalDisconnect&&this.autoReconnect&&this._doConnect().catch(t=>{this._log("Reconnect attempt failed:",t.message),null!==this.reconnectTimer||this._intentionalDisconnect||this._scheduleReconnect()})},t)}_nudgeReconnect(){!this._intentionalDisconnect&&this.autoReconnect&&(this.isConnected||this.isConnecting||(this._log("Focus/visibility restored — nudging reconnect immediately"),null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),setTimeout(()=>{if(this._intentionalDisconnect||this.isConnected||this.isConnecting)return;const t=this.reconnectAttempts;this._doConnect().catch(e=>{this._log("Nudge reconnect failed:",e.message),this.reconnectAttempts=t})},200)))}_startHeartbeat(){this.pingInterval&&(this.pingTimer=setInterval(()=>{if(this.isConnected)try{this.send({action:"ping"}),this._startPongTimeout()}catch(t){this._log("Ping send failed:",t.message)}},this.pingInterval))}_startPongTimeout(){this._clearPongTimeout(),this.pongTimer=setTimeout(()=>{console.warn("[WebSocket] Pong timeout — forcing reconnect"),this.emit("pong-timeout"),this.socket&&this.socket.close(4001,"Pong timeout")},this.pongTimeout)}_clearPongTimeout(){null!==this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}_clearTimers(){null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),null!==this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this._clearPongTimeout()}_setupVisibilityHandlers(){"undefined"!=typeof document&&(document.addEventListener("visibilitychange",this._onVisibilityChange),"undefined"!=typeof window&&window.addEventListener("focus",this._onWindowFocus))}_teardownVisibilityHandlers(){"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this._onVisibilityChange),"undefined"!=typeof window&&window.removeEventListener("focus",this._onWindowFocus))}_handleVisibilityChange(){document.hidden||this._nudgeReconnect()}_handleWindowFocus(){this._nudgeReconnect()}_setupAppFocusHandler(){this._app?.events&&(this._appFocusHandler=()=>this._nudgeReconnect(),this._app.events.on("browser:focus",this._appFocusHandler))}_teardownAppFocusHandler(){this._app?.events&&this._appFocusHandler&&(this._app.events.off("browser:focus",this._appFocusHandler),this._appFocusHandler=null)}_log(...t){this.debug}static deriveURL(t,e="/ws/realtime/"){if(!t)throw new Error("baseURL is required");const n=new URL(t);return n.protocol="https:"===n.protocol?"wss:":"ws:",n.pathname=e.startsWith("/")?e:`/${e}`,n.toString()}}Object.assign(WebSocketClient.prototype,t.EventEmitter),exports.WebSocketClient=WebSocketClient;
2
- //# sourceMappingURL=WebSocketClient-BxL2M7p0.js.map
1
+ "use strict";const t=require("./Rest-B1eUyLX5.js");class WebSocketClient{constructor(t={}){this.url=t.url,this.socket=null,this.isConnected=!1,this.isConnecting=!1,this.getToken=t.getToken||null,this.tokenPrefix=t.tokenPrefix||"bearer",this.autoReconnect=!1!==t.autoReconnect,this._intentionalDisconnect=!1,this.reconnectInterval=t.reconnectInterval||2e3,this.reconnectBackoff=t.reconnectBackoff||1.5,this.maxReconnectDelay=t.maxReconnectDelay||3e4,this.reconnectJitter=!1!==t.reconnectJitter,this.reconnectAttempts=0,this.reconnectTimer=null,this.pingInterval=t.pingInterval||3e4,this.pongTimeout=t.pongTimeout||1e4,this.pingTimer=null,this.pongTimer=null,this._app=t.app||null,this.debug=t.debug||!1,this._onVisibilityChange=this._handleVisibilityChange.bind(this),this._onWindowFocus=this._handleWindowFocus.bind(this),this._setupVisibilityHandlers(),this._setupAppFocusHandler()}async connect(t=null){if(t&&(this.url=t),!this.url)throw new Error("WebSocket URL is required");if(this._intentionalDisconnect=!1,!this.isConnected&&!this.isConnecting)return this._doConnect()}disconnect(){this._intentionalDisconnect=!0,this._clearTimers(),this.socket&&(this._log("Disconnecting (intentional)"),this.socket.close(1e3,"Client disconnect"),this.socket=null),this.isConnected=!1,this.isConnecting=!1}send(t){if(!this.isConnected||!this.socket)throw new Error("WebSocket not connected");const e="string"==typeof t?t:JSON.stringify(t);this.socket.send(e),this._log("Sent:",e)}destroy(){this.disconnect(),this._teardownVisibilityHandlers(),this._teardownAppFocusHandler()}_doConnect(){return this.isConnected||this.isConnecting?Promise.resolve():(this.isConnecting=!0,this._log("Connecting to:",this.url),new Promise((t,e)=>{let n=!1;const i=(t,e)=>{n||(n=!0,t(e))};try{const n=new WebSocket(this.url);this.socket=n,n.onopen=()=>{this._log("Connected"),this.isConnected=!0,this.isConnecting=!1,this.reconnectAttempts=0,this._authenticate(),this._startHeartbeat(),this.emit("connected"),i(t,void 0)},n.onmessage=t=>this._handleMessage(t),n.onerror=t=>{this._log("Socket error:",t),this.emit("error",t),this.isConnected||i(e,new Error("WebSocket connection failed"))},n.onclose=t=>this._handleClose(t,i.bind(null,e))}catch(s){this.isConnecting=!1,this.socket=null,i(e,s),this._scheduleReconnect()}}))}_authenticate(){const t=this.getToken?this.getToken():null;t?this.send({type:"authenticate",token:t,prefix:this.tokenPrefix}):console.warn("[WebSocket] No token available — skipping authentication")}_handleMessage(t){let e;this._log("Received:",t.data);try{e=JSON.parse(t.data)}catch{e=t.data}"pong"!==e?.type?(e?.type&&this.emit(`message:${e.type}`,e),this.emit("message",e)):this._clearPongTimeout()}_handleClose(t,e){this._log("Closed:",t.code,t.reason);const n=this.isConnecting;this.isConnected=!1,this.isConnecting=!1,this._clearTimers(),this.socket=null,this.emit("disconnected",{code:t.code,reason:t.reason,wasClean:t.wasClean}),n&&"function"==typeof e&&e(new Error(`WebSocket closed before connecting (code ${t.code})`)),!this._intentionalDisconnect&&this.autoReconnect&&this._scheduleReconnect()}_scheduleReconnect(){if(this._intentionalDisconnect||!this.autoReconnect)return;if(null!==this.reconnectTimer)return;this.reconnectAttempts++;let t=Math.min(this.reconnectInterval*Math.pow(this.reconnectBackoff,this.reconnectAttempts-1),this.maxReconnectDelay);this.reconnectJitter&&(t*=.8+.4*Math.random()),t=Math.round(t),this._log(`Reconnecting in ${t}ms (attempt ${this.reconnectAttempts})`),this.emit("reconnecting",{attempt:this.reconnectAttempts,delay:t}),this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,!this._intentionalDisconnect&&this.autoReconnect&&this._doConnect().catch(t=>{this._log("Reconnect attempt failed:",t.message),null!==this.reconnectTimer||this._intentionalDisconnect||this._scheduleReconnect()})},t)}_nudgeReconnect(){!this._intentionalDisconnect&&this.autoReconnect&&(this.isConnected||this.isConnecting||(this._log("Focus/visibility restored — nudging reconnect immediately"),null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),setTimeout(()=>{if(this._intentionalDisconnect||this.isConnected||this.isConnecting)return;const t=this.reconnectAttempts;this._doConnect().catch(e=>{this._log("Nudge reconnect failed:",e.message),this.reconnectAttempts=t})},200)))}_startHeartbeat(){this.pingInterval&&(this.pingTimer=setInterval(()=>{if(this.isConnected)try{this.send({action:"ping"}),this._startPongTimeout()}catch(t){this._log("Ping send failed:",t.message)}},this.pingInterval))}_startPongTimeout(){this._clearPongTimeout(),this.pongTimer=setTimeout(()=>{console.warn("[WebSocket] Pong timeout — forcing reconnect"),this.emit("pong-timeout"),this.socket&&this.socket.close(4001,"Pong timeout")},this.pongTimeout)}_clearPongTimeout(){null!==this.pongTimer&&(clearTimeout(this.pongTimer),this.pongTimer=null)}_clearTimers(){null!==this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),null!==this.pingTimer&&(clearInterval(this.pingTimer),this.pingTimer=null),this._clearPongTimeout()}_setupVisibilityHandlers(){"undefined"!=typeof document&&(document.addEventListener("visibilitychange",this._onVisibilityChange),"undefined"!=typeof window&&window.addEventListener("focus",this._onWindowFocus))}_teardownVisibilityHandlers(){"undefined"!=typeof document&&(document.removeEventListener("visibilitychange",this._onVisibilityChange),"undefined"!=typeof window&&window.removeEventListener("focus",this._onWindowFocus))}_handleVisibilityChange(){document.hidden||this._nudgeReconnect()}_handleWindowFocus(){this._nudgeReconnect()}_setupAppFocusHandler(){this._app?.events&&(this._appFocusHandler=()=>this._nudgeReconnect(),this._app.events.on("browser:focus",this._appFocusHandler))}_teardownAppFocusHandler(){this._app?.events&&this._appFocusHandler&&(this._app.events.off("browser:focus",this._appFocusHandler),this._appFocusHandler=null)}_log(...t){this.debug}static deriveURL(t,e="/ws/realtime/"){if(!t)throw new Error("baseURL is required");const n=new URL(t);return n.protocol="https:"===n.protocol?"wss:":"ws:",n.pathname=e.startsWith("/")?e:`/${e}`,n.toString()}}Object.assign(WebSocketClient.prototype,t.EventEmitter),exports.WebSocketClient=WebSocketClient;
2
+ //# sourceMappingURL=WebSocketClient-CLgYPxWX.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebSocketClient-BxL2M7p0.js","sources":["../../src/core/services/WebSocketClient.js"],"sourcesContent":["/**\n * WebSocketClient - Robust, infinitely-resilient WebSocket client\n *\n * Features:\n * - Infinite auto-reconnect with capped exponential backoff + jitter (never gives up)\n * - Separate \"intentional disconnect\" flag so clean closes still reconnect\n * - Heartbeat ping/pong with timeout-driven force-reconnect\n * - Immediate reconnect nudge on browser visibility / window focus restore\n * - Optional integration with WebApp's browser:focus event bus\n * - Event-driven architecture using EventEmitter\n * - Token-based authentication\n *\n * Usage:\n * const ws = new WebSocketClient({\n * url: \"wss://api.example.com/ws/realtime\",\n * tokenPrefix: \"bearer\",\n * getToken: () => app.tokenManager.getToken(),\n * app, // optional – hooks into app.events 'browser:focus'\n * });\n *\n * ws.on('connected', () => console.log('Connected!'));\n * ws.on('message', (data) => console.log('Received:', data));\n * ws.on('reconnecting', ({attempt, delay}) => console.log(`Retry #${attempt} in ${delay}ms`));\n * ws.connect();\n */\n\nimport EventEmitter from '@core/mixins/EventEmitter.js';\n\nclass WebSocketClient {\n constructor(options = {}) {\n // ── Connection ──────────────────────────────────────────────────────────\n this.url = options.url;\n this.socket = null;\n this.isConnected = false;\n this.isConnecting = false;\n\n // ── Auth ────────────────────────────────────────────────────────────────\n this.getToken = options.getToken || null;\n this.tokenPrefix = options.tokenPrefix || 'bearer';\n\n // ── Reconnection ────────────────────────────────────────────────────────\n // `autoReconnect` – master switch (default true)\n // `_intentionalDisconnect` – set only when the caller explicitly calls\n // disconnect(), so that clean server closes\n // (code 1000) are still retried automatically.\n this.autoReconnect = options.autoReconnect !== false;\n this._intentionalDisconnect = false;\n\n this.reconnectInterval = options.reconnectInterval || 2000; // base delay ms\n this.reconnectBackoff = options.reconnectBackoff || 1.5; // multiplier\n this.maxReconnectDelay = options.maxReconnectDelay || 30000; // hard cap ms\n this.reconnectJitter = options.reconnectJitter !== false; // ±20 % jitter\n this.reconnectAttempts = 0;\n this.reconnectTimer = null;\n\n // ── Heartbeat ────────────────────────────────────────────────────────────\n this.pingInterval = options.pingInterval || 30000;\n this.pongTimeout = options.pongTimeout || 10000;\n this.pingTimer = null;\n this.pongTimer = null;\n\n // ── Optional WebApp integration ──────────────────────────────────────────\n // Pass `app` to also hook into app.events 'browser:focus' in addition to\n // the native visibility / window focus events we listen to below.\n this._app = options.app || null;\n\n // ── Debug ────────────────────────────────────────────────────────────────\n this.debug = options.debug || false;\n\n // Bind handlers so they can be cleanly removed later\n this._onVisibilityChange = this._handleVisibilityChange.bind(this);\n this._onWindowFocus = this._handleWindowFocus.bind(this);\n\n this._setupVisibilityHandlers();\n this._setupAppFocusHandler();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Public API\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Connect to the WebSocket server.\n * Safe to call multiple times – extra calls are no-ops when already\n * connected or connecting.\n */\n async connect(url = null) {\n if (url) this.url = url;\n if (!this.url) throw new Error('WebSocket URL is required');\n\n // Any explicit call to connect() resets the intentional-disconnect flag.\n this._intentionalDisconnect = false;\n\n if (this.isConnected || this.isConnecting) return;\n\n return this._doConnect();\n }\n\n /**\n * Permanently stop the client. No further reconnect attempts are made\n * until connect() is called again.\n */\n disconnect() {\n this._intentionalDisconnect = true;\n this._clearTimers();\n\n if (this.socket) {\n this._log('Disconnecting (intentional)');\n this.socket.close(1000, 'Client disconnect');\n this.socket = null;\n }\n\n this.isConnected = false;\n this.isConnecting = false;\n }\n\n /**\n * Send data. Objects are auto-serialised to JSON.\n */\n send(data) {\n if (!this.isConnected || !this.socket) {\n throw new Error('WebSocket not connected');\n }\n\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(message);\n this._log('Sent:', message);\n }\n\n /**\n * Fully tear down the client, removing all DOM/app listeners.\n * Call this when the owning view/page is destroyed.\n */\n destroy() {\n this.disconnect();\n this._teardownVisibilityHandlers();\n this._teardownAppFocusHandler();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Connection internals\n // ═══════════════════════════════════════════════════════════════════════════\n\n _doConnect() {\n if (this.isConnected || this.isConnecting) return Promise.resolve();\n\n this.isConnecting = true;\n this._log('Connecting to:', this.url);\n\n return new Promise((resolve, reject) => {\n // `settled` ensures the promise is only resolved/rejected once even\n // though onerror and onclose can both fire on a failed connection.\n let settled = false;\n const settle = (fn, value) => {\n if (settled) return;\n settled = true;\n fn(value);\n };\n\n try {\n const socket = new WebSocket(this.url);\n this.socket = socket;\n\n socket.onopen = () => {\n this._log('Connected');\n this.isConnected = true;\n this.isConnecting = false;\n this.reconnectAttempts = 0;\n\n this._authenticate();\n this._startHeartbeat();\n\n this.emit('connected');\n settle(resolve, undefined);\n };\n\n socket.onmessage = (event) => this._handleMessage(event);\n\n // onerror in browsers is always followed by onclose, so we let\n // _handleClose drive the reconnect to avoid double-scheduling.\n // We only use the error event to emit and to reject the initial\n // connect() promise if we haven't successfully opened yet.\n socket.onerror = (event) => {\n this._log('Socket error:', event);\n this.emit('error', event);\n\n if (!this.isConnected) {\n settle(reject, new Error('WebSocket connection failed'));\n }\n };\n\n // Pass the settle-reject so _handleClose can reject the promise when\n // the socket closes before we ever reached onopen.\n socket.onclose = (event) => this._handleClose(event, settle.bind(null, reject));\n\n } catch (error) {\n // Synchronous WebSocket constructor failure (bad URL, etc.)\n this.isConnecting = false;\n this.socket = null;\n settle(reject, error);\n this._scheduleReconnect();\n }\n });\n }\n\n _authenticate() {\n const token = this.getToken ? this.getToken() : null;\n if (!token) {\n console.warn('[WebSocket] No token available — skipping authentication');\n return;\n }\n\n this.send({ type: 'authenticate', token, prefix: this.tokenPrefix });\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Event handlers\n // ═══════════════════════════════════════════════════════════════════════════\n\n _handleMessage(event) {\n this._log('Received:', event.data);\n\n let data;\n try {\n data = JSON.parse(event.data);\n } catch {\n data = event.data;\n }\n\n // Absorb pong heartbeat response\n if (data?.type === 'pong') {\n this._clearPongTimeout();\n return;\n }\n\n if (data?.type) {\n this.emit(`message:${data.type}`, data);\n }\n this.emit('message', data);\n }\n\n _handleClose(event, initialRejectFn) {\n this._log('Closed:', event.code, event.reason);\n\n const wasConnecting = this.isConnecting;\n\n this.isConnected = false;\n this.isConnecting = false;\n this._clearTimers();\n this.socket = null;\n\n this.emit('disconnected', {\n code: event.code,\n reason: event.reason,\n wasClean: event.wasClean\n });\n\n // Reject the caller's connect() promise if we closed before onopen fired\n if (wasConnecting && typeof initialRejectFn === 'function') {\n initialRejectFn(new Error(`WebSocket closed before connecting (code ${event.code})`));\n }\n\n // Always reconnect unless the user explicitly called disconnect()\n if (!this._intentionalDisconnect && this.autoReconnect) {\n this._scheduleReconnect();\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Reconnect\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Schedule the next reconnect with capped exponential backoff + optional\n * jitter. This is the single code path through which all retries are queued.\n */\n _scheduleReconnect() {\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n\n // Guard against queuing a second timer while one is already pending\n if (this.reconnectTimer !== null) return;\n\n this.reconnectAttempts++;\n\n // Exponential backoff, hard-capped\n let delay = Math.min(\n this.reconnectInterval * Math.pow(this.reconnectBackoff, this.reconnectAttempts - 1),\n this.maxReconnectDelay\n );\n\n // ±20 % jitter to avoid thundering-herd problems after server restarts\n if (this.reconnectJitter) {\n delay = delay * (0.8 + Math.random() * 0.4);\n }\n\n delay = Math.round(delay);\n\n this._log(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);\n this.emit('reconnecting', { attempt: this.reconnectAttempts, delay });\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n\n this._doConnect().catch((err) => {\n this._log('Reconnect attempt failed:', err.message);\n // _handleClose already called _scheduleReconnect for us; if somehow it\n // didn't (e.g. synchronous throw path), make sure we still retry.\n if (this.reconnectTimer === null && !this._intentionalDisconnect) {\n this._scheduleReconnect();\n }\n });\n }, delay);\n }\n\n /**\n * Skip the remaining backoff wait and attempt a reconnect right away.\n * Called when the browser regains visibility or focus so we don't leave\n * the user sitting at the max-delay cap after waking a laptop or switching\n * back to the tab.\n */\n _nudgeReconnect() {\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n if (this.isConnected || this.isConnecting) return;\n\n this._log('Focus/visibility restored — nudging reconnect immediately');\n\n // Cancel the pending backoff timer; we're going now\n if (this.reconnectTimer !== null) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n\n // Small grace period (200 ms) to let the network stack wake up before\n // we try to open the socket.\n setTimeout(() => {\n if (this._intentionalDisconnect || this.isConnected || this.isConnecting) return;\n\n // Don't inflate the attempts counter for a nudge — treat it as\n // retrying the current attempt rather than starting a new one.\n const savedAttempts = this.reconnectAttempts;\n this._doConnect().catch((err) => {\n this._log('Nudge reconnect failed:', err.message);\n // Restore attempt count so backoff calculation stays consistent\n this.reconnectAttempts = savedAttempts;\n });\n }, 200);\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Heartbeat\n // ═══════════════════════════════════════════════════════════════════════════\n\n _startHeartbeat() {\n if (!this.pingInterval) return;\n\n this.pingTimer = setInterval(() => {\n if (!this.isConnected) return;\n try {\n this.send({ action: 'ping' });\n this._startPongTimeout();\n } catch (err) {\n this._log('Ping send failed:', err.message);\n }\n }, this.pingInterval);\n }\n\n _startPongTimeout() {\n this._clearPongTimeout();\n\n this.pongTimer = setTimeout(() => {\n console.warn('[WebSocket] Pong timeout — forcing reconnect');\n this.emit('pong-timeout');\n if (this.socket) {\n // Non-1000 code so _handleClose knows this was not an intentional close\n this.socket.close(4001, 'Pong timeout');\n }\n }, this.pongTimeout);\n }\n\n _clearPongTimeout() {\n if (this.pongTimer !== null) {\n clearTimeout(this.pongTimer);\n this.pongTimer = null;\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Timer cleanup\n // ═══════════════════════════════════════════════════════════════════════════\n\n _clearTimers() {\n if (this.reconnectTimer !== null) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.pingTimer !== null) {\n clearInterval(this.pingTimer);\n this.pingTimer = null;\n }\n this._clearPongTimeout();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Visibility / focus integration\n // ═══════════════════════════════════════════════════════════════════════════\n\n _setupVisibilityHandlers() {\n if (typeof document === 'undefined') return;\n document.addEventListener('visibilitychange', this._onVisibilityChange);\n if (typeof window !== 'undefined') {\n window.addEventListener('focus', this._onWindowFocus);\n }\n }\n\n _teardownVisibilityHandlers() {\n if (typeof document === 'undefined') return;\n document.removeEventListener('visibilitychange', this._onVisibilityChange);\n if (typeof window !== 'undefined') {\n window.removeEventListener('focus', this._onWindowFocus);\n }\n }\n\n _handleVisibilityChange() {\n if (!document.hidden) {\n this._nudgeReconnect();\n }\n }\n\n _handleWindowFocus() {\n this._nudgeReconnect();\n }\n\n /**\n * Hook into a WebApp instance's unified event bus so that PortalApp's\n * existing browser:focus handling also triggers a reconnect nudge.\n * This is intentionally additive — the native DOM listeners above already\n * cover the common cases; the app bus is a belt-and-suspenders extra.\n */\n _setupAppFocusHandler() {\n if (!this._app?.events) return;\n this._appFocusHandler = () => this._nudgeReconnect();\n this._app.events.on('browser:focus', this._appFocusHandler);\n }\n\n _teardownAppFocusHandler() {\n if (!this._app?.events || !this._appFocusHandler) return;\n this._app.events.off('browser:focus', this._appFocusHandler);\n this._appFocusHandler = null;\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Logging\n // ═══════════════════════════════════════════════════════════════════════════\n\n _log(...args) {\n if (this.debug) {\n console.log('[WebSocket]', ...args);\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Static helpers\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Convert a REST API base URL to a WebSocket URL.\n *\n * @param {string} baseURL - REST base URL (http / https)\n * @param {string} path - WebSocket path (default: '/ws/realtime/')\n * @returns {string} WebSocket URL (ws / wss)\n *\n * @example\n * WebSocketClient.deriveURL('https://api.example.com', '/ws/realtime')\n * // → 'wss://api.example.com/ws/realtime'\n *\n * WebSocketClient.deriveURL('http://localhost:3000')\n * // → 'ws://localhost:3000/ws/realtime/'\n */\n static deriveURL(baseURL, path = '/ws/realtime/') {\n if (!baseURL) throw new Error('baseURL is required');\n const url = new URL(baseURL);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.pathname = path.startsWith('/') ? path : `/${path}`;\n return url.toString();\n }\n}\n\n// Mix in EventEmitter (adds on / off / emit / once)\nObject.assign(WebSocketClient.prototype, EventEmitter);\n\nexport default WebSocketClient;"],"names":["WebSocketClient","constructor","options","this","url","socket","isConnected","isConnecting","getToken","tokenPrefix","autoReconnect","_intentionalDisconnect","reconnectInterval","reconnectBackoff","maxReconnectDelay","reconnectJitter","reconnectAttempts","reconnectTimer","pingInterval","pongTimeout","pingTimer","pongTimer","_app","app","debug","_onVisibilityChange","_handleVisibilityChange","bind","_onWindowFocus","_handleWindowFocus","_setupVisibilityHandlers","_setupAppFocusHandler","connect","Error","_doConnect","disconnect","_clearTimers","_log","close","send","data","message","JSON","stringify","destroy","_teardownVisibilityHandlers","_teardownAppFocusHandler","Promise","resolve","reject","settled","settle","fn","value","WebSocket","onopen","_authenticate","_startHeartbeat","emit","onmessage","event","_handleMessage","onerror","onclose","_handleClose","error","_scheduleReconnect","token","type","prefix","console","warn","parse","_clearPongTimeout","initialRejectFn","code","reason","wasConnecting","wasClean","delay","Math","min","pow","random","round","attempt","setTimeout","catch","err","_nudgeReconnect","clearTimeout","savedAttempts","setInterval","action","_startPongTimeout","clearInterval","document","addEventListener","window","removeEventListener","hidden","events","_appFocusHandler","on","off","args","deriveURL","baseURL","path","URL","protocol","pathname","startsWith","toString","Object","assign","prototype","EventEmitter"],"mappings":"mDA4BA,MAAMA,gBACJ,WAAAC,CAAYC,EAAU,IAEpBC,KAAKC,IAAeF,EAAQE,IAC5BD,KAAKE,OAAe,KACpBF,KAAKG,aAAe,EACpBH,KAAKI,cAAe,EAGpBJ,KAAKK,SAAcN,EAAQM,UAAc,KACzCL,KAAKM,YAAcP,EAAQO,aAAe,SAO1CN,KAAKO,eAAkD,IAA1BR,EAAQQ,cACrCP,KAAKQ,wBAAyB,EAE9BR,KAAKS,kBAAqBV,EAAQU,mBAAsB,IACxDT,KAAKU,iBAAqBX,EAAQW,kBAAsB,IACxDV,KAAKW,kBAAqBZ,EAAQY,mBAAsB,IACxDX,KAAKY,iBAAoD,IAA/Bb,EAAQa,gBAClCZ,KAAKa,kBAAqB,EAC1Bb,KAAKc,eAAqB,KAG1Bd,KAAKe,aAAehB,EAAQgB,cAAgB,IAC5Cf,KAAKgB,YAAejB,EAAQiB,aAAgB,IAC5ChB,KAAKiB,UAAe,KACpBjB,KAAKkB,UAAe,KAKpBlB,KAAKmB,KAAOpB,EAAQqB,KAAO,KAG3BpB,KAAKqB,MAAQtB,EAAQsB,QAAS,EAG9BrB,KAAKsB,oBAAsBtB,KAAKuB,wBAAwBC,KAAKxB,MAC7DA,KAAKyB,eAAsBzB,KAAK0B,mBAAmBF,KAAKxB,MAExDA,KAAK2B,2BACL3B,KAAK4B,uBACP,CAW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AS,MAAM,IAAI1E,MAAM,uBAC9B,MAAM7B,EAAW,IAAIyG,IAAIF,GAGzB,OAFAvG,EAAI0G,SAA8B,WAAjB1G,EAAI0G,SAAwB,OAAS,MACtD1G,EAAI2G,SAAaH,EAAKI,WAAW,KAAOJ,EAAO,IAAIA,IAC5CxG,EAAI6G,UACb,EAIFC,OAAOC,OAAOnH,gBAAgBoH,UAAWC"}
1
+ {"version":3,"file":"WebSocketClient-CLgYPxWX.js","sources":["../../src/core/services/WebSocketClient.js"],"sourcesContent":["/**\n * WebSocketClient - Robust, infinitely-resilient WebSocket client\n *\n * Features:\n * - Infinite auto-reconnect with capped exponential backoff + jitter (never gives up)\n * - Separate \"intentional disconnect\" flag so clean closes still reconnect\n * - Heartbeat ping/pong with timeout-driven force-reconnect\n * - Immediate reconnect nudge on browser visibility / window focus restore\n * - Optional integration with WebApp's browser:focus event bus\n * - Event-driven architecture using EventEmitter\n * - Token-based authentication\n *\n * Usage:\n * const ws = new WebSocketClient({\n * url: \"wss://api.example.com/ws/realtime\",\n * tokenPrefix: \"bearer\",\n * getToken: () => app.tokenManager.getToken(),\n * app, // optional – hooks into app.events 'browser:focus'\n * });\n *\n * ws.on('connected', () => console.log('Connected!'));\n * ws.on('message', (data) => console.log('Received:', data));\n * ws.on('reconnecting', ({attempt, delay}) => console.log(`Retry #${attempt} in ${delay}ms`));\n * ws.connect();\n */\n\nimport EventEmitter from '@core/mixins/EventEmitter.js';\n\nclass WebSocketClient {\n constructor(options = {}) {\n // ── Connection ──────────────────────────────────────────────────────────\n this.url = options.url;\n this.socket = null;\n this.isConnected = false;\n this.isConnecting = false;\n\n // ── Auth ────────────────────────────────────────────────────────────────\n this.getToken = options.getToken || null;\n this.tokenPrefix = options.tokenPrefix || 'bearer';\n\n // ── Reconnection ────────────────────────────────────────────────────────\n // `autoReconnect` – master switch (default true)\n // `_intentionalDisconnect` – set only when the caller explicitly calls\n // disconnect(), so that clean server closes\n // (code 1000) are still retried automatically.\n this.autoReconnect = options.autoReconnect !== false;\n this._intentionalDisconnect = false;\n\n this.reconnectInterval = options.reconnectInterval || 2000; // base delay ms\n this.reconnectBackoff = options.reconnectBackoff || 1.5; // multiplier\n this.maxReconnectDelay = options.maxReconnectDelay || 30000; // hard cap ms\n this.reconnectJitter = options.reconnectJitter !== false; // ±20 % jitter\n this.reconnectAttempts = 0;\n this.reconnectTimer = null;\n\n // ── Heartbeat ────────────────────────────────────────────────────────────\n this.pingInterval = options.pingInterval || 30000;\n this.pongTimeout = options.pongTimeout || 10000;\n this.pingTimer = null;\n this.pongTimer = null;\n\n // ── Optional WebApp integration ──────────────────────────────────────────\n // Pass `app` to also hook into app.events 'browser:focus' in addition to\n // the native visibility / window focus events we listen to below.\n this._app = options.app || null;\n\n // ── Debug ────────────────────────────────────────────────────────────────\n this.debug = options.debug || false;\n\n // Bind handlers so they can be cleanly removed later\n this._onVisibilityChange = this._handleVisibilityChange.bind(this);\n this._onWindowFocus = this._handleWindowFocus.bind(this);\n\n this._setupVisibilityHandlers();\n this._setupAppFocusHandler();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Public API\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Connect to the WebSocket server.\n * Safe to call multiple times – extra calls are no-ops when already\n * connected or connecting.\n */\n async connect(url = null) {\n if (url) this.url = url;\n if (!this.url) throw new Error('WebSocket URL is required');\n\n // Any explicit call to connect() resets the intentional-disconnect flag.\n this._intentionalDisconnect = false;\n\n if (this.isConnected || this.isConnecting) return;\n\n return this._doConnect();\n }\n\n /**\n * Permanently stop the client. No further reconnect attempts are made\n * until connect() is called again.\n */\n disconnect() {\n this._intentionalDisconnect = true;\n this._clearTimers();\n\n if (this.socket) {\n this._log('Disconnecting (intentional)');\n this.socket.close(1000, 'Client disconnect');\n this.socket = null;\n }\n\n this.isConnected = false;\n this.isConnecting = false;\n }\n\n /**\n * Send data. Objects are auto-serialised to JSON.\n */\n send(data) {\n if (!this.isConnected || !this.socket) {\n throw new Error('WebSocket not connected');\n }\n\n const message = typeof data === 'string' ? data : JSON.stringify(data);\n this.socket.send(message);\n this._log('Sent:', message);\n }\n\n /**\n * Fully tear down the client, removing all DOM/app listeners.\n * Call this when the owning view/page is destroyed.\n */\n destroy() {\n this.disconnect();\n this._teardownVisibilityHandlers();\n this._teardownAppFocusHandler();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Connection internals\n // ═══════════════════════════════════════════════════════════════════════════\n\n _doConnect() {\n if (this.isConnected || this.isConnecting) return Promise.resolve();\n\n this.isConnecting = true;\n this._log('Connecting to:', this.url);\n\n return new Promise((resolve, reject) => {\n // `settled` ensures the promise is only resolved/rejected once even\n // though onerror and onclose can both fire on a failed connection.\n let settled = false;\n const settle = (fn, value) => {\n if (settled) return;\n settled = true;\n fn(value);\n };\n\n try {\n const socket = new WebSocket(this.url);\n this.socket = socket;\n\n socket.onopen = () => {\n this._log('Connected');\n this.isConnected = true;\n this.isConnecting = false;\n this.reconnectAttempts = 0;\n\n this._authenticate();\n this._startHeartbeat();\n\n this.emit('connected');\n settle(resolve, undefined);\n };\n\n socket.onmessage = (event) => this._handleMessage(event);\n\n // onerror in browsers is always followed by onclose, so we let\n // _handleClose drive the reconnect to avoid double-scheduling.\n // We only use the error event to emit and to reject the initial\n // connect() promise if we haven't successfully opened yet.\n socket.onerror = (event) => {\n this._log('Socket error:', event);\n this.emit('error', event);\n\n if (!this.isConnected) {\n settle(reject, new Error('WebSocket connection failed'));\n }\n };\n\n // Pass the settle-reject so _handleClose can reject the promise when\n // the socket closes before we ever reached onopen.\n socket.onclose = (event) => this._handleClose(event, settle.bind(null, reject));\n\n } catch (error) {\n // Synchronous WebSocket constructor failure (bad URL, etc.)\n this.isConnecting = false;\n this.socket = null;\n settle(reject, error);\n this._scheduleReconnect();\n }\n });\n }\n\n _authenticate() {\n const token = this.getToken ? this.getToken() : null;\n if (!token) {\n console.warn('[WebSocket] No token available — skipping authentication');\n return;\n }\n\n this.send({ type: 'authenticate', token, prefix: this.tokenPrefix });\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Event handlers\n // ═══════════════════════════════════════════════════════════════════════════\n\n _handleMessage(event) {\n this._log('Received:', event.data);\n\n let data;\n try {\n data = JSON.parse(event.data);\n } catch {\n data = event.data;\n }\n\n // Absorb pong heartbeat response\n if (data?.type === 'pong') {\n this._clearPongTimeout();\n return;\n }\n\n if (data?.type) {\n this.emit(`message:${data.type}`, data);\n }\n this.emit('message', data);\n }\n\n _handleClose(event, initialRejectFn) {\n this._log('Closed:', event.code, event.reason);\n\n const wasConnecting = this.isConnecting;\n\n this.isConnected = false;\n this.isConnecting = false;\n this._clearTimers();\n this.socket = null;\n\n this.emit('disconnected', {\n code: event.code,\n reason: event.reason,\n wasClean: event.wasClean\n });\n\n // Reject the caller's connect() promise if we closed before onopen fired\n if (wasConnecting && typeof initialRejectFn === 'function') {\n initialRejectFn(new Error(`WebSocket closed before connecting (code ${event.code})`));\n }\n\n // Always reconnect unless the user explicitly called disconnect()\n if (!this._intentionalDisconnect && this.autoReconnect) {\n this._scheduleReconnect();\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Reconnect\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Schedule the next reconnect with capped exponential backoff + optional\n * jitter. This is the single code path through which all retries are queued.\n */\n _scheduleReconnect() {\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n\n // Guard against queuing a second timer while one is already pending\n if (this.reconnectTimer !== null) return;\n\n this.reconnectAttempts++;\n\n // Exponential backoff, hard-capped\n let delay = Math.min(\n this.reconnectInterval * Math.pow(this.reconnectBackoff, this.reconnectAttempts - 1),\n this.maxReconnectDelay\n );\n\n // ±20 % jitter to avoid thundering-herd problems after server restarts\n if (this.reconnectJitter) {\n delay = delay * (0.8 + Math.random() * 0.4);\n }\n\n delay = Math.round(delay);\n\n this._log(`Reconnecting in ${delay}ms (attempt ${this.reconnectAttempts})`);\n this.emit('reconnecting', { attempt: this.reconnectAttempts, delay });\n\n this.reconnectTimer = setTimeout(() => {\n this.reconnectTimer = null;\n\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n\n this._doConnect().catch((err) => {\n this._log('Reconnect attempt failed:', err.message);\n // _handleClose already called _scheduleReconnect for us; if somehow it\n // didn't (e.g. synchronous throw path), make sure we still retry.\n if (this.reconnectTimer === null && !this._intentionalDisconnect) {\n this._scheduleReconnect();\n }\n });\n }, delay);\n }\n\n /**\n * Skip the remaining backoff wait and attempt a reconnect right away.\n * Called when the browser regains visibility or focus so we don't leave\n * the user sitting at the max-delay cap after waking a laptop or switching\n * back to the tab.\n */\n _nudgeReconnect() {\n if (this._intentionalDisconnect || !this.autoReconnect) return;\n if (this.isConnected || this.isConnecting) return;\n\n this._log('Focus/visibility restored — nudging reconnect immediately');\n\n // Cancel the pending backoff timer; we're going now\n if (this.reconnectTimer !== null) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n\n // Small grace period (200 ms) to let the network stack wake up before\n // we try to open the socket.\n setTimeout(() => {\n if (this._intentionalDisconnect || this.isConnected || this.isConnecting) return;\n\n // Don't inflate the attempts counter for a nudge — treat it as\n // retrying the current attempt rather than starting a new one.\n const savedAttempts = this.reconnectAttempts;\n this._doConnect().catch((err) => {\n this._log('Nudge reconnect failed:', err.message);\n // Restore attempt count so backoff calculation stays consistent\n this.reconnectAttempts = savedAttempts;\n });\n }, 200);\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Heartbeat\n // ═══════════════════════════════════════════════════════════════════════════\n\n _startHeartbeat() {\n if (!this.pingInterval) return;\n\n this.pingTimer = setInterval(() => {\n if (!this.isConnected) return;\n try {\n this.send({ action: 'ping' });\n this._startPongTimeout();\n } catch (err) {\n this._log('Ping send failed:', err.message);\n }\n }, this.pingInterval);\n }\n\n _startPongTimeout() {\n this._clearPongTimeout();\n\n this.pongTimer = setTimeout(() => {\n console.warn('[WebSocket] Pong timeout — forcing reconnect');\n this.emit('pong-timeout');\n if (this.socket) {\n // Non-1000 code so _handleClose knows this was not an intentional close\n this.socket.close(4001, 'Pong timeout');\n }\n }, this.pongTimeout);\n }\n\n _clearPongTimeout() {\n if (this.pongTimer !== null) {\n clearTimeout(this.pongTimer);\n this.pongTimer = null;\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Timer cleanup\n // ═══════════════════════════════════════════════════════════════════════════\n\n _clearTimers() {\n if (this.reconnectTimer !== null) {\n clearTimeout(this.reconnectTimer);\n this.reconnectTimer = null;\n }\n if (this.pingTimer !== null) {\n clearInterval(this.pingTimer);\n this.pingTimer = null;\n }\n this._clearPongTimeout();\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Visibility / focus integration\n // ═══════════════════════════════════════════════════════════════════════════\n\n _setupVisibilityHandlers() {\n if (typeof document === 'undefined') return;\n document.addEventListener('visibilitychange', this._onVisibilityChange);\n if (typeof window !== 'undefined') {\n window.addEventListener('focus', this._onWindowFocus);\n }\n }\n\n _teardownVisibilityHandlers() {\n if (typeof document === 'undefined') return;\n document.removeEventListener('visibilitychange', this._onVisibilityChange);\n if (typeof window !== 'undefined') {\n window.removeEventListener('focus', this._onWindowFocus);\n }\n }\n\n _handleVisibilityChange() {\n if (!document.hidden) {\n this._nudgeReconnect();\n }\n }\n\n _handleWindowFocus() {\n this._nudgeReconnect();\n }\n\n /**\n * Hook into a WebApp instance's unified event bus so that PortalApp's\n * existing browser:focus handling also triggers a reconnect nudge.\n * This is intentionally additive — the native DOM listeners above already\n * cover the common cases; the app bus is a belt-and-suspenders extra.\n */\n _setupAppFocusHandler() {\n if (!this._app?.events) return;\n this._appFocusHandler = () => this._nudgeReconnect();\n this._app.events.on('browser:focus', this._appFocusHandler);\n }\n\n _teardownAppFocusHandler() {\n if (!this._app?.events || !this._appFocusHandler) return;\n this._app.events.off('browser:focus', this._appFocusHandler);\n this._appFocusHandler = null;\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Logging\n // ═══════════════════════════════════════════════════════════════════════════\n\n _log(...args) {\n if (this.debug) {\n console.log('[WebSocket]', ...args);\n }\n }\n\n // ═══════════════════════════════════════════════════════════════════════════\n // Static helpers\n // ═══════════════════════════════════════════════════════════════════════════\n\n /**\n * Convert a REST API base URL to a WebSocket URL.\n *\n * @param {string} baseURL - REST base URL (http / https)\n * @param {string} path - WebSocket path (default: '/ws/realtime/')\n * @returns {string} WebSocket URL (ws / wss)\n *\n * @example\n * WebSocketClient.deriveURL('https://api.example.com', '/ws/realtime')\n * // → 'wss://api.example.com/ws/realtime'\n *\n * WebSocketClient.deriveURL('http://localhost:3000')\n * // → 'ws://localhost:3000/ws/realtime/'\n */\n static deriveURL(baseURL, path = '/ws/realtime/') {\n if (!baseURL) throw new Error('baseURL is required');\n const url = new URL(baseURL);\n url.protocol = url.protocol === 'https:' ? 'wss:' : 'ws:';\n url.pathname = path.startsWith('/') ? path : `/${path}`;\n return url.toString();\n }\n}\n\n// Mix in EventEmitter (adds on / off / emit / once)\nObject.assign(WebSocketClient.prototype, EventEmitter);\n\nexport default WebSocketClient;"],"names":["WebSocketClient","constructor","options","this","url","socket","isConnected","isConnecting","getToken","tokenPrefix","autoReconnect","_intentionalDisconnect","reconnectInterval","reconnectBackoff","maxReconnectDelay","reconnectJitter","reconnectAttempts","reconnectTimer","pingInterval","pongTimeout","pingTimer","pongTimer","_app","app","debug","_onVisibilityChange","_handleVisibilityChange","bind","_onWindowFocus","_handleWindowFocus","_setupVisibilityHandlers","_setupAppFocusHandler","connect","Error","_doConnect","disconnect","_clearTimers","_log","close","send","data","message","JSON","stringify","destroy","_teardownVisibilityHandlers","_teardownAppFocusHandler","Promise","resolve","reject","settled","settle","fn","value","WebSocket","onopen","_authenticate","_startHeartbeat","emit","onmessage","event","_handleMessage","onerror","onclose","_handleClose","error","_scheduleReconnect","token","type","prefix","console","warn","parse","_clearPongTimeout","initialRejectFn","code","reason","wasConnecting","wasClean","delay","Math","min","pow","random","round","attempt","setTimeout","catch","err","_nudgeReconnect","clearTimeout","savedAttempts","setInterval","action","_startPongTimeout","clearInterval","document","addEventListener","window","removeEventListener","hidden","events","_appFocusHandler","on","off","args","deriveURL","baseURL","path","URL","protocol","pathname","startsWith","toString","Object","assign","prototype","EventEmitter"],"mappings":"mDA4BA,MAAMA,gBACJ,WAAAC,CAAYC,EAAU,IAEpBC,KAAKC,IAAeF,EAAQE,IAC5BD,KAAKE,OAAe,KACpBF,KAAKG,aAAe,EACpBH,KAAKI,cAAe,EAGpBJ,KAAKK,SAAcN,EAAQM,UAAc,KACzCL,KAAKM,YAAcP,EAAQO,aAAe,SAO1CN,KAAKO,eAAkD,IAA1BR,EAAQQ,cACrCP,KAAKQ,wBAAyB,EAE9BR,KAAKS,kBAAqBV,EAAQU,mBAAsB,IACxDT,KAAKU,iBAAqBX,EAAQW,kBAAsB,IACxDV,KAAKW,kBAAqBZ,EAAQY,mBAAsB,IACxDX,KAAKY,iBAAoD,IAA/Bb,EAAQa,gBAClCZ,KAAKa,kBAAqB,EAC1Bb,KAAKc,eAAqB,KAG1Bd,KAAKe,aAAehB,EAAQgB,cAAgB,IAC5Cf,KAAKgB,YAAejB,EAAQiB,aAAgB,IAC5ChB,KAAKiB,UAAe,KACpBjB,KAAKkB,UAAe,KAKpBlB,KAAKmB,KAAOpB,EAAQqB,KAAO,KAG3BpB,KAAKqB,MAAQtB,EAAQsB,QAAS,EAG9BrB,KAAKsB,oBAAsBtB,KAAKuB,wBAAwBC,KAAKxB,MAC7DA,KAAKyB,eAAsBzB,KAAK0B,mBAAmBF,KAAKxB,MAExDA,KAAK2B,2BACL3B,KAAK4B,uBACP,CAWA,aAAMC,CAAQ5B,EAAM,MAElB,GADIA,SAAUA,IAAMA,IACfD,KAAKC,IAAK,MAAM,IAAI6B,MAAM,6BAK/B,GAFA9B,KAAKQ,wBAAyB,GAE1BR,KAAKG,cAAeH,KAAKI,aAE7B,OAAOJ,KAAK+B,YACd,CAMA,UAAAC,GACEhC,KAAKQ,wBAAyB,EAC9BR,KAAKiC,eAEDjC,KAAKE,S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1,2 +1,2 @@
1
- const i="2.2.65",n=2,o=2,s=65,O="2026-03-09T05:18:47.130Z",r={full:i,major:2,minor:2,revision:65,buildTime:O,toString(){return this.full},compare(i){const n=i=>i.split(".").map(Number),[o,s,O]=n(this.full),[r,w,e]=n(i);return o!==r?o-r:s!==w?s-w:O-e}};"undefined"!=typeof window&&(window.MOJO=window.MOJO||{},window.MOJO.VERSION=i,window.MOJO.VERSION_INFO=r,window.MOJO.version=i);export{O as B,i as V,r as a,n as b,o as c,s as d};
2
- //# sourceMappingURL=version-kTtMlfsq.js.map
1
+ const i="2.2.67",n=2,o=2,s=67,O="2026-03-16T00:07:53.940Z",r={full:i,major:2,minor:2,revision:67,buildTime:O,toString(){return this.full},compare(i){const n=i=>i.split(".").map(Number),[o,s,O]=n(this.full),[r,w,e]=n(i);return o!==r?o-r:s!==w?s-w:O-e}};"undefined"!=typeof window&&(window.MOJO=window.MOJO||{},window.MOJO.VERSION=i,window.MOJO.VERSION_INFO=r,window.MOJO.version=i);export{O as B,i as V,r as a,n as b,o as c,s as d};
2
+ //# sourceMappingURL=version-BY7AsEkb.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-kTtMlfsq.js","sources":["../../src/version.js"],"sourcesContent":["/**\n * MOJO Framework Version Information\n * Auto-generated on 2026-03-09T05:18:47.130Z\n */\n\nexport const VERSION = '2.2.65';\nexport const VERSION_MAJOR = 2;\nexport const VERSION_MINOR = 2;\nexport const VERSION_REVISION = 65;\nexport const BUILD_TIME = '2026-03-09T05:18:47.130Z';\n\n// Version object for easy access\nexport const VERSION_INFO = {\n full: VERSION,\n major: VERSION_MAJOR,\n minor: VERSION_MINOR,\n revision: VERSION_REVISION,\n buildTime: BUILD_TIME,\n toString() {\n return this.full;\n },\n compare(other) {\n const parseVer = (v) => v.split('.').map(Number);\n const [a1, a2, a3] = parseVer(this.full);\n const [b1, b2, b3] = parseVer(other);\n\n if (a1 !== b1) return a1 - b1;\n if (a2 !== b2) return a2 - b2;\n return a3 - b3;\n }\n};\n\n// Make version globally available if in browser\nif (typeof window !== 'undefined') {\n window.MOJO = window.MOJO || {};\n window.MOJO.VERSION = VERSION;\n window.MOJO.VERSION_INFO = VERSION_INFO;\n\n // Also add to MOJO.version for convenience\n window.MOJO.version = VERSION;\n}\n\nexport default VERSION_INFO;\n"],"names":["VERSION","VERSION_MAJOR","VERSION_MINOR","VERSION_REVISION","BUILD_TIME","VERSION_INFO","full","major","minor","revision","buildTime","toString","this","compare","other","parseVer","v","split","map","Number","a1","a2","a3","b1","b2","b3","window","MOJO","version"],"mappings":"AAKY,MAACA,EAAU,SACVC,EAAgB,EAChBC,EAAgB,EAChBC,EAAmB,GACnBC,EAAa,2BAGbC,EAAe,CACxBC,KAAMN,EACNO,MARyB,EASzBC,MARyB,EASzBC,SAR4B,GAS5BC,UAAWN,EACX,QAAAO,GACI,OAAOC,KAAKN,IAChB,EACA,OAAAO,CAAQC,GACJ,MAAMC,EAAYC,GAAMA,EAAEC,MAAM,KAAKC,IAAIC,SAClCC,EAAIC,EAAIC,GAAMP,EAASH,KAAKN,OAC5BiB,EAAIC,EAAIC,GAAMV,EAASD,GAE9B,OAAIM,IAAOG,EAAWH,EAAKG,EACvBF,IAAOG,EAAWH,EAAKG,EACpBF,EAAKG,CAChB,GAIkB,oBAAXC,SACPA,OAAOC,KAAOD,OAAOC,MAAQ,CAAA,EAC7BD,OAAOC,KAAK3B,QAAUA,EACtB0B,OAAOC,KAAKtB,aAAeA,EAG3BqB,OAAOC,KAAKC,QAAU5B"}
1
+ {"version":3,"file":"version-BY7AsEkb.js","sources":["../../src/version.js"],"sourcesContent":["/**\n * MOJO Framework Version Information\n * Auto-generated on 2026-03-16T00:07:53.940Z\n */\n\nexport const VERSION = '2.2.67';\nexport const VERSION_MAJOR = 2;\nexport const VERSION_MINOR = 2;\nexport const VERSION_REVISION = 67;\nexport const BUILD_TIME = '2026-03-16T00:07:53.940Z';\n\n// Version object for easy access\nexport const VERSION_INFO = {\n full: VERSION,\n major: VERSION_MAJOR,\n minor: VERSION_MINOR,\n revision: VERSION_REVISION,\n buildTime: BUILD_TIME,\n toString() {\n return this.full;\n },\n compare(other) {\n const parseVer = (v) => v.split('.').map(Number);\n const [a1, a2, a3] = parseVer(this.full);\n const [b1, b2, b3] = parseVer(other);\n\n if (a1 !== b1) return a1 - b1;\n if (a2 !== b2) return a2 - b2;\n return a3 - b3;\n }\n};\n\n// Make version globally available if in browser\nif (typeof window !== 'undefined') {\n window.MOJO = window.MOJO || {};\n window.MOJO.VERSION = VERSION;\n window.MOJO.VERSION_INFO = VERSION_INFO;\n\n // Also add to MOJO.version for convenience\n window.MOJO.version = VERSION;\n}\n\nexport default VERSION_INFO;\n"],"names":["VERSION","VERSION_MAJOR","VERSION_MINOR","VERSION_REVISION","BUILD_TIME","VERSION_INFO","full","major","minor","revision","buildTime","toString","this","compare","other","parseVer","v","split","map","Number","a1","a2","a3","b1","b2","b3","window","MOJO","version"],"mappings":"AAKY,MAACA,EAAU,SACVC,EAAgB,EAChBC,EAAgB,EAChBC,EAAmB,GACnBC,EAAa,2BAGbC,EAAe,CACxBC,KAAMN,EACNO,MARyB,EASzBC,MARyB,EASzBC,SAR4B,GAS5BC,UAAWN,EACX,QAAAO,GACI,OAAOC,KAAKN,IAChB,EACA,OAAAO,CAAQC,GACJ,MAAMC,EAAYC,GAAMA,EAAEC,MAAM,KAAKC,IAAIC,SAClCC,EAAIC,EAAIC,GAAMP,EAASH,KAAKN,OAC5BiB,EAAIC,EAAIC,GAAMV,EAASD,GAE9B,OAAIM,IAAOG,EAAWH,EAAKG,EACvBF,IAAOG,EAAWH,EAAKG,EACpBF,EAAKG,CAChB,GAIkB,oBAAXC,SACPA,OAAOC,KAAOD,OAAOC,MAAQ,CAAA,EAC7BD,OAAOC,KAAK3B,QAAUA,EACtB0B,OAAOC,KAAKtB,aAAeA,EAG3BqB,OAAOC,KAAKC,QAAU5B"}
@@ -1,2 +1,2 @@
1
- "use strict";const O="2.2.65",o="2026-03-09T05:18:47.130Z",i={full:O,major:2,minor:2,revision:65,buildTime:o,toString(){return this.full},compare(O){const o=O=>O.split(".").map(Number),[i,r,t]=o(this.full),[e,n,s]=o(O);return i!==e?i-e:r!==n?r-n:t-s}};"undefined"!=typeof window&&(window.MOJO=window.MOJO||{},window.MOJO.VERSION=O,window.MOJO.VERSION_INFO=i,window.MOJO.version=O),exports.BUILD_TIME=o,exports.VERSION=O,exports.VERSION_INFO=i,exports.VERSION_MAJOR=2,exports.VERSION_MINOR=2,exports.VERSION_REVISION=65;
2
- //# sourceMappingURL=version-Cn26llLs.js.map
1
+ "use strict";const O="2.2.67",o="2026-03-16T00:07:53.940Z",i={full:O,major:2,minor:2,revision:67,buildTime:o,toString(){return this.full},compare(O){const o=O=>O.split(".").map(Number),[i,r,t]=o(this.full),[e,n,s]=o(O);return i!==e?i-e:r!==n?r-n:t-s}};"undefined"!=typeof window&&(window.MOJO=window.MOJO||{},window.MOJO.VERSION=O,window.MOJO.VERSION_INFO=i,window.MOJO.version=O),exports.BUILD_TIME=o,exports.VERSION=O,exports.VERSION_INFO=i,exports.VERSION_MAJOR=2,exports.VERSION_MINOR=2,exports.VERSION_REVISION=67;
2
+ //# sourceMappingURL=version-BdfRyQDm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version-Cn26llLs.js","sources":["../../src/version.js"],"sourcesContent":["/**\n * MOJO Framework Version Information\n * Auto-generated on 2026-03-09T05:18:47.130Z\n */\n\nexport const VERSION = '2.2.65';\nexport const VERSION_MAJOR = 2;\nexport const VERSION_MINOR = 2;\nexport const VERSION_REVISION = 65;\nexport const BUILD_TIME = '2026-03-09T05:18:47.130Z';\n\n// Version object for easy access\nexport const VERSION_INFO = {\n full: VERSION,\n major: VERSION_MAJOR,\n minor: VERSION_MINOR,\n revision: VERSION_REVISION,\n buildTime: BUILD_TIME,\n toString() {\n return this.full;\n },\n compare(other) {\n const parseVer = (v) => v.split('.').map(Number);\n const [a1, a2, a3] = parseVer(this.full);\n const [b1, b2, b3] = parseVer(other);\n\n if (a1 !== b1) return a1 - b1;\n if (a2 !== b2) return a2 - b2;\n return a3 - b3;\n }\n};\n\n// Make version globally available if in browser\nif (typeof window !== 'undefined') {\n window.MOJO = window.MOJO || {};\n window.MOJO.VERSION = VERSION;\n window.MOJO.VERSION_INFO = VERSION_INFO;\n\n // Also add to MOJO.version for convenience\n window.MOJO.version = VERSION;\n}\n\nexport default VERSION_INFO;\n"],"names":["VERSION","BUILD_TIME","VERSION_INFO","full","major","minor","revision","buildTime","toString","this","compare","other","parseVer","v","split","map","Number","a1","a2","a3","b1","b2","b3","window","MOJO","version"],"mappings":"aAKY,MAACA,EAAU,SAIVC,EAAa,2BAGbC,EAAe,CACxBC,KAAMH,EACNI,MARyB,EASzBC,MARyB,EASzBC,SAR4B,GAS5BC,UAAWN,EACX,QAAAO,GACI,OAAOC,KAAKN,IAChB,EACA,OAAAO,CAAQC,GACJ,MAAMC,EAAYC,GAAMA,EAAEC,MAAM,KAAKC,IAAIC,SAClCC,EAAIC,EAAIC,GAAMP,EAASH,KAAKN,OAC5BiB,EAAIC,EAAIC,GAAMV,EAASD,GAE9B,OAAIM,IAAOG,EAAWH,EAAKG,EACvBF,IAAOG,EAAWH,EAAKG,EACpBF,EAAKG,CAChB,GAIkB,oBAAXC,SACPA,OAAOC,KAAOD,OAAOC,MAAQ,CAAA,EAC7BD,OAAOC,KAAKxB,QAAUA,EACtBuB,OAAOC,KAAKtB,aAAeA,EAG3BqB,OAAOC,KAAKC,QAAUzB,uFAjCG,wBACA,2BACG"}
1
+ {"version":3,"file":"version-BdfRyQDm.js","sources":["../../src/version.js"],"sourcesContent":["/**\n * MOJO Framework Version Information\n * Auto-generated on 2026-03-16T00:07:53.940Z\n */\n\nexport const VERSION = '2.2.67';\nexport const VERSION_MAJOR = 2;\nexport const VERSION_MINOR = 2;\nexport const VERSION_REVISION = 67;\nexport const BUILD_TIME = '2026-03-16T00:07:53.940Z';\n\n// Version object for easy access\nexport const VERSION_INFO = {\n full: VERSION,\n major: VERSION_MAJOR,\n minor: VERSION_MINOR,\n revision: VERSION_REVISION,\n buildTime: BUILD_TIME,\n toString() {\n return this.full;\n },\n compare(other) {\n const parseVer = (v) => v.split('.').map(Number);\n const [a1, a2, a3] = parseVer(this.full);\n const [b1, b2, b3] = parseVer(other);\n\n if (a1 !== b1) return a1 - b1;\n if (a2 !== b2) return a2 - b2;\n return a3 - b3;\n }\n};\n\n// Make version globally available if in browser\nif (typeof window !== 'undefined') {\n window.MOJO = window.MOJO || {};\n window.MOJO.VERSION = VERSION;\n window.MOJO.VERSION_INFO = VERSION_INFO;\n\n // Also add to MOJO.version for convenience\n window.MOJO.version = VERSION;\n}\n\nexport default VERSION_INFO;\n"],"names":["VERSION","BUILD_TIME","VERSION_INFO","full","major","minor","revision","buildTime","toString","this","compare","other","parseVer","v","split","map","Number","a1","a2","a3","b1","b2","b3","window","MOJO","version"],"mappings":"aAKY,MAACA,EAAU,SAIVC,EAAa,2BAGbC,EAAe,CACxBC,KAAMH,EACNI,MARyB,EASzBC,MARyB,EASzBC,SAR4B,GAS5BC,UAAWN,EACX,QAAAO,GACI,OAAOC,KAAKN,IAChB,EACA,OAAAO,CAAQC,GACJ,MAAMC,EAAYC,GAAMA,EAAEC,MAAM,KAAKC,IAAIC,SAClCC,EAAIC,EAAIC,GAAMP,EAASH,KAAKN,OAC5BiB,EAAIC,EAAIC,GAAMV,EAASD,GAE9B,OAAIM,IAAOG,EAAWH,EAAKG,EACvBF,IAAOG,EAAWH,EAAKG,EACpBF,EAAKG,CAChB,GAIkB,oBAAXC,SACPA,OAAOC,KAAOD,OAAOC,MAAQ,CAAA,EAC7BD,OAAOC,KAAKxB,QAAUA,EACtBuB,OAAOC,KAAKtB,aAAeA,EAG3BqB,OAAOC,KAAKC,QAAUzB,uFAjCG,wBACA,2BACG"}