- Track Needle/MenuScene/dist and Needle/SampleScene/dist for container deploys - Dockerfile copies pre-built dist (no npm in image); rebuild with npm run build before commit - Fix Needle .gitignore: /assets/ so dist/assets is not ignored - Git LFS: track *.wasm; relax .dockerignore so dist is sent as build context Made-with: Cursor
1 line
8.6 KiB
JavaScript
1 line
8.6 KiB
JavaScript
import{n as e}from"./rolldown-runtime.CYVBeYYp.js";var t=class{constructor(e){if(this._retries=0,!Number.isInteger(e)||e<0)throw Error(`Backoff must be a positive integer`);this.backoff=e}get retries(){return this._retries}get current(){return this.backoff}next(){return this._retries++,this.backoff}reset(){this._retries=0}},n=class{constructor(e,t){if(this._retries=0,!Number.isInteger(e)||e<0)throw Error(`Base must be a positive integer or zero`);if(t!==void 0&&(!Number.isInteger(t)||t<0))throw Error(`ExpMax must be a undefined, a positive integer or zero`);this.base=e,this.expMax=t,this.i=0}get retries(){return this._retries}get current(){return this.base*2**this.i}next(){return this._retries++,this.i=this.expMax===void 0?this.i+1:Math.min(this.i+1,this.expMax),this.current}reset(){this._retries=0,this.i=0}},r=class{constructor(e,t,n){if(this.i=0,this._retries=0,e<0)throw Error(`Initial must be a positive number or zero`);if(t<0)throw Error(`Increment must be a positive number or zero`);if(n!==void 0&&n<0)throw Error(`Max must be undefined, a positive number or zero`);if(n!==void 0&&n<e)throw Error(`Max must be undefined or greater than or equal to initial`);this.initial=e,this.increment=t,this.max=n}get retries(){return this._retries}get current(){return this.max===void 0?this.initial+this.increment*this.i:Math.min(this.initial+this.increment*this.i,this.max)}next(){return this._retries++,this.i++,this.current}reset(){this._retries=0,this.i=0}},i=class{constructor(){this.elements=[]}add(e){this.elements.push(e)}clear(){this.elements.length=0}forEach(e){this.elements.forEach(e)}length(){return this.elements.length}isEmpty(){return this.elements.length===0}peek(){return this.elements[0]}read(){return this.elements.shift()}},a=class{constructor(e){if(!Number.isInteger(e)||e<=0)throw Error(`Capacity must be a positive integer`);this.elements=Array(e+1),this.head=0,this.tail=0}add(e){this.elements[this.head]=e,this.head=(this.head+1)%this.elements.length,this.head===this.tail&&(this.tail=(this.tail+1)%this.elements.length)}clear(){this.head=0,this.tail=0}forEach(e){for(let t=this.tail;t!==this.head;t=(t+1)%this.elements.length)e(this.elements[t])}length(){return this.tail===this.head?0:this.tail<this.head?this.head-this.tail:this.elements.length-this.tail+this.head}isEmpty(){return this.head===this.tail}peek(){return this.isEmpty()?void 0:this.elements[this.tail]}read(){let e=this.peek();return e!==void 0&&(this.tail=(this.tail+1)%this.elements.length),e}},o;(function(e){e.open=`open`,e.close=`close`,e.error=`error`,e.message=`message`,e.retry=`retry`,e.reconnect=`reconnect`})(o||={});var s=class{constructor(e,t,n){this._closedByUser=!1,this.handleOpenEvent=e=>this.handleEvent(o.open,e),this.handleErrorEvent=e=>this.handleEvent(o.error,e),this.handleCloseEvent=e=>this.handleEvent(o.close,e),this.handleMessageEvent=e=>this.handleEvent(o.message,e),this._url=e,this._protocols=t,this._options={buffer:n?.buffer,retry:{maxRetries:n?.retry?.maxRetries,instantReconnect:n?.retry?.instantReconnect,backoff:n?.retry?.backoff},listeners:{open:[...n?.listeners?.open??[]],close:[...n?.listeners?.close??[]],error:[...n?.listeners?.error??[]],message:[...n?.listeners?.message??[]],retry:[...n?.listeners?.retry??[]],reconnect:[...n?.listeners?.reconnect??[]]}},this._underlyingWebsocket=this.tryConnect()}get url(){return this._url}get protocols(){return this._protocols}get buffer(){return this._options.buffer}get maxRetries(){return this._options.retry.maxRetries}get instantReconnect(){return this._options.retry.instantReconnect}get backoff(){return this._options.retry.backoff}get closedByUser(){return this._closedByUser}get lastConnection(){return this._lastConnection}get underlyingWebsocket(){return this._underlyingWebsocket}get readyState(){return this._underlyingWebsocket.readyState}get bufferedAmount(){return this._underlyingWebsocket.bufferedAmount}get extensions(){return this._underlyingWebsocket.extensions}get binaryType(){return this._underlyingWebsocket.binaryType}set binaryType(e){this._underlyingWebsocket.binaryType=e}send(e){this.closedByUser||(this._underlyingWebsocket.readyState===this._underlyingWebsocket.OPEN?this._underlyingWebsocket.send(e):this.buffer!==void 0&&this.buffer.add(e))}close(e,t){this.cancelScheduledConnectionRetry(),this._closedByUser=!0,this._underlyingWebsocket.close(e,t)}addEventListener(e,t,n){this._options.listeners[e].push({listener:t,options:n})}removeEventListener(e,t,n){let r=e=>e.listener!==t||e.options!==n;this._options.listeners[e]=this._options.listeners[e].filter(r)}tryConnect(){return this._underlyingWebsocket=new WebSocket(this.url,this.protocols),this._underlyingWebsocket.addEventListener(o.open,this.handleOpenEvent),this._underlyingWebsocket.addEventListener(o.close,this.handleCloseEvent),this._underlyingWebsocket.addEventListener(o.error,this.handleErrorEvent),this._underlyingWebsocket.addEventListener(o.message,this.handleMessageEvent),this._underlyingWebsocket}clearWebsocket(){this._underlyingWebsocket.removeEventListener(o.open,this.handleOpenEvent),this._underlyingWebsocket.removeEventListener(o.close,this.handleCloseEvent),this._underlyingWebsocket.removeEventListener(o.error,this.handleErrorEvent),this._underlyingWebsocket.removeEventListener(o.message,this.handleMessageEvent),this._underlyingWebsocket.close()}dispatchEvent(e,t){let n=this._options.listeners[e],r=[];n.forEach(({listener:e,options:n})=>{e(this,t),(n===void 0||n.once===void 0||!n.once)&&r.push({listener:e,options:n})}),this._options.listeners[e]=r}handleEvent(e,t){switch(e){case o.close:this.dispatchEvent(e,t),this.scheduleConnectionRetryIfNeeded();break;case o.open:if(this.backoff!==void 0&&this._lastConnection!==void 0){let e={retries:this.backoff.retries,lastConnection:new Date(this._lastConnection)},t=new CustomEvent(o.reconnect,{detail:e});this.dispatchEvent(o.reconnect,t),this.backoff.reset()}this._lastConnection=new Date,this.dispatchEvent(e,t),this.sendBufferedData();break;case o.retry:this.dispatchEvent(e,t),this.clearWebsocket(),this.tryConnect();break;default:this.dispatchEvent(e,t);break}}sendBufferedData(){if(this.buffer!==void 0)for(let e=this.buffer.read();e!==void 0;e=this.buffer.read())this.send(e)}scheduleConnectionRetryIfNeeded(){if(this.closedByUser||this.backoff===void 0)return;let e=e=>{let t=new CustomEvent(o.retry,{detail:e});this.handleEvent(o.retry,t)},t={backoff:this._options.retry.instantReconnect===!0?0:this.backoff.next(),retries:this._options.retry.instantReconnect===!0?0:this.backoff.retries,lastConnection:this._lastConnection};(this._options.retry.maxRetries===void 0||t.retries<=this._options.retry.maxRetries)&&(this.retryTimeout=globalThis.setTimeout(()=>e(t),t.backoff))}cancelScheduledConnectionRetry(){globalThis.clearTimeout(this.retryTimeout)}},c=class{constructor(e){this._url=e}get url(){return this._url}withProtocols(e){return this._protocols=e,this}get protocols(){return this._protocols}withMaxRetries(e){return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},this._options?.retry),{maxRetries:e})}),this}get maxRetries(){return this._options?.retry?.maxRetries}withInstantReconnect(e){return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},this._options?.retry),{instantReconnect:e})}),this}get instantReconnect(){return this._options?.retry?.instantReconnect}withBackoff(e){return this._options=Object.assign(Object.assign({},this._options),{retry:Object.assign(Object.assign({},this._options?.retry),{backoff:e})}),this}get backoff(){return this._options?.retry?.backoff}withBuffer(e){return this._options=Object.assign(Object.assign({},this._options),{buffer:e}),this}get buffer(){return this._options?.buffer}onOpen(e,t){return this.addListener(o.open,e,t),this}onClose(e,t){return this.addListener(o.close,e,t),this}onError(e,t){return this.addListener(o.error,e,t),this}onMessage(e,t){return this.addListener(o.message,e,t),this}onRetry(e,t){return this.addListener(o.retry,e,t),this}onReconnect(e,t){return this.addListener(o.reconnect,e,t),this}build(){return new s(this._url,this._protocols,this._options)}addListener(e,t,n){return this._options=Object.assign(Object.assign({},this._options),{listeners:{open:this._options?.listeners?.open??[],close:this._options?.listeners?.close??[],error:this._options?.listeners?.error??[],message:this._options?.listeners?.message??[],retry:this._options?.listeners?.retry??[],reconnect:this._options?.listeners?.reconnect??[],[e]:[...this._options?.listeners?.[e]??[],{listener:t,options:n}]}}),this}},l=e({ArrayQueue:()=>i,ConstantBackoff:()=>t,ExponentialBackoff:()=>n,LinearBackoff:()=>r,RingQueue:()=>a,Websocket:()=>s,WebsocketBuilder:()=>c,WebsocketEvent:()=>o});export{l as t}; |