@busy-app/busy-lib 0.2.0 → 0.3.0
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 +124 -97
- package/dist/index.js +135 -148
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var k=Object.defineProperty;var P=(e,t,i)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var o=(e,t,i)=>P(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("openapi-fetch");function b(e){const t=e.split(".");if(t.length!==4)return!1;for(const i of t){if(i.length===0||i.length>1&&i[0]==="0"||!/^\d+$/.test(i))return!1;const n=Number(i);if(n<0||n>255)return!1}return!0}const I=(e,t)=>{if(typeof FormData<"u"&&e instanceof FormData||typeof Buffer<"u"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(e)||typeof File<"u"&&e instanceof File||typeof Blob<"u"&&e instanceof Blob||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ArrayBuffer<"u"&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return e;let i;return t&&(t instanceof Headers?i=t.get("Content-Type")??t.get("content-type")??void 0:typeof t=="object"&&(i=t["Content-Type"]??t["content-type"]),i==="application/x-www-form-urlencoded")?e&&typeof e=="object"&&!(e instanceof URLSearchParams)?new URLSearchParams(e).toString():String(e):JSON.stringify(e)};let y,w,l=null;async function E(){if(!w){if(!y)throw new Error("getApiVersionFn is not set");l||(l=(async()=>{const e=await y();if(!e.api_semver)throw new Error("Empty API version");w=e.api_semver})().finally(()=>{l=null})),await l}}async function p(e){const n=(e.headers.get("content-type")||"").includes("application/json")?await e.clone().json():await e.clone().text(),s=typeof n=="object"&&n!==null?n.error||n.message:typeof n=="string"?n:void 0;return Object.assign(new Error(s||`HTTP ${e.status} ${e.statusText}`),{status:e.status,statusText:e.statusText,body:n})}let m;function v(e){m=e}const B={async onRequest({request:e,schemaPath:t}){if(t!=="/version"){if(await E(),w)return e.headers.set("X-API-Sem-Ver",w);m&&e.headers.set("X-API-Token",m)}return e},async onResponse({request:e,response:t,options:i,schemaPath:n}){if(t.ok)return t;if(n==="/version")throw await p(t);if(t.status!==405)throw await p(t);w=void 0,await E(),w&&e.headers.set("X-API-Sem-Ver",w);const s=await(i.fetch??fetch)(e);if(s.ok)return s;throw await p(s)}};let r=null;function L(e,t){y=t,r=T({baseUrl:e,bodySerializer:I}),r.use(B)}async function z(e){const{appId:t,fileName:i,file:n}=e;if(!r)throw new Error("API client is not initialized");const{data:s,error:a}=await r.POST("/assets/upload",{params:{query:{app_id:t,file:i}},headers:{"Content-Type":"application/octet-stream"},body:n});if(a)throw a;return s}async function D(e){const{appId:t}=e;if(!r)throw new Error("API client is not initialized");const{data:i,error:n}=await r.DELETE("/assets/upload",{params:{query:{app_id:t}}});if(n)throw n;return i}const O={timeout:5,x:0,y:0,display:"front"};function K(e){return{...O,...e}}async function U(e){const{appId:t,elements:i}=e;if(!r)throw new Error("API client is not initialized");const n=i.map(K),{data:s,error:a}=await r.POST("/display/draw",{body:{app_id:t,elements:n}});if(a)throw a;return s}async function C(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.DELETE("/display/draw");if(t)throw t;return e}async function W(e){const{appId:t,path:i}=e;if(!r)throw new Error("API client is not initialized");const{data:n,error:s}=await r.POST("/audio/play",{params:{query:{app_id:t,path:i}}});if(s)throw s;return n}async function $(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.DELETE("/audio/play");if(t)throw t;return e}async function F(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/enable");if(t)throw t;return e}async function R(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/disable");if(t)throw t;return e}async function V(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/wifi/status");if(t)throw t;return e}async function _(e){if(!r)throw new Error("API client is not initialized");const{data:t,error:i}=await r.POST("/wifi/connect",{body:{ssid:e.ssid,password:e.password,security:e.security,ip_config:{ip_method:e.ipConfig.ipMethod,ip_type:e.ipConfig.ipType,address:e.ipConfig.address,mask:e.ipConfig.mask,gateway:e.ipConfig.gateway}}});if(i)throw i;return t}async function q(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/disconnect");if(t)throw t;return e}async function x(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/wifi/networks");if(t)throw t;return e}async function N(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/forget");if(t)throw t;return e}async function G(e){if(!r)throw new Error("API client is not initialized");const{path:t,file:i}=e,{data:n,error:s}=await r.POST("/storage/write",{params:{query:{path:t}},headers:{"Content-Type":"application/octet-stream"},body:i});if(s)throw s;return n}async function j(e){if(!r)throw new Error("API client is not initialized");const{path:t,asArrayBuffer:i}=e,{data:n,error:s}=await r.GET("/storage/read",{params:{query:{path:t}},parseAs:i?"arrayBuffer":"blob"});if(s)throw s;return n}async function H(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.GET("/storage/list",{params:{query:{path:t}}});if(n)throw n;return i}async function J(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.DELETE("/storage/remove",{params:{query:{path:t}}});if(n)throw n;return i}async function X(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.POST("/storage/mkdir",{params:{query:{path:t}}});if(n)throw n;return i}async function M(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/version");if(t)throw t;return e}async function Q(e){if(!r)throw new Error("API client is not initialized");const{name:t,file:i}=e,{data:n,error:s}=await r.POST("/update",{params:{query:{name:t}},headers:{"Content-Type":"application/octet-stream"},body:i});if(s)throw s;return n}async function Y(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status");if(t)throw t;return e}async function Z(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status/system");if(t)throw t;return e}async function tt(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status/power");if(t)throw t;return e}async function et(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/display/brightness");if(t)throw t;return e}async function it(e){if(!r)throw new Error("API client is not initialized");const{front:t,back:i}=e,n=u=>{if(typeof u=="number"){if(u<0||u>100)throw new Error("Brightness value must be between 0 and 100 or 'auto'");return String(u)}if(u==="auto")return"auto"},s=n(t),a=n(i),{data:c,error:f}=await r.POST("/display/brightness",{params:{query:{front:s,back:a}}});if(f)throw f;return c}async function rt(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/audio/volume");if(t)throw t;return e}async function nt(e){if(!r)throw new Error("API client is not initialized");const{volume:t}=e;if(typeof t!="number"||t<0||t>100)throw new Error("Volume must be a number between 0 and 100");const{data:i,error:n}=await r.POST("/audio/volume",{params:{query:{volume:t}}});if(n)throw n;return i}async function st(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/access");if(t)throw t;return e}async function ot(e){if(!r)throw new Error("API client is not initialized");const{mode:t,key:i}=e;if(!/^\d{4,10}$/.test(String(i)))throw new Error("Key must be a string of 4 to 10 digits");const{data:n,error:s}=await r.POST("/access",{params:{query:{mode:t,key:i}}});if(s)throw s;return n}async function at(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/ble/enable");if(t)throw t;return e}async function ct(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/ble/disable");if(t)throw t;return e}async function ft(e){if(!r)throw new Error("API client is not initialized");const{keyName:t}=e,{data:i,error:n}=await r.POST("/input",{params:{query:{key:t}}});if(n)throw n;return i}class ut{constructor(t="10.0.4.20"){o(this,"ip");o(this,"apiSemver");if(!b(t))throw new Error(`Incorrect IPv4: ${t}`);this.ip=t,this.apiSemver="",L(`http://${this.ip}/api/`,this.getApiVersion.bind(this))}async getApiVersion(){const t=await M();return this.apiSemver=t.api_semver,t}async updateFirmware(t){return await Q(t)}async deviceStatus(){return await Y()}async systemStatus(){return await Z()}async powerStatus(){return await tt()}async uploadAsset(t){return await z(t)}async deleteAssets(t){return await D(t)}async drawDisplay(t){return await U(t)}async clearDisplay(){return await C()}async playSound(t){return await W(t)}async stopSound(){return await $()}async enableWifi(){return await F()}async disableWifi(){return await R()}async statusWifi(){return await V()}async connectWifi(t){return await _(t)}async disconnectWifi(){return await q()}async networksWifi(){return await x()}async forgetWifi(){return await N()}async uploadFile(t){return await G(t)}async downloadFile(t){return await j(t)}async readDirectory(t){return await H(t)}async removeResource(t){return await J(t)}async createDirectory(t){return await X(t)}async getDisplayBrightness(){return await et()}async setDisplayBrightness(t){return await it(t)}async getAudioVolume(){return await rt()}async setAudioVolume(t){return await nt(t)}async getHttpAccess(){return await st()}async setHttpAccess(t){const i=await ot(t);return t.mode==="key"&&t.key&&this.setApiKey(t.key),i}setApiKey(t){v(t)}async enableBle(){return await at()}async disableBle(){return await ct()}async pressButton(t){return await ft(t)}}var h=(e=>(e[e.FRONT=0]="FRONT",e[e.BACK=1]="BACK",e))(h||{});const g=3e3,S=new Set([1001,1006,1012,1013,1014,3008]);function A(e,t){if(t<0||t>=e.length)throw new Error(`Index ${t} is out of bounds (0…${e.length-1})`);const i=e[t];if(i===void 0)throw new Error(`Unexpected undefined at index ${t}`);return i}function wt(e,t){let i=0;const n=e.length,s=[];for(;i<n;){const a=A(e,i);if(i+=1,(a&128)!==0){const c=a&127;for(let f=0;f<c*t;f++)s.push(e[i+f]);i+=c*t}else{const c=a,f=e.slice(i,i+t);for(let u=0;u<c;u++)for(let d=0;d<t;d++)s.push(f[d]);i+=t}}return new Uint8Array(s)}function lt(e){const t=new Uint8Array(e.length*2);let i=0,n=0;for(;i<e.length;){const s=A(e,i),a=s&15,c=s>>4&15;t[n]=a,t[n+1]=c,i+=1,n+=2}return t}class ht{constructor(t){o(this,"connected",!1);o(this,"apiKey");o(this,"apiSemver");o(this,"dataListeners",[]);o(this,"stopListeners",[]);o(this,"errorListeners",[]);o(this,"socket",null);if(this.config=t,!(()=>typeof window<"u"&&typeof window.document<"u"))throw new Error("not browser");t.apiKey&&(this.apiKey=t.apiKey),t.apiSemver&&(this.apiSemver=t.apiSemver)}onData(t){this.dataListeners.push(t)}onStop(t){this.stopListeners.push(t)}onError(t){this.errorListeners.push(t)}emitData(t){for(const i of this.dataListeners)i(t)}emitStop(){for(const t of this.stopListeners)t()}emitError(t){for(const i of this.errorListeners)i(t)}async openWebsocket(){this.socket&&await this.closeWebsocket();let t;if(this.config.mode==="cloud"?t=new URL(`${this.config.domain}/bars/${this.config.idDevice}/ws`):this.config.mode==="local"&&(t=new URL(`${this.config.barUrl}/api/screen/ws`),this.apiKey&&t.searchParams.append("x-api-key",this.apiKey),this.apiSemver&&t.searchParams.append("x-api-sem-ver",this.apiSemver)),!t)throw new Error("The WebSocket URL is not specified");this.socket=new WebSocket(t),this.socket.onopen=()=>{this.socket&&(this.config.mode==="cloud"?this.socket.send(JSON.stringify({token:this.config.token,display:this.config.deviceScreen})):this.config.mode==="local"&&this.socket.send(JSON.stringify({display:this.config.deviceScreen})),this.connected=!0)},this.socket.binaryType="arraybuffer",this.socket.onmessage=i=>{try{if(typeof i.data=="string")return;const n=new Uint8Array(i.data);if(this.config.mode==="cloud")this.emitData(n);else if(this.config.mode==="local"){let s;const a=this.config.deviceScreen===h.FRONT?3:2;try{const c=wt(n,a);this.config.deviceScreen===h.BACK?s=lt(c):s=c,this.emitData(s)}catch{this.emitData(n)}}}catch{this.connected=!1,this.emitStop()}},this.socket.onerror=i=>{this.connected=!1,this.emitError({code:1006,message:"WebSocket error occurred",raw:i}),this.emitStop()},this.socket.onclose=async i=>{if(this.socket=null,this.connected=!1,i.code===g||S.has(i.code)){this.emitError({code:i.code,message:i.reason,raw:i});return}this.emitStop()}}closeWebsocket(){return this.connected=!1,new Promise(t=>{this.socket?(this.socket.onclose=()=>{t()},this.socket.close(),this.socket=null):t(),this.emitStop()})}}class dt{constructor(t){o(this,"connected",!1);o(this,"apiKey");o(this,"apiSemver");o(this,"inputEvent");o(this,"dataListeners",[]);o(this,"stopListeners",[]);o(this,"errorListeners",[]);o(this,"socket",null);if(this.config=t,!(()=>typeof window<"u"&&typeof window.document<"u"))throw new Error("not browser");t.apiKey&&(this.apiKey=t.apiKey),t.apiSemver&&(this.apiSemver=t.apiSemver),this.inputEvent={}}onData(t){this.dataListeners.push(t)}onStop(t){this.stopListeners.push(t)}onError(t){this.errorListeners.push(t)}emitData(t){for(const i of this.dataListeners)i(t)}emitStop(){for(const t of this.stopListeners)t()}emitError(t){for(const i of this.errorListeners)i(t)}async openWebsocket(){this.socket&&await this.closeWebsocket();let t;if(this.config.mode==="cloud"?t=new URL(`${this.config.domain}/bars/${this.config.idDevice}/ws`):this.config.mode==="local"&&(t=new URL(`${this.config.barUrl}/api/input`),this.apiKey&&t.searchParams.append("x-api-key",this.apiKey),this.apiSemver&&t.searchParams.append("x-api-sem-ver",this.apiSemver)),!t)throw new Error("The WebSocket URL is not specified");this.socket=new WebSocket(t),this.socket.onopen=()=>{this.socket&&(this.connected=!0)},this.socket.binaryType="arraybuffer",this.socket.onmessage=i=>{try{if(typeof i.data=="string")return;const n=new Uint8Array(i.data);this.emitData(n)}catch{this.connected=!1,this.emitStop()}},this.socket.onerror=i=>{this.connected=!1,this.emitError({code:1006,message:"WebSocket error occurred",raw:i}),this.emitStop()},this.socket.onclose=async i=>{if(this.socket=null,this.connected=!1,i.code===g||S.has(i.code)){this.emitError({code:i.code,message:i.reason,raw:i});return}this.emitStop()}}sendInput({keyName:t,value:i}){if(!this.socket||!this.connected)throw new Error("WebSocket: Not connected");this.inputEvent[t]=i,this.socket.send(JSON.stringify(this.inputEvent)),i===0&&delete this.inputEvent[t]}closeWebsocket(){return this.connected=!1,new Promise(t=>{this.socket?(this.socket.onclose=()=>{t()},this.socket.close(),this.socket=null):t(),this.emitStop()})}}exports.BusyBar=ut;exports.DeviceScreen=h;exports.Input=dt;exports.ScreenStream=ht;
|
|
1
|
+
"use strict";var k=Object.defineProperty;var P=(e,t,i)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var o=(e,t,i)=>P(e,typeof t!="symbol"?t+"":t,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const T=require("openapi-fetch"),b=(e,t)=>{if(typeof FormData<"u"&&e instanceof FormData||typeof Buffer<"u"&&typeof Buffer.isBuffer=="function"&&Buffer.isBuffer(e)||typeof File<"u"&&e instanceof File||typeof Blob<"u"&&e instanceof Blob||typeof ArrayBuffer<"u"&&e instanceof ArrayBuffer||typeof ArrayBuffer<"u"&&ArrayBuffer.isView&&ArrayBuffer.isView(e))return e;let i;return t&&(t instanceof Headers?i=t.get("Content-Type")??t.get("content-type")??void 0:typeof t=="object"&&(i=t["Content-Type"]??t["content-type"]),i==="application/x-www-form-urlencoded")?e&&typeof e=="object"&&!(e instanceof URLSearchParams)?new URLSearchParams(e).toString():String(e):JSON.stringify(e)};let y,w,h=null;async function E(){if(!w){if(!y)throw new Error("getApiVersionFn is not set");h||(h=(async()=>{const e=await y();if(!e.api_semver)throw new Error("Empty API version");w=e.api_semver})().finally(()=>{h=null})),await h}}async function p(e){const n=(e.headers.get("content-type")||"").includes("application/json")?await e.clone().json():await e.clone().text(),s=typeof n=="object"&&n!==null?n.error||n.message:typeof n=="string"?n:void 0;return Object.assign(new Error(s||`HTTP ${e.status} ${e.statusText}`),{status:e.status,statusText:e.statusText,body:n})}let m;function I(e){m=e}const v={async onRequest({request:e,schemaPath:t}){if(t!=="/version"){if(await E(),w)return e.headers.set("X-API-Sem-Ver",w);m&&e.headers.set("X-API-Token",m)}return e},async onResponse({request:e,response:t,options:i,schemaPath:n}){if(t.ok)return t;if(n==="/version")throw await p(t);if(t.status!==405)throw await p(t);w=void 0,await E(),w&&e.headers.set("X-API-Sem-Ver",w);const s=await(i.fetch??fetch)(e);if(s.ok)return s;throw await p(s)}};let r=null;function B(e,t){y=t,r=T({baseUrl:e,bodySerializer:b}),r.use(v)}async function L(e){const{appId:t,fileName:i,file:n}=e;if(!r)throw new Error("API client is not initialized");const{data:s,error:a}=await r.POST("/assets/upload",{params:{query:{app_id:t,file:i}},headers:{"Content-Type":"application/octet-stream"},body:n});if(a)throw a;return s}async function z(e){const{appId:t}=e;if(!r)throw new Error("API client is not initialized");const{data:i,error:n}=await r.DELETE("/assets/upload",{params:{query:{app_id:t}}});if(n)throw n;return i}const D={timeout:5,x:0,y:0,display:"front"};function O(e){return{...D,...e}}async function K(e){const{appId:t,elements:i}=e;if(!r)throw new Error("API client is not initialized");const n=i.map(O),{data:s,error:a}=await r.POST("/display/draw",{body:{app_id:t,elements:n}});if(a)throw a;return s}async function U(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.DELETE("/display/draw");if(t)throw t;return e}async function C(e){const{appId:t,path:i}=e;if(!r)throw new Error("API client is not initialized");const{data:n,error:s}=await r.POST("/audio/play",{params:{query:{app_id:t,path:i}}});if(s)throw s;return n}async function W(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.DELETE("/audio/play");if(t)throw t;return e}async function $(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/enable");if(t)throw t;return e}async function F(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/disable");if(t)throw t;return e}async function R(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/wifi/status");if(t)throw t;return e}async function V(e){if(!r)throw new Error("API client is not initialized");const{data:t,error:i}=await r.POST("/wifi/connect",{body:{ssid:e.ssid,password:e.password,security:e.security,ip_config:{ip_method:e.ipConfig.ipMethod,ip_type:e.ipConfig.ipType,address:e.ipConfig.address,mask:e.ipConfig.mask,gateway:e.ipConfig.gateway}}});if(i)throw i;return t}async function _(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/disconnect");if(t)throw t;return e}async function q(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/wifi/networks");if(t)throw t;return e}async function x(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/wifi/forget");if(t)throw t;return e}async function G(e){if(!r)throw new Error("API client is not initialized");const{path:t,file:i}=e,{data:n,error:s}=await r.POST("/storage/write",{params:{query:{path:t}},headers:{"Content-Type":"application/octet-stream"},body:i});if(s)throw s;return n}async function N(e){if(!r)throw new Error("API client is not initialized");const{path:t,asArrayBuffer:i}=e,{data:n,error:s}=await r.GET("/storage/read",{params:{query:{path:t}},parseAs:i?"arrayBuffer":"blob"});if(s)throw s;return n}async function j(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.GET("/storage/list",{params:{query:{path:t}}});if(n)throw n;return i}async function H(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.DELETE("/storage/remove",{params:{query:{path:t}}});if(n)throw n;return i}async function J(e){if(!r)throw new Error("API client is not initialized");const{path:t}=e,{data:i,error:n}=await r.POST("/storage/mkdir",{params:{query:{path:t}}});if(n)throw n;return i}async function X(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/version");if(t)throw t;return e}async function M(e){if(!r)throw new Error("API client is not initialized");const{name:t,file:i}=e,{data:n,error:s}=await r.POST("/update",{params:{query:{name:t}},headers:{"Content-Type":"application/octet-stream"},body:i});if(s)throw s;return n}async function Q(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status");if(t)throw t;return e}async function Y(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status/system");if(t)throw t;return e}async function Z(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/status/power");if(t)throw t;return e}async function tt(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/display/brightness");if(t)throw t;return e}async function et(e){if(!r)throw new Error("API client is not initialized");const{front:t,back:i}=e,n=u=>{if(typeof u=="number"){if(u<0||u>100)throw new Error("Brightness value must be between 0 and 100 or 'auto'");return String(u)}if(u==="auto")return"auto"},s=n(t),a=n(i),{data:c,error:f}=await r.POST("/display/brightness",{params:{query:{front:s,back:a}}});if(f)throw f;return c}async function it(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/audio/volume");if(t)throw t;return e}async function rt(e){if(!r)throw new Error("API client is not initialized");const{volume:t}=e;if(typeof t!="number"||t<0||t>100)throw new Error("Volume must be a number between 0 and 100");const{data:i,error:n}=await r.POST("/audio/volume",{params:{query:{volume:t}}});if(n)throw n;return i}async function nt(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.GET("/access");if(t)throw t;return e}async function st(e){if(!r)throw new Error("API client is not initialized");const{mode:t,key:i}=e;if(!/^\d{4,10}$/.test(String(i)))throw new Error("Key must be a string of 4 to 10 digits");const{data:n,error:s}=await r.POST("/access",{params:{query:{mode:t,key:i}}});if(s)throw s;return n}async function ot(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/ble/enable");if(t)throw t;return e}async function at(){if(!r)throw new Error("API client is not initialized");const{data:e,error:t}=await r.POST("/ble/disable");if(t)throw t;return e}async function ct(e){if(!r)throw new Error("API client is not initialized");const{keyName:t}=e,{data:i,error:n}=await r.POST("/input",{params:{query:{key:t}}});if(n)throw n;return i}class ft{constructor(t){o(this,"host");o(this,"apiSemver");this.host=t.host,this.apiSemver="",B(`http://${this.host}/api/`,this.getApiVersion.bind(this))}async getApiVersion(){const t=await X();return this.apiSemver=t.api_semver,t}async updateFirmware(t){return await M(t)}async deviceStatus(){return await Q()}async systemStatus(){return await Y()}async powerStatus(){return await Z()}async uploadAsset(t){return await L(t)}async deleteAssets(t){return await z(t)}async drawDisplay(t){return await K(t)}async clearDisplay(){return await U()}async playSound(t){return await C(t)}async stopSound(){return await W()}async enableWifi(){return await $()}async disableWifi(){return await F()}async statusWifi(){return await R()}async connectWifi(t){return await V(t)}async disconnectWifi(){return await _()}async networksWifi(){return await q()}async forgetWifi(){return await x()}async uploadFile(t){return await G(t)}async downloadFile(t){return await N(t)}async readDirectory(t){return await j(t)}async removeResource(t){return await H(t)}async createDirectory(t){return await J(t)}async getDisplayBrightness(){return await tt()}async setDisplayBrightness(t){return await et(t)}async getAudioVolume(){return await it()}async setAudioVolume(t){return await rt(t)}async getHttpAccess(){return await nt()}async setHttpAccess(t){const i=await st(t);return t.mode==="key"&&t.key&&this.setApiKey(t.key),i}setApiKey(t){I(t)}async enableBle(){return await ot()}async disableBle(){return await at()}async pressButton(t){return await ct(t)}}var l=(e=>(e[e.FRONT=0]="FRONT",e[e.BACK=1]="BACK",e))(l||{});const g=3e3,S=new Set([1001,1006,1012,1013,1014,3008]);function A(e,t){if(t<0||t>=e.length)throw new Error(`Index ${t} is out of bounds (0…${e.length-1})`);const i=e[t];if(i===void 0)throw new Error(`Unexpected undefined at index ${t}`);return i}function ut(e,t){let i=0;const n=e.length,s=[];for(;i<n;){const a=A(e,i);if(i+=1,(a&128)!==0){const c=a&127;for(let f=0;f<c*t;f++)s.push(e[i+f]);i+=c*t}else{const c=a,f=e.slice(i,i+t);for(let u=0;u<c;u++)for(let d=0;d<t;d++)s.push(f[d]);i+=t}}return new Uint8Array(s)}function wt(e){const t=new Uint8Array(e.length*2);let i=0,n=0;for(;i<e.length;){const s=A(e,i),a=s&15,c=s>>4&15;t[n]=a,t[n+1]=c,i+=1,n+=2}return t}class ht{constructor(t){o(this,"connected",!1);o(this,"apiKey");o(this,"apiSemver");o(this,"dataListeners",[]);o(this,"stopListeners",[]);o(this,"errorListeners",[]);o(this,"socket",null);if(this.config=t,!(()=>typeof window<"u"&&typeof window.document<"u"))throw new Error("not browser");t.apiKey&&(this.apiKey=t.apiKey),t.apiSemver&&(this.apiSemver=t.apiSemver)}onData(t){this.dataListeners.push(t)}onStop(t){this.stopListeners.push(t)}onError(t){this.errorListeners.push(t)}emitData(t){for(const i of this.dataListeners)i(t)}emitStop(){for(const t of this.stopListeners)t()}emitError(t){for(const i of this.errorListeners)i(t)}async openWebsocket(){this.socket&&await this.closeWebsocket();let t;if(this.config.mode==="cloud"?t=new URL(`${this.config.domain}/bars/${this.config.idDevice}/ws`):this.config.mode==="local"&&(t=new URL(`${this.config.barUrl}/api/screen/ws`),this.apiKey&&t.searchParams.append("x-api-token",this.apiKey),this.apiSemver&&t.searchParams.append("x-api-sem-ver",this.apiSemver)),!t)throw new Error("The WebSocket URL is not specified");this.socket=new WebSocket(t),this.socket.onopen=()=>{this.socket&&(this.config.mode==="cloud"?this.socket.send(JSON.stringify({token:this.config.token,display:this.config.deviceScreen})):this.config.mode==="local"&&this.socket.send(JSON.stringify({display:this.config.deviceScreen})),this.connected=!0)},this.socket.binaryType="arraybuffer",this.socket.onmessage=i=>{try{if(typeof i.data=="string")return;const n=new Uint8Array(i.data);if(this.config.mode==="cloud")this.emitData(n);else if(this.config.mode==="local"){let s;const a=this.config.deviceScreen===l.FRONT?3:2;try{const c=ut(n,a);this.config.deviceScreen===l.BACK?s=wt(c):s=c,this.emitData(s)}catch{this.emitData(n)}}}catch{this.connected=!1,this.emitStop()}},this.socket.onerror=i=>{this.connected=!1,this.emitError({code:1006,message:"WebSocket error occurred",raw:i}),this.emitStop()},this.socket.onclose=async i=>{if(this.socket=null,this.connected=!1,i.code===g||S.has(i.code)){this.emitError({code:i.code,message:i.reason,raw:i});return}this.emitStop()}}closeWebsocket(){return this.connected=!1,new Promise(t=>{this.socket?(this.socket.onclose=()=>{t()},this.socket.close(),this.socket=null):t(),this.emitStop()})}}class lt{constructor(t){o(this,"connected",!1);o(this,"apiKey");o(this,"apiSemver");o(this,"inputEvent");o(this,"dataListeners",[]);o(this,"stopListeners",[]);o(this,"errorListeners",[]);o(this,"socket",null);if(this.config=t,!(()=>typeof window<"u"&&typeof window.document<"u"))throw new Error("not browser");t.apiKey&&(this.apiKey=t.apiKey),t.apiSemver&&(this.apiSemver=t.apiSemver),this.inputEvent={}}onData(t){this.dataListeners.push(t)}onStop(t){this.stopListeners.push(t)}onError(t){this.errorListeners.push(t)}emitData(t){for(const i of this.dataListeners)i(t)}emitStop(){for(const t of this.stopListeners)t()}emitError(t){for(const i of this.errorListeners)i(t)}async openWebsocket(){this.socket&&await this.closeWebsocket();let t;if(this.config.mode==="cloud"?t=new URL(`${this.config.domain}/bars/${this.config.idDevice}/ws`):this.config.mode==="local"&&(t=new URL(`${this.config.barUrl}/api/input`),this.apiKey&&t.searchParams.append("x-api-token",this.apiKey),this.apiSemver&&t.searchParams.append("x-api-sem-ver",this.apiSemver)),!t)throw new Error("The WebSocket URL is not specified");this.socket=new WebSocket(t),this.socket.onopen=()=>{this.socket&&(this.connected=!0)},this.socket.binaryType="arraybuffer",this.socket.onmessage=i=>{try{if(typeof i.data=="string")return;const n=new Uint8Array(i.data);this.emitData(n)}catch{this.connected=!1,this.emitStop()}},this.socket.onerror=i=>{this.connected=!1,this.emitError({code:1006,message:"WebSocket error occurred",raw:i}),this.emitStop()},this.socket.onclose=async i=>{if(this.socket=null,this.connected=!1,i.code===g||S.has(i.code)){this.emitError({code:i.code,message:i.reason,raw:i});return}this.emitStop()}}sendInput({keyName:t,value:i}){if(!this.socket||!this.connected)throw new Error("WebSocket: Not connected");this.inputEvent[t]=i,this.socket.send(JSON.stringify(this.inputEvent)),i===0&&delete this.inputEvent[t]}closeWebsocket(){return this.connected=!1,new Promise(t=>{this.socket?(this.socket.onclose=()=>{t()},this.socket.close(),this.socket=null):t(),this.emitStop()})}}exports.BusyBar=ft;exports.DeviceScreen=l;exports.Input=lt;exports.ScreenStream=ht;
|
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,8 @@ declare interface AudioParams {
|
|
|
7
7
|
path: paths["/audio/play"]["post"]["parameters"]["query"]["path"];
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
export declare type AudioVolumeInfo = components["schemas"]["AudioVolumeInfo"];
|
|
11
|
+
|
|
10
12
|
declare interface AudioVolumeParams {
|
|
11
13
|
volume: operations["setAudioVolume"]["parameters"]["query"]["volume"];
|
|
12
14
|
}
|
|
@@ -36,58 +38,56 @@ declare interface BrightnessParams {
|
|
|
36
38
|
*/
|
|
37
39
|
export declare class BusyBar {
|
|
38
40
|
/**
|
|
39
|
-
* Device
|
|
40
|
-
* @type {
|
|
41
|
+
* Device host address (IP or mDNS).
|
|
42
|
+
* @type {BusyBarConfig['host']}
|
|
41
43
|
* @readonly
|
|
42
44
|
*/
|
|
43
|
-
readonly
|
|
44
|
-
|
|
45
|
+
readonly host: BusyBarConfig["host"];
|
|
46
|
+
/**
|
|
47
|
+
* Current API semantic version.
|
|
48
|
+
* @type {ApiSemver}
|
|
49
|
+
*/
|
|
50
|
+
apiSemver: ApiSemver;
|
|
45
51
|
/**
|
|
46
52
|
* Creates an instance of BUSY Bar.
|
|
47
|
-
* Initializes the API client with the provided
|
|
53
|
+
* Initializes the API client with the provided host address.
|
|
48
54
|
*
|
|
49
|
-
* @param {
|
|
50
|
-
* @throws {Error} If the provided IP is not a valid IPv4 address.
|
|
55
|
+
* @param {BusyBarConfig} config - The host address of the device (IP or mDNS).
|
|
51
56
|
*/
|
|
52
|
-
constructor(
|
|
57
|
+
constructor(config: BusyBarConfig);
|
|
53
58
|
/**
|
|
54
59
|
* Retrieves the API semantic version.
|
|
55
60
|
*
|
|
56
|
-
* @returns A promise that resolves to an object containing the `api_semver` string.
|
|
61
|
+
* @returns {Promise<VersionInfo>} A promise that resolves to an object containing the `api_semver` string.
|
|
57
62
|
*/
|
|
58
|
-
|
|
63
|
+
getApiVersion(): Promise<VersionInfo>;
|
|
59
64
|
/**
|
|
60
65
|
* Updates the firmware.
|
|
61
66
|
*
|
|
62
67
|
* @param {UpdateParams} params - Parameters for the firmware update.
|
|
63
68
|
* @param {UpdateParams['name']} params.name - Name for the update package.
|
|
64
69
|
* @param {UpdateParams['file']} params.file - File data to upload.
|
|
65
|
-
* @returns Result of the update operation.
|
|
70
|
+
* @returns {Promise<SuccessResponse>} Result of the update operation.
|
|
66
71
|
*/
|
|
67
|
-
updateFirmware(params: UpdateParams): Promise<
|
|
68
|
-
result: string;
|
|
69
|
-
}>;
|
|
72
|
+
updateFirmware(params: UpdateParams): Promise<SuccessResponse>;
|
|
70
73
|
/**
|
|
71
74
|
* Gets the current status of the device, including system and power information.
|
|
72
75
|
*
|
|
73
|
-
* @returns Current status of the device.
|
|
76
|
+
* @returns {Promise<Status>} Current status of the device.
|
|
74
77
|
*/
|
|
75
|
-
deviceStatus(): Promise<
|
|
76
|
-
system?: components["schemas"]["StatusSystem"];
|
|
77
|
-
power?: components["schemas"]["StatusPower"];
|
|
78
|
-
}>;
|
|
78
|
+
deviceStatus(): Promise<Status>;
|
|
79
79
|
/**
|
|
80
80
|
* Gets the current system status.
|
|
81
81
|
*
|
|
82
|
-
* @returns Current system status.
|
|
82
|
+
* @returns {Promise<StatusSystem>} Current system status.
|
|
83
83
|
*/
|
|
84
|
-
systemStatus(): Promise<
|
|
84
|
+
systemStatus(): Promise<StatusSystem>;
|
|
85
85
|
/**
|
|
86
86
|
* Gets the current power status.
|
|
87
87
|
*
|
|
88
|
-
* @returns Current power status.
|
|
88
|
+
* @returns {Promise<StatusPower>} Current power status.
|
|
89
89
|
*/
|
|
90
|
-
powerStatus(): Promise<
|
|
90
|
+
powerStatus(): Promise<StatusPower>;
|
|
91
91
|
/**
|
|
92
92
|
* Uploads an asset to the device.
|
|
93
93
|
*
|
|
@@ -95,77 +95,65 @@ export declare class BusyBar {
|
|
|
95
95
|
* @param {UploadParams['appId']} params.appId - Application ID for organizing assets.
|
|
96
96
|
* @param {UploadParams['fileName']} params.fileName - Filename for the uploaded asset.
|
|
97
97
|
* @param {UploadParams['file']} params.file - File data to upload.
|
|
98
|
-
* @returns {Promise<
|
|
98
|
+
* @returns {Promise<SuccessResponse>} Result of the upload operation.
|
|
99
99
|
*/
|
|
100
|
-
uploadAsset(params: UploadParams): Promise<
|
|
101
|
-
result: string;
|
|
102
|
-
}>;
|
|
100
|
+
uploadAsset(params: UploadParams): Promise<SuccessResponse>;
|
|
103
101
|
/**
|
|
104
102
|
* Deletes all assets for a specific application from the device.
|
|
105
103
|
*
|
|
106
104
|
* @param {DeleteParams} params - Parameters for the delete.
|
|
107
105
|
* @param {DeleteParams['appId']} params.appId - Application ID whose assets should be deleted.
|
|
108
|
-
* @returns {Promise<
|
|
106
|
+
* @returns {Promise<SuccessResponse>} Result of the delete operation.
|
|
109
107
|
*/
|
|
110
|
-
deleteAssets(params: DeleteParams): Promise<
|
|
111
|
-
result: string;
|
|
112
|
-
}>;
|
|
108
|
+
deleteAssets(params: DeleteParams): Promise<SuccessResponse>;
|
|
113
109
|
/**
|
|
114
110
|
* Draws elements on the device display.
|
|
115
111
|
*
|
|
116
112
|
* @param {DrawParams} params - Parameters for the draw operation.
|
|
117
113
|
* @param {DrawParams['appId']} params.appId - Application ID for organizing display elements.
|
|
118
114
|
* @param {DrawParams['elements'][]} params.elements - Array of display elements (text or image).
|
|
119
|
-
* @returns {Promise<
|
|
115
|
+
* @returns {Promise<SuccessResponse>} Result of the draw operation.
|
|
120
116
|
*/
|
|
121
|
-
drawDisplay(params: DrawParams): Promise<
|
|
122
|
-
result: string;
|
|
123
|
-
}>;
|
|
117
|
+
drawDisplay(params: DrawParams): Promise<SuccessResponse>;
|
|
124
118
|
/**
|
|
125
119
|
* Clears the device display and stops the Canvas application if running.
|
|
126
120
|
*
|
|
127
|
-
* @returns {Promise<
|
|
121
|
+
* @returns {Promise<SuccessResponse>} Result of the clear operation.
|
|
128
122
|
*/
|
|
129
|
-
clearDisplay(): Promise<
|
|
130
|
-
result: string;
|
|
131
|
-
}>;
|
|
123
|
+
clearDisplay(): Promise<SuccessResponse>;
|
|
132
124
|
/**
|
|
133
125
|
* Plays an audio file from the assets directory.
|
|
134
126
|
*
|
|
135
127
|
* @param {AudioParams} params - Parameters for the audio playback.
|
|
136
128
|
* @param {AudioParams['appId']} params.appId - Application ID for organizing assets.
|
|
137
129
|
* @param {AudioParams['path']} params.path - Path to the audio file within the app's assets directory.
|
|
138
|
-
* @returns {Promise<
|
|
130
|
+
* @returns {Promise<SuccessResponse>} Result of the play operation.
|
|
139
131
|
*/
|
|
140
|
-
playSound(params: AudioParams): Promise<
|
|
141
|
-
result: string;
|
|
142
|
-
}>;
|
|
132
|
+
playSound(params: AudioParams): Promise<SuccessResponse>;
|
|
143
133
|
/**
|
|
144
134
|
* Stops any currently playing audio on the device.
|
|
145
135
|
*
|
|
146
|
-
* @returns {Promise<
|
|
136
|
+
* @returns {Promise<SuccessResponse>} Result of the stop operation.
|
|
147
137
|
*/
|
|
148
|
-
stopSound(): Promise<
|
|
149
|
-
result: string;
|
|
150
|
-
}>;
|
|
138
|
+
stopSound(): Promise<SuccessResponse>;
|
|
151
139
|
/**
|
|
152
140
|
* Enables the device's Wi-Fi module.
|
|
153
141
|
*
|
|
154
|
-
* @returns {Promise<
|
|
142
|
+
* @returns {Promise<SuccessResponse>} Result of the enable operation.
|
|
155
143
|
*/
|
|
156
|
-
enableWifi(): Promise<
|
|
144
|
+
enableWifi(): Promise<SuccessResponse>;
|
|
157
145
|
/**
|
|
158
146
|
* Disables the device's Wi-Fi module.
|
|
159
147
|
*
|
|
160
|
-
* @returns {Promise<
|
|
148
|
+
* @returns {Promise<SuccessResponse>} Result of the disable operation.
|
|
161
149
|
*/
|
|
162
|
-
disableWifi(): Promise<
|
|
150
|
+
disableWifi(): Promise<SuccessResponse>;
|
|
163
151
|
/**
|
|
164
152
|
* Gets the current status of the Wi-Fi module.
|
|
165
153
|
*
|
|
166
|
-
* @returns {Promise<
|
|
154
|
+
* @returns {Promise<WifiStatusResponse>} Current Wi-Fi status.
|
|
167
155
|
*/
|
|
168
|
-
statusWifi(): Promise<
|
|
156
|
+
statusWifi(): Promise<WifiStatusResponse>;
|
|
169
157
|
/**
|
|
170
158
|
* Connects the device to a Wi-Fi network with the specified parameters.
|
|
171
159
|
*
|
|
@@ -179,21 +167,21 @@ export declare class BusyBar {
|
|
|
179
167
|
* @param {ConnectParams['ipConfig']['address']} [params.ipConfig.address] - Static IP address (if using "static" method).
|
|
180
168
|
* @param {ConnectParams['ipConfig']['mask']} [params.ipConfig.mask] - Subnet mask (if using "static" method).
|
|
181
169
|
* @param {ConnectParams['ipConfig']['gateway']} [params.ipConfig.gateway] - Gateway address (if using "static" method).
|
|
182
|
-
* @returns {Promise<
|
|
170
|
+
* @returns {Promise<SuccessResponse>} Result of the connect operation.
|
|
183
171
|
*/
|
|
184
|
-
connectWifi(params: ConnectParams): Promise<
|
|
172
|
+
connectWifi(params: ConnectParams): Promise<SuccessResponse>;
|
|
185
173
|
/**
|
|
186
174
|
* Disconnects the device from the current Wi-Fi network.
|
|
187
175
|
*
|
|
188
|
-
* @returns {Promise<
|
|
176
|
+
* @returns {Promise<SuccessResponse>} Result of the disconnect operation.
|
|
189
177
|
*/
|
|
190
|
-
disconnectWifi(): Promise<
|
|
178
|
+
disconnectWifi(): Promise<SuccessResponse>;
|
|
191
179
|
/**
|
|
192
180
|
* Scans for available Wi-Fi networks near your device.
|
|
193
181
|
*
|
|
194
|
-
* @returns {Promise<
|
|
182
|
+
* @returns {Promise<WifiNetworkResponse>} List of discovered networks.
|
|
195
183
|
*/
|
|
196
|
-
networksWifi(): Promise<
|
|
184
|
+
networksWifi(): Promise<WifiNetworkResponse>;
|
|
197
185
|
/**
|
|
198
186
|
* Removes the saved Wi-Fi configuration (forgets the network).
|
|
199
187
|
*
|
|
@@ -206,103 +194,103 @@ export declare class BusyBar {
|
|
|
206
194
|
* @param {UploadFileParams} params - Upload parameters:
|
|
207
195
|
* @param {UploadFileParams['path']} params.path - Path where the file will be saved (e.g., "/ext/test.png").
|
|
208
196
|
* @param {UploadFileParams['file']} params.file - File data to upload.
|
|
209
|
-
* @returns {Promise<
|
|
197
|
+
* @returns {Promise<SuccessResponse>} Result of the upload operation.
|
|
210
198
|
*/
|
|
211
|
-
uploadFile(params: UploadFileParams): Promise<
|
|
199
|
+
uploadFile(params: UploadFileParams): Promise<SuccessResponse>;
|
|
212
200
|
/**
|
|
213
201
|
* Downloads a file from the device's internal storage.
|
|
214
202
|
*
|
|
215
203
|
* @param {DownloadFileParams} params - Download parameters:
|
|
216
204
|
* @param {DownloadFileParams['path']} params.path - Path to the file to download (e.g., "/ext/test.png").
|
|
217
205
|
* @param {DownloadFileParams['asArrayBuffer']} [params.asArrayBuffer] - If true, returns data as ArrayBuffer; otherwise, as Blob.
|
|
218
|
-
* @returns {Promise<
|
|
206
|
+
* @returns {Promise<StorageReadResponse>} The file data.
|
|
219
207
|
*/
|
|
220
|
-
downloadFile(params: DownloadFileParams): Promise<
|
|
208
|
+
downloadFile(params: DownloadFileParams): Promise<StorageReadResponse>;
|
|
221
209
|
/**
|
|
222
210
|
* Reads the contents of a directory (files and subdirectories) at the specified path.
|
|
223
211
|
*
|
|
224
212
|
* @param {ReadDirectoryParams} params - List parameters:
|
|
225
213
|
* @param {ReadDirectoryParams['path']} params.path - Path to the directory to list (e.g., "/ext").
|
|
226
|
-
* @returns {Promise<
|
|
214
|
+
* @returns {Promise<StorageList>} List of files and directories.
|
|
227
215
|
*/
|
|
228
|
-
readDirectory(params: ReadDirectoryParams): Promise<
|
|
216
|
+
readDirectory(params: ReadDirectoryParams): Promise<StorageList>;
|
|
229
217
|
/**
|
|
230
218
|
* Removes a file or a directory from the device's internal storage.
|
|
231
219
|
*
|
|
232
220
|
* @param {RemoveParams} params - Remove parameters:
|
|
233
221
|
* @param {RemoveParams['path']} params.path - Path of the file to remove (e.g., "/ext/test.png").
|
|
234
|
-
* @returns {Promise<
|
|
222
|
+
* @returns {Promise<SuccessResponse>} Result of the remove operation.
|
|
235
223
|
*/
|
|
236
|
-
removeResource(params: RemoveParams): Promise<
|
|
224
|
+
removeResource(params: RemoveParams): Promise<SuccessResponse>;
|
|
237
225
|
/**
|
|
238
226
|
* Creates a new directory in the device's internal storage.
|
|
239
227
|
*
|
|
240
228
|
* @param {CreateDirectoryParams} params - Directory creation parameters:
|
|
241
229
|
* @param {CreateDirectoryParams['path']} params.path - Path to the new directory (e.g., "/ext/newdir").
|
|
242
|
-
* @returns {Promise<
|
|
230
|
+
* @returns {Promise<SuccessResponse>} Result of the create operation.
|
|
243
231
|
*/
|
|
244
|
-
createDirectory(params: CreateDirectoryParams): Promise<
|
|
232
|
+
createDirectory(params: CreateDirectoryParams): Promise<SuccessResponse>;
|
|
245
233
|
/**
|
|
246
234
|
* Gets the current display brightness settings for the device.
|
|
247
235
|
*
|
|
248
|
-
* @returns {Promise<
|
|
236
|
+
* @returns {Promise<DisplayBrightnessInfo>} Current brightness information for front and back panels.
|
|
249
237
|
*/
|
|
250
|
-
getDisplayBrightness(): Promise<
|
|
238
|
+
getDisplayBrightness(): Promise<DisplayBrightnessInfo>;
|
|
251
239
|
/**
|
|
252
240
|
* Sets the display brightness for the device.
|
|
253
241
|
*
|
|
254
242
|
* @param {BrightnessParams} params - Brightness parameters:
|
|
255
243
|
* @param {BrightnessParams['front']} [params.front] - Brightness for the front panel (0-100 or "auto").
|
|
256
244
|
* @param {BrightnessParams['back']} [params.back] - Brightness for the back panel (0-100 or "auto").
|
|
257
|
-
* @returns {Promise<
|
|
245
|
+
* @returns {Promise<SuccessResponse>} Result of the brightness update operation.
|
|
258
246
|
* @throws {Error} If brightness value is outside the range 0-100 or not "auto".
|
|
259
247
|
*/
|
|
260
|
-
setDisplayBrightness(params: BrightnessParams): Promise<
|
|
248
|
+
setDisplayBrightness(params: BrightnessParams): Promise<SuccessResponse>;
|
|
261
249
|
/**
|
|
262
250
|
* Gets the current audio volume value.
|
|
263
251
|
*
|
|
264
|
-
* @returns {Promise<
|
|
252
|
+
* @returns {Promise<AudioVolumeInfo>} Current audio volume (0-100).
|
|
265
253
|
*/
|
|
266
|
-
getAudioVolume(): Promise<
|
|
254
|
+
getAudioVolume(): Promise<AudioVolumeInfo>;
|
|
267
255
|
/**
|
|
268
256
|
* Sets the audio volume value.
|
|
269
257
|
*
|
|
270
258
|
* @param {AudioVolumeParams} params - Audio volume parameters:
|
|
271
259
|
* @param {AudioVolumeParams['volume']} params.volume - Audio volume (number from 0 to 100).
|
|
272
|
-
* @returns {Promise<
|
|
260
|
+
* @returns {Promise<SuccessResponse>} Result of the volume update operation.
|
|
273
261
|
* @throws {Error} If volume is outside the range 0-100 or request fails.
|
|
274
262
|
*/
|
|
275
|
-
setAudioVolume(params: AudioVolumeParams): Promise<
|
|
263
|
+
setAudioVolume(params: AudioVolumeParams): Promise<SuccessResponse>;
|
|
276
264
|
/**
|
|
277
265
|
* Gets the current HTTP API access configuration.
|
|
278
266
|
*
|
|
279
|
-
* @returns {Promise<
|
|
267
|
+
* @returns {Promise<HttpAccessInfo>} Current HTTP access info.
|
|
280
268
|
*/
|
|
281
|
-
getHttpAccess(): Promise<
|
|
269
|
+
getHttpAccess(): Promise<HttpAccessInfo>;
|
|
282
270
|
/**
|
|
283
271
|
* Sets the HTTP API access configuration.
|
|
284
272
|
*
|
|
285
|
-
* @param {
|
|
286
|
-
* @param {
|
|
287
|
-
* @param {
|
|
288
|
-
* @returns {Promise<
|
|
273
|
+
* @param {HttpAccessParams} params - Access parameters:
|
|
274
|
+
* @param {HttpAccessParams['mode']} params.mode - Access mode ("disabled", "enabled", "key").
|
|
275
|
+
* @param {HttpAccessParams['key']} params.key - Access key (4-10 digits).
|
|
276
|
+
* @returns {Promise<SuccessResponse>} Result of the set operation.
|
|
289
277
|
*/
|
|
290
|
-
setHttpAccess(params:
|
|
278
|
+
setHttpAccess(params: HttpAccessParams): Promise<SuccessResponse>;
|
|
291
279
|
/**
|
|
292
280
|
* Sets API key for all subsequent requests.
|
|
293
|
-
* @param {string} key - API key to use in "X-API-
|
|
281
|
+
* @param {string} key - API key to use in "X-API-Token" header.
|
|
294
282
|
*/
|
|
295
283
|
setApiKey(key: string): void;
|
|
296
284
|
/**
|
|
297
285
|
* Enables BLE module.
|
|
298
|
-
* @returns {Promise<
|
|
286
|
+
* @returns {Promise<SuccessResponse>} Result of the enable operation.
|
|
299
287
|
*/
|
|
300
|
-
enableBle(): Promise<
|
|
288
|
+
enableBle(): Promise<SuccessResponse>;
|
|
301
289
|
/**
|
|
302
290
|
* Disables BLE module.
|
|
303
|
-
* @returns {Promise<
|
|
291
|
+
* @returns {Promise<SuccessResponse>} Result of the disable operation.
|
|
304
292
|
*/
|
|
305
|
-
disableBle(): Promise<
|
|
293
|
+
disableBle(): Promise<SuccessResponse>;
|
|
306
294
|
/**
|
|
307
295
|
* Sends a button press.
|
|
308
296
|
*
|
|
@@ -312,9 +300,13 @@ export declare class BusyBar {
|
|
|
312
300
|
* {
|
|
313
301
|
* keyName: "ok"
|
|
314
302
|
* }
|
|
315
|
-
* @returns {Promise<
|
|
303
|
+
* @returns {Promise<SuccessResponse>} Result of pressing the button.
|
|
316
304
|
*/
|
|
317
|
-
pressButton(params: InputKey): Promise<
|
|
305
|
+
pressButton(params: InputKey): Promise<SuccessResponse>;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
declare interface BusyBarConfig {
|
|
309
|
+
host: string;
|
|
318
310
|
}
|
|
319
311
|
|
|
320
312
|
declare type BusyFile = Buffer | Blob | File | ArrayBuffer;
|
|
@@ -675,6 +667,8 @@ export declare enum DeviceScreen {
|
|
|
675
667
|
BACK = 1
|
|
676
668
|
}
|
|
677
669
|
|
|
670
|
+
export declare type DisplayBrightnessInfo = components["schemas"]["DisplayBrightnessInfo"];
|
|
671
|
+
|
|
678
672
|
export declare interface DownloadFileParams {
|
|
679
673
|
path: operations["readStorageFile"]["parameters"]["query"]["path"];
|
|
680
674
|
asArrayBuffer?: boolean;
|
|
@@ -685,15 +679,20 @@ declare interface DrawParams {
|
|
|
685
679
|
elements: CustomElement[];
|
|
686
680
|
}
|
|
687
681
|
|
|
682
|
+
declare type Error_2 = components["schemas"]["Error"];
|
|
683
|
+
export { Error_2 as Error }
|
|
684
|
+
|
|
688
685
|
declare type ErrorListener = (payload: ErrorPayload) => void;
|
|
689
686
|
|
|
690
687
|
declare interface ErrorPayload {
|
|
691
688
|
code: number;
|
|
692
689
|
message: string;
|
|
693
|
-
raw:
|
|
690
|
+
raw: Error_2 | CloseEvent | Event;
|
|
694
691
|
}
|
|
695
692
|
|
|
696
|
-
declare
|
|
693
|
+
export declare type HttpAccessInfo = components["schemas"]["HttpAccessInfo"];
|
|
694
|
+
|
|
695
|
+
declare interface HttpAccessParams {
|
|
697
696
|
mode: operations["setHttpAccess"]["parameters"]["query"]["mode"];
|
|
698
697
|
key: operations["setHttpAccess"]["parameters"]["query"]["key"];
|
|
699
698
|
}
|
|
@@ -727,8 +726,6 @@ declare interface InputKey {
|
|
|
727
726
|
keyName: KeyName;
|
|
728
727
|
}
|
|
729
728
|
|
|
730
|
-
declare type IPv4 = string;
|
|
731
|
-
|
|
732
729
|
export declare type KeyName = operations["setInputKey"]["parameters"]["query"]["key"];
|
|
733
730
|
|
|
734
731
|
export declare type KeyValue = 1 | 0;
|
|
@@ -745,8 +742,6 @@ declare interface LocalConfig_2 extends BaseConfig_2 {
|
|
|
745
742
|
|
|
746
743
|
declare type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
747
744
|
|
|
748
|
-
export declare type Network = components["schemas"]["Network"];
|
|
749
|
-
|
|
750
745
|
declare interface operations {
|
|
751
746
|
getVersion: {
|
|
752
747
|
parameters: {
|
|
@@ -2521,10 +2516,26 @@ declare interface SiteConfig_2 extends BaseConfig_2 {
|
|
|
2521
2516
|
|
|
2522
2517
|
declare type SnakeToCamel<S extends string> = S extends `${infer Head}_${infer Tail}` ? `${Head}${Capitalize<SnakeToCamel<Tail>>}` : S;
|
|
2523
2518
|
|
|
2519
|
+
export declare type Status = components["schemas"]["Status"];
|
|
2520
|
+
|
|
2521
|
+
export declare type StatusPower = components["schemas"]["StatusPower"];
|
|
2522
|
+
|
|
2523
|
+
export declare type StatusSystem = components["schemas"]["StatusSystem"];
|
|
2524
|
+
|
|
2524
2525
|
declare type StopListener = () => void;
|
|
2525
2526
|
|
|
2527
|
+
export declare type StorageDirElement = components["schemas"]["StorageDirElement"];
|
|
2528
|
+
|
|
2529
|
+
export declare type StorageFileElement = components["schemas"]["StorageFileElement"];
|
|
2530
|
+
|
|
2531
|
+
export declare type StorageList = components["schemas"]["StorageList"];
|
|
2532
|
+
|
|
2526
2533
|
export declare type StorageListElement = components["schemas"]["StorageListElement"];
|
|
2527
2534
|
|
|
2535
|
+
export declare type StorageReadResponse = ArrayBuffer | Blob;
|
|
2536
|
+
|
|
2537
|
+
export declare type SuccessResponse = components["schemas"]["SuccessResponse"];
|
|
2538
|
+
|
|
2528
2539
|
declare interface UpdateParams {
|
|
2529
2540
|
name?: string;
|
|
2530
2541
|
file: BusyFile;
|
|
@@ -2541,4 +2552,20 @@ declare interface UploadParams {
|
|
|
2541
2552
|
file: BusyFile;
|
|
2542
2553
|
}
|
|
2543
2554
|
|
|
2555
|
+
export declare type VersionInfo = components["schemas"]["VersionInfo"];
|
|
2556
|
+
|
|
2557
|
+
export declare type WifiConnectRequestConfig = components["schemas"]["ConnectRequestConfig"];
|
|
2558
|
+
|
|
2559
|
+
export declare type WifiIpMethod = components["schemas"]["WifiIpMethod"];
|
|
2560
|
+
|
|
2561
|
+
export declare type WifiIpType = components["schemas"]["WifiIpType"];
|
|
2562
|
+
|
|
2563
|
+
export declare type WifiNetwork = components["schemas"]["Network"];
|
|
2564
|
+
|
|
2565
|
+
export declare type WifiNetworkResponse = components["schemas"]["NetworkResponse"];
|
|
2566
|
+
|
|
2567
|
+
export declare type WifiSecurityMethod = components["schemas"]["WifiSecurityMethod"];
|
|
2568
|
+
|
|
2569
|
+
export declare type WifiStatusResponse = components["schemas"]["StatusResponse"];
|
|
2570
|
+
|
|
2544
2571
|
export { }
|