Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ray-js/wechat-helper

Package Overview
Dependencies
Maintainers
1
Versions
155
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ray-js/wechat-helper - npm Package Compare versions

Comparing version 0.0.25-beta-1 to 0.0.25-beta-10

2

index.esm.js

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

function e(e,t){return!!((e&Math.pow(2,t))>>t)}function t(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=n(e);const r=Math.pow(2,8*e.length)/2;return t>=r&&(t%=r,t=-1*(r-t)),t}}}function n(e){const t=new DataView(e.buffer);switch(e.length){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(o(e),16)}}function r(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 o(e){return e.length<=4?n(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 a(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 c(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)}function s(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e[r].toString(2),o=n.match(/^1+?(?=0)/);if(o&&8==n.length){const i=o[0].length;let a=n.slice(7-i);for(let t=1;t<i;t++)a+=e[t+r].toString(2).slice(2);t.push(String.fromCharCode(parseInt(a,2))),r+=i-1}else t.push(String.fromCharCode(e[r]))}return t.join("")}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:{},C="undefined"!=typeof wx,v="undefined"!=typeof my;function y(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:i,fail:a}=e||{};r(Object.assign(Object.assign({},e),{success:e=>{n&&(e=n(e)),i&&i(e),t(e)},fail:e=>{a&&a(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=y("getFileSystemManager"),w=S("downloadFile"),A=S("getFileInfo"),m=y("getSystemInfoSync"),D=y("getAccountInfoSync"),E=y("getAppAuthorizeSetting"),b=S("authorizeForMiniProgram"),L=S("authorize"),I=S("getBLEDeviceServices",(e=>v?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),U=S("getBLEDeviceCharacteristics",(e=>v?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),j=S("createBLEConnection","connectBLEDevice"),M=S("closeBLEConnection","disconnectBLEDevice"),T=S("startBluetoothDevicesDiscovery"),F=S("stopBluetoothDevicesDiscovery"),V=S("getBLEDeviceRSSI"),O=S("getConnectedBluetoothDevices"),P=y("onBLEConnectionStateChange","onBLEConnectionStateChanged"),k=y("offBLEConnectionStateChange","offBLEConnectionStateChanged"),x=y("onBluetoothAdapterStateChange"),W=S("notifyBLECharacteristicValueChange"),z=S("readBLECharacteristicValue"),_=S("getBLEMTU"),H=S("setBLEMTU"),R=S("getBluetoothAdapterState"),$=new Map,q=S("getBluetoothDevices",(e=>v?{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"),N=S("createBLEPeripheralServer"),G=S("openBluetoothAdapter"),J=S("closeBluetoothAdapter"),Q=y("connectSocket"),X=S("login"),Y=S("getUserInfo"),Z=y("createUDPSocket"),ee=S("scanCode"),te=S("getSetting"),ne=S("getLocalIPAddress"),re=S("startWifi"),oe=S("stopWifi"),ie=S("getConnectedWifi"),ae=S("request"),ce=y("onAppHide"),se=y("offAppHide"),ue=y("onAppShow"),le=y("offAppShow"),fe=S("navigateToMiniProgram"),he=S("navigateTo"),ge=S("redirectTo"),pe=S("navigateBack"),de=S("reLaunch"),Ce=y("setStorageSync"),ve=y("getStorageSync"),ye=y("removeStorageSync"),Se=y("showToast"),Be=d.env||{};var we=Object.freeze({__proto__:null,isWechat:C,isAlipay:v,hasBaseApi:e=>!!d[e]||!1,getFileSystemManager:B,downloadFile:w,getFileInfo:A,getSystemInfoSync:m,getAccountInfoSync:D,getAppAuthorizeSetting:E,authorizeForMiniProgram:b,authorize:L,getBLEDeviceServices:I,getBLEDeviceCharacteristics:U,createBLEConnection:j,closeBLEConnection:M,startBluetoothDevicesDiscovery:T,stopBluetoothDevicesDiscovery:F,getBLEDeviceRSSI:V,getConnectedBluetoothDevices:O,onBLEConnectionStateChange:P,offBLEConnectionStateChange:k,onBluetoothAdapterStateChange:x,notifyBLECharacteristicValueChange:W,readBLECharacteristicValue:z,getBLEMTU:_,setBLEMTU:H,getBluetoothAdapterState:R,onBluetoothDeviceFound:e=>{if(v){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 $.set(e,t),void d.onBluetoothDeviceFound(t)}d.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{v&&$.has(e)?d.offBluetoothDeviceFound($.get(e)):d.offBluetoothDeviceFound(e)},getBluetoothDevices:q,onBLECharacteristicValueChange:e=>{if(v){const t=t=>{e(Object.assign(Object.assign({},t),{value:p(t.value)}))};return $.set(e,t),void d.onBLECharacteristicValueChange(t)}d.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{v&&$.has(e)?d.offBLECharacteristicValueChange($.get(e)):d.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:K,createBLEPeripheralServer:N,openBluetoothAdapter:G,closeBluetoothAdapter:J,connectSocket:Q,login:X,getUserInfo:Y,createUDPSocket:Z,scanCode:ee,getSetting:te,getLocalIPAddress:ne,startWifi:re,stopWifi:oe,getConnectedWifi:ie,request:ae,onAppHide:ce,offAppHide:se,onAppShow:ue,offAppShow:le,navigateToMiniProgram:fe,navigateTo:he,redirectTo:ge,navigateBack:pe,reLaunch:de,setStorageSync:Ce,getStorageSync:ve,removeStorageSync:ye,showToast:Se,env:Be});function Ae(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}function me(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(Ae(e))})),t}function De(e){return parseInt(e,16)}function Ee(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 be(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)}function Le(e){const t=255&e;let n=0;return t>=128?(n=t%128,n=-1*(128-n)):n=t,n}function Ie(e){const t=Le(255&e);return[Le(e>>8&255),t]}function Ue(e,t=!1){const n=e.length,r=new Uint8Array(t?4*n:n);let o=0;for(let i=0;i<n;i++){let a=e.charCodeAt(i);if(t&&55296<=a&&a<=56319){if(++i>=n)throw new Error("Malformed string, low surrogate expected at position "+i);a=(55296^a)<<10|65536|56320^e.charCodeAt(i)}else if(!t&&a>>>8)throw new Error("Wide characters are not allowed.");!t||a<=127?r[o++]=a:a<=2047?(r[o++]=192|a>>6,r[o++]=128|63&a):a<=65535?(r[o++]=224|a>>12,r[o++]=128|a>>6&63,r[o++]=128|63&a):(r[o++]=240|a>>18,r[o++]=128|a>>12&63,r[o++]=128|a>>6&63,r[o++]=128|63&a)}return r.subarray(0,o)}function je(e){return Ue(e,!0)}function Me(e,t=!1){const n=e.length,r=new Array(n);let o=0;for(let i=0;i<n;i++){const a=e[i];if(!t||a<128)r[o++]=a;else if(a>=192&&a<224&&i+1<n)r[o++]=(31&a)<<6|63&e[++i];else if(a>=224&&a<240&&i+2<n)r[o++]=(15&a)<<12|(63&e[++i])<<6|63&e[++i];else{if(!(a>=240&&a<248&&i+3<n))throw new Error("Malformed UTF8 character at byte offset "+i);{let t=(7&a)<<18|(63&e[++i])<<12|(63&e[++i])<<6|63&e[++i];t<=65535?r[o++]=t:(t^=65536,r[o++]=55296|t>>10,r[o++]=56320|1023&t)}}}let i="";const a=16384;for(let e=0;e<o;e+=a)i+=String.fromCharCode(...r.slice(e,e+a<=o?e+a:o));return i}const Te=(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("&")},Fe=e=>{const t=m().SDKVersion;return Ve(e,t)},Ve=(e,t,n=!0)=>{const r=e.split("."),o=t.split("."),i=Math.max(o.length,r.length);for(;o.length<i;)o.splice(0,0,"0");for(;r.length<i;)r.splice(0,0,"0");for(let e=0;e<i;e++){const t=parseInt(r[e]),n=parseInt(o[e]);if(t>n)return!0;if(t===n)break;return!1}return n},Oe=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));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?Oe(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 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)?(r<<1^e)%256:(r<<1)%256;t[n]=r}return t}(7)},_e=e=>{let t=ze.initial_value;for(let n=0;n<e.length;n++)t=ze.table[(t^e[n])%256];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 $e={encrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let i,a,c=n[o],s=n[0],u=Math.floor(6+52/(o+1)),l=0;for(;u-- >0;){l=l+2654435769&4294967295,a=l>>>2&3;let e=0;for(;e<o;e++)s=n[e+1],i=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^a]^c),c=n[e]=n[e]+i&4294967295;s=n[0],i=(c>>>5^s<<2)+(s>>>3^c<<4)^(l^s)+(r[3&e^a]^c),c=n[o]=n[o]+i&4294967295}return Re(n)},decrypt:function(e,t){const n=He(e),r=He(t),o=n.length-1;let i=n[o-1],a=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--)i=n[e-1],s=(i>>>5^a<<2)+(a>>>3^i<<4)^(l^a)+(r[3&e^u]^i),a=n[e]=n[e]-s&4294967295;i=n[o],s=(i>>>5^a<<2)+(a>>>3^i<<4)^(l^a)+(r[3&e^u]^i),a=n[0]=n[0]-s&4294967295,l=l-c&4294967295}return Re(n)}},qe={},Ke=()=>"undefined"!=typeof globalThis?globalThis:qe;function Ne(e,t){const n=Ke();return n[e]?n[e][t]:null}function Ge(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{we as BaseApi,We as CRC16,xe as CRC32,_e as CRC8,me as ab2hex,e as bitToBoolean,Me as bytes2string,r as bytesToBits,i as bytesToCharts,o as bytesToHex,t as bytesToInt,f as bytesToIntBy128,s as bytesToString,n as bytesToUint,a as bytesToUtf8,Ve as checkVersion,Fe as checkWxVersion,Qe as clearCache,Ae as dec2hex,Oe as firstUpperCase,Te as formatQuery,Ne as getCache,Ge as getCacheSpace,Ke as getGlobal,be as hex2ab,De as hex2dec,Ee as hex2string,p as hexToBytes,Ie as int2TwoBytes,Le as intToByte,g as intToBytes,Pe as keyToHump,u as randomBytes,Je as setCache,Ue as string2bytes,c as stringToBytes,h as uintToBytes,l as uintToBytesBy128,je as utf8ToBytes,$e as xxtea};
function e(e,t){return(e&Math.pow(2,t))>>t==1}function t(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=n(e);const r=Math.pow(2,8*e.length)/2;return t>=r&&(t%=r,t=-1*(r-t)),t}}}function n(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(o(e),16)}}function r(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 o(e){return e.length?e.length<=4?n(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 a(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")}function i(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 c(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)}function s(e){const t=[],n=e.length;for(let r=0;r<n;r++){const n=e[r].toString(2),o=n.match(/^1+?(?=0)/);if(o&&8==n.length){const a=o[0].length;let i=n.slice(7-a);for(let t=1;t<a;t++)i+=e[t+r].toString(2).slice(2);t.push(String.fromCharCode(parseInt(i,2))),r+=a-1}else t.push(String.fromCharCode(e[r]))}return t.join("")}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:{},y="undefined"!=typeof wx,C="undefined"!=typeof my;function v(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=v("getFileSystemManager"),w=S("downloadFile"),A=S("getFileInfo"),m=v("getSystemInfoSync"),D=v("getAccountInfoSync"),E=v("getAppAuthorizeSetting"),b=S("authorizeForMiniProgram"),L=S("authorize"),I=S("getBLEDeviceServices",(e=>C?{services:e.services.map((e=>({uuid:e.serviceId.toUpperCase(),isPrimary:e.isPrimary})))}:e)),U=S("getBLEDeviceCharacteristics",(e=>C?{characteristics:e.characteristics.map((e=>Object.assign(Object.assign({},e),{uuid:e.characteristicId.toUpperCase()})))}:e)),j=S("createBLEConnection","connectBLEDevice"),M=S("closeBLEConnection","disconnectBLEDevice"),T=S("startBluetoothDevicesDiscovery"),F=S("stopBluetoothDevicesDiscovery"),V=S("getBLEDeviceRSSI"),O=S("getConnectedBluetoothDevices"),P=v("onBLEConnectionStateChange","onBLEConnectionStateChanged"),k=v("offBLEConnectionStateChange","offBLEConnectionStateChanged"),x=v("onBluetoothAdapterStateChange"),W=S("notifyBLECharacteristicValueChange"),z=S("readBLECharacteristicValue"),_=S("getBLEMTU"),H=S("setBLEMTU"),R=S("getBluetoothAdapterState"),$=new Map,q=S("getBluetoothDevices",(e=>C?{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"),N=S("createBLEPeripheralServer"),G=S("openBluetoothAdapter"),J=S("closeBluetoothAdapter"),Q=v("connectSocket"),X=S("login"),Y=S("getUserInfo"),Z=v("createUDPSocket"),ee=S("scanCode"),te=S("getSetting"),ne=S("getLocalIPAddress"),re=S("startWifi"),oe=S("stopWifi"),ae=S("getConnectedWifi"),ie=S("request"),ce=v("onAppHide"),se=v("offAppHide"),ue=v("onAppShow"),le=v("offAppShow"),fe=S("navigateToMiniProgram"),he=S("navigateTo"),ge=S("redirectTo"),pe=S("navigateBack"),de=S("reLaunch"),ye=v("setStorageSync"),Ce=v("getStorageSync"),ve=v("removeStorageSync"),Se=v("showToast"),Be=d.env||{};var we=Object.freeze({__proto__:null,isWechat:y,isAlipay:C,hasBaseApi:e=>!!d[e]||!1,getFileSystemManager:B,downloadFile:w,getFileInfo:A,getSystemInfoSync:m,getAccountInfoSync:D,getAppAuthorizeSetting:E,authorizeForMiniProgram:b,authorize:L,getBLEDeviceServices:I,getBLEDeviceCharacteristics:U,createBLEConnection:j,closeBLEConnection:M,startBluetoothDevicesDiscovery:T,stopBluetoothDevicesDiscovery:F,getBLEDeviceRSSI:V,getConnectedBluetoothDevices:O,onBLEConnectionStateChange:P,offBLEConnectionStateChange:k,onBluetoothAdapterStateChange:x,notifyBLECharacteristicValueChange:W,readBLECharacteristicValue:z,getBLEMTU:_,setBLEMTU:H,getBluetoothAdapterState:R,onBluetoothDeviceFound:e=>{if(C){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 $.set(e,t),void d.onBluetoothDeviceFound(t)}d.onBluetoothDeviceFound(e)},offBluetoothDeviceFound:e=>{C&&$.has(e)?d.offBluetoothDeviceFound($.get(e)):d.offBluetoothDeviceFound(e)},getBluetoothDevices:q,onBLECharacteristicValueChange:e=>{if(C){const t=t=>{e(Object.assign(Object.assign({},t),{value:p(t.value)}))};return $.set(e,t),void d.onBLECharacteristicValueChange(t)}d.onBLECharacteristicValueChange(e)},offBLECharacteristicValueChange:e=>{C&&$.has(e)?d.offBLECharacteristicValueChange($.get(e)):d.offBLECharacteristicValueChange(e)},writeBLECharacteristicValue:K,createBLEPeripheralServer:N,openBluetoothAdapter:G,closeBluetoothAdapter:J,connectSocket:Q,login:X,getUserInfo:Y,createUDPSocket:Z,scanCode:ee,getSetting:te,getLocalIPAddress:ne,startWifi:re,stopWifi:oe,getConnectedWifi:ae,request:ie,onAppHide:ce,offAppHide:se,onAppShow:ue,offAppShow:le,navigateToMiniProgram:fe,navigateTo:he,redirectTo:ge,navigateBack:pe,reLaunch:de,setStorageSync:ye,getStorageSync:Ce,removeStorageSync:ve,showToast:Se,env:Be});const Ae=m()||{};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 Ee(e){return parseInt(e,16)}function be(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 Le(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)}function Ie(e){const t=255&e;let n=0;return t>=128?(n=t%128,n=-1*(128-n)):n=t,n}function Ue(e){const t=Ie(255&e);return[Ie(e>>8&255),t]}function je(e,t=!1){const n=e.length,r=new Uint8Array(t?4*n:n);let o=0;for(let a=0;a<n;a++){let i=e.charCodeAt(a);if(t&&55296<=i&&i<=56319){if(++a>=n)throw new Error("Malformed string, low surrogate expected at position "+a);i=(55296^i)<<10|65536|56320^e.charCodeAt(a)}else if(!t&&i>>>8)throw new Error("Wide characters are not allowed.");!t||i<=127?r[o++]=i:i<=2047?(r[o++]=192|i>>6,r[o++]=128|63&i):i<=65535?(r[o++]=224|i>>12,r[o++]=128|i>>6&63,r[o++]=128|63&i):(r[o++]=240|i>>18,r[o++]=128|i>>12&63,r[o++]=128|i>>6&63,r[o++]=128|63&i)}return r.subarray(0,o)}function Me(e){return je(e,!0)}function Te(e,t=!1){const n=e.length,r=new Array(n);let o=0;for(let a=0;a<n;a++){const i=e[a];if(!t||i<128)r[o++]=i;else if(i>=192&&i<224&&a+1<n)r[o++]=(31&i)<<6|63&e[++a];else if(i>=224&&i<240&&a+2<n)r[o++]=(15&i)<<12|(63&e[++a])<<6|63&e[++a];else{if(!(i>=240&&i<248&&a+3<n))throw new Error("Malformed UTF8 character at byte offset "+a);{let t=(7&i)<<18|(63&e[++a])<<12|(63&e[++a])<<6|63&e[++a];t<=65535?r[o++]=t:(t^=65536,r[o++]=55296|t>>10,r[o++]=56320|1023&t)}}}let a="";const i=16384;for(let e=0;e<o;e+=i)a+=String.fromCharCode(...r.slice(e,e+i<=o?e+i:o));return a}const Fe=(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("&")},Ve=e=>Oe(e,Ae.SDKVersion),Oe=(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},Pe=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));function ke(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>ke(e))):Object.keys(e).reduce(((t,n)=>{const r=n.split("_").map(((e,t)=>t>0?Pe(e):e)).join("");let o=e[n];return Array.isArray(o)?o=o.map((e=>ke(e))):"object"==typeof o&&(o=ke(o)),t[r]=o,t}),{})}const xe="ios"===Ae.platform,We="ios"===Ae.platform,ze=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;ze[e]=t}function _e(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^ze[255&(t^e[n])];return-1^t}function He(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 Re={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)?(r<<1^e)%256:(r<<1)%256;t[n]=r}return t}(7)},$e=e=>{let t=Re.initial_value;for(let n=0;n<e.length;n++)t=Re.table[(t^e[n])%256];return t},qe=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},Ke=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 Ne={encrypt:function(e,t){const n=qe(e),r=qe(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 Ke(n)},decrypt:function(e,t){const n=qe(e),r=qe(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 Ke(n)}},Ge={},Je=()=>"undefined"!=typeof globalThis?globalThis:Ge;function Qe(e,t){const n=Je();return n[e]?n[e][t]:null}function Xe(e){const t=Je();return t[e]?t[e]:null}function Ye(e,t,n){const r=Je();r[e]||(r[e]={}),r[e][t]=n}function Ze(e){const t=Je();t[e]&&(t[e]={})}export{we as BaseApi,He as CRC16,_e as CRC32,$e as CRC8,De as ab2hex,e as bitToBoolean,Te as bytes2string,r as bytesToBits,a as bytesToCharts,o as bytesToHex,t as bytesToInt,f as bytesToIntBy128,s as bytesToString,n as bytesToUint,i as bytesToUtf8,Oe as checkVersion,Ve as checkWxVersion,Ze as clearCache,me as dec2hex,Pe as firstUpperCase,Fe as formatQuery,Qe as getCache,Xe as getCacheSpace,Je as getGlobal,Le as hex2ab,Ee as hex2dec,be as hex2string,p as hexToBytes,Ue as int2TwoBytes,Ie as intToByte,g as intToBytes,We as isAndroid,xe as isIOS,ke as keyToHump,u as randomBytes,Ye as setCache,je as string2bytes,c as stringToBytes,h as uintToBytes,l as uintToBytesBy128,Me as utf8ToBytes,Ne as xxtea};

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

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

@@ -15,2 +15,3 @@ "access": "public",

],
"license": "MIT",
"module": "./index.esm.js",

@@ -17,0 +18,0 @@ "main": "./index.js",

@@ -96,1 +96,3 @@ /**

export declare function keyToHump(data: any): any;
export declare const isIOS: boolean;
export declare const isAndroid: boolean;
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc