@busy-app/busy-lib 0.14.1 → 0.14.2
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.
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8062,7 +8062,7 @@ if ("SharedWorkerGlobalScope" in self) {
|
|
|
8062
8062
|
handleCommand(f.data, u);
|
|
8063
8063
|
};
|
|
8064
8064
|
}
|
|
8065
|
-
`;function pe(e){return new SharedWorker("data:text/javascript;charset=utf-8,"+encodeURIComponent(de),{type:"module",name:e==null?void 0:e.name})}const E=class E{constructor(n,t){l(this,"addr");l(this,"token");l(this,"isBinary");l(this,"connectTimeout");l(this,"dataTimeout");l(this,"worker",null);l(this,"connectionTimer",null);l(this,"dataTimer",null);l(this,"_status");l(this,"dataCallback");l(this,"rawDataCallback");l(this,"errorCallback");l(this,"statusCallback");this.addr=n.addr||"",this.token=n.token,this.isBinary=n.isBinary??!0,this.connectTimeout=(t==null?void 0:t.timeout)??5e3,this.dataTimeout=(t==null?void 0:t.dataTimeout)??15e3,this._status={main:{status:d.IDLE},connection:{status:m.DISCONNECTED},auth:{status:v.UNAUTHENTICATED},data:{status:g.NONE},worker:{status:b.OFF}}}get status(){return this._status}resolveProtocol(n){let t=n.trim();if(t.startsWith("https://"))return t.replace("https://","wss://");if(t.startsWith("http://"))return t.replace("http://","ws://");if(t.startsWith("wss://")||t.startsWith("ws://"))return t;let r="ws:";return typeof window<"u"&&window.location.protocol==="https:"&&(r="wss:"),`${r}//${t}`}start({dataCallback:n,rawDataCallback:t,errorCallback:r,statusCallback:i}){if(this._status.main.status===d.STARTING||this._status.main.status===d.RUNNING){const o=new h(c.STREAM_ALREADY_STARTED,"StateStream is already running. Call stop() before starting again.");if(i&&i({...this._status,main:{...this._status.main,lastError:o}}),r)r(o);else throw o;return}this.dataCallback=n,this.rawDataCallback=t,this.errorCallback=r,this.statusCallback=i,this.updateStatusComponent("main",{status:d.STARTING,lastError:void 0});try{this.ensureWorker(),this.sendCommand({type:"START",addr:this.normalizeUrl(this.addr),token:this.token,isBinary:this.isBinary,mode:this.streamMode}),this.clearConnectionTimer(),this.connectionTimer=setTimeout(()=>{const o=new h(c.CONNECTION_TIMEOUT,`Connection timed out after ${this.connectTimeout}ms`);this.mapErrorToStatus(o),this.errorCallback&&this.errorCallback(o),this.stop()},this.connectTimeout)}catch(o){const s=o instanceof h?o:new h(c.UNKNOWN_ERROR,String(o));this.errorCallback&&this.errorCallback(s)}}stop(){this.clearConnectionTimer(),this.clearDataTimer(),!(this._status.main.status===d.IDLE||this._status.main.status===d.STOPPED)&&(this.updateStatusComponent("main",{status:d.STOPPED}),this.updateStatusComponent("connection",{status:m.DISCONNECTED}),this.sendCommand({type:"STOP"}),this.clearCallbacks())}destroy(){this.stop(),this.worker&&(this.worker.terminate?this.worker.terminate():"close"in this.worker.port&&this.worker.port.close(),this.worker=null)}clearCallbacks(){this.dataCallback=void 0,this.rawDataCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0}sendToken(n){this.token=n,this.sendCommand({type:"UPDATE_TOKEN",token:n})}sendCommand(n){this.worker&&this.worker.port.postMessage(n)}ensureWorker(){if(this.worker||typeof window>"u")return;const n=btoa(this.addr);try{if(this.updateStatusComponent("worker",{status:b.INITIALIZING,lastError:void 0}),window.SharedWorker){const t=new pe({name:n});this.worker={port:t.port},t.port.onmessage=r=>{this.handleWorkerMessage(r.data)},t.port.start()}else{const t=new ce;this.worker={port:t,terminate:()=>t.terminate()},t.onmessage=r=>{this.handleWorkerMessage(r.data)}}this.updateStatusComponent("worker",{status:b.READY})}catch(t){const r=new h(c.WORKER_INIT_FAILED,`Failed to initialize worker: ${String(t)}`);throw this.updateStatusComponent("worker",{status:b.ERROR,lastError:r}),this.updateStatusComponent("main",{status:d.FAILED,lastError:r}),r}}handleWorkerMessage(n){switch(n.type){case"DATA":this.resetDataTimer(),this.dataCallback&&this.dataCallback(this.normalizeState(n.data));break;case"RAW_DATA":this.resetDataTimer(),this.rawDataCallback&&this.rawDataCallback(n.data);break;case"CONNECTED":this.clearConnectionTimer(),this.updateStatusComponent("connection",{status:m.CONNECTED}),this.streamMode==="local"&&this.updateStatusComponent("main",{status:d.RUNNING});break;case"STATUS_UPDATE":n.connection&&this.updateStatusComponent("connection",{status:n.connection}),n.auth&&(this.updateStatusComponent("auth",{status:n.auth}),n.auth===v.AUTHENTICATED&&this.updateStatusComponent("main",{status:d.RUNNING}));break;case"ERROR":{this.clearConnectionTimer();const t=new h(n.code,n.message,n.data);this.mapErrorToStatus(t),this.errorCallback&&this.errorCallback(t);break}case"TOKEN_EXPIRED":this.updateStatusComponent("auth",{status:v.AUTHENTICATING}),this.handleTokenExpiredInternal();break;case"DISCONNECTED":this.updateStatusComponent("connection",{status:m.DISCONNECTED});break}}mapErrorToStatus(n){const t=n.code;(t===c.CONNECTION_FAILED||t===c.CONNECTION_LOST||t===c.RECONNECT_FAILED||t===c.CONNECTION_TIMEOUT)&&(this.updateStatusComponent("connection",{status:m.DISCONNECTED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.AUTH_FAILED||t===c.AUTH_REFRESH_FAILED)&&(this.updateStatusComponent("auth",{status:v.FAILED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.DEVICE_ERROR||t===c.DECODE_ERROR)&&this.updateStatusComponent("main",{lastError:n})}updateStatusComponent(n,t){const r=this._status[n];this._status[n]={...r,...t},this.statusCallback&&this.statusCallback({...this._status})}clearConnectionTimer(){this.connectionTimer&&(clearTimeout(this.connectionTimer),this.connectionTimer=null)}resetDataTimer(){this.clearDataTimer(),this._status.data.status!==g.ACTIVE?this.updateStatusComponent("data",{status:g.ACTIVE,lastActivity:Date.now()}):this._status.data.lastActivity=Date.now(),this.dataTimer=setTimeout(()=>{this.updateStatusComponent("data",{status:g.STALE})},this.dataTimeout)}clearDataTimer(){this.dataTimer&&(clearTimeout(this.dataTimer),this.dataTimer=null)}normalizeState(n){let t,r;"bar_id"in n&&"state"in n?(t=n.state,r=n.bar_id):t=n;let i=t.updates;return i&&(i=i.map(o=>{const s=Object.keys(o).find(u=>o[u]!=null);return{...o,state:s}})),{...t,updates:i,bar_id:r}}async handleTokenExpiredInternal(){const n=this.addr;let t=E.tokenRefreshPromises.get(n);if(!t&&this.onTokenExpired&&(t=(async()=>{try{const i=this.onTokenExpired();return i instanceof Promise?await i:""}finally{E.tokenRefreshPromises.delete(n)}})(),E.tokenRefreshPromises.set(n,t)),t){const r=await t;r&&this.sendToken(r)}}};l(E,"tokenRefreshPromises",new Map);let O=E;class he extends O{constructor(t={},r){let i=t.addr;i||(typeof window<"u"?i=window.location.origin:i="10.0.4.20");super({isBinary:!0,...t,addr:i},r);l(this,"streamMode","local")}normalizeUrl(t){const r=this.resolveProtocol(t),i=new URL(r);return(i.pathname==="/"||!i.pathname)&&(i.pathname="/api/status/ws"),i.toString()}}class ye extends O{constructor(t,r){super({isBinary:!1,...t},r);l(this,"streamMode","remote");l(this,"tokenProvider");this.tokenProvider=t.tokenProvider}subscribe(t){this.sendCommand({type:"SUBSCRIBE",guid:t})}unsubscribe(t){this.sendCommand({type:"UNSUBSCRIBE",guid:t})}normalizeUrl(t){return this.resolveProtocol(t)}onTokenExpired(){if(this.tokenProvider)return this.tokenProvider().then(t=>(this.sendToken(t),t)).catch(t=>{const r=`Failed to refresh token: ${t.message}`;throw this.errorCallback&&this.errorCallback(new h(c.AUTH_REFRESH_FAILED,r)),t})}}exports.BSB_State=void 0;(e=>{(n=>{n[n.DISCHARGING=0]="DISCHARGING",n[n.CHARGING=1]="CHARGING",n[n.CHARGED=2]="CHARGED"})(e.BatteryStatus||(e.BatteryStatus={})),(n=>{n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTING=2]="DISCONNECTING",n[n.RECONNECTING=3]="RECONNECTING"})(e.WifiConnectionStatus||(e.WifiConnectionStatus={})),(n=>{n[n.UNKNOWN=0]="UNKNOWN",n[n.OPEN=1]="OPEN",n[n.WPA=2]="WPA",n[n.WPA2=3]="WPA2",n[n.WEP=4]="WEP",n[n.WPA_WPA2=5]="WPA_WPA2",n[n.WPA3=6]="WPA3",n[n.WPA2_WPA3=7]="WPA2_WPA3"})(e.WifiSecurity||(e.WifiSecurity={})),(n=>{n[n.DHCP=0]="DHCP",n[n.STATIC=1]="STATIC"})(e.IpConfigurationMethod||(e.IpConfigurationMethod={})),(n=>{n[n.IPV4=0]="IPV4",n[n.IPV6=1]="IPV6"})(e.IpProtocol||(e.IpProtocol={})),(n=>{n[n.NEVER_STARTED=0]="NEVER_STARTED",n[n.STARTED=1]="STARTED",n[n.COMPLETED_SUCCESSFULLY=2]="COMPLETED_SUCCESSFULLY",n[n.FAILED=3]="FAILED"})(e.MatterCommissioningStatus||(e.MatterCommissioningStatus={})),(n=>{(t=>{t[t.RESET=0]="RESET",t[t.INITIALIZATION=1]="INITIALIZATION",t[t.READY=2]="READY",t[t.ADVERTISING=3]="ADVERTISING",t[t.CONNECTABLE=4]="CONNECTABLE",t[t.CONNECTED=5]="CONNECTED",t[t.ERROR=6]="ERROR"})(n.ServiceStatus||(n.ServiceStatus={}))})(e.Ble||(e.Ble={}))})(exports.BSB_State||(exports.BSB_State={}));exports.BSB_Update=void 0;(e=>{(n=>{n[n.SESSION_START=0]="SESSION_START",n[n.SESSION_STOP=1]="SESSION_STOP",n[n.ACTION_BEGIN=2]="ACTION_BEGIN",n[n.ACTION_DONE=3]="ACTION_DONE",n[n.DETAIL_CHANGE=4]="DETAIL_CHANGE",n[n.ACTION_PROGRESS=5]="ACTION_PROGRESS",n[n.EVENT_NONE=6]="EVENT_NONE"})(e.UpdateEvent||(e.UpdateEvent={})),(n=>{n[n.DOWNLOAD=0]="DOWNLOAD",n[n.SHA_VERIFICATION=1]="SHA_VERIFICATION",n[n.UNPACK=2]="UNPACK",n[n.INSTALLATION_PREPARE=3]="INSTALLATION_PREPARE",n[n.INSTALLATION_APPLY=4]="INSTALLATION_APPLY",n[n.ACTION_NONE=5]="ACTION_NONE"})(e.UpdateAction||(e.UpdateAction={})),(n=>{n[n.OK=0]="OK",n[n.BATTERY_LOW=1]="BATTERY_LOW",n[n.BUSY=2]="BUSY",n[n.DOWNLOAD_FAILURE=3]="DOWNLOAD_FAILURE",n[n.DOWNLOAD_ABORT=4]="DOWNLOAD_ABORT",n[n.SHA_MISMATCH=5]="SHA_MISMATCH",n[n.UNPACK_CREATE_STAGING_DIRECTORY_FAILURE=6]="UNPACK_CREATE_STAGING_DIRECTORY_FAILURE",n[n.UNPACK_ARCHIVE_OPEN_FAILURE=7]="UNPACK_ARCHIVE_OPEN_FAILURE",n[n.UNPACK_ARCHIVE_UNPACK_FAILURE=8]="UNPACK_ARCHIVE_UNPACK_FAILURE",n[n.INSTALLATION_PREPARE_MANIFEST_NOT_FOUND=9]="INSTALLATION_PREPARE_MANIFEST_NOT_FOUND",n[n.INSTALLATION_PREPARE_MANIFEST_INVALID=10]="INSTALLATION_PREPARE_MANIFEST_INVALID",n[n.INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE=11]="INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE",n[n.INSTALLATION_PREPARE_POINTER_SETUP_FAILURE=12]="INSTALLATION_PREPARE_POINTER_SETUP_FAILURE",n[n.UNKNOWN_FAILURE=13]="UNKNOWN_FAILURE"})(e.UpdateStatus||(e.UpdateStatus={})),(n=>{n[n.NOT_AVAILABLE=0]="NOT_AVAILABLE",n[n.FAILURE=1]="FAILURE",n[n.IDLE=2]="IDLE"})(e.CheckError||(e.CheckError={}))})(exports.BSB_Update||(exports.BSB_Update={}));exports.BSB_Frame=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.RUN_LENGTH=1]="RUN_LENGTH",n[n.DEFLATE=2]="DEFLATE",n[n.DEFLATE_RUN_LENGTH=3]="DEFLATE_RUN_LENGTH"})(e.Encoding||(e.Encoding={})),(n=>{n[n.RGB888=0]="RGB888",n[n.L8=1]="L8",n[n.L4=2]="L4"})(e.PixelFormat||(e.PixelFormat={})),(n=>{n[n.FRONT=0]="FRONT",n[n.BACK=1]="BACK"})(e.Screen||(e.Screen={}))})(exports.BSB_Frame||(exports.BSB_Frame={}));exports.BSB_Util=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.GZIP=1]="GZIP"})(e.Compression||(e.Compression={}))})(exports.BSB_Util||(exports.BSB_Util={}));exports.BSB_Input=void 0;(e=>{(n=>{n[n.OK=0]="OK",n[n.BACK=1]="BACK",n[n.START=2]="START"})(e.Button||(e.Button={})),(n=>{n[n.PRESS=0]="PRESS",n[n.RELEASE=1]="RELEASE"})(e.ButtonAction||(e.ButtonAction={})),(n=>{n[n.BUSY=0]="BUSY",n[n.CUSTOM=1]="CUSTOM",n[n.OFF=2]="OFF",n[n.APPS=3]="APPS",n[n.SETTINGS=4]="SETTINGS"})(e.SwitchPosition||(e.SwitchPosition={}))})(exports.BSB_Input||(exports.BSB_Input={}));exports.BSB_Error=void 0;(e=>{(n=>{n[n.RESOURCE_LIMIT=0]="RESOURCE_LIMIT"})(e.Cause||(e.Cause={})),(n=>{n[n.FATAL=0]="FATAL",n[n.ERROR=1]="ERROR",n[n.WARNING=2]="WARNING"})(e.Severity||(e.Severity={}))})(exports.BSB_Error||(exports.BSB_Error={}));const _=class _{constructor(){l(this,"gl",null);l(this,"program",null);l(this,"texture",null);l(this,"vs",`#version 300 es
|
|
8065
|
+
`;function pe(e){return new SharedWorker("data:text/javascript;charset=utf-8,"+encodeURIComponent(de),{type:"module",name:e==null?void 0:e.name})}const E=class E{constructor(n,t){l(this,"addr");l(this,"token");l(this,"isBinary");l(this,"connectTimeout");l(this,"dataTimeout");l(this,"worker",null);l(this,"connectionTimer",null);l(this,"dataTimer",null);l(this,"_status");l(this,"dataCallback");l(this,"rawDataCallback");l(this,"errorCallback");l(this,"statusCallback");this.addr=n.addr||"",this.token=n.token,this.isBinary=n.isBinary??!0,this.connectTimeout=(t==null?void 0:t.timeout)??5e3,this.dataTimeout=(t==null?void 0:t.dataTimeout)??15e3,this._status={main:{status:d.IDLE},connection:{status:m.DISCONNECTED},auth:{status:v.UNAUTHENTICATED},data:{status:g.NONE},worker:{status:b.OFF}}}get status(){return this._status}resolveProtocol(n){let t=n.trim();if(t.startsWith("https://"))return t.replace("https://","wss://");if(t.startsWith("http://"))return t.replace("http://","ws://");if(t.startsWith("wss://")||t.startsWith("ws://"))return t;let r="ws:";return typeof window<"u"&&window.location.protocol==="https:"&&(r="wss:"),`${r}//${t}`}start({dataCallback:n,rawDataCallback:t,errorCallback:r,statusCallback:i}){if(this._status.main.status===d.STARTING||this._status.main.status===d.RUNNING){const o=new h(c.STREAM_ALREADY_STARTED,"StateStream is already running. Call stop() before starting again.");if(i&&i({...this._status,main:{...this._status.main,lastError:o}}),r)r(o);else throw o;return}this.dataCallback=n,this.rawDataCallback=t,this.errorCallback=r,this.statusCallback=i,this.updateStatusComponent("main",{status:d.STARTING,lastError:void 0});try{this.ensureWorker(),this.sendCommand({type:"START",addr:this.normalizeUrl(this.addr),token:this.token,isBinary:this.isBinary,mode:this.streamMode}),this.clearConnectionTimer(),this.connectionTimer=setTimeout(()=>{const o=new h(c.CONNECTION_TIMEOUT,`Connection timed out after ${this.connectTimeout}ms`);this.mapErrorToStatus(o),this.errorCallback&&this.errorCallback(o),this.stop()},this.connectTimeout)}catch(o){const s=o instanceof h?o:new h(c.UNKNOWN_ERROR,String(o));this.errorCallback&&this.errorCallback(s)}}stop(){this.clearConnectionTimer(),this.clearDataTimer(),!(this._status.main.status===d.IDLE||this._status.main.status===d.STOPPED)&&(this.updateStatusComponent("main",{status:d.STOPPED}),this.updateStatusComponent("connection",{status:m.DISCONNECTED}),this.sendCommand({type:"STOP"}),this.clearCallbacks())}destroy(){this.stop(),this.worker&&(this.worker.terminate?this.worker.terminate():"close"in this.worker.port&&this.worker.port.close(),this.worker=null)}clearCallbacks(){this.dataCallback=void 0,this.rawDataCallback=void 0,this.errorCallback=void 0,this.statusCallback=void 0}sendToken(n){this.token=n,this.sendCommand({type:"UPDATE_TOKEN",token:n})}sendCommand(n){this.worker&&this.worker.port.postMessage(n)}ensureWorker(){if(this.worker||typeof window>"u")return;const n=btoa(this.addr);try{if(this.updateStatusComponent("worker",{status:b.INITIALIZING,lastError:void 0}),window.SharedWorker){const t=new pe({name:n});this.worker={port:t.port},t.port.onmessage=r=>{this.handleWorkerMessage(r.data)},t.port.start()}else{const t=new ce;this.worker={port:t,terminate:()=>t.terminate()},t.onmessage=r=>{this.handleWorkerMessage(r.data)}}this.updateStatusComponent("worker",{status:b.READY})}catch(t){const r=new h(c.WORKER_INIT_FAILED,`Failed to initialize worker: ${String(t)}`);throw this.updateStatusComponent("worker",{status:b.ERROR,lastError:r}),this.updateStatusComponent("main",{status:d.FAILED,lastError:r}),r}}handleWorkerMessage(n){switch(n.type){case"DATA":this.resetDataTimer(),this.dataCallback&&this.dataCallback(this.normalizeState(n.data));break;case"RAW_DATA":this.resetDataTimer(),this.rawDataCallback&&this.rawDataCallback(n.data);break;case"CONNECTED":this.clearConnectionTimer(),this.updateStatusComponent("connection",{status:m.CONNECTED}),this.streamMode==="local"&&this.updateStatusComponent("main",{status:d.RUNNING});break;case"STATUS_UPDATE":n.connection&&this.updateStatusComponent("connection",{status:n.connection}),n.auth&&(this.updateStatusComponent("auth",{status:n.auth}),n.auth===v.AUTHENTICATED&&this.updateStatusComponent("main",{status:d.RUNNING}));break;case"ERROR":{this.clearConnectionTimer();const t=new h(n.code,n.message,n.data);this.mapErrorToStatus(t),this.errorCallback&&this.errorCallback(t);break}case"TOKEN_EXPIRED":this.updateStatusComponent("auth",{status:v.AUTHENTICATING}),this.handleTokenExpiredInternal();break;case"DISCONNECTED":this.updateStatusComponent("connection",{status:m.DISCONNECTED});break}}mapErrorToStatus(n){const t=n.code;(t===c.CONNECTION_FAILED||t===c.CONNECTION_LOST||t===c.RECONNECT_FAILED||t===c.CONNECTION_TIMEOUT)&&(this.updateStatusComponent("connection",{status:m.DISCONNECTED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.AUTH_FAILED||t===c.AUTH_REFRESH_FAILED)&&(this.updateStatusComponent("auth",{status:v.FAILED,lastError:n}),this.updateStatusComponent("main",{status:d.FAILED,lastError:n})),(t===c.DEVICE_ERROR||t===c.DECODE_ERROR)&&this.updateStatusComponent("main",{lastError:n})}updateStatusComponent(n,t){const r=this._status[n];this._status[n]={...r,...t},this.statusCallback&&this.statusCallback({...this._status})}clearConnectionTimer(){this.connectionTimer&&(clearTimeout(this.connectionTimer),this.connectionTimer=null)}resetDataTimer(){this.clearDataTimer(),this._status.data.status!==g.ACTIVE?this.updateStatusComponent("data",{status:g.ACTIVE,lastActivity:Date.now()}):this._status.data.lastActivity=Date.now(),this.dataTimer=setTimeout(()=>{this.updateStatusComponent("data",{status:g.STALE})},this.dataTimeout)}clearDataTimer(){this.dataTimer&&(clearTimeout(this.dataTimer),this.dataTimer=null)}normalizeState(n){let t,r;"bar_id"in n&&"state"in n?(t=n.state,r=n.bar_id):t=n;let i=t.updates;return i&&(i=i.map(o=>{const s=Object.keys(o).find(u=>o[u]!=null);return{...o,state:s}})),{...t,updates:i,bar_id:r}}async handleTokenExpiredInternal(){const n=this.addr;let t=E.tokenRefreshPromises.get(n);if(!t&&this.onTokenExpired&&(t=(async()=>{try{const i=this.onTokenExpired();return i instanceof Promise?await i:""}finally{E.tokenRefreshPromises.delete(n)}})(),E.tokenRefreshPromises.set(n,t)),t){const r=await t;r&&this.sendToken(r)}}};l(E,"tokenRefreshPromises",new Map);let O=E;class he extends O{constructor(t={},r){let i=t.addr;i||(typeof window<"u"?i=window.location.origin:i="10.0.4.20");super({isBinary:!0,...t,addr:i},r);l(this,"streamMode","local")}normalizeUrl(t){const r=this.resolveProtocol(t),i=new URL(r);return(i.pathname==="/"||!i.pathname)&&(i.pathname="/api/status/ws"),this.token&&i.searchParams.set("x-api-token",this.token),i.toString()}}class ye extends O{constructor(t,r){super({isBinary:!1,...t},r);l(this,"streamMode","remote");l(this,"tokenProvider");this.tokenProvider=t.tokenProvider}subscribe(t){this.sendCommand({type:"SUBSCRIBE",guid:t})}unsubscribe(t){this.sendCommand({type:"UNSUBSCRIBE",guid:t})}normalizeUrl(t){return this.resolveProtocol(t)}onTokenExpired(){if(this.tokenProvider)return this.tokenProvider().then(t=>(this.sendToken(t),t)).catch(t=>{const r=`Failed to refresh token: ${t.message}`;throw this.errorCallback&&this.errorCallback(new h(c.AUTH_REFRESH_FAILED,r)),t})}}exports.BSB_State=void 0;(e=>{(n=>{n[n.DISCHARGING=0]="DISCHARGING",n[n.CHARGING=1]="CHARGING",n[n.CHARGED=2]="CHARGED"})(e.BatteryStatus||(e.BatteryStatus={})),(n=>{n[n.CONNECTED=0]="CONNECTED",n[n.CONNECTING=1]="CONNECTING",n[n.DISCONNECTING=2]="DISCONNECTING",n[n.RECONNECTING=3]="RECONNECTING"})(e.WifiConnectionStatus||(e.WifiConnectionStatus={})),(n=>{n[n.UNKNOWN=0]="UNKNOWN",n[n.OPEN=1]="OPEN",n[n.WPA=2]="WPA",n[n.WPA2=3]="WPA2",n[n.WEP=4]="WEP",n[n.WPA_WPA2=5]="WPA_WPA2",n[n.WPA3=6]="WPA3",n[n.WPA2_WPA3=7]="WPA2_WPA3"})(e.WifiSecurity||(e.WifiSecurity={})),(n=>{n[n.DHCP=0]="DHCP",n[n.STATIC=1]="STATIC"})(e.IpConfigurationMethod||(e.IpConfigurationMethod={})),(n=>{n[n.IPV4=0]="IPV4",n[n.IPV6=1]="IPV6"})(e.IpProtocol||(e.IpProtocol={})),(n=>{n[n.NEVER_STARTED=0]="NEVER_STARTED",n[n.STARTED=1]="STARTED",n[n.COMPLETED_SUCCESSFULLY=2]="COMPLETED_SUCCESSFULLY",n[n.FAILED=3]="FAILED"})(e.MatterCommissioningStatus||(e.MatterCommissioningStatus={})),(n=>{(t=>{t[t.RESET=0]="RESET",t[t.INITIALIZATION=1]="INITIALIZATION",t[t.READY=2]="READY",t[t.ADVERTISING=3]="ADVERTISING",t[t.CONNECTABLE=4]="CONNECTABLE",t[t.CONNECTED=5]="CONNECTED",t[t.ERROR=6]="ERROR"})(n.ServiceStatus||(n.ServiceStatus={}))})(e.Ble||(e.Ble={}))})(exports.BSB_State||(exports.BSB_State={}));exports.BSB_Update=void 0;(e=>{(n=>{n[n.SESSION_START=0]="SESSION_START",n[n.SESSION_STOP=1]="SESSION_STOP",n[n.ACTION_BEGIN=2]="ACTION_BEGIN",n[n.ACTION_DONE=3]="ACTION_DONE",n[n.DETAIL_CHANGE=4]="DETAIL_CHANGE",n[n.ACTION_PROGRESS=5]="ACTION_PROGRESS",n[n.EVENT_NONE=6]="EVENT_NONE"})(e.UpdateEvent||(e.UpdateEvent={})),(n=>{n[n.DOWNLOAD=0]="DOWNLOAD",n[n.SHA_VERIFICATION=1]="SHA_VERIFICATION",n[n.UNPACK=2]="UNPACK",n[n.INSTALLATION_PREPARE=3]="INSTALLATION_PREPARE",n[n.INSTALLATION_APPLY=4]="INSTALLATION_APPLY",n[n.ACTION_NONE=5]="ACTION_NONE"})(e.UpdateAction||(e.UpdateAction={})),(n=>{n[n.OK=0]="OK",n[n.BATTERY_LOW=1]="BATTERY_LOW",n[n.BUSY=2]="BUSY",n[n.DOWNLOAD_FAILURE=3]="DOWNLOAD_FAILURE",n[n.DOWNLOAD_ABORT=4]="DOWNLOAD_ABORT",n[n.SHA_MISMATCH=5]="SHA_MISMATCH",n[n.UNPACK_CREATE_STAGING_DIRECTORY_FAILURE=6]="UNPACK_CREATE_STAGING_DIRECTORY_FAILURE",n[n.UNPACK_ARCHIVE_OPEN_FAILURE=7]="UNPACK_ARCHIVE_OPEN_FAILURE",n[n.UNPACK_ARCHIVE_UNPACK_FAILURE=8]="UNPACK_ARCHIVE_UNPACK_FAILURE",n[n.INSTALLATION_PREPARE_MANIFEST_NOT_FOUND=9]="INSTALLATION_PREPARE_MANIFEST_NOT_FOUND",n[n.INSTALLATION_PREPARE_MANIFEST_INVALID=10]="INSTALLATION_PREPARE_MANIFEST_INVALID",n[n.INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE=11]="INSTALLATION_PREPARE_SESSION_CONFIG_SETUP_FAILURE",n[n.INSTALLATION_PREPARE_POINTER_SETUP_FAILURE=12]="INSTALLATION_PREPARE_POINTER_SETUP_FAILURE",n[n.UNKNOWN_FAILURE=13]="UNKNOWN_FAILURE"})(e.UpdateStatus||(e.UpdateStatus={})),(n=>{n[n.NOT_AVAILABLE=0]="NOT_AVAILABLE",n[n.FAILURE=1]="FAILURE",n[n.IDLE=2]="IDLE"})(e.CheckError||(e.CheckError={}))})(exports.BSB_Update||(exports.BSB_Update={}));exports.BSB_Frame=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.RUN_LENGTH=1]="RUN_LENGTH",n[n.DEFLATE=2]="DEFLATE",n[n.DEFLATE_RUN_LENGTH=3]="DEFLATE_RUN_LENGTH"})(e.Encoding||(e.Encoding={})),(n=>{n[n.RGB888=0]="RGB888",n[n.L8=1]="L8",n[n.L4=2]="L4"})(e.PixelFormat||(e.PixelFormat={})),(n=>{n[n.FRONT=0]="FRONT",n[n.BACK=1]="BACK"})(e.Screen||(e.Screen={}))})(exports.BSB_Frame||(exports.BSB_Frame={}));exports.BSB_Util=void 0;(e=>{(n=>{n[n.PLAIN=0]="PLAIN",n[n.GZIP=1]="GZIP"})(e.Compression||(e.Compression={}))})(exports.BSB_Util||(exports.BSB_Util={}));exports.BSB_Input=void 0;(e=>{(n=>{n[n.OK=0]="OK",n[n.BACK=1]="BACK",n[n.START=2]="START"})(e.Button||(e.Button={})),(n=>{n[n.PRESS=0]="PRESS",n[n.RELEASE=1]="RELEASE"})(e.ButtonAction||(e.ButtonAction={})),(n=>{n[n.BUSY=0]="BUSY",n[n.CUSTOM=1]="CUSTOM",n[n.OFF=2]="OFF",n[n.APPS=3]="APPS",n[n.SETTINGS=4]="SETTINGS"})(e.SwitchPosition||(e.SwitchPosition={}))})(exports.BSB_Input||(exports.BSB_Input={}));exports.BSB_Error=void 0;(e=>{(n=>{n[n.RESOURCE_LIMIT=0]="RESOURCE_LIMIT"})(e.Cause||(e.Cause={})),(n=>{n[n.FATAL=0]="FATAL",n[n.ERROR=1]="ERROR",n[n.WARNING=2]="WARNING"})(e.Severity||(e.Severity={}))})(exports.BSB_Error||(exports.BSB_Error={}));const _=class _{constructor(){l(this,"gl",null);l(this,"program",null);l(this,"texture",null);l(this,"vs",`#version 300 es
|
|
8066
8066
|
in vec2 position;
|
|
8067
8067
|
out vec2 v_uv;
|
|
8068
8068
|
void main() {
|
package/dist/index.d.ts
CHANGED
|
@@ -1901,6 +1901,7 @@ export declare class LocalStateStream extends BaseStateStream {
|
|
|
1901
1901
|
constructor(options?: LocalStreamOptions, config?: StreamConfig);
|
|
1902
1902
|
/**
|
|
1903
1903
|
* Normalizes the address to use ws:// protocol and adds default path if missing.
|
|
1904
|
+
* Adds x-api-token query parameter if token is provided.
|
|
1904
1905
|
*/
|
|
1905
1906
|
protected normalizeUrl(addr: string): string;
|
|
1906
1907
|
}
|
package/dist/index.js
CHANGED
|
@@ -9924,10 +9924,11 @@ class Te extends O {
|
|
|
9924
9924
|
}
|
|
9925
9925
|
/**
|
|
9926
9926
|
* Normalizes the address to use ws:// protocol and adds default path if missing.
|
|
9927
|
+
* Adds x-api-token query parameter if token is provided.
|
|
9927
9928
|
*/
|
|
9928
9929
|
normalizeUrl(t) {
|
|
9929
9930
|
const r = this.resolveProtocol(t), i = new URL(r);
|
|
9930
|
-
return (i.pathname === "/" || !i.pathname) && (i.pathname = "/api/status/ws"), i.toString();
|
|
9931
|
+
return (i.pathname === "/" || !i.pathname) && (i.pathname = "/api/status/ws"), this.token && i.searchParams.set("x-api-token", this.token), i.toString();
|
|
9931
9932
|
}
|
|
9932
9933
|
}
|
|
9933
9934
|
class Oe extends O {
|