Socket
Socket
Sign inDemoInstall

@ray-js/wechat-helper

Package Overview
Dependencies
0
Maintainers
1
Versions
135
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.4 to 0.2.5

2

index.esm.js

@@ -1,1 +0,1 @@

function e(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))}function t(e,t){return(e&Math.pow(2,t))>>t==1}function n(e){if(e.length>6)throw new Error("The number of bytes exceeds 6");const t=new DataView(e.buffer);switch(e.length){case 1:return t.getInt8(0);case 2:return t.getInt16(0);case 4:return t.getInt32(0);default:{let t=r(e);const n=Math.pow(2,8*e.length)/2;return t>=n&&(t%=n,t=-1*(n-t)),t}}}function r(e){const t=new DataView(e.buffer);switch(e.length){case 0:throw new Error("data of Uint8Array is empty");case 1:return t.getUint8(0);case 2:return t.getUint16(0);case 3:return e.reduce(((e,t)=>e<<8|t),0);case 4:return t.getUint32(0);default:return parseInt(a(e),16)}}function o(e){return e.reduceRight(((e,t)=>{const n=t.toString(2).padStart(8,"0").split("").map((e=>Number(e))).reverse();return e.concat(n)}),[])}function a(e){return e.length?e.length<=4?r(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase():""}function i(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")}function c(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}function s(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=65536&&n<=1114111?(t.push(n>>18&7|240),t.push(n>>12&63|128),t.push(n>>6&63|128),t.push(63&n|128)):n>=2048&&n<=65535?(t.push(n>>12&15|224),t.push(n>>6&63|128),t.push(63&n|128)):n>=128&&n<=2047?(t.push(n>>6&31|192),t.push(63&n|128)):t.push(255&n)}return new Uint8Array(t)}const u=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},l=e=>{const t=[];do{let n=e%128;(e=parseInt(""+e/128))>0&&(n|=128),t.push(n)}while(e>0);return new Uint8Array(t)},f=(e,t=0)=>{let n=0,r=t;for(;r<4&&r<e.length;r++){const o=e[r];if(n|=(127&o)<<7*(r-t),0==(o>>7&1))break}return{num:n,end:r-t<4?r+1:r}},h=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},g=(e,t)=>{const n=new Int32Array([e]),r=new Int8Array(n.buffer);return r.reverse(),t?new Uint8Array(r.slice(4-t)):new Uint8Array(r)},p=e=>{if(e.length%2!=0)throw new Error("hex length error");const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.slice(2*r,2*r+2),16);return n},d="undefined"!=typeof wx?wx:"undefined"!=typeof my?my:"undefined"!=typeof ty?ty:{},v="undefined"!=typeof wx,y="undefined"!=typeof my;function C(e,t){return d[e]||t&&d[t]||(()=>{console.warn(`The Api ${e} is not found`)})}function S(e,t,n){"function"==typeof t&&(n=t,t="");const r=d[e]||t&&d[t];return r?e=>new Promise(((t,o)=>{const{success:a,fail:i}=e||{};r(Object.assign(Object.assign({},e),{success:e=>{n&&(e=n(e)),a&&a(e),t(e)},fail:e=>{i&&i(e),"undefined"!=typeof my&&e.error&&(e.errCode=e.error,e.errMsg=e.errorMessage),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}const B=C("getFileSystemManager"),w=S("downloadFile"),A=S("getFileInfo"),b=C("getSystemInfoSync"),m=C("getAccountInfoSync"),D=C("getAppAuthorizeSetting"),L=S("authorizeForMiniProgram"),E=S("authorize"),I=S("getBLEDeviceServices",(e=>y?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),U=S("getBLEDeviceCharacteristics",(e=>y?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),j=S("createBLEConnection","connectBLEDevice"),T=S("closeBLEConnection","disconnectBLEDevice"),M=S("startBluetoothDevicesDiscovery"),O=S("stopBluetoothDevicesDiscovery"),P=S("getBLEDeviceRSSI"),V=S("getConnectedBluetoothDevices"),F=C("onBLEConnectionStateChange","onBLEConnectionStateChanged"),_=C("offBLEConnectionStateChange","offBLEConnectionStateChanged"),k=C("onBluetoothAdapterStateChange"),x=S("notifyBLECharacteristicValueChange"),W=S("readBLECharacteristicValue"),z=S("getBLEMTU"),$=S("setBLEMTU"),H=S("getBluetoothAdapterState"),R=new Map,q=S("getBluetoothDevices",(e=>y?{devices:e.devices.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:p(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=p(e.serviceData[n]),t)),{})})))}:e)),K=S("writeBLECharacteristicValue"),G=S("createBLEPeripheralServer"),N=S("openBluetoothAdapter"),J=S("closeBluetoothAdapter"),Q=C("connectSocket"),X=S("login"),Y=S("getUserInfo"),Z=C("createUDPSocket"),ee=C("createTCPSocket"),te=S("scanCode"),ne=S("getSetting"),re=S("getLocalIPAddress"),oe=S("startWifi"),ae=S("stopWifi"),ie=S("getConnectedWifi"),ce=S("request"),se=C("onAppHide"),ue=C("offAppHide"),le=C("onAppShow"),fe=C("offAppShow"),he=S("navigateToMiniProgram"),ge=S("navigateTo"),pe=S("redirectTo"),de=S("navigateBack"),ve=S("reLaunch"),ye=C("setStorageSync"),Ce=C("getStorageSync"),Se=C("removeStorageSync"),Be=C("showToast"),we=d.env||{};var Ae=Object.freeze({__proto__:null,isWechat:v,isAlipay:y,hasBaseApi:e=>!!d[e]||!1,getFileSystemManager:B,downloadFile:w,getFileInfo:A,getSystemInfoSync:b,getAccountInfoSync:m,getAppAuthorizeSetting:D,authorizeForMiniProgram:L,authorize:E,getBLEDeviceServices:I,getBLEDeviceCharacteristics:U,createBLEConnection:j,closeBLEConnection:T,startBluetoothDevicesDiscovery:M,stopBluetoothDevicesDiscovery:O,getBLEDeviceRSSI:P,getConnectedBluetoothDevices:V,onBLEConnectionStateChange:F,offBLEConnectionStateChange:_,onBluetoothAdapterStateChange:k,notifyBLECharacteristicValueChange:x,readBLECharacteristicValue:W,getBLEMTU:z,setBLEMTU:$,getBluetoothAdapterState:H,onBluetoothDeviceFound:e=>{if(y){const t=({devices:t})=>{const n=t.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:p(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=p(e.serviceData[n]),t)),{})})));e({devices:n})};return R.set(e,t),void d.onBluetoothDeviceFound(t)}d.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{y&&R.has(e)?d.offBluetoothDeviceFound(R.get(e)):d.offBluetoothDeviceFound(e)},getBluetoothDevices:q,onBLECharacteristicValueChange:e=>{if(y){const t=t=>{e(Object.assign(Object.assign({},t),{value:p(t.value)}))};return R.set(e,t),void d.onBLECharacteristicValueChange(t)}d.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{y&&R.has(e)?d.offBLECharacteristicValueChange(R.get(e)):d.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:K,createBLEPeripheralServer:G,openBluetoothAdapter:N,closeBluetoothAdapter:J,connectSocket:Q,login:X,getUserInfo:Y,createUDPSocket:Z,createTCPSocket:ee,scanCode:te,getSetting:ne,getLocalIPAddress:re,startWifi:oe,stopWifi:ae,getConnectedWifi:ie,request:ce,onAppHide:se,offAppHide:ue,onAppShow:le,offAppShow:fe,navigateToMiniProgram:he,navigateTo:ge,redirectTo:pe,navigateBack:de,reLaunch:ve,setStorageSync:ye,getStorageSync:Ce,removeStorageSync:Se,showToast:Be,env:we});const be=b()||{};function me(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}function De(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(me(e))})),t}function Le(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2){const r=parseInt(e.slice(n,n+2),16);t.push(String.fromCharCode(r))}else for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);t.push(String.fromCharCode(r))}return t.join("")}function Ee(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2)t.push(parseInt(e.slice(n,n+2),16));else if("string"==typeof e[0])for(let n=0;n<e.length;n++)t.push(parseInt(e[n],16));return new Uint8Array(t)}const Ie=(e,t=!1)=>{if(!e)return"";return Object.keys(e).reduce(((n,r)=>{const o=e[r];return void 0!==o&&n.push(`${r}=${t?encodeURIComponent(o):o}`),n}),[]).join("&")},Ue=e=>Te(e,be.SDKVersion),je=()=>be.SDKVersion,Te=(e,t,n=!0)=>{const r=e.split("."),o=t.split("."),a=Math.max(o.length,r.length);for(;o.length<a;)o.splice(0,0,"0");for(;r.length<a;)r.splice(0,0,"0");for(let e=0;e<a;e++){const t=parseInt(r[e]),n=parseInt(o[e]);if(t>n)return!0;if(t===n)break;return!1}return n},Me=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()})),Oe=e=>{if(0!==e.indexOf("http")){return`https://images.tuyacn.com${/^\/[\w\W]+/.test(e)?"":"/"}${e}`}return e};function Pe(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>Pe(e))):Object.keys(e).reduce(((t,n)=>{const r=n.split("_").map(((e,t)=>t>0?Me(e):e)).join("");let o=e[n];return Array.isArray(o)?o=o.map((e=>Pe(e))):"object"==typeof o&&(o=Pe(o)),t[r]=o,t}),{})}const Ve="ios"===be.platform,Fe="ios"===be.platform,_e=(t,n)=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{if(n){const r=t/10;let o=0;const a=setInterval((()=>{o+=r,o>=t&&(clearInterval(a),e(!0)),n()&&(clearInterval(a),e(!0))}),r)}setTimeout((()=>{e(!0)}),t)}))})),ke=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=1&t?t>>>1^3988292384:t>>>1;ke[e]=t}function xe(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^ke[255&(t^e[n])];return-1^t}function We(e){let t=65535;let n,r;for(n=0;n<e.length;n++)for(t^=255&e[n],r=0;r<8;r++)0!=(1&t)?(t>>=1,t^=40961):t>>=1;return t}const ze={initial_value:0,table:function(e){const t=[];for(let n=0;n<256;++n){let r=n;for(let t=0;t<8;++t)r=0!=(128&r)?255&(r<<1^e):r<<1&255;t[n]=r}return t}(7)},$e=e=>{let t=ze.initial_value;for(let n=0;n<e.length;n++)t=ze.table[255&(t^e[n])];return t},He=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},Re=e=>{const t=new Uint8Array(4*e.length),n=new DataView(t.buffer);for(let t=0;t<e.length;t++)n.setInt32(4*t,e[t]);return t};const qe={encrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let a,i,c=n[o],s=n[0],u=Math.floor(6+52/(o+1)),l=0;for(;u-- >0;){l=l+2654435769&4294967295,i=l>>>2&3;let e=0;for(;e<o;e++)s=n[e+1],a=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^i]^c),c=n[e]=n[e]+a&4294967295;s=n[0],a=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^i]^c),c=n[o]=n[o]+a&4294967295}return Re(n)},decrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let a=n[o-1],i=n[0];const c=2654435769;let s,u,l=Math.floor(6+52/(o+1))*c&4294967295;for(;0!==l;){u=l>>>2&3;let e=o;for(;e>0;e--)a=n[e-1],s=(a>>>5^i<<2)+(i>>>3^a<<4)^(l^i)+(r[3&e^u]^a),i=n[e]=n[e]-s&4294967295;a=n[o],s=(a>>>5^i<<2)+(i>>>3^a<<4)^(l^i)+(r[3&e^u]^a),i=n[0]=n[0]-s&4294967295,l=l-c&4294967295}return Re(n)}},Ke=()=>{if("undefined"!=typeof globalThis)try{return globalThis.__tyGlobal={},globalThis}catch(e){}return void 0===Object.prototype.__globalData&&Object.defineProperty(Object.prototype,"__globalData",{value:{},configurable:!1,enumerable:!1}),Object.prototype.__globalData};function Ge(e,t){const n=Ke();return n[e]?n[e][t]:null}function Ne(e){const t=Ke();return t[e]?t[e]:null}function Je(e,t,n){const r=Ke();r[e]||(r[e]={}),r[e][t]=n}function Qe(e){const t=Ke();t[e]&&(t[e]={})}export{Ae as BaseApi,We as CRC16,xe as CRC32,$e as CRC8,De as ab2hex,t as bitToBoolean,o as bytesToBits,i as bytesToCharts,a as bytesToHex,n as bytesToInt,f as bytesToIntBy128,c as bytesToString,r as bytesToUint,Te as checkVersion,Ue as checkWxVersion,Qe as clearCache,me as dec2hex,Me as firstUpperCase,Ie as formatQuery,Ge as getCache,Ne as getCacheSpace,Ke as getGlobal,Oe as getImageUrl,je as getWxSDKVersion,Ee as hex2ab,Le as hex2string,p as hexToBytes,g as intToBytes,Fe as isAndroid,Ve as isIOS,Pe as keyToHump,u as randomBytes,Je as setCache,_e as sleep,s as stringToBytes,h as uintToBytes,l as uintToBytesBy128,qe as xxtea};
function e(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,c)}s((r=r.apply(e,t||[])).next())}))}function t(e,t){return(e&Math.pow(2,t))>>t==1}function n(e){if(e.length>6)throw new Error("The number of bytes exceeds 6");const t=new DataView(e.buffer);switch(e.length){case 1:return t.getInt8(0);case 2:return t.getInt16(0);case 4:return t.getInt32(0);default:{let t=r(e);const n=Math.pow(2,8*e.length)/2;return t>=n&&(t%=n,t=-1*(n-t)),t}}}function r(e){const t=new DataView(e.buffer);switch(e.length){case 0:throw new Error("data of Uint8Array is empty");case 1:return t.getUint8(0);case 2:return t.getUint16(0);case 3:return e.reduce(((e,t)=>e<<8|t),0);case 4:return t.getUint32(0);default:return parseInt(a(e),16)}}function o(e){return e.reduceRight(((e,t)=>{const n=t.toString(2).padStart(8,"0").split("").map((e=>Number(e))).reverse();return e.concat(n)}),[])}function a(e){return e.length?e.length<=4?r(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase():""}function i(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")}function c(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}function s(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=65536&&n<=1114111?(t.push(n>>18&7|240),t.push(n>>12&63|128),t.push(n>>6&63|128),t.push(63&n|128)):n>=2048&&n<=65535?(t.push(n>>12&15|224),t.push(n>>6&63|128),t.push(63&n|128)):n>=128&&n<=2047?(t.push(n>>6&31|192),t.push(63&n|128)):t.push(255&n)}return new Uint8Array(t)}const u=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},l=e=>{const t=[];do{let n=e%128;(e=parseInt(""+e/128))>0&&(n|=128),t.push(n)}while(e>0);return new Uint8Array(t)},f=(e,t=0)=>{let n=0,r=t;for(;r<4&&r<e.length;r++){const o=e[r];if(n|=(127&o)<<7*(r-t),0==(o>>7&1))break}return{num:n,end:r-t<4?r+1:r}},h=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},g=(e,t)=>{const n=new Int32Array([e]),r=new Int8Array(n.buffer);return r.reverse(),t?new Uint8Array(r.slice(4-t)):new Uint8Array(r)},p=e=>{if(e.length%2!=0)throw new Error("hex length error");const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.slice(2*r,2*r+2),16);return n},d="undefined"!=typeof wx?wx:"undefined"!=typeof my?my:"undefined"!=typeof ty?ty:{},v="undefined"!=typeof wx,y="undefined"!=typeof my;function C(e,t){return d[e]||t&&d[t]||(()=>{console.warn(`The Api ${e} is not found`)})}function S(e,t,n){"function"==typeof t&&(n=t,t="");const r=d[e]||t&&d[t];return r?e=>new Promise(((t,o)=>{const{success:a,fail:i}=e||{};r(Object.assign(Object.assign({},e),{success:e=>{n&&(e=n(e)),a&&a(e),t(e)},fail:e=>{i&&i(e),"undefined"!=typeof my&&e.error&&(e.errCode=e.error,e.errMsg=e.errorMessage),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}const B=C("getFileSystemManager"),w=S("downloadFile"),A=S("getFileInfo"),b=C("getSystemInfoSync"),m=C("getAccountInfoSync"),D=C("getAppAuthorizeSetting"),L=S("authorizeForMiniProgram"),E=S("authorize"),I=S("getBLEDeviceServices",(e=>y?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),U=S("getBLEDeviceCharacteristics",(e=>y?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),j=S("createBLEConnection","connectBLEDevice"),T=S("closeBLEConnection","disconnectBLEDevice"),M=S("startBluetoothDevicesDiscovery"),O=S("stopBluetoothDevicesDiscovery"),P=S("getBLEDeviceRSSI"),V=S("getConnectedBluetoothDevices"),F=C("onBLEConnectionStateChange","onBLEConnectionStateChanged"),_=C("offBLEConnectionStateChange","offBLEConnectionStateChanged"),k=C("onBluetoothAdapterStateChange"),x=S("notifyBLECharacteristicValueChange"),W=S("readBLECharacteristicValue"),z=S("getBLEMTU"),$=S("setBLEMTU"),H=S("getBluetoothAdapterState"),R=new Map,q=S("getBluetoothDevices",(e=>y?{devices:e.devices.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:p(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=p(e.serviceData[n]),t)),{})})))}:e)),K=S("writeBLECharacteristicValue"),G=S("createBLEPeripheralServer"),N=S("openBluetoothAdapter"),J=S("closeBluetoothAdapter"),Q=C("connectSocket"),X=S("login"),Y=S("getUserInfo"),Z=C("createUDPSocket"),ee=C("createTCPSocket"),te=S("scanCode"),ne=S("getSetting"),re=S("getLocalIPAddress"),oe=S("startWifi"),ae=S("stopWifi"),ie=S("getConnectedWifi"),ce=S("request"),se=C("onAppHide"),ue=C("offAppHide"),le=C("onAppShow"),fe=C("offAppShow"),he=S("navigateToMiniProgram"),ge=S("navigateTo"),pe=S("redirectTo"),de=S("navigateBack"),ve=S("reLaunch"),ye=C("setStorageSync"),Ce=C("getStorageSync"),Se=C("removeStorageSync"),Be=C("showToast"),we=d.env||{};var Ae=Object.freeze({__proto__:null,isWechat:v,isAlipay:y,hasBaseApi:e=>!!d[e]||!1,getFileSystemManager:B,downloadFile:w,getFileInfo:A,getSystemInfoSync:b,getAccountInfoSync:m,getAppAuthorizeSetting:D,authorizeForMiniProgram:L,authorize:E,getBLEDeviceServices:I,getBLEDeviceCharacteristics:U,createBLEConnection:j,closeBLEConnection:T,startBluetoothDevicesDiscovery:M,stopBluetoothDevicesDiscovery:O,getBLEDeviceRSSI:P,getConnectedBluetoothDevices:V,onBLEConnectionStateChange:F,offBLEConnectionStateChange:_,onBluetoothAdapterStateChange:k,notifyBLECharacteristicValueChange:x,readBLECharacteristicValue:W,getBLEMTU:z,setBLEMTU:$,getBluetoothAdapterState:H,onBluetoothDeviceFound:e=>{if(y){const t=({devices:t})=>{const n=t.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:p(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=p(e.serviceData[n]),t)),{})})));e({devices:n})};return R.set(e,t),void d.onBluetoothDeviceFound(t)}d.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{y&&R.has(e)?d.offBluetoothDeviceFound(R.get(e)):d.offBluetoothDeviceFound(e)},getBluetoothDevices:q,onBLECharacteristicValueChange:e=>{if(y){const t=t=>{e(Object.assign(Object.assign({},t),{value:p(t.value)}))};return R.set(e,t),void d.onBLECharacteristicValueChange(t)}d.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{y&&R.has(e)?d.offBLECharacteristicValueChange(R.get(e)):d.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:K,createBLEPeripheralServer:G,openBluetoothAdapter:N,closeBluetoothAdapter:J,connectSocket:Q,login:X,getUserInfo:Y,createUDPSocket:Z,createTCPSocket:ee,scanCode:te,getSetting:ne,getLocalIPAddress:re,startWifi:oe,stopWifi:ae,getConnectedWifi:ie,request:ce,onAppHide:se,offAppHide:ue,onAppShow:le,offAppShow:fe,navigateToMiniProgram:he,navigateTo:ge,redirectTo:pe,navigateBack:de,reLaunch:ve,setStorageSync:ye,getStorageSync:Ce,removeStorageSync:Se,showToast:Be,env:we});const be=b()||{};function me(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}function De(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(me(e))})),t}function Le(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2){const r=parseInt(e.slice(n,n+2),16);t.push(String.fromCharCode(r))}else for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);t.push(String.fromCharCode(r))}return t.join("")}function Ee(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2)t.push(parseInt(e.slice(n,n+2),16));else if("string"==typeof e[0])for(let n=0;n<e.length;n++)t.push(parseInt(e[n],16));return new Uint8Array(t)}const Ie=(e,t=!1)=>{if(!e)return"";return Object.keys(e).reduce(((n,r)=>{const o=e[r];return void 0!==o&&n.push(`${r}=${t?encodeURIComponent(o):o}`),n}),[]).join("&")},Ue=e=>Te(be.SDKVersion,e),je=()=>be.SDKVersion,Te=(e,t,n=!0)=>{const r=e.split("."),o=t.split("."),a=Math.max(o.length,r.length);for(;o.length<a;)o.splice(0,0,"0");for(;r.length<a;)r.splice(0,0,"0");for(let e=0;e<a;e++){const t=parseInt(r[e]),n=parseInt(o[e]);if(t>n)return!0;if(t===n)break;return!1}return n},Me=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()})),Oe=e=>{if(0!==e.indexOf("http")){return`https://images.tuyacn.com${/^\/[\w\W]+/.test(e)?"":"/"}${e}`}return e};function Pe(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>Pe(e))):Object.keys(e).reduce(((t,n)=>{const r=n.split("_").map(((e,t)=>t>0?Me(e):e)).join("");let o=e[n];return Array.isArray(o)?o=o.map((e=>Pe(e))):"object"==typeof o&&(o=Pe(o)),t[r]=o,t}),{})}const Ve="ios"===be.platform,Fe="ios"===be.platform,_e=(t,n)=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{if(n){const r=t/10;let o=0;const a=setInterval((()=>{o+=r,o>=t&&(clearInterval(a),e(!0)),n()&&(clearInterval(a),e(!0))}),r)}setTimeout((()=>{e(!0)}),t)}))})),ke=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=1&t?t>>>1^3988292384:t>>>1;ke[e]=t}function xe(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^ke[255&(t^e[n])];return-1^t}function We(e){let t=65535;let n,r;for(n=0;n<e.length;n++)for(t^=255&e[n],r=0;r<8;r++)0!=(1&t)?(t>>=1,t^=40961):t>>=1;return t}const ze={initial_value:0,table:function(e){const t=[];for(let n=0;n<256;++n){let r=n;for(let t=0;t<8;++t)r=0!=(128&r)?255&(r<<1^e):r<<1&255;t[n]=r}return t}(7)},$e=e=>{let t=ze.initial_value;for(let n=0;n<e.length;n++)t=ze.table[255&(t^e[n])];return t},He=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},Re=e=>{const t=new Uint8Array(4*e.length),n=new DataView(t.buffer);for(let t=0;t<e.length;t++)n.setInt32(4*t,e[t]);return t};const qe={encrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let a,i,c=n[o],s=n[0],u=Math.floor(6+52/(o+1)),l=0;for(;u-- >0;){l=l+2654435769&4294967295,i=l>>>2&3;let e=0;for(;e<o;e++)s=n[e+1],a=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^i]^c),c=n[e]=n[e]+a&4294967295;s=n[0],a=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^i]^c),c=n[o]=n[o]+a&4294967295}return Re(n)},decrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let a=n[o-1],i=n[0];const c=2654435769;let s,u,l=Math.floor(6+52/(o+1))*c&4294967295;for(;0!==l;){u=l>>>2&3;let e=o;for(;e>0;e--)a=n[e-1],s=(a>>>5^i<<2)+(i>>>3^a<<4)^(l^i)+(r[3&e^u]^a),i=n[e]=n[e]-s&4294967295;a=n[o],s=(a>>>5^i<<2)+(i>>>3^a<<4)^(l^i)+(r[3&e^u]^a),i=n[0]=n[0]-s&4294967295,l=l-c&4294967295}return Re(n)}},Ke=()=>{if("undefined"!=typeof globalThis)try{return globalThis.__tyGlobal={},globalThis}catch(e){}return void 0===Object.prototype.__globalData&&Object.defineProperty(Object.prototype,"__globalData",{value:{},configurable:!1,enumerable:!1}),Object.prototype.__globalData};function Ge(e,t){const n=Ke();return n[e]?n[e][t]:null}function Ne(e){const t=Ke();return t[e]?t[e]:null}function Je(e,t,n){const r=Ke();r[e]||(r[e]={}),r[e][t]=n}function Qe(e){const t=Ke();t[e]&&(t[e]={})}export{Ae as BaseApi,We as CRC16,xe as CRC32,$e as CRC8,De as ab2hex,t as bitToBoolean,o as bytesToBits,i as bytesToCharts,a as bytesToHex,n as bytesToInt,f as bytesToIntBy128,c as bytesToString,r as bytesToUint,Te as checkVersion,Ue as checkWxVersion,Qe as clearCache,me as dec2hex,Me as firstUpperCase,Ie as formatQuery,Ge as getCache,Ne as getCacheSpace,Ke as getGlobal,Oe as getImageUrl,je as getWxSDKVersion,Ee as hex2ab,Le as hex2string,p as hexToBytes,g as intToBytes,Fe as isAndroid,Ve as isIOS,Pe as keyToHump,u as randomBytes,Je as setCache,_e as sleep,s as stringToBytes,h as uintToBytes,l as uintToBytesBy128,qe as xxtea};

@@ -1,1 +0,1 @@

"use strict";function e(e,t,n,r){return new(n||(n=Promise))((function(o,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function i(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}c((r=r.apply(e,t||[])).next())}))}function t(e){const t=new DataView(e.buffer);switch(e.length){case 0:throw new Error("data of Uint8Array is empty");case 1:return t.getUint8(0);case 2:return t.getUint16(0);case 3:return e.reduce(((e,t)=>e<<8|t),0);case 4:return t.getUint32(0);default:return parseInt(n(e),16)}}function n(e){return e.length?e.length<=4?t(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase():""}Object.defineProperty(exports,"__esModule",{value:!0});const r=e=>{if(e.length%2!=0)throw new Error("hex length error");const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.slice(2*r,2*r+2),16);return n},o="undefined"!=typeof wx?wx:"undefined"!=typeof my?my:"undefined"!=typeof ty?ty:{},a="undefined"!=typeof wx,s="undefined"!=typeof my;function i(e,t){return o[e]||t&&o[t]||(()=>{console.warn(`The Api ${e} is not found`)})}function c(e,t,n){"function"==typeof t&&(n=t,t="");const r=o[e]||t&&o[t];return r?e=>new Promise(((t,o)=>{const{success:a,fail:s}=e||{};r(Object.assign(Object.assign({},e),{success:e=>{n&&(e=n(e)),a&&a(e),t(e)},fail:e=>{s&&s(e),"undefined"!=typeof my&&e.error&&(e.errCode=e.error,e.errMsg=e.errorMessage),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}const u=i("getFileSystemManager"),l=c("downloadFile"),p=c("getFileInfo"),f=i("getSystemInfoSync"),h=i("getAccountInfoSync"),g=i("getAppAuthorizeSetting"),d=c("authorizeForMiniProgram"),y=c("authorize"),v=c("getBLEDeviceServices",(e=>s?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),C=c("getBLEDeviceCharacteristics",(e=>s?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),S=c("createBLEConnection","connectBLEDevice"),B=c("closeBLEConnection","disconnectBLEDevice"),b=c("startBluetoothDevicesDiscovery"),x=c("stopBluetoothDevicesDiscovery"),w=c("getBLEDeviceRSSI"),m=c("getConnectedBluetoothDevices"),A=i("onBLEConnectionStateChange","onBLEConnectionStateChanged"),D=i("offBLEConnectionStateChange","offBLEConnectionStateChanged"),I=i("onBluetoothAdapterStateChange"),L=c("notifyBLECharacteristicValueChange"),E=c("readBLECharacteristicValue"),T=c("getBLEMTU"),U=c("setBLEMTU"),j=c("getBluetoothAdapterState"),O=new Map,M=c("getBluetoothDevices",(e=>s?{devices:e.devices.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:r(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=r(e.serviceData[n]),t)),{})})))}:e)),V=c("writeBLECharacteristicValue"),P=c("createBLEPeripheralServer"),k=c("openBluetoothAdapter"),_=c("closeBluetoothAdapter"),F=i("connectSocket"),W=c("login"),z=c("getUserInfo"),R=i("createUDPSocket"),H=i("createTCPSocket"),$=c("scanCode"),K=c("getSetting"),q=c("getLocalIPAddress"),G=c("startWifi"),N=c("stopWifi"),Q=c("getConnectedWifi"),J=c("request"),X=i("onAppHide"),Y=i("offAppHide"),Z=i("onAppShow"),ee=i("offAppShow"),te=c("navigateToMiniProgram"),ne=c("navigateTo"),re=c("redirectTo"),oe=c("navigateBack"),ae=c("reLaunch"),se=i("setStorageSync"),ie=i("getStorageSync"),ce=i("removeStorageSync"),ue=i("showToast"),le=o.env||{};var pe=Object.freeze({__proto__:null,isWechat:a,isAlipay:s,hasBaseApi:e=>!!o[e]||!1,getFileSystemManager:u,downloadFile:l,getFileInfo:p,getSystemInfoSync:f,getAccountInfoSync:h,getAppAuthorizeSetting:g,authorizeForMiniProgram:d,authorize:y,getBLEDeviceServices:v,getBLEDeviceCharacteristics:C,createBLEConnection:S,closeBLEConnection:B,startBluetoothDevicesDiscovery:b,stopBluetoothDevicesDiscovery:x,getBLEDeviceRSSI:w,getConnectedBluetoothDevices:m,onBLEConnectionStateChange:A,offBLEConnectionStateChange:D,onBluetoothAdapterStateChange:I,notifyBLECharacteristicValueChange:L,readBLECharacteristicValue:E,getBLEMTU:T,setBLEMTU:U,getBluetoothAdapterState:j,onBluetoothDeviceFound:e=>{if(s){const t=({devices:t})=>{const n=t.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:r(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=r(e.serviceData[n]),t)),{})})));e({devices:n})};return O.set(e,t),void o.onBluetoothDeviceFound(t)}o.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{s&&O.has(e)?o.offBluetoothDeviceFound(O.get(e)):o.offBluetoothDeviceFound(e)},getBluetoothDevices:M,onBLECharacteristicValueChange:e=>{if(s){const t=t=>{e(Object.assign(Object.assign({},t),{value:r(t.value)}))};return O.set(e,t),void o.onBLECharacteristicValueChange(t)}o.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{s&&O.has(e)?o.offBLECharacteristicValueChange(O.get(e)):o.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:V,createBLEPeripheralServer:P,openBluetoothAdapter:k,closeBluetoothAdapter:_,connectSocket:F,login:W,getUserInfo:z,createUDPSocket:R,createTCPSocket:H,scanCode:$,getSetting:K,getLocalIPAddress:q,startWifi:G,stopWifi:N,getConnectedWifi:Q,request:J,onAppHide:X,offAppHide:Y,onAppShow:Z,offAppShow:ee,navigateToMiniProgram:te,navigateTo:ne,redirectTo:re,navigateBack:oe,reLaunch:ae,setStorageSync:se,getStorageSync:ie,removeStorageSync:ce,showToast:ue,env:le});const fe=f()||{};function he(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}const ge=(e,t,n=!0)=>{const r=e.split("."),o=t.split("."),a=Math.max(o.length,r.length);for(;o.length<a;)o.splice(0,0,"0");for(;r.length<a;)r.splice(0,0,"0");for(let e=0;e<a;e++){const t=parseInt(r[e]),n=parseInt(o[e]);if(t>n)return!0;if(t===n)break;return!1}return n},de=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));const ye="ios"===fe.platform,ve="ios"===fe.platform,Ce=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=1&t?t>>>1^3988292384:t>>>1;Ce[e]=t}const Se={initial_value:0,table:function(e){const t=[];for(let n=0;n<256;++n){let r=n;for(let t=0;t<8;++t)r=0!=(128&r)?255&(r<<1^e):r<<1&255;t[n]=r}return t}(7)},Be=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},be=e=>{const t=new Uint8Array(4*e.length),n=new DataView(t.buffer);for(let t=0;t<e.length;t++)n.setInt32(4*t,e[t]);return t};const xe={encrypt:function(e,t){const n=Be(e),r=Be(t),o=n.length-1;let a,s,i=n[o],c=n[0],u=Math.floor(6+52/(o+1)),l=0;for(;u-- >0;){l=l+2654435769&4294967295,s=l>>>2&3;let e=0;for(;e<o;e++)c=n[e+1],a=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(r[3&e^s]^i),i=n[e]=n[e]+a&4294967295;c=n[0],a=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(r[3&e^s]^i),i=n[o]=n[o]+a&4294967295}return be(n)},decrypt:function(e,t){const n=Be(e),r=Be(t),o=n.length-1;let a=n[o-1],s=n[0];const i=2654435769;let c,u,l=Math.floor(6+52/(o+1))*i&4294967295;for(;0!==l;){u=l>>>2&3;let e=o;for(;e>0;e--)a=n[e-1],c=(a>>>5^s<<2)+(s>>>3^a<<4)^(l^s)+(r[3&e^u]^a),s=n[e]=n[e]-c&4294967295;a=n[o],c=(a>>>5^s<<2)+(s>>>3^a<<4)^(l^s)+(r[3&e^u]^a),s=n[0]=n[0]-c&4294967295,l=l-i&4294967295}return be(n)}},we=()=>{if("undefined"!=typeof globalThis)try{return globalThis.__tyGlobal={},globalThis}catch(e){}return void 0===Object.prototype.__globalData&&Object.defineProperty(Object.prototype,"__globalData",{value:{},configurable:!1,enumerable:!1}),Object.prototype.__globalData};exports.BaseApi=pe,exports.CRC16=function(e){let t,n,r=65535;for(t=0;t<e.length;t++)for(r^=255&e[t],n=0;n<8;n++)0!=(1&r)?(r>>=1,r^=40961):r>>=1;return r},exports.CRC32=function(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^Ce[255&(t^e[n])];return-1^t},exports.CRC8=e=>{let t=Se.initial_value;for(let n=0;n<e.length;n++)t=Se.table[255&(t^e[n])];return t},exports.ab2hex=function(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(he(e))})),t},exports.bitToBoolean=function(e,t){return(e&Math.pow(2,t))>>t==1},exports.bytesToBits=function(e){return e.reduceRight(((e,t)=>{const n=t.toString(2).padStart(8,"0").split("").map((e=>Number(e))).reverse();return e.concat(n)}),[])},exports.bytesToCharts=function(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")},exports.bytesToHex=n,exports.bytesToInt=function(e){if(e.length>6)throw new Error("The number of bytes exceeds 6");const n=new DataView(e.buffer);switch(e.length){case 1:return n.getInt8(0);case 2:return n.getInt16(0);case 4:return n.getInt32(0);default:{let n=t(e);const r=Math.pow(2,8*e.length)/2;return n>=r&&(n%=r,n=-1*(r-n)),n}}},exports.bytesToIntBy128=(e,t=0)=>{let n=0,r=t;for(;r<4&&r<e.length;r++){const o=e[r];if(n|=(127&o)<<7*(r-t),0==(o>>7&1))break}return{num:n,end:r-t<4?r+1:r}},exports.bytesToString=function(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")},exports.bytesToUint=t,exports.checkVersion=ge,exports.checkWxVersion=e=>ge(e,fe.SDKVersion),exports.clearCache=function(e){const t=we();t[e]&&(t[e]={})},exports.dec2hex=he,exports.firstUpperCase=de,exports.formatQuery=(e,t=!1)=>{if(!e)return"";return Object.keys(e).reduce(((n,r)=>{const o=e[r];return void 0!==o&&n.push(`${r}=${t?encodeURIComponent(o):o}`),n}),[]).join("&")},exports.getCache=function(e,t){const n=we();return n[e]?n[e][t]:null},exports.getCacheSpace=function(e){const t=we();return t[e]?t[e]:null},exports.getGlobal=we,exports.getImageUrl=e=>{if(0!==e.indexOf("http")){return`https://images.tuyacn.com${/^\/[\w\W]+/.test(e)?"":"/"}${e}`}return e},exports.getWxSDKVersion=()=>fe.SDKVersion,exports.hex2ab=function(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2)t.push(parseInt(e.slice(n,n+2),16));else if("string"==typeof e[0])for(let n=0;n<e.length;n++)t.push(parseInt(e[n],16));return new Uint8Array(t)},exports.hex2string=function(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2){const r=parseInt(e.slice(n,n+2),16);t.push(String.fromCharCode(r))}else for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);t.push(String.fromCharCode(r))}return t.join("")},exports.hexToBytes=r,exports.intToBytes=(e,t)=>{const n=new Int32Array([e]),r=new Int8Array(n.buffer);return r.reverse(),t?new Uint8Array(r.slice(4-t)):new Uint8Array(r)},exports.isAndroid=ve,exports.isIOS=ye,exports.keyToHump=function e(t){return"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t))):Object.keys(t).reduce(((n,r)=>{const o=r.split("_").map(((e,t)=>t>0?de(e):e)).join("");let a=t[r];return Array.isArray(a)?a=a.map((t=>e(t))):"object"==typeof a&&(a=e(a)),n[o]=a,n}),{})},exports.randomBytes=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},exports.setCache=function(e,t,n){const r=we();r[e]||(r[e]={}),r[e][t]=n},exports.sleep=(t,n)=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{if(n){const r=t/10;let o=0;const a=setInterval((()=>{o+=r,o>=t&&(clearInterval(a),e(!0)),n()&&(clearInterval(a),e(!0))}),r)}setTimeout((()=>{e(!0)}),t)}))})),exports.stringToBytes=function(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=65536&&n<=1114111?(t.push(n>>18&7|240),t.push(n>>12&63|128),t.push(n>>6&63|128),t.push(63&n|128)):n>=2048&&n<=65535?(t.push(n>>12&15|224),t.push(n>>6&63|128),t.push(63&n|128)):n>=128&&n<=2047?(t.push(n>>6&31|192),t.push(63&n|128)):t.push(255&n)}return new Uint8Array(t)},exports.uintToBytes=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},exports.uintToBytesBy128=e=>{const t=[];do{let n=e%128;(e=parseInt(""+e/128))>0&&(n|=128),t.push(n)}while(e>0);return new Uint8Array(t)},exports.xxtea=xe;
"use strict";function e(e,t,n,r){return new(n||(n=Promise))((function(o,a){function s(e){try{c(r.next(e))}catch(e){a(e)}}function i(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,i)}c((r=r.apply(e,t||[])).next())}))}function t(e){const t=new DataView(e.buffer);switch(e.length){case 0:throw new Error("data of Uint8Array is empty");case 1:return t.getUint8(0);case 2:return t.getUint16(0);case 3:return e.reduce(((e,t)=>e<<8|t),0);case 4:return t.getUint32(0);default:return parseInt(n(e),16)}}function n(e){return e.length?e.length<=4?t(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase():""}Object.defineProperty(exports,"__esModule",{value:!0});const r=e=>{if(e.length%2!=0)throw new Error("hex length error");const t=e.length/2,n=new Uint8Array(t);for(let r=0;r<t;r++)n[r]=parseInt(e.slice(2*r,2*r+2),16);return n},o="undefined"!=typeof wx?wx:"undefined"!=typeof my?my:"undefined"!=typeof ty?ty:{},a="undefined"!=typeof wx,s="undefined"!=typeof my;function i(e,t){return o[e]||t&&o[t]||(()=>{console.warn(`The Api ${e} is not found`)})}function c(e,t,n){"function"==typeof t&&(n=t,t="");const r=o[e]||t&&o[t];return r?e=>new Promise(((t,o)=>{const{success:a,fail:s}=e||{};r(Object.assign(Object.assign({},e),{success:e=>{n&&(e=n(e)),a&&a(e),t(e)},fail:e=>{s&&s(e),"undefined"!=typeof my&&e.error&&(e.errCode=e.error,e.errMsg=e.errorMessage),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}const u=i("getFileSystemManager"),l=c("downloadFile"),p=c("getFileInfo"),f=i("getSystemInfoSync"),h=i("getAccountInfoSync"),g=i("getAppAuthorizeSetting"),d=c("authorizeForMiniProgram"),y=c("authorize"),v=c("getBLEDeviceServices",(e=>s?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),C=c("getBLEDeviceCharacteristics",(e=>s?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),S=c("createBLEConnection","connectBLEDevice"),B=c("closeBLEConnection","disconnectBLEDevice"),b=c("startBluetoothDevicesDiscovery"),x=c("stopBluetoothDevicesDiscovery"),w=c("getBLEDeviceRSSI"),m=c("getConnectedBluetoothDevices"),A=i("onBLEConnectionStateChange","onBLEConnectionStateChanged"),D=i("offBLEConnectionStateChange","offBLEConnectionStateChanged"),I=i("onBluetoothAdapterStateChange"),L=c("notifyBLECharacteristicValueChange"),E=c("readBLECharacteristicValue"),T=c("getBLEMTU"),U=c("setBLEMTU"),j=c("getBluetoothAdapterState"),O=new Map,M=c("getBluetoothDevices",(e=>s?{devices:e.devices.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:r(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=r(e.serviceData[n]),t)),{})})))}:e)),V=c("writeBLECharacteristicValue"),P=c("createBLEPeripheralServer"),k=c("openBluetoothAdapter"),_=c("closeBluetoothAdapter"),F=i("connectSocket"),W=c("login"),z=c("getUserInfo"),R=i("createUDPSocket"),H=i("createTCPSocket"),$=c("scanCode"),K=c("getSetting"),q=c("getLocalIPAddress"),G=c("startWifi"),N=c("stopWifi"),Q=c("getConnectedWifi"),J=c("request"),X=i("onAppHide"),Y=i("offAppHide"),Z=i("onAppShow"),ee=i("offAppShow"),te=c("navigateToMiniProgram"),ne=c("navigateTo"),re=c("redirectTo"),oe=c("navigateBack"),ae=c("reLaunch"),se=i("setStorageSync"),ie=i("getStorageSync"),ce=i("removeStorageSync"),ue=i("showToast"),le=o.env||{};var pe=Object.freeze({__proto__:null,isWechat:a,isAlipay:s,hasBaseApi:e=>!!o[e]||!1,getFileSystemManager:u,downloadFile:l,getFileInfo:p,getSystemInfoSync:f,getAccountInfoSync:h,getAppAuthorizeSetting:g,authorizeForMiniProgram:d,authorize:y,getBLEDeviceServices:v,getBLEDeviceCharacteristics:C,createBLEConnection:S,closeBLEConnection:B,startBluetoothDevicesDiscovery:b,stopBluetoothDevicesDiscovery:x,getBLEDeviceRSSI:w,getConnectedBluetoothDevices:m,onBLEConnectionStateChange:A,offBLEConnectionStateChange:D,onBluetoothAdapterStateChange:I,notifyBLECharacteristicValueChange:L,readBLECharacteristicValue:E,getBLEMTU:T,setBLEMTU:U,getBluetoothAdapterState:j,onBluetoothDeviceFound:e=>{if(s){const t=({devices:t})=>{const n=t.map((e=>Object.assign(Object.assign({},e),{connectable:void 0===e.connectable||e.connectable,advertisData:r(e.advertisData),serviceData:Object.keys(e.serviceData||{}).reduce(((t,n)=>(t[n]=r(e.serviceData[n]),t)),{})})));e({devices:n})};return O.set(e,t),void o.onBluetoothDeviceFound(t)}o.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{s&&O.has(e)?o.offBluetoothDeviceFound(O.get(e)):o.offBluetoothDeviceFound(e)},getBluetoothDevices:M,onBLECharacteristicValueChange:e=>{if(s){const t=t=>{e(Object.assign(Object.assign({},t),{value:r(t.value)}))};return O.set(e,t),void o.onBLECharacteristicValueChange(t)}o.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{s&&O.has(e)?o.offBLECharacteristicValueChange(O.get(e)):o.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:V,createBLEPeripheralServer:P,openBluetoothAdapter:k,closeBluetoothAdapter:_,connectSocket:F,login:W,getUserInfo:z,createUDPSocket:R,createTCPSocket:H,scanCode:$,getSetting:K,getLocalIPAddress:q,startWifi:G,stopWifi:N,getConnectedWifi:Q,request:J,onAppHide:X,offAppHide:Y,onAppShow:Z,offAppShow:ee,navigateToMiniProgram:te,navigateTo:ne,redirectTo:re,navigateBack:oe,reLaunch:ae,setStorageSync:se,getStorageSync:ie,removeStorageSync:ce,showToast:ue,env:le});const fe=f()||{};function he(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}const ge=(e,t,n=!0)=>{const r=e.split("."),o=t.split("."),a=Math.max(o.length,r.length);for(;o.length<a;)o.splice(0,0,"0");for(;r.length<a;)r.splice(0,0,"0");for(let e=0;e<a;e++){const t=parseInt(r[e]),n=parseInt(o[e]);if(t>n)return!0;if(t===n)break;return!1}return n},de=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));const ye="ios"===fe.platform,ve="ios"===fe.platform,Ce=new Uint32Array(256);for(let e=0;e<256;e++){let t=e;for(let e=0;e<8;e++)t=1&t?t>>>1^3988292384:t>>>1;Ce[e]=t}const Se={initial_value:0,table:function(e){const t=[];for(let n=0;n<256;++n){let r=n;for(let t=0;t<8;++t)r=0!=(128&r)?255&(r<<1^e):r<<1&255;t[n]=r}return t}(7)},Be=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},be=e=>{const t=new Uint8Array(4*e.length),n=new DataView(t.buffer);for(let t=0;t<e.length;t++)n.setInt32(4*t,e[t]);return t};const xe={encrypt:function(e,t){const n=Be(e),r=Be(t),o=n.length-1;let a,s,i=n[o],c=n[0],u=Math.floor(6+52/(o+1)),l=0;for(;u-- >0;){l=l+2654435769&4294967295,s=l>>>2&3;let e=0;for(;e<o;e++)c=n[e+1],a=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(r[3&e^s]^i),i=n[e]=n[e]+a&4294967295;c=n[0],a=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(r[3&e^s]^i),i=n[o]=n[o]+a&4294967295}return be(n)},decrypt:function(e,t){const n=Be(e),r=Be(t),o=n.length-1;let a=n[o-1],s=n[0];const i=2654435769;let c,u,l=Math.floor(6+52/(o+1))*i&4294967295;for(;0!==l;){u=l>>>2&3;let e=o;for(;e>0;e--)a=n[e-1],c=(a>>>5^s<<2)+(s>>>3^a<<4)^(l^s)+(r[3&e^u]^a),s=n[e]=n[e]-c&4294967295;a=n[o],c=(a>>>5^s<<2)+(s>>>3^a<<4)^(l^s)+(r[3&e^u]^a),s=n[0]=n[0]-c&4294967295,l=l-i&4294967295}return be(n)}},we=()=>{if("undefined"!=typeof globalThis)try{return globalThis.__tyGlobal={},globalThis}catch(e){}return void 0===Object.prototype.__globalData&&Object.defineProperty(Object.prototype,"__globalData",{value:{},configurable:!1,enumerable:!1}),Object.prototype.__globalData};exports.BaseApi=pe,exports.CRC16=function(e){let t,n,r=65535;for(t=0;t<e.length;t++)for(r^=255&e[t],n=0;n<8;n++)0!=(1&r)?(r>>=1,r^=40961):r>>=1;return r},exports.CRC32=function(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^Ce[255&(t^e[n])];return-1^t},exports.CRC8=e=>{let t=Se.initial_value;for(let n=0;n<e.length;n++)t=Se.table[255&(t^e[n])];return t},exports.ab2hex=function(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(he(e))})),t},exports.bitToBoolean=function(e,t){return(e&Math.pow(2,t))>>t==1},exports.bytesToBits=function(e){return e.reduceRight(((e,t)=>{const n=t.toString(2).padStart(8,"0").split("").map((e=>Number(e))).reverse();return e.concat(n)}),[])},exports.bytesToCharts=function(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")},exports.bytesToHex=n,exports.bytesToInt=function(e){if(e.length>6)throw new Error("The number of bytes exceeds 6");const n=new DataView(e.buffer);switch(e.length){case 1:return n.getInt8(0);case 2:return n.getInt16(0);case 4:return n.getInt32(0);default:{let n=t(e);const r=Math.pow(2,8*e.length)/2;return n>=r&&(n%=r,n=-1*(r-n)),n}}},exports.bytesToIntBy128=(e,t=0)=>{let n=0,r=t;for(;r<4&&r<e.length;r++){const o=e[r];if(n|=(127&o)<<7*(r-t),0==(o>>7&1))break}return{num:n,end:r-t<4?r+1:r}},exports.bytesToString=function(e){const t=[];let n=0;for(;n<e.length;){const r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")},exports.bytesToUint=t,exports.checkVersion=ge,exports.checkWxVersion=e=>ge(fe.SDKVersion,e),exports.clearCache=function(e){const t=we();t[e]&&(t[e]={})},exports.dec2hex=he,exports.firstUpperCase=de,exports.formatQuery=(e,t=!1)=>{if(!e)return"";return Object.keys(e).reduce(((n,r)=>{const o=e[r];return void 0!==o&&n.push(`${r}=${t?encodeURIComponent(o):o}`),n}),[]).join("&")},exports.getCache=function(e,t){const n=we();return n[e]?n[e][t]:null},exports.getCacheSpace=function(e){const t=we();return t[e]?t[e]:null},exports.getGlobal=we,exports.getImageUrl=e=>{if(0!==e.indexOf("http")){return`https://images.tuyacn.com${/^\/[\w\W]+/.test(e)?"":"/"}${e}`}return e},exports.getWxSDKVersion=()=>fe.SDKVersion,exports.hex2ab=function(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2)t.push(parseInt(e.slice(n,n+2),16));else if("string"==typeof e[0])for(let n=0;n<e.length;n++)t.push(parseInt(e[n],16));return new Uint8Array(t)},exports.hex2string=function(e){const t=[];if("string"==typeof e)for(let n=0;n<e.length;n+=2){const r=parseInt(e.slice(n,n+2),16);t.push(String.fromCharCode(r))}else for(let n=0;n<e.length;n++){const r=parseInt(e[n],16);t.push(String.fromCharCode(r))}return t.join("")},exports.hexToBytes=r,exports.intToBytes=(e,t)=>{const n=new Int32Array([e]),r=new Int8Array(n.buffer);return r.reverse(),t?new Uint8Array(r.slice(4-t)):new Uint8Array(r)},exports.isAndroid=ve,exports.isIOS=ye,exports.keyToHump=function e(t){return"object"!=typeof t?t:Array.isArray(t)?t.map((t=>e(t))):Object.keys(t).reduce(((n,r)=>{const o=r.split("_").map(((e,t)=>t>0?de(e):e)).join("");let a=t[r];return Array.isArray(a)?a=a.map((t=>e(t))):"object"==typeof a&&(a=e(a)),n[o]=a,n}),{})},exports.randomBytes=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},exports.setCache=function(e,t,n){const r=we();r[e]||(r[e]={}),r[e][t]=n},exports.sleep=(t,n)=>e(void 0,void 0,void 0,(function*(){return new Promise((e=>{if(n){const r=t/10;let o=0;const a=setInterval((()=>{o+=r,o>=t&&(clearInterval(a),e(!0)),n()&&(clearInterval(a),e(!0))}),r)}setTimeout((()=>{e(!0)}),t)}))})),exports.stringToBytes=function(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e.charCodeAt(r);n>=65536&&n<=1114111?(t.push(n>>18&7|240),t.push(n>>12&63|128),t.push(n>>6&63|128),t.push(63&n|128)):n>=2048&&n<=65535?(t.push(n>>12&15|224),t.push(n>>6&63|128),t.push(63&n|128)):n>=128&&n<=2047?(t.push(n>>6&31|192),t.push(63&n|128)):t.push(255&n)}return new Uint8Array(t)},exports.uintToBytes=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},exports.uintToBytesBy128=e=>{const t=[];do{let n=e%128;(e=parseInt(""+e/128))>0&&(n|=128),t.push(n)}while(e>0);return new Uint8Array(t)},exports.xxtea=xe;
{
"name": "@ray-js/wechat-helper",
"version": "0.2.4",
"version": "0.2.5",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc