@lmjs/core 2.8.4 → 2.8.6

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.
@@ -1,7 +1,7 @@
1
1
  {
2
- "version": "2.8.4",
2
+ "version": "2.8.6",
3
3
  "files": {
4
- "lm.js": "sha384-LIZhfq7UGNrpf+s0EqREAMeAeGbkaBZqzI5L/sr9xDhRqb28WDA4qQ6/xZ5mfWOO",
5
- "lm.full.js": "sha384-Bf5RyIidxGRzKqJkA3eqWK1dXSBrxnpjDhfrnrNF9X0zWdKXnAPouKwt+KBKgcaX"
4
+ "lm.js": "sha384-/ihLLVb9Uf/u9zAlEF7cMYnjAq/MTO0PkOhvWKVBOJM+Oy/btkwof4i57OZAXq3d",
5
+ "lm.full.js": "sha384-euTUtPp9f5WUF03EATEMDhgO3ArfTjWTVjMYRtlhb0RgW/RaI8L0SD6H+fpJI9wX"
6
6
  }
7
7
  }
package/cdn/lm.full.js CHANGED
@@ -107,7 +107,7 @@ var LM_BUILD=0;var LM_VERSION="dev";var _lmBuildCache=0;function _lmVersionOf(bu
107
107
  <ul style="list-style-type: none;">
108
108
  `;const pagings=this.pagination(this.config.page);if(pagings.hasStart){if(self.config.page>2)html+=`<li page="1"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`}if(pagings.hasPrev){if(self.config.page>1)html+=`<li page="`+(pagings.current-1>0?pagings.current-1:1)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`}if(pagings.totalpages>1)pagings.first.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.totalpages>5)html+=`<li>`+pagings.middle+`</li>`;if(pagings.totalpages>1)pagings.last.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.hasNext){if(self.config.page!=pagings.totalpages)html+=`<li page="`+(pagings.current*1+1<pagings.totalpages?pagings.current*1+1:pagings.totalpages)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`}if(pagings.hasEnd){if(self.config.page!=pagings.totalpages)html+=`<li page="`+pagings.totalpages+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`}html+=`</ul>`;html+=`
109
109
  </lmlst-footer>
110
- `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("orientationchange",function(){if(typeof document!=="undefined"&&document.body){fire(document.body,"orientationchange")}})}})();
110
+ `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){var reorienting=false;window.addEventListener("orientationchange",function(e){if(reorienting||e&&e.target!==window)return;if(typeof document!=="undefined"&&document.body){reorienting=true;try{fire(document.body,"orientationchange")}finally{reorienting=false}}})}})();
111
111
 
112
112
  class AbstractWebSocket{constructor(url,connectionTimeout=5e3){this.url=url;this.socket=null;this.reconnectInterval=3e3;this.reconnectTimeout=null;this.connectionTimeout=connectionTimeout;this.connectionTimeoutId=null;this.connected=false;this.messageQueue=[]}connect(){this.socket=new WebSocket(this.url);this.connectionTimeoutId=setTimeout(()=>{this.handleConnectionTimeout()},this.connectionTimeout);this.socket.onopen=()=>{clearTimeout(this.connectionTimeoutId);this.connected=true;this.onOpen();this.processMessageQueue()};this.socket.onmessage=event=>{this.onMessage(event.data)};this.socket.onclose=event=>{clearTimeout(this.connectionTimeoutId);this.connected=false;this.onClose(event.code);this.reconnect()};this.socket.onerror=error=>{clearTimeout(this.connectionTimeoutId);this.onError(error)}}send(message){cl("Sending ",message);if(this.connected){this.socket.send(message)}else{this.messageQueue.push(message);console.error("WebSocket is not open. Unable to send message.")}}processMessageQueue(){while(this.messageQueue.length>0){const message=this.messageQueue.shift();cl("Sending From Queue ",message);this.socket.send(message)}}handleConnectionTimeout(){this.socket.close()}disconnect(){if(this.socket){this.socket.close()}clearTimeout(this.reconnectTimeout)}onOpen(){}onMessage(message){}onClose(code){}onError(error){}reconnect(){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=setTimeout(()=>{this.connect()},this.reconnectInterval)}}class MyWebSocket extends AbstractWebSocket{constructor(url){super(url)}onOpen(){super.onOpen()}onMessage(message){super.onMessage(message)}onClose(code){super.onClose(code)}onError(error){super.onError(error)}}class Nuclear{_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{return false});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}class _Ticker{id="";tick=1e3;duration=1e4;data={};status="created";user=void 0;channel=void 0;_cbs={};constructor(obj,channel,user){this.id=obj.id;this.tick=obj?.tick??1e3;this.duration=obj?.duration??1e4;this.data=obj?.data??{};this.user=user;this.channel=channel;this.user.id=this.user.id;this.init();return this}init(opts,lstnrs){let t=this.tick;let d=this.duration;let data=this.data;if(opts){if(opts.hasOwnProperty("tick"))t=opts.tick;if(opts.hasOwnProperty("duration"))d=opts.duration;if(opts.hasOwnProperty("data"))data=opts.data}this.user.nuke.emit("subscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,data:{tick:t,duration:d,data}});if(!this.user.nuke._tickers.hasOwnProperty(this.channel.id))this.user.nuke._tickers[this.channel.id]={};this.user.nuke._tickers[this.channel.id][this.id]=this;if(!lstnrs){var self=this;this.on("create.class",function(e){self.status="created"});this.on("start.class",function(e){self.status="started"});this.on("tick.class",function(e){self.status="started"});this.on("pause.class",function(e){self.status="paused"});this.on("finish.class",function(e){self.status="finished"})}}start(){if(this.status=="started"){setError(null,`This ticker is already started`);return this}if(this.status=="finished"){setError(null,`This ticker is finished`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"start"})}pause(){if(this.status=="paused"){setError(null,`This ticker is already paused`);return this}if(this.status!="started"){setError(null,`This ticker is not started yet!`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"pause"})}restart(opts){if(this.status!="finished"){setError(null,`This ticker is not finished yet!`);return this}this.init(opts,true)}delete(){this.user.nuke.emit("unsubscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"delete"})}extend(t){this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"extend",data:{time:t}})}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}}class _Channel{id="/";user=void 0;type="room";_cbs={};constructor(id,type,user){this.id=id;this.type=type;this.user=user;this.user.id=this.user.id??"Guest";return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}join(){this.user.nuke.emit("subscribe",{type:this.type,channel:this.id,user:this.user.id});if(!this.user.nuke._chnls.hasOwnProperty(this.user.id))this.user.nuke._chnls[this.user.id]={};this.user.nuke._chnls[this.user.id][this.id]=this}leave(){this.user.nuke.emit("unsubscribe",{type:this.type,channel:this.id,user:this.user.id,ev:"leave"});if(this.user.nuke._chnls.hasOwnProperty(this.user.id)){delete this.user.nuke._chnls[this.user.id][this.id]}}broadcast(ev,options){this.user.nuke.emit("broadcast",{type:"room",channel:this.id,user:this.user.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}off(e){if(e=="connect")return this;if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}createTicker(obj){if(!this.user.nuke._tickers.hasOwnProperty(this.id)){this.user.nuke._tickers[this.id]={}}let t=new _Ticker(obj,this,this.user);return t}getTicker(id){this.user.nuke.emit("get",{type:"ticker",channel:this.id,user:this.user.id,ticker:id})}}class _User{id="";nuke=void 0;_cbs={};constructor(id,nuke){this.id=id;this.nuke=nuke;this.init();return this}init(){this.nuke.emit("subscribe",{type:"user",channel:this.id,user:this.id});if(!this.nuke._users.hasOwnProperty("/"+this.id))this.nuke._users["/"+this.id]=this}on(e,cb){if(this.nuke._users["/"+this.id]._cbs.hasOwnProperty(e)){this.nuke._users["/"+this.id]._cbs[e].push(cb)}else this.nuke._users["/"+this.id]._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}broadcast(ev,options){this.nuke.emit("broadcast",{type:"user",channel:this.id,user:this.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}_broadcastToAll(IDs,e,d,t){this.nuke.emit("broadcast",{type:t=="u"?"user":"room",user:this.id,ev:e,includeMe:d["includeMe"]??true,data:d["data"],...t=="u"?{users:IDs.join(",")}:{channels:IDs.join(",")}})}broadcastToUsers(uIDs,e,d){this._broadcastToAll(uIDs,e,d,"u")}broadcastToChannels(cIDs,e,d){this._broadcastToAll(cIDs,e,d,"c")}unsubscribe(c){if(this.nuke._chnls.hasOwnProperty(this.id)){if(this.nuke._chnls[this.id].hasOwnProperty(c))this.nuke._chnls[this.id][c].leave()}}subscribe(e,cb){if(!this.nuke._chnls.hasOwnProperty(this.id)){this.nuke._chnls[this.id]={}}let channel=new _Channel(e,"room",this);channel.join();return channel}destroy(){this._cbs={};if(this.nuke._chnls.hasOwnProperty(this.id)){let chnls=this.nuke._chnls[this.id];for(const chnl in chnls){this.unsubscribe(chnl)}}}}class _Live{_chnls={};_users={};_tickers={};_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}createUser(id){let user=new _User(id,this);return user}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;if(_s.ready()||_s.connecting()){return}this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("for")){let t=data["type"]??"room";let ev=data["ev"]??"message";const customEvent=new CustomEvent(ev,{detail:data["payload"]});customEvent.data=data["payload"];let payload=data["payload"];if(payload.hasOwnProperty("user")){if(t=="user"){_s._users[data["for"]].trigger(ev,customEvent)}else if(t=="room")_s._chnls[payload.user.id][data["for"]].trigger(ev,customEvent);else if(t=="ticker"){_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev,customEvent);_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev+".class",customEvent)}}}else if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}let LIVE;let Nuke;LIVE=new _Live("wss://www.beaapis.com/");Nuke=new Nuclear(_beaTn||typeof _lmStatic!=="undefined"?void 0:(window.location.protocol==="https:"?"wss://":"ws://")+window.location.hostname+(window.location.port?":"+window.location.port:""));let _ovcD,_vcD;function syncViewFiles(){Nuke.emit("getfiles",{},function(e){var _files=e.data;let views=_files["views"];let layouts=_files["layouts"];_vcD=_files;if(!_ovcD)_ovcD=clone(_vcD);else{for(var key in views){if(_ovcD["views"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["views"][key]),clone(views[key]))){cl("Changed the view "+atob(key));let n=atob(key).split("src/views/").join("").split(".view").join("");let nodes=getURLNodes();_ovcD["views"][key]=views[key];cl("view",n,atob(key));if(n.indexOf("widgets/")===0){let changedWidgetName=n.split("widgets/").join("");for(let regionName in _vt.Widgets){if(_vt.Widgets[regionName]._resolvedFile===changedWidgetName){_vt.Widgets[regionName]._resolvedFile=void 0}}renderView(nodes[0],null,View.props??{})}else if(nodes[0]==n){renderView(nodes[0],null,View.props??{})}else{renderView(nodes[0],null,View.props??{})}}}}for(var key in layouts){if(_ovcD["layouts"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["layouts"][key]),clone(layouts[key]))){cl("Changed the layout "+atob(key));let n=atob(key).split("src/layouts/").join("").split(".layout").join("");let nodes=getURLNodes();_ovcD["layouts"][key]=layouts[key];cl("layout",n,atob(key));renderView(n,false,{},"layouts")}}}let tpls=_files["tpls"]||{};let tplsChanged=!deepCompare(clone(_ovcD["tpls"]||{}),clone(tpls));if(tplsChanged){_ovcD["tpls"]=tpls;let nodes=getURLNodes();renderView(nodes[0],null,View.props??{})}}})}Nuke.on("connect",function(){if(_beaTn){Nuke.emit("get_uniquer",{beajsToken:_beaTn,uniquer:globals.uniquer},function(e){let d=e.data;let data=d.uniquer;globals.uniquer=data})}else if(typeof _lmStatic==="undefined"){syncViewFiles()}});Nuke.on("files-changed",function(){if(!_beaTn&&typeof _lmStatic==="undefined")syncViewFiles()});var API={get:function(u,d,h,a,opts){return this.req(u,d,h,"GET",a,opts)},put:function(u,d,h,a,opts){return this.req(u,d,h,"PUT",a,opts)},post:function(u,d,h,a,opts){return this.req(u,d,h,"POST",a,opts)},delete:function(u,d,h,a,opts){return this.req(u,d,h,"DELETE",a,opts)},patch:function(u,d,h,a,opts){return this.req(u,d,h,"PATCH",a,opts)},req:function(u,d,h,m,a,opts,_prom){if(!opts)opts={full:false,progress:true};let prog=opts.hasOwnProperty("progress")?opts.progress:true;let full=opts.hasOwnProperty("full")?opts.full:false;let prom=_prom?_prom:defer();try{return prom}finally{if(Nuke&&Nuke._ws&&Nuke._ws.readyState==1&&(_beaTn?globals.uniquer>0:true)){if(prog){_gn=0;_work()}Nuke.emit("request",{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,data:d},function(e){if(prog){_gn=0;barSet(1,200)}var r=e.data;prom.resolve(r)})}else{if(_beaTn&&_beaTn!=""){$.ajax({"url":"https://www.beaapis.com/req",headers:{},type:"POST",dataType:"json",data:{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,_beaTn,data:d},cache:false,success:function(r,s){prom.resolve(r)},error:function(){prom.reject("error")}})}else{setTimeout(()=>{this.req(u,d,h,m,a,opts,prom)},_tickTime)}}}}};
113
113
 
package/cdn/lm.js CHANGED
@@ -90,7 +90,7 @@ var LM_BUILD=0;var LM_VERSION="dev";var _lmBuildCache=0;function _lmVersionOf(bu
90
90
  <ul style="list-style-type: none;">
91
91
  `;const pagings=this.pagination(this.config.page);if(pagings.hasStart){if(self.config.page>2)html+=`<li page="1"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`}if(pagings.hasPrev){if(self.config.page>1)html+=`<li page="`+(pagings.current-1>0?pagings.current-1:1)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`}if(pagings.totalpages>1)pagings.first.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.totalpages>5)html+=`<li>`+pagings.middle+`</li>`;if(pagings.totalpages>1)pagings.last.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.hasNext){if(self.config.page!=pagings.totalpages)html+=`<li page="`+(pagings.current*1+1<pagings.totalpages?pagings.current*1+1:pagings.totalpages)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`}if(pagings.hasEnd){if(self.config.page!=pagings.totalpages)html+=`<li page="`+pagings.totalpages+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`}html+=`</ul>`;html+=`
92
92
  </lmlst-footer>
93
- `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("orientationchange",function(){if(typeof document!=="undefined"&&document.body){fire(document.body,"orientationchange")}})}})();
93
+ `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){var reorienting=false;window.addEventListener("orientationchange",function(e){if(reorienting||e&&e.target!==window)return;if(typeof document!=="undefined"&&document.body){reorienting=true;try{fire(document.body,"orientationchange")}finally{reorienting=false}}})}})();
94
94
 
95
95
  class AbstractWebSocket{constructor(url,connectionTimeout=5e3){this.url=url;this.socket=null;this.reconnectInterval=3e3;this.reconnectTimeout=null;this.connectionTimeout=connectionTimeout;this.connectionTimeoutId=null;this.connected=false;this.messageQueue=[]}connect(){this.socket=new WebSocket(this.url);this.connectionTimeoutId=setTimeout(()=>{this.handleConnectionTimeout()},this.connectionTimeout);this.socket.onopen=()=>{clearTimeout(this.connectionTimeoutId);this.connected=true;this.onOpen();this.processMessageQueue()};this.socket.onmessage=event=>{this.onMessage(event.data)};this.socket.onclose=event=>{clearTimeout(this.connectionTimeoutId);this.connected=false;this.onClose(event.code);this.reconnect()};this.socket.onerror=error=>{clearTimeout(this.connectionTimeoutId);this.onError(error)}}send(message){cl("Sending ",message);if(this.connected){this.socket.send(message)}else{this.messageQueue.push(message);console.error("WebSocket is not open. Unable to send message.")}}processMessageQueue(){while(this.messageQueue.length>0){const message=this.messageQueue.shift();cl("Sending From Queue ",message);this.socket.send(message)}}handleConnectionTimeout(){this.socket.close()}disconnect(){if(this.socket){this.socket.close()}clearTimeout(this.reconnectTimeout)}onOpen(){}onMessage(message){}onClose(code){}onError(error){}reconnect(){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=setTimeout(()=>{this.connect()},this.reconnectInterval)}}class MyWebSocket extends AbstractWebSocket{constructor(url){super(url)}onOpen(){super.onOpen()}onMessage(message){super.onMessage(message)}onClose(code){super.onClose(code)}onError(error){super.onError(error)}}class Nuclear{_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{return false});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}class _Ticker{id="";tick=1e3;duration=1e4;data={};status="created";user=void 0;channel=void 0;_cbs={};constructor(obj,channel,user){this.id=obj.id;this.tick=obj?.tick??1e3;this.duration=obj?.duration??1e4;this.data=obj?.data??{};this.user=user;this.channel=channel;this.user.id=this.user.id;this.init();return this}init(opts,lstnrs){let t=this.tick;let d=this.duration;let data=this.data;if(opts){if(opts.hasOwnProperty("tick"))t=opts.tick;if(opts.hasOwnProperty("duration"))d=opts.duration;if(opts.hasOwnProperty("data"))data=opts.data}this.user.nuke.emit("subscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,data:{tick:t,duration:d,data}});if(!this.user.nuke._tickers.hasOwnProperty(this.channel.id))this.user.nuke._tickers[this.channel.id]={};this.user.nuke._tickers[this.channel.id][this.id]=this;if(!lstnrs){var self=this;this.on("create.class",function(e){self.status="created"});this.on("start.class",function(e){self.status="started"});this.on("tick.class",function(e){self.status="started"});this.on("pause.class",function(e){self.status="paused"});this.on("finish.class",function(e){self.status="finished"})}}start(){if(this.status=="started"){setError(null,`This ticker is already started`);return this}if(this.status=="finished"){setError(null,`This ticker is finished`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"start"})}pause(){if(this.status=="paused"){setError(null,`This ticker is already paused`);return this}if(this.status!="started"){setError(null,`This ticker is not started yet!`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"pause"})}restart(opts){if(this.status!="finished"){setError(null,`This ticker is not finished yet!`);return this}this.init(opts,true)}delete(){this.user.nuke.emit("unsubscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"delete"})}extend(t){this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"extend",data:{time:t}})}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}}class _Channel{id="/";user=void 0;type="room";_cbs={};constructor(id,type,user){this.id=id;this.type=type;this.user=user;this.user.id=this.user.id??"Guest";return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}join(){this.user.nuke.emit("subscribe",{type:this.type,channel:this.id,user:this.user.id});if(!this.user.nuke._chnls.hasOwnProperty(this.user.id))this.user.nuke._chnls[this.user.id]={};this.user.nuke._chnls[this.user.id][this.id]=this}leave(){this.user.nuke.emit("unsubscribe",{type:this.type,channel:this.id,user:this.user.id,ev:"leave"});if(this.user.nuke._chnls.hasOwnProperty(this.user.id)){delete this.user.nuke._chnls[this.user.id][this.id]}}broadcast(ev,options){this.user.nuke.emit("broadcast",{type:"room",channel:this.id,user:this.user.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}off(e){if(e=="connect")return this;if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}createTicker(obj){if(!this.user.nuke._tickers.hasOwnProperty(this.id)){this.user.nuke._tickers[this.id]={}}let t=new _Ticker(obj,this,this.user);return t}getTicker(id){this.user.nuke.emit("get",{type:"ticker",channel:this.id,user:this.user.id,ticker:id})}}class _User{id="";nuke=void 0;_cbs={};constructor(id,nuke){this.id=id;this.nuke=nuke;this.init();return this}init(){this.nuke.emit("subscribe",{type:"user",channel:this.id,user:this.id});if(!this.nuke._users.hasOwnProperty("/"+this.id))this.nuke._users["/"+this.id]=this}on(e,cb){if(this.nuke._users["/"+this.id]._cbs.hasOwnProperty(e)){this.nuke._users["/"+this.id]._cbs[e].push(cb)}else this.nuke._users["/"+this.id]._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}broadcast(ev,options){this.nuke.emit("broadcast",{type:"user",channel:this.id,user:this.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}_broadcastToAll(IDs,e,d,t){this.nuke.emit("broadcast",{type:t=="u"?"user":"room",user:this.id,ev:e,includeMe:d["includeMe"]??true,data:d["data"],...t=="u"?{users:IDs.join(",")}:{channels:IDs.join(",")}})}broadcastToUsers(uIDs,e,d){this._broadcastToAll(uIDs,e,d,"u")}broadcastToChannels(cIDs,e,d){this._broadcastToAll(cIDs,e,d,"c")}unsubscribe(c){if(this.nuke._chnls.hasOwnProperty(this.id)){if(this.nuke._chnls[this.id].hasOwnProperty(c))this.nuke._chnls[this.id][c].leave()}}subscribe(e,cb){if(!this.nuke._chnls.hasOwnProperty(this.id)){this.nuke._chnls[this.id]={}}let channel=new _Channel(e,"room",this);channel.join();return channel}destroy(){this._cbs={};if(this.nuke._chnls.hasOwnProperty(this.id)){let chnls=this.nuke._chnls[this.id];for(const chnl in chnls){this.unsubscribe(chnl)}}}}class _Live{_chnls={};_users={};_tickers={};_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}createUser(id){let user=new _User(id,this);return user}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;if(_s.ready()||_s.connecting()){return}this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("for")){let t=data["type"]??"room";let ev=data["ev"]??"message";const customEvent=new CustomEvent(ev,{detail:data["payload"]});customEvent.data=data["payload"];let payload=data["payload"];if(payload.hasOwnProperty("user")){if(t=="user"){_s._users[data["for"]].trigger(ev,customEvent)}else if(t=="room")_s._chnls[payload.user.id][data["for"]].trigger(ev,customEvent);else if(t=="ticker"){_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev,customEvent);_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev+".class",customEvent)}}}else if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}let LIVE;let Nuke;LIVE=new _Live("wss://www.beaapis.com/");Nuke=new Nuclear(_beaTn||typeof _lmStatic!=="undefined"?void 0:(window.location.protocol==="https:"?"wss://":"ws://")+window.location.hostname+(window.location.port?":"+window.location.port:""));let _ovcD,_vcD;function syncViewFiles(){Nuke.emit("getfiles",{},function(e){var _files=e.data;let views=_files["views"];let layouts=_files["layouts"];_vcD=_files;if(!_ovcD)_ovcD=clone(_vcD);else{for(var key in views){if(_ovcD["views"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["views"][key]),clone(views[key]))){cl("Changed the view "+atob(key));let n=atob(key).split("src/views/").join("").split(".view").join("");let nodes=getURLNodes();_ovcD["views"][key]=views[key];cl("view",n,atob(key));if(n.indexOf("widgets/")===0){let changedWidgetName=n.split("widgets/").join("");for(let regionName in _vt.Widgets){if(_vt.Widgets[regionName]._resolvedFile===changedWidgetName){_vt.Widgets[regionName]._resolvedFile=void 0}}renderView(nodes[0],null,View.props??{})}else if(nodes[0]==n){renderView(nodes[0],null,View.props??{})}else{renderView(nodes[0],null,View.props??{})}}}}for(var key in layouts){if(_ovcD["layouts"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["layouts"][key]),clone(layouts[key]))){cl("Changed the layout "+atob(key));let n=atob(key).split("src/layouts/").join("").split(".layout").join("");let nodes=getURLNodes();_ovcD["layouts"][key]=layouts[key];cl("layout",n,atob(key));renderView(n,false,{},"layouts")}}}let tpls=_files["tpls"]||{};let tplsChanged=!deepCompare(clone(_ovcD["tpls"]||{}),clone(tpls));if(tplsChanged){_ovcD["tpls"]=tpls;let nodes=getURLNodes();renderView(nodes[0],null,View.props??{})}}})}Nuke.on("connect",function(){if(_beaTn){Nuke.emit("get_uniquer",{beajsToken:_beaTn,uniquer:globals.uniquer},function(e){let d=e.data;let data=d.uniquer;globals.uniquer=data})}else if(typeof _lmStatic==="undefined"){syncViewFiles()}});Nuke.on("files-changed",function(){if(!_beaTn&&typeof _lmStatic==="undefined")syncViewFiles()});var API={get:function(u,d,h,a,opts){return this.req(u,d,h,"GET",a,opts)},put:function(u,d,h,a,opts){return this.req(u,d,h,"PUT",a,opts)},post:function(u,d,h,a,opts){return this.req(u,d,h,"POST",a,opts)},delete:function(u,d,h,a,opts){return this.req(u,d,h,"DELETE",a,opts)},patch:function(u,d,h,a,opts){return this.req(u,d,h,"PATCH",a,opts)},req:function(u,d,h,m,a,opts,_prom){if(!opts)opts={full:false,progress:true};let prog=opts.hasOwnProperty("progress")?opts.progress:true;let full=opts.hasOwnProperty("full")?opts.full:false;let prom=_prom?_prom:defer();try{return prom}finally{if(Nuke&&Nuke._ws&&Nuke._ws.readyState==1&&(_beaTn?globals.uniquer>0:true)){if(prog){_gn=0;_work()}Nuke.emit("request",{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,data:d},function(e){if(prog){_gn=0;barSet(1,200)}var r=e.data;prom.resolve(r)})}else{if(_beaTn&&_beaTn!=""){$.ajax({"url":"https://www.beaapis.com/req",headers:{},type:"POST",dataType:"json",data:{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,_beaTn,data:d},cache:false,success:function(r,s){prom.resolve(r)},error:function(){prom.reject("error")}})}else{setTimeout(()=>{this.req(u,d,h,m,a,opts,prom)},_tickTime)}}}}};
96
96
 
@@ -107,7 +107,7 @@ var LM_BUILD=0;var LM_VERSION="dev";var _lmBuildCache=0;function _lmVersionOf(bu
107
107
  <ul style="list-style-type: none;">
108
108
  `;const pagings=this.pagination(this.config.page);if(pagings.hasStart){if(self.config.page>2)html+=`<li page="1"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34m192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4l-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8"></path></svg></li>`}if(pagings.hasPrev){if(self.config.page>1)html+=`<li page="`+(pagings.current-1>0?pagings.current-1:1)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4l-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34"></path></svg></li>`}if(pagings.totalpages>1)pagings.first.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.totalpages>5)html+=`<li>`+pagings.middle+`</li>`;if(pagings.totalpages>1)pagings.last.forEach(function(page){html+=`<li class='pointer `+(self.config.page==page?"active":"")+`' page="`+page+`">`+page+`</li>`});if(pagings.hasNext){if(self.config.page!=pagings.totalpages)html+=`<li page="`+(pagings.current*1+1<pagings.totalpages?pagings.current*1+1:pagings.totalpages)+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.5em" height="1em" viewBox="0 0 256 512" class="op40 vm"><path fill="currentColor" d="m31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34"></path></svg></li>`}if(pagings.hasEnd){if(self.config.page!=pagings.totalpages)html+=`<li page="`+pagings.totalpages+`"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`;else html+=`<li><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" width="0.88em" height="1em" viewBox="0 0 448 512" class="op40 vm"><path fill="currentColor" d="m223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34m-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34"></path></svg></li>`}html+=`</ul>`;html+=`
109
109
  </lmlst-footer>
110
- `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){window.addEventListener("orientationchange",function(){if(typeof document!=="undefined"&&document.body){fire(document.body,"orientationchange")}})}})();
110
+ `}}this.el.html(html);globalWatch()}}refresh(){this.el.trigger("query-list",[this,this.config,"refresh"])}setPage(p){this.config.page=p}setOrder(o){this.config.order=o}setLoading(){this.state="loading";this.render()}setData(data2){this.data=data2;if(data2.length)this.state="loaded";else this.state="empty";this.render()}pagination(currPage){var show=this.config.show;var total=this.config.total;var totalpages=Math.ceil(total/show);if(currPage>totalpages)currPage=totalpages;if(currPage<=0)currPage=1;if(currPage>totalpages)currPage=totalpages;var previousPage=currPage-1;var nextPage=currPage*1+1;let weight=currPage<=totalpages/2?"left":"right";var result={hasStart:false,hasEnd:false,first:[],totalpages,middle:this.config.pagination.middle,last:[],weight,current:currPage};if(totalpages>5){result.hasEnd=true;result.hasStart=true;result.hasPrev=true;result.hasNext=true;if(currPage<totalpages*1-2){if(currPage>1){result.first=[previousPage,currPage,nextPage];result.last=[totalpages*1-1,totalpages]}else{result.first=[currPage,nextPage,nextPage*1+1];result.last=[totalpages*1-1,totalpages]}}else{if(currPage>=totalpages){result.first=[1,2];result.last=[previousPage*1-1,previousPage,currPage]}else if(currPage==totalpages*1-2){result.first=[1,2];result.last=[previousPage,currPage,nextPage,totalpages]}else{result.first=[1,2];result.last=[previousPage,currPage,nextPage]}}}else if(totalpages>0&&totalpages<=5){for(var i2=0;i2<totalpages;i2++){if(weight=="left"&&result.first.length<Math.trunc(totalpages/2)+1){result.first.push(i2*1+1)}else if(weight=="right"&&result.first.length<Math.trunc(totalpages/2)){result.first.push(i2*1+1)}else{result.last.push(i2*1+1)}}}return result}}$("body").on("query-list","lmlst",function(ev,list,config,type2){processEv(ev,$(this),"query",list,config,type2)});$("body").on("click touch","[page]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(el2.attr("page"));list.setLoading();list.el.trigger("query-list",[list,list.config,"page-changed"])});$("body").on("click touch","[order]",function(ev){let el2=$(this);let host=el2.closest("lmlst")[0];if(!host||!host.list)return;let list=host.list;list.setPage(1);list.setOrder({column:el2.attr("column")??null,order:list.config.order.column!=el2.attr("column")?"asc":el2.attr("order")??"asc"});list.setLoading();list.el.trigger("query-list",[list,list.config,"order-changed"])});(function(){var TAP_MAX_MS=400;var TAP_MOVE_PX=12;var DOUBLE_TAP_WINDOW_MS=350;var HOLD_MS=500;var SWIPE_H_THRESHOLD=50;var SWIPE_V_THRESHOLD=50;var SWIPE_MAX_MS=1e3;function swipeThreshold(target,attr,dflt){try{var el2=$(target);var raw=el2.parent().data(attr);if(!raw)raw=el2.data(attr);var n2=parseInt(raw,10);return n2?n2:dflt}catch(e){return dflt}}var active={};var activeCount=0;var pendingSingleTap=null;function fire(target,type2){target.dispatchEvent(new CustomEvent(type2,{bubbles:true,cancelable:true}))}function onPointerDown(e){activeCount++;var state={startX:e.clientX,startY:e.clientY,startTime:Date.now(),target:e.target,moved:false,holdFired:false,wasMultiTouch:activeCount>=2};active[e.pointerId]=state;state.holdTimer=setTimeout(function(){if(state.moved)return;state.holdFired=true;if(state.wasMultiTouch){fire(state.target,"tap2hold")}else{fire(state.target,"taphold");fire(state.target,"clickhold")}},HOLD_MS);fire(e.target,"tapstart")}function onPointerMove(e){var state=active[e.pointerId];if(!state)return;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&Math.sqrt(dx*dx+dy*dy)>TAP_MOVE_PX)state.moved=true;fire(e.target,"tapmove")}function endPointer(e){var state=active[e.pointerId];if(!state)return;clearTimeout(state.holdTimer);state.wasMultiTouch=state.wasMultiTouch||activeCount>=2;delete active[e.pointerId];activeCount=Math.max(0,activeCount-1);return state}function onPointerUp(e){var state=endPointer(e);if(!state)return;fire(e.target,"tapend");var dt=Date.now()-state.startTime;var dx=e.clientX-state.startX,dy=e.clientY-state.startY;if(!state.moved&&!state.holdFired&&dt<TAP_MAX_MS){if(state.wasMultiTouch){fire(state.target,"tap2")}else{fire(state.target,"tap");if(pendingSingleTap&&pendingSingleTap.target===state.target){clearTimeout(pendingSingleTap.timer);pendingSingleTap=null;fire(state.target,"doubletap")}else{if(pendingSingleTap){clearTimeout(pendingSingleTap.timer);fire(pendingSingleTap.target,"singletap")}var pending={target:state.target,timer:setTimeout(function(){fire(pending.target,"singletap");if(pendingSingleTap===pending)pendingSingleTap=null},DOUBLE_TAP_WINDOW_MS)};pendingSingleTap=pending}}return}if(state.moved&&!state.holdFired&&dt<SWIPE_MAX_MS){var hT=swipeThreshold(state.target,"xthreshold",SWIPE_H_THRESHOLD);var vT=swipeThreshold(state.target,"ythreshold",SWIPE_V_THRESHOLD);var dir;if(dy<0&&-dy>vT)dir="swipeup";if(dx>0&&dx>hT)dir="swiperight";if(dy>0&&dy>vT)dir="swipedown";if(dx<0&&-dx>hT)dir="swipeleft";if(dir){fire(state.target,"swipe");fire(state.target,dir);fire(state.target,"swipeend")}}}function onPointerCancel(e){endPointer(e)}if(typeof document!=="undefined"&&document.addEventListener){document.addEventListener("pointerdown",onPointerDown,true);document.addEventListener("pointermove",onPointerMove,true);document.addEventListener("pointerup",onPointerUp,true);document.addEventListener("pointercancel",onPointerCancel,true)}if(typeof window!=="undefined"&&window.addEventListener){var reorienting=false;window.addEventListener("orientationchange",function(e){if(reorienting||e&&e.target!==window)return;if(typeof document!=="undefined"&&document.body){reorienting=true;try{fire(document.body,"orientationchange")}finally{reorienting=false}}})}})();
111
111
 
112
112
  class AbstractWebSocket{constructor(url,connectionTimeout=5e3){this.url=url;this.socket=null;this.reconnectInterval=3e3;this.reconnectTimeout=null;this.connectionTimeout=connectionTimeout;this.connectionTimeoutId=null;this.connected=false;this.messageQueue=[]}connect(){this.socket=new WebSocket(this.url);this.connectionTimeoutId=setTimeout(()=>{this.handleConnectionTimeout()},this.connectionTimeout);this.socket.onopen=()=>{clearTimeout(this.connectionTimeoutId);this.connected=true;this.onOpen();this.processMessageQueue()};this.socket.onmessage=event=>{this.onMessage(event.data)};this.socket.onclose=event=>{clearTimeout(this.connectionTimeoutId);this.connected=false;this.onClose(event.code);this.reconnect()};this.socket.onerror=error=>{clearTimeout(this.connectionTimeoutId);this.onError(error)}}send(message){cl("Sending ",message);if(this.connected){this.socket.send(message)}else{this.messageQueue.push(message);console.error("WebSocket is not open. Unable to send message.")}}processMessageQueue(){while(this.messageQueue.length>0){const message=this.messageQueue.shift();cl("Sending From Queue ",message);this.socket.send(message)}}handleConnectionTimeout(){this.socket.close()}disconnect(){if(this.socket){this.socket.close()}clearTimeout(this.reconnectTimeout)}onOpen(){}onMessage(message){}onClose(code){}onError(error){}reconnect(){clearTimeout(this.reconnectTimeout);this.reconnectTimeout=setTimeout(()=>{this.connect()},this.reconnectInterval)}}class MyWebSocket extends AbstractWebSocket{constructor(url){super(url)}onOpen(){super.onOpen()}onMessage(message){super.onMessage(message)}onClose(code){super.onClose(code)}onError(error){super.onError(error)}}class Nuclear{_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{return false});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}class _Ticker{id="";tick=1e3;duration=1e4;data={};status="created";user=void 0;channel=void 0;_cbs={};constructor(obj,channel,user){this.id=obj.id;this.tick=obj?.tick??1e3;this.duration=obj?.duration??1e4;this.data=obj?.data??{};this.user=user;this.channel=channel;this.user.id=this.user.id;this.init();return this}init(opts,lstnrs){let t=this.tick;let d=this.duration;let data=this.data;if(opts){if(opts.hasOwnProperty("tick"))t=opts.tick;if(opts.hasOwnProperty("duration"))d=opts.duration;if(opts.hasOwnProperty("data"))data=opts.data}this.user.nuke.emit("subscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,data:{tick:t,duration:d,data}});if(!this.user.nuke._tickers.hasOwnProperty(this.channel.id))this.user.nuke._tickers[this.channel.id]={};this.user.nuke._tickers[this.channel.id][this.id]=this;if(!lstnrs){var self=this;this.on("create.class",function(e){self.status="created"});this.on("start.class",function(e){self.status="started"});this.on("tick.class",function(e){self.status="started"});this.on("pause.class",function(e){self.status="paused"});this.on("finish.class",function(e){self.status="finished"})}}start(){if(this.status=="started"){setError(null,`This ticker is already started`);return this}if(this.status=="finished"){setError(null,`This ticker is finished`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"start"})}pause(){if(this.status=="paused"){setError(null,`This ticker is already paused`);return this}if(this.status!="started"){setError(null,`This ticker is not started yet!`);return this}this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"pause"})}restart(opts){if(this.status!="finished"){setError(null,`This ticker is not finished yet!`);return this}this.init(opts,true)}delete(){this.user.nuke.emit("unsubscribe",{type:"ticker",ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"delete"})}extend(t){this.user.nuke.emit("ticker",{ticker:this.id,channel:this.channel.id,user:this.user.id,ev:"extend",data:{time:t}})}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}}class _Channel{id="/";user=void 0;type="room";_cbs={};constructor(id,type,user){this.id=id;this.type=type;this.user=user;this.user.id=this.user.id??"Guest";return this}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}join(){this.user.nuke.emit("subscribe",{type:this.type,channel:this.id,user:this.user.id});if(!this.user.nuke._chnls.hasOwnProperty(this.user.id))this.user.nuke._chnls[this.user.id]={};this.user.nuke._chnls[this.user.id][this.id]=this}leave(){this.user.nuke.emit("unsubscribe",{type:this.type,channel:this.id,user:this.user.id,ev:"leave"});if(this.user.nuke._chnls.hasOwnProperty(this.user.id)){delete this.user.nuke._chnls[this.user.id][this.id]}}broadcast(ev,options){this.user.nuke.emit("broadcast",{type:"room",channel:this.id,user:this.user.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}off(e){if(e=="connect")return this;if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}on(e,cb){let myRef2=document.createElement("live");myRef2.dataset["cb"]=cb;document.body.append(myRef2);if(this._cbs.hasOwnProperty(e)){this._cbs[e].push(cb)}else this._cbs[e]=[cb];return this}createTicker(obj){if(!this.user.nuke._tickers.hasOwnProperty(this.id)){this.user.nuke._tickers[this.id]={}}let t=new _Ticker(obj,this,this.user);return t}getTicker(id){this.user.nuke.emit("get",{type:"ticker",channel:this.id,user:this.user.id,ticker:id})}}class _User{id="";nuke=void 0;_cbs={};constructor(id,nuke){this.id=id;this.nuke=nuke;this.init();return this}init(){this.nuke.emit("subscribe",{type:"user",channel:this.id,user:this.id});if(!this.nuke._users.hasOwnProperty("/"+this.id))this.nuke._users["/"+this.id]=this}on(e,cb){if(this.nuke._users["/"+this.id]._cbs.hasOwnProperty(e)){this.nuke._users["/"+this.id]._cbs[e].push(cb)}else this.nuke._users["/"+this.id]._cbs[e]=[cb];return this}off(e){if(this._cbs.hasOwnProperty(e))delete this._cbs[e];return this}broadcast(ev,options){this.nuke.emit("broadcast",{type:"user",channel:this.id,user:this.id,ev,includeMe:options?.includeMe??true,data:options?.data??{}})}trigger(e,customEvent){if(this._cbs.hasOwnProperty(e)){for(let i=0;i<this._cbs[e].length;i++){const cb=this._cbs[e][i];cb(customEvent)}}return this}_broadcastToAll(IDs,e,d,t){this.nuke.emit("broadcast",{type:t=="u"?"user":"room",user:this.id,ev:e,includeMe:d["includeMe"]??true,data:d["data"],...t=="u"?{users:IDs.join(",")}:{channels:IDs.join(",")}})}broadcastToUsers(uIDs,e,d){this._broadcastToAll(uIDs,e,d,"u")}broadcastToChannels(cIDs,e,d){this._broadcastToAll(cIDs,e,d,"c")}unsubscribe(c){if(this.nuke._chnls.hasOwnProperty(this.id)){if(this.nuke._chnls[this.id].hasOwnProperty(c))this.nuke._chnls[this.id][c].leave()}}subscribe(e,cb){if(!this.nuke._chnls.hasOwnProperty(this.id)){this.nuke._chnls[this.id]={}}let channel=new _Channel(e,"room",this);channel.join();return channel}destroy(){this._cbs={};if(this.nuke._chnls.hasOwnProperty(this.id)){let chnls=this.nuke._chnls[this.id];for(const chnl in chnls){this.unsubscribe(chnl)}}}}class _Live{_chnls={};_users={};_tickers={};_iter=0;reconnectAttempts=0;timeoutInterval=4e3;cbs={};_cbs={};lstnrs={};_ws;srvr=void 0;constructor(srvr){this.srvr=srvr;this.init();return this}on(e,cb){if(!this.lstnrs.hasOwnProperty(e))this.lstnrs[e]=[];this.lstnrs[e].push(cb);if(e=="open"&&this._ws?.readyState==1){this.trigger("open",this._ws)}return this}off(e){if(e=="connect")return this;if(this.lstnrs.hasOwnProperty(e))delete this.lstnrs[e];return this}createUser(id){let user=new _User(id,this);return user}subscribe(e,cb){return this.on(e,cb)}unsubscribe(e,cb){return this.off(e,cb)}trigger(n,e){if(this.lstnrs.hasOwnProperty(n)){for(let x=0;x<this.lstnrs[n].length;x++){this.lstnrs[n][x](e)}}return this}emit(e,data,cb){try{this._iter++;if(cb)this.cbs["cb_"+this._iter]=cb;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}}catch(error){if(_debugMode)cl(error)}return this}_emit(e,data){this._iter++;let prom=defer();this._cbs["cb_"+this._iter]=prom;if(this.ready()){this._ws.send(JSON.stringify({e,payload:data,_iter:this._iter}))}else{this._send(JSON.stringify({e,payload:data,_iter:this._iter}))}return prom}_send(m){let _s=this;setTimeout(function(){if(_s.ready())_s._ws.send(m);else _s._send(m)},500)}ready(){return this._ws!==void 0&&this._ws.readyState==WebSocket.OPEN}connecting(){return this._ws!==void 0&&this._ws.readyState==WebSocket.CONNECTING}init(){var _s=this;if(_s.ready()||_s.connecting()){return}this._ws=new ReconnectingWebSocket(this.srvr?this.srvr:"wss://www.beaapis.com/");this._ws.addEventListener("error",event=>{});this._ws.onopen=function(e){_s.trigger("connect",e);_s.trigger("open",e)};this._ws.onclose=function(e){_s._iter=0;_s.cbs={};_gn=0;barSet(1,200);_s.reconnectAttempts++};this._ws.onmessage=function(e){try{let data=JSON.parse(e.data);if(data.hasOwnProperty("for")){let t=data["type"]??"room";let ev=data["ev"]??"message";const customEvent=new CustomEvent(ev,{detail:data["payload"]});customEvent.data=data["payload"];let payload=data["payload"];if(payload.hasOwnProperty("user")){if(t=="user"){_s._users[data["for"]].trigger(ev,customEvent)}else if(t=="room")_s._chnls[payload.user.id][data["for"]].trigger(ev,customEvent);else if(t=="ticker"){_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev,customEvent);_s._tickers[data["for"]][payload?.ticker?.id].trigger(ev+".class",customEvent)}}}else if(data.hasOwnProperty("e")){let event=data["e"];let iter=data["_iter"];const customEvent=new CustomEvent(event,{detail:data["payload"]});customEvent.data=data["payload"];if(event!="rooms")_s.trigger(event,customEvent);if(_s.cbs["cb_"+iter])_s.cbs["cb_"+iter](customEvent);if(_s._cbs["cb_"+iter])_s._cbs["cb_"+iter].resolve(customEvent)}}catch(e2){if(_debugMode)cl(e2)}};this._ws.onerror=function(e){_gn=0;barSet(1,200)}}}let LIVE;let Nuke;LIVE=new _Live("wss://www.beaapis.com/");Nuke=new Nuclear(_beaTn||typeof _lmStatic!=="undefined"?void 0:(window.location.protocol==="https:"?"wss://":"ws://")+window.location.hostname+(window.location.port?":"+window.location.port:""));let _ovcD,_vcD;function syncViewFiles(){Nuke.emit("getfiles",{},function(e){var _files=e.data;let views=_files["views"];let layouts=_files["layouts"];_vcD=_files;if(!_ovcD)_ovcD=clone(_vcD);else{for(var key in views){if(_ovcD["views"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["views"][key]),clone(views[key]))){cl("Changed the view "+atob(key));let n=atob(key).split("src/views/").join("").split(".view").join("");let nodes=getURLNodes();_ovcD["views"][key]=views[key];cl("view",n,atob(key));if(n.indexOf("widgets/")===0){let changedWidgetName=n.split("widgets/").join("");for(let regionName in _vt.Widgets){if(_vt.Widgets[regionName]._resolvedFile===changedWidgetName){_vt.Widgets[regionName]._resolvedFile=void 0}}renderView(nodes[0],null,View.props??{})}else if(nodes[0]==n){renderView(nodes[0],null,View.props??{})}else{renderView(nodes[0],null,View.props??{})}}}}for(var key in layouts){if(_ovcD["layouts"].hasOwnProperty(key)){if(!deepCompare(clone(_ovcD["layouts"][key]),clone(layouts[key]))){cl("Changed the layout "+atob(key));let n=atob(key).split("src/layouts/").join("").split(".layout").join("");let nodes=getURLNodes();_ovcD["layouts"][key]=layouts[key];cl("layout",n,atob(key));renderView(n,false,{},"layouts")}}}let tpls=_files["tpls"]||{};let tplsChanged=!deepCompare(clone(_ovcD["tpls"]||{}),clone(tpls));if(tplsChanged){_ovcD["tpls"]=tpls;let nodes=getURLNodes();renderView(nodes[0],null,View.props??{})}}})}Nuke.on("connect",function(){if(_beaTn){Nuke.emit("get_uniquer",{beajsToken:_beaTn,uniquer:globals.uniquer},function(e){let d=e.data;let data=d.uniquer;globals.uniquer=data})}else if(typeof _lmStatic==="undefined"){syncViewFiles()}});Nuke.on("files-changed",function(){if(!_beaTn&&typeof _lmStatic==="undefined")syncViewFiles()});var API={get:function(u,d,h,a,opts){return this.req(u,d,h,"GET",a,opts)},put:function(u,d,h,a,opts){return this.req(u,d,h,"PUT",a,opts)},post:function(u,d,h,a,opts){return this.req(u,d,h,"POST",a,opts)},delete:function(u,d,h,a,opts){return this.req(u,d,h,"DELETE",a,opts)},patch:function(u,d,h,a,opts){return this.req(u,d,h,"PATCH",a,opts)},req:function(u,d,h,m,a,opts,_prom){if(!opts)opts={full:false,progress:true};let prog=opts.hasOwnProperty("progress")?opts.progress:true;let full=opts.hasOwnProperty("full")?opts.full:false;let prom=_prom?_prom:defer();try{return prom}finally{if(Nuke&&Nuke._ws&&Nuke._ws.readyState==1&&(_beaTn?globals.uniquer>0:true)){if(prog){_gn=0;_work()}Nuke.emit("request",{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,data:d},function(e){if(prog){_gn=0;barSet(1,200)}var r=e.data;prom.resolve(r)})}else{if(_beaTn&&_beaTn!=""){$.ajax({"url":"https://www.beaapis.com/req",headers:{},type:"POST",dataType:"json",data:{body:{method:m,path:u,api:a??0,headers:h,full},uniquer:globals.uniquer??0,_beaTn,data:d},cache:false,success:function(r,s){prom.resolve(r)},error:function(){prom.reject("error")}})}else{setTimeout(()=>{this.req(u,d,h,m,a,opts,prom)},_tickTime)}}}}};
113
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lmjs/core",
3
- "version": "2.8.4",
3
+ "version": "2.8.6",
4
4
  "description": "LumenJS reactive core runtime — the reactive engine, HTML/JS AST compiler, realtime socket client, and delegated event listeners powering LumenJS applications.",
5
5
  "files": [
6
6
  "dist/",
@@ -5210,9 +5210,14 @@ $("body").on("click touch", "[order]", function (ev) {
5210
5210
  // the real event only ever fires on `window` — can never reach a
5211
5211
  // body-delegated listener without this re-dispatch).
5212
5212
  if (typeof window !== "undefined" && window.addEventListener) {
5213
- window.addEventListener("orientationchange", function () {
5213
+ // Only the browser's own event counts: ours bubbles from body back up to window, and re-firing that one
5214
+ // looped until "Maximum call stack size exceeded" on every phone rotation (2.8.4, fixed 2.8.5).
5215
+ var reorienting = false;
5216
+ window.addEventListener("orientationchange", function (e) {
5217
+ if (reorienting || (e && e.target !== window)) return;
5214
5218
  if (typeof document !== "undefined" && document.body) {
5215
- fire(document.body, "orientationchange");
5219
+ reorienting = true;
5220
+ try { fire(document.body, "orientationchange"); } finally { reorienting = false; }
5216
5221
  }
5217
5222
  });
5218
5223
  }