@ray-js/wechat-helper
Advanced tools
Comparing version 0.0.20-beta-3 to 0.0.20-beta-4
@@ -1,1 +0,1 @@ | ||
function e(e,t){const n=wx||(my||{});return n[e]?t?t=>new Promise(((r,o)=>{const{success:a,fail:i}=t||{};n[e](Object.assign(Object.assign({},t),{success:e=>{a&&a(e),r(e)},fail:e=>{i&&i(e),o(e)}}))})):n[e]:()=>{console.warn(`The Api ${e} is not found`)}}const t=e("getFileSystemManager"),n=e("downloadFile",!0),r=e("getFileInfo",!0),o=e("getSystemInfoSync"),a=e("getAccountInfoSync"),i=e("getAppAuthorizeSetting"),c=e("authorizeForMiniProgram",!0),s=e("authorize",!0),u=e("onBLEConnectionStateChange"),l=e("offBLEConnectionStateChange"),f=e("onBluetoothAdapterStateChange"),h=e("notifyBLECharacteristicValueChange",!0),g=e("readBLECharacteristicValue",!0),p=e("getBLEMTU",!0),d=e("setBLEMTU",!0),S=e("getBluetoothAdapterState",!0),y=e("onBluetoothDeviceFound"),w=e("offBluetoothDeviceFound"),C=e("getBluetoothDevices",!0),A=e("onBLECharacteristicValueChange"),m=e("offBLECharacteristicValueChange"),B=e("writeBLECharacteristicValue",!0),I=e("createBLEPeripheralServer",!0),U=e("openBluetoothAdapter",!0),v=e("closeBluetoothAdapter",!0),E=e("connectSocket"),b=e("login",!0),L=e("getUserInfo",!0),M=e("createUDPSocket"),T=e("scanCode",!0),x=e("getSetting",!0),F=e("getLocalIPAddress",!0),V=e("startWifi",!0),j=e("stopWifi",!0),D=e("getConnectedWifi",!0),P=e("request",!0),k=e("onAppHide"),z=e("offAppHide"),W=e("onAppShow"),_=e("offAppShow"),O=e("navigateToMiniProgram",!0),H=e("navigateTo",!0),$=e("redirectTo",!0),q=e("navigateBack",!0),R=e("reLaunch",!0),K=()=>{},N=wx?wx.setStorageSync:my?my.setStorageSync:K,G=wx?wx.getStorageSync:my?my.getStorageSync:K,J=wx?wx.removeStorageSync:my?my.removeStorageSync:K,Q=e("showToast",!1),X=wx?wx.env:my?my.env:{};var Y=Object.freeze({__proto__:null,hasBaseApi:e=>!!wx[e],getFileSystemManager:t,downloadFile:n,getFileInfo:r,getSystemInfoSync:o,getAccountInfoSync:a,getAppAuthorizeSetting:i,authorizeForMiniProgram:c,authorize:s,onBLEConnectionStateChange:u,offBLEConnectionStateChange:l,onBluetoothAdapterStateChange:f,notifyBLECharacteristicValueChange:h,readBLECharacteristicValue:g,getBLEMTU:p,setBLEMTU:d,getBluetoothAdapterState:S,onBluetoothDeviceFound:y,offBluetoothDeviceFound:w,getBluetoothDevices:C,onBLECharacteristicValueChange:A,offBLECharacteristicValueChange:m,writeBLECharacteristicValue:B,createBLEPeripheralServer:I,openBluetoothAdapter:U,closeBluetoothAdapter:v,connectSocket:E,login:b,getUserInfo:L,createUDPSocket:M,scanCode:T,getSetting:x,getLocalIPAddress:F,startWifi:V,stopWifi:j,getConnectedWifi:D,request:P,onAppHide:k,offAppHide:z,onAppShow:W,offAppShow:_,navigateToMiniProgram:O,navigateTo:H,redirectTo:$,navigateBack:q,reLaunch:R,setStorageSync:N,getStorageSync:G,removeStorageSync:J,showToast:Q,env:X});function Z(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}function ee(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(Z(e))})),t}function te(e){return parseInt(e,16)}function ne(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 re(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 oe(e){const t=255&e;let n=0;return t>=128?(n=t%128,n=-1*(128-n)):n=t,n}function ae(e){const t=oe(255&e);return[oe(e>>8&255),t]}function ie(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 ce(e){return ie(e,!0)}function se(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 ue=(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("&")},le=e=>{const t=o().SDKVersion;return fe(e,t)},fe=(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},he=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));function ge(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>ge(e))):Object.keys(e).reduce(((t,n)=>{const r=n.split("_").map(((e,t)=>t>0?he(e):e)).join("");let o=e[n];return Array.isArray(o)?o=o.map((e=>ge(e))):"object"==typeof o&&(o=ge(o)),t[r]=o,t}),{})}const pe=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;pe[e]=t}function de(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^pe[255&(t^e[n])];return-1^t}function Se(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 ye={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)},we=e=>{let t=ye.initial_value;for(let n=0;n<e.length;n++)t=ye.table[(t^e[n])%256];return t};function Ce(e,t){return!!((e&Math.pow(2,t))>>t)}function Ae(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=me(e);const n=Math.pow(2,8*e.length)/2;return t>=n&&(t%=n,t=-1*(n-t)),t}}}function me(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(Ie(e),16)}}function Be(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 Ie(e){return e.length<=4?me(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 Ue(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")}function ve(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 Ee(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 be(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 Le=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},Me=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)},Te=(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}},xe=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},Fe=(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)},Ve=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},je=e=>{const t=new DataView(e.buffer),n=[];for(let r=0;r<e.length;r+=4)n.push(t.getInt32(r));return n},De=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 Pe={encrypt:function(e,t){const n=je(e),r=je(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 De(n)},decrypt:function(e,t){const n=je(e),r=je(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 De(n)}},ke={},ze=()=>"undefined"!=typeof globalThis?globalThis:ke;function We(e,t){const n=ze();return n[e]?n[e][t]:null}function _e(e){const t=ze();return t[e]?t[e]:null}function Oe(e,t,n){const r=ze();r[e]||(r[e]={}),r[e][t]=n}function He(e){const t=ze();t[e]&&(t[e]={})}export{Y as BaseApi,Se as CRC16,de as CRC32,we as CRC8,ee as ab2hex,Ce as bitToBoolean,se as bytes2string,Be as bytesToBits,Ue as bytesToCharts,Ie as bytesToHex,Ae as bytesToInt,Te as bytesToIntBy128,be as bytesToString,me as bytesToUint,ve as bytesToUtf8,fe as checkVersion,le as checkWxVersion,He as clearCache,Z as dec2hex,he as firstUpperCase,ue as formatQuery,We as getCache,_e as getCacheSpace,re as hex2ab,te as hex2dec,ne as hex2string,Ve as hexToBytes,ae as int2TwoBytes,oe as intToByte,Fe as intToBytes,ge as keyToHump,Le as randomBytes,Oe as setCache,ie as string2bytes,Ee as stringToBytes,xe as uintToBytes,Me as uintToBytesBy128,ce as utf8ToBytes,Pe as xxtea}; | ||
function e(e){const t=wx||(my||{});return t[e]?t[e]:()=>{console.warn(`The Api ${e} is not found`)}}function t(e){const t=wx||(my||{});return t[e]?n=>new Promise(((r,o)=>{const{success:i,fail:a}=n||{};t[e](Object.assign(Object.assign({},n),{success:e=>{i&&i(e),r(e)},fail:e=>{a&&a(e),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}const n=e("getFileSystemManager"),r=t("downloadFile"),o=t("getFileInfo"),i=e("getSystemInfoSync"),a=e("getAccountInfoSync"),c=e("getAppAuthorizeSetting"),s=t("authorizeForMiniProgram"),u=t("authorize"),l=t("getBLEDeviceServices"),f=t("getBLEDeviceCharacteristics"),h=t("createBLEConnection"),g=t("closeBLEConnection"),p=t("startBluetoothDevicesDiscovery"),d=t("stopBluetoothDevicesDiscovery"),S=t("getBLEDeviceRSSI"),C=t("getConnectedBluetoothDevices"),y=e("onBLEConnectionStateChange"),w=e("offBLEConnectionStateChange"),B=e("onBluetoothAdapterStateChange"),A=t("notifyBLECharacteristicValueChange"),v=t("readBLECharacteristicValue"),m=t("getBLEMTU"),E=t("setBLEMTU"),L=t("getBluetoothAdapterState"),I=e("onBluetoothDeviceFound"),U=e("offBluetoothDeviceFound"),D=t("getBluetoothDevices"),b=e("onBLECharacteristicValueChange"),M=e("offBLECharacteristicValueChange"),T=t("writeBLECharacteristicValue"),F=t("createBLEPeripheralServer"),V=t("openBluetoothAdapter"),j=t("closeBluetoothAdapter"),P=e("connectSocket"),x=t("login"),k=t("getUserInfo"),z=e("createUDPSocket"),W=t("scanCode"),_=t("getSetting"),O=t("getLocalIPAddress"),H=t("startWifi"),R=t("stopWifi"),$=t("getConnectedWifi"),q=t("request"),K=e("onAppHide"),N=e("offAppHide"),G=e("onAppShow"),J=e("offAppShow"),Q=t("navigateToMiniProgram"),X=t("navigateTo"),Y=t("redirectTo"),Z=t("navigateBack"),ee=t("reLaunch"),te=e("setStorageSync"),ne=e("getStorageSync"),re=e("removeStorageSync"),oe=e("showToast"),ie=wx?wx.env:my?my.env:{};var ae=Object.freeze({__proto__:null,hasBaseApi:e=>wx?!!wx[e]:!!my&&!!my[e],getFileSystemManager:n,downloadFile:r,getFileInfo:o,getSystemInfoSync:i,getAccountInfoSync:a,getAppAuthorizeSetting:c,authorizeForMiniProgram:s,authorize:u,getBLEDeviceServices:l,getBLEDeviceCharacteristics:f,createBLEConnection:h,closeBLEConnection:g,startBluetoothDevicesDiscovery:p,stopBluetoothDevicesDiscovery:d,getBLEDeviceRSSI:S,getConnectedBluetoothDevices:C,onBLEConnectionStateChange:y,offBLEConnectionStateChange:w,onBluetoothAdapterStateChange:B,notifyBLECharacteristicValueChange:A,readBLECharacteristicValue:v,getBLEMTU:m,setBLEMTU:E,getBluetoothAdapterState:L,onBluetoothDeviceFound:I,offBluetoothDeviceFound:U,getBluetoothDevices:D,onBLECharacteristicValueChange:b,offBLECharacteristicValueChange:M,writeBLECharacteristicValue:T,createBLEPeripheralServer:F,openBluetoothAdapter:V,closeBluetoothAdapter:j,connectSocket:P,login:x,getUserInfo:k,createUDPSocket:z,scanCode:W,getSetting:_,getLocalIPAddress:O,startWifi:H,stopWifi:R,getConnectedWifi:$,request:q,onAppHide:K,offAppHide:N,onAppShow:G,offAppShow:J,navigateToMiniProgram:Q,navigateTo:X,redirectTo:Y,navigateBack:Z,reLaunch:ee,setStorageSync:te,getStorageSync:ne,removeStorageSync:re,showToast:oe,env:ie});function ce(e,t=2){let n=e;return"string"==typeof e&&(n=parseInt(e)),n.toString(16).padStart(t,"0")}function se(e){const t=[];return Array.prototype.map.call(new Uint8Array(e),(function(e){t.push(ce(e))})),t}function ue(e){return parseInt(e,16)}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 fe(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 he(e){const t=255&e;let n=0;return t>=128?(n=t%128,n=-1*(128-n)):n=t,n}function ge(e){const t=he(255&e);return[he(e>>8&255),t]}function pe(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 de(e){return pe(e,!0)}function Se(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 Ce=(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("&")},ye=e=>{const t=i().SDKVersion;return we(e,t)},we=(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},Be=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));function Ae(e){return"object"!=typeof e?e:Array.isArray(e)?e.map((e=>Ae(e))):Object.keys(e).reduce(((t,n)=>{const r=n.split("_").map(((e,t)=>t>0?Be(e):e)).join("");let o=e[n];return Array.isArray(o)?o=o.map((e=>Ae(e))):"object"==typeof o&&(o=Ae(o)),t[r]=o,t}),{})}const ve=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;ve[e]=t}function me(e){let t=-1;for(let n=0,r=e.length;n<r;n++)t=t>>>8^ve[255&(t^e[n])];return-1^t}function Ee(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 Le={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)},Ie=e=>{let t=Le.initial_value;for(let n=0;n<e.length;n++)t=Le.table[(t^e[n])%256];return t};function Ue(e,t){return!!((e&Math.pow(2,t))>>t)}function De(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=be(e);const n=Math.pow(2,8*e.length)/2;return t>=n&&(t%=n,t=-1*(n-t)),t}}}function be(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(Te(e),16)}}function Me(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 Te(e){return e.length<=4?be(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 Fe(e){return e.length%2!=0?(console.error("Illegal Format UTF16 Code!"),""):e.reduce(((e,t)=>(e.push(String.fromCharCode(t)),e)),[]).join("")}function Ve(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 je(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 Pe(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 xe=e=>{const t=new Uint8Array(e);for(let n=0;n<e;n++)t[n]=Math.floor(256*Math.random());return t},ke=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)},ze=(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}},We=(e,t)=>{const n=new Uint32Array([e]),r=new Uint8Array(n.buffer);return r.reverse(),t?r.slice(4-t):r},_e=(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)},Oe=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},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{ae as BaseApi,Ee as CRC16,me as CRC32,Ie as CRC8,se as ab2hex,Ue as bitToBoolean,Se as bytes2string,Me as bytesToBits,Fe as bytesToCharts,Te as bytesToHex,De as bytesToInt,ze as bytesToIntBy128,Pe as bytesToString,be as bytesToUint,Ve as bytesToUtf8,we as checkVersion,ye as checkWxVersion,Qe as clearCache,ce as dec2hex,Be as firstUpperCase,Ce as formatQuery,Ne as getCache,Ge as getCacheSpace,fe as hex2ab,ue as hex2dec,le as hex2string,Oe as hexToBytes,ge as int2TwoBytes,he as intToByte,_e as intToBytes,Ae as keyToHump,xe as randomBytes,Je as setCache,pe as string2bytes,je as stringToBytes,We as uintToBytes,ke as uintToBytesBy128,de as utf8ToBytes,$e as xxtea}; |
@@ -1,1 +0,1 @@ | ||
"use strict";function e(e,t){const r=wx||(my||{});return r[e]?t?t=>new Promise(((n,o)=>{const{success:s,fail:a}=t||{};r[e](Object.assign(Object.assign({},t),{success:e=>{s&&s(e),n(e)},fail:e=>{a&&a(e),o(e)}}))})):r[e]:()=>{console.warn(`The Api ${e} is not found`)}}Object.defineProperty(exports,"__esModule",{value:!0});const t=e("getFileSystemManager"),r=e("downloadFile",!0),n=e("getFileInfo",!0),o=e("getSystemInfoSync"),s=e("getAccountInfoSync"),a=e("getAppAuthorizeSetting"),i=e("authorizeForMiniProgram",!0),c=e("authorize",!0),u=e("onBLEConnectionStateChange"),l=e("offBLEConnectionStateChange"),f=e("onBluetoothAdapterStateChange"),h=e("notifyBLECharacteristicValueChange",!0),p=e("readBLECharacteristicValue",!0),g=e("getBLEMTU",!0),y=e("setBLEMTU",!0),d=e("getBluetoothAdapterState",!0),S=e("onBluetoothDeviceFound"),C=e("offBluetoothDeviceFound"),w=e("getBluetoothDevices",!0),x=e("onBLECharacteristicValueChange"),A=e("offBLECharacteristicValueChange"),B=e("writeBLECharacteristicValue",!0),m=e("createBLEPeripheralServer",!0),b=e("openBluetoothAdapter",!0),T=e("closeBluetoothAdapter",!0),I=e("connectSocket"),U=e("login",!0),v=e("getUserInfo",!0),E=e("createUDPSocket"),L=e("scanCode",!0),M=e("getSetting",!0),V=e("getLocalIPAddress",!0),j=e("startWifi",!0),F=e("stopWifi",!0),k=e("getConnectedWifi",!0),D=e("request",!0),P=e("onAppHide"),_=e("offAppHide"),W=e("onAppShow"),z=e("offAppShow"),H=e("navigateToMiniProgram",!0),O=e("navigateTo",!0),R=e("redirectTo",!0),$=e("navigateBack",!0),q=e("reLaunch",!0),K=()=>{},N=wx?wx.setStorageSync:my?my.setStorageSync:K,Q=wx?wx.getStorageSync:my?my.getStorageSync:K,G=wx?wx.removeStorageSync:my?my.removeStorageSync:K,J=e("showToast",!1),X=wx?wx.env:my?my.env:{};var Y=Object.freeze({__proto__:null,hasBaseApi:e=>!!wx[e],getFileSystemManager:t,downloadFile:r,getFileInfo:n,getSystemInfoSync:o,getAccountInfoSync:s,getAppAuthorizeSetting:a,authorizeForMiniProgram:i,authorize:c,onBLEConnectionStateChange:u,offBLEConnectionStateChange:l,onBluetoothAdapterStateChange:f,notifyBLECharacteristicValueChange:h,readBLECharacteristicValue:p,getBLEMTU:g,setBLEMTU:y,getBluetoothAdapterState:d,onBluetoothDeviceFound:S,offBluetoothDeviceFound:C,getBluetoothDevices:w,onBLECharacteristicValueChange:x,offBLECharacteristicValueChange:A,writeBLECharacteristicValue:B,createBLEPeripheralServer:m,openBluetoothAdapter:b,closeBluetoothAdapter:T,connectSocket:I,login:U,getUserInfo:v,createUDPSocket:E,scanCode:L,getSetting:M,getLocalIPAddress:V,startWifi:j,stopWifi:F,getConnectedWifi:k,request:D,onAppHide:P,offAppHide:_,onAppShow:W,offAppShow:z,navigateToMiniProgram:H,navigateTo:O,redirectTo:R,navigateBack:$,reLaunch:q,setStorageSync:N,getStorageSync:Q,removeStorageSync:G,showToast:J,env:X});function Z(e,t=2){let r=e;return"string"==typeof e&&(r=parseInt(e)),r.toString(16).padStart(t,"0")}function ee(e){const t=255&e;let r=0;return t>=128?(r=t%128,r=-1*(128-r)):r=t,r}function te(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 a=e.charCodeAt(s);if(t&&55296<=a&&a<=56319){if(++s>=r)throw new Error("Malformed string, low surrogate expected at position "+s);a=(55296^a)<<10|65536|56320^e.charCodeAt(s)}else if(!t&&a>>>8)throw new Error("Wide characters are not allowed.");!t||a<=127?n[o++]=a:a<=2047?(n[o++]=192|a>>6,n[o++]=128|63&a):a<=65535?(n[o++]=224|a>>12,n[o++]=128|a>>6&63,n[o++]=128|63&a):(n[o++]=240|a>>18,n[o++]=128|a>>12&63,n[o++]=128|a>>6&63,n[o++]=128|63&a)}return n.subarray(0,o)}const re=(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},ne=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));const oe=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;oe[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)};function ae(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(ie(e),16)}}function ie(e){return e.length<=4?ae(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase()}const 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},ue=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 le={encrypt:function(e,t){const r=ce(e),n=ce(t),o=r.length-1;let s,a,i=r[o],c=r[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++)c=r[e+1],s=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(n[3&e^a]^i),i=r[e]=r[e]+s&4294967295;c=r[0],s=(i>>>5^c<<2)+(c>>>3^i<<4)^(l^c)+(n[3&e^a]^i),i=r[o]=r[o]+s&4294967295}return ue(r)},decrypt:function(e,t){const r=ce(e),n=ce(t),o=r.length-1;let s=r[o-1],a=r[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--)s=r[e-1],c=(s>>>5^a<<2)+(a>>>3^s<<4)^(l^a)+(n[3&e^u]^s),a=r[e]=r[e]-c&4294967295;s=r[o],c=(s>>>5^a<<2)+(a>>>3^s<<4)^(l^a)+(n[3&e^u]^s),a=r[0]=r[0]-c&4294967295,l=l-i&4294967295}return ue(r)}},fe={},he=()=>"undefined"!=typeof globalThis?globalThis:fe;exports.BaseApi=Y,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^oe[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(Z(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 a=e[s];if(!t||a<128)n[o++]=a;else if(a>=192&&a<224&&s+1<r)n[o++]=(31&a)<<6|63&e[++s];else if(a>=224&&a<240&&s+2<r)n[o++]=(15&a)<<12|(63&e[++s])<<6|63&e[++s];else{if(!(a>=240&&a<248&&s+3<r))throw new Error("Malformed UTF8 character at byte offset "+s);{let t=(7&a)<<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 a=16384;for(let e=0;e<o;e+=a)s+=String.fromCharCode(...n.slice(e,e+a<=o?e+a: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=ie,exports.bytesToInt=function(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=ae(e);const r=Math.pow(2,8*e.length)/2;return t>=r&&(t%=r,t=-1*(r-t)),t}}},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 a=r.slice(7-s);for(let t=1;t<s;t++)a+=e[t+n].toString(2).slice(2);t.push(String.fromCharCode(parseInt(a,2))),n+=s-1}else t.push(String.fromCharCode(e[n]))}return t.join("")},exports.bytesToUint=ae,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=re,exports.checkWxVersion=e=>{const t=o().SDKVersion;return re(e,t)},exports.clearCache=function(e){const t=he();t[e]&&(t[e]={})},exports.dec2hex=Z,exports.firstUpperCase=ne,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=he();return r[e]?r[e][t]:null},exports.getCacheSpace=function(e){const t=he();return t[e]?t[e]:null},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=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},exports.int2TwoBytes=function(e){const t=ee(255&e);return[ee(e>>8&255),t]},exports.intToByte=ee,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?ne(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=he();n[e]||(n[e]={}),n[e][t]=r},exports.string2bytes=te,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 te(e,!0)},exports.xxtea=le; | ||
"use strict";function e(e){const t=wx||(my||{});return t[e]?t[e]:()=>{console.warn(`The Api ${e} is not found`)}}function t(e){const t=wx||(my||{});return t[e]?r=>new Promise(((n,o)=>{const{success:s,fail:i}=r||{};t[e](Object.assign(Object.assign({},r),{success:e=>{s&&s(e),n(e)},fail:e=>{i&&i(e),o(e)}}))})):()=>(console.warn(`The Api ${e} is not found`),Promise.resolve())}Object.defineProperty(exports,"__esModule",{value:!0});const r=e("getFileSystemManager"),n=t("downloadFile"),o=t("getFileInfo"),s=e("getSystemInfoSync"),i=e("getAccountInfoSync"),a=e("getAppAuthorizeSetting"),c=t("authorizeForMiniProgram"),u=t("authorize"),l=t("getBLEDeviceServices"),h=t("getBLEDeviceCharacteristics"),f=t("createBLEConnection"),p=t("closeBLEConnection"),g=t("startBluetoothDevicesDiscovery"),y=t("stopBluetoothDevicesDiscovery"),d=t("getBLEDeviceRSSI"),C=t("getConnectedBluetoothDevices"),S=e("onBLEConnectionStateChange"),B=e("offBLEConnectionStateChange"),w=e("onBluetoothAdapterStateChange"),x=t("notifyBLECharacteristicValueChange"),A=t("readBLECharacteristicValue"),v=t("getBLEMTU"),m=t("setBLEMTU"),b=t("getBluetoothAdapterState"),T=e("onBluetoothDeviceFound"),E=e("offBluetoothDeviceFound"),I=t("getBluetoothDevices"),L=e("onBLECharacteristicValueChange"),U=e("offBLECharacteristicValueChange"),D=t("writeBLECharacteristicValue"),M=t("createBLEPeripheralServer"),V=t("openBluetoothAdapter"),j=t("closeBluetoothAdapter"),F=e("connectSocket"),k=t("login"),P=t("getUserInfo"),_=e("createUDPSocket"),W=t("scanCode"),z=t("getSetting"),R=t("getLocalIPAddress"),H=t("startWifi"),O=t("stopWifi"),$=t("getConnectedWifi"),q=t("request"),K=e("onAppHide"),N=e("offAppHide"),Q=e("onAppShow"),G=e("offAppShow"),J=t("navigateToMiniProgram"),X=t("navigateTo"),Y=t("redirectTo"),Z=t("navigateBack"),ee=t("reLaunch"),te=e("setStorageSync"),re=e("getStorageSync"),ne=e("removeStorageSync"),oe=e("showToast"),se=wx?wx.env:my?my.env:{};var ie=Object.freeze({__proto__:null,hasBaseApi:e=>wx?!!wx[e]:!!my&&!!my[e],getFileSystemManager:r,downloadFile:n,getFileInfo:o,getSystemInfoSync:s,getAccountInfoSync:i,getAppAuthorizeSetting:a,authorizeForMiniProgram:c,authorize:u,getBLEDeviceServices:l,getBLEDeviceCharacteristics:h,createBLEConnection:f,closeBLEConnection:p,startBluetoothDevicesDiscovery:g,stopBluetoothDevicesDiscovery:y,getBLEDeviceRSSI:d,getConnectedBluetoothDevices:C,onBLEConnectionStateChange:S,offBLEConnectionStateChange:B,onBluetoothAdapterStateChange:w,notifyBLECharacteristicValueChange:x,readBLECharacteristicValue:A,getBLEMTU:v,setBLEMTU:m,getBluetoothAdapterState:b,onBluetoothDeviceFound:T,offBluetoothDeviceFound:E,getBluetoothDevices:I,onBLECharacteristicValueChange:L,offBLECharacteristicValueChange:U,writeBLECharacteristicValue:D,createBLEPeripheralServer:M,openBluetoothAdapter:V,closeBluetoothAdapter:j,connectSocket:F,login:k,getUserInfo:P,createUDPSocket:_,scanCode:W,getSetting:z,getLocalIPAddress:R,startWifi:H,stopWifi:O,getConnectedWifi:$,request:q,onAppHide:K,offAppHide:N,onAppShow:Q,offAppShow:G,navigateToMiniProgram:J,navigateTo:X,redirectTo:Y,navigateBack:Z,reLaunch:ee,setStorageSync:te,getStorageSync:re,removeStorageSync:ne,showToast:oe,env:se});function ae(e,t=2){let r=e;return"string"==typeof e&&(r=parseInt(e)),r.toString(16).padStart(t,"0")}function ce(e){const t=255&e;let r=0;return t>=128?(r=t%128,r=-1*(128-r)):r=t,r}function ue(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 le=(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},he=e=>e.replace(/^\S/,(function(e){return e.toUpperCase()}));const fe=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;fe[e]=t}const pe={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)};function ge(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(ye(e),16)}}function ye(e){return e.length<=4?ge(e).toString(16).padStart(2*e.length,"0").toUpperCase():e.reduce(((e,t)=>(e.push(t.toString(16).padStart(2,"0")),e)),[]).join("").toUpperCase()}const de=e=>{const t=new DataView(e.buffer),r=[];for(let n=0;n<e.length;n+=4)r.push(t.getInt32(n));return r},Ce=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=de(e),n=de(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 Ce(r)},decrypt:function(e,t){const r=de(e),n=de(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 Ce(r)}},Be={},we=()=>"undefined"!=typeof globalThis?globalThis:Be;exports.BaseApi=ie,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^fe[255&(t^e[r])];return-1^t},exports.CRC8=e=>{let t=pe.initial_value;for(let r=0;r<e.length;r++)t=pe.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(ae(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=ye,exports.bytesToInt=function(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=ge(e);const r=Math.pow(2,8*e.length)/2;return t>=r&&(t%=r,t=-1*(r-t)),t}}},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=ge,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=le,exports.checkWxVersion=e=>{const t=s().SDKVersion;return le(e,t)},exports.clearCache=function(e){const t=we();t[e]&&(t[e]={})},exports.dec2hex=ae,exports.firstUpperCase=he,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.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=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},exports.int2TwoBytes=function(e){const t=ce(255&e);return[ce(e>>8&255),t]},exports.intToByte=ce,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?he(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=ue,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 ue(e,!0)},exports.xxtea=Se; |
{ | ||
"name": "@ray-js/wechat-helper", | ||
"version": "0.0.20-beta-3", | ||
"version": "0.0.20-beta-4", | ||
"publishConfig": { | ||
@@ -5,0 +5,0 @@ "access": "public", |
@@ -0,51 +1,112 @@ | ||
declare type Callback = (...data: any[]) => void; | ||
export declare const hasBaseApi: (apiName: string) => boolean; | ||
export declare const getFileSystemManager: (option?: any) => any; | ||
export declare const downloadFile: (option?: any) => Promise<any>; | ||
export declare const getFileInfo: (option?: any) => Promise<any>; | ||
export declare const getSystemInfoSync: (option?: any) => any; | ||
export declare const getAccountInfoSync: (option?: any) => any; | ||
export declare const getAppAuthorizeSetting: (option?: any) => any; | ||
export declare const authorizeForMiniProgram: (option?: any) => Promise<any>; | ||
export declare const authorize: (option?: any) => Promise<any>; | ||
export declare const onBLEConnectionStateChange: (option?: any) => any; | ||
export declare const offBLEConnectionStateChange: (option?: any) => any; | ||
export declare const onBluetoothAdapterStateChange: (option?: any) => any; | ||
export declare const notifyBLECharacteristicValueChange: (option?: any) => Promise<any>; | ||
export declare const readBLECharacteristicValue: (option?: any) => Promise<any>; | ||
export declare const getBLEMTU: (option?: any) => Promise<any>; | ||
export declare const setBLEMTU: (option?: any) => Promise<any>; | ||
export declare const getBluetoothAdapterState: (option?: any) => Promise<any>; | ||
export declare const onBluetoothDeviceFound: (option?: any) => any; | ||
export declare const offBluetoothDeviceFound: (option?: any) => any; | ||
export declare const getBluetoothDevices: (option?: any) => Promise<any>; | ||
export declare const onBLECharacteristicValueChange: (option?: any) => any; | ||
export declare const offBLECharacteristicValueChange: (option?: any) => any; | ||
export declare const writeBLECharacteristicValue: (option?: any) => Promise<any>; | ||
export declare const createBLEPeripheralServer: (option?: any) => Promise<any>; | ||
export declare const openBluetoothAdapter: (option?: any) => Promise<any>; | ||
export declare const closeBluetoothAdapter: (option?: any) => Promise<any>; | ||
export declare const connectSocket: (option?: any) => any; | ||
export declare const login: (option?: any) => Promise<any>; | ||
export declare const getUserInfo: (option?: any) => Promise<any>; | ||
export declare const createUDPSocket: (option?: any) => any; | ||
export declare const scanCode: (option?: any) => Promise<any>; | ||
export declare const getSetting: (option?: any) => Promise<any>; | ||
export declare const getLocalIPAddress: (option?: any) => Promise<any>; | ||
export declare const startWifi: (option?: any) => Promise<any>; | ||
export declare const stopWifi: (option?: any) => Promise<any>; | ||
export declare const getConnectedWifi: (option?: any) => Promise<any>; | ||
export declare const request: (option?: any) => Promise<any>; | ||
export declare const onAppHide: (option?: any) => any; | ||
export declare const offAppHide: (option?: any) => any; | ||
export declare const onAppShow: (option?: any) => any; | ||
export declare const offAppShow: (option?: any) => any; | ||
export declare const navigateToMiniProgram: (option?: any) => Promise<any>; | ||
export declare const navigateTo: (option?: any) => Promise<any>; | ||
export declare const redirectTo: (option?: any) => Promise<any>; | ||
export declare const navigateBack: (option?: any) => Promise<any>; | ||
export declare const reLaunch: (option?: any) => Promise<any>; | ||
export declare const setStorageSync: any; | ||
export declare const getStorageSync: any; | ||
export declare const removeStorageSync: any; | ||
export declare const showToast: (option?: any) => Promise<any>; | ||
export declare const getFileSystemManager: () => any; | ||
export declare const downloadFile: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getFileInfo: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getSystemInfoSync: () => any; | ||
export declare const getAccountInfoSync: () => any; | ||
export declare const getAppAuthorizeSetting: () => any; | ||
export declare const authorizeForMiniProgram: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const authorize: (option: { | ||
scope: string; | ||
}, ...rest: any[]) => Promise<any>; | ||
export declare const getBLEDeviceServices: (option: { | ||
deviceId: string; | ||
}, ...rest: any[]) => Promise<{ | ||
services: { | ||
uuid: string; | ||
isPrimary: boolean; | ||
}[]; | ||
}>; | ||
export declare const getBLEDeviceCharacteristics: (option: { | ||
deviceId: string; | ||
serviceId: string; | ||
}, ...rest: any[]) => Promise<{ | ||
characteristics: any[]; | ||
}>; | ||
export declare const createBLEConnection: (option: { | ||
deviceId: string; | ||
timeout: number; | ||
}, ...rest: any[]) => Promise<any>; | ||
export declare const closeBLEConnection: (option: { | ||
deviceId: string; | ||
}, ...rest: any[]) => Promise<any>; | ||
export declare const startBluetoothDevicesDiscovery: (option?: { | ||
services?: string[] | undefined; | ||
interval?: number | undefined; | ||
allowDuplicatesKey?: boolean | undefined; | ||
powerLevel?: "low" | "medium" | "high" | undefined; | ||
} | undefined, ...rest: any[]) => Promise<void>; | ||
export declare const stopBluetoothDevicesDiscovery: () => Promise<void>; | ||
export declare const getBLEDeviceRSSI: (option: { | ||
deviceId: string; | ||
}, ...rest: any[]) => Promise<{ | ||
RSSI: number; | ||
}>; | ||
export declare const getConnectedBluetoothDevices: (option: { | ||
services: string[]; | ||
}, ...rest: any[]) => Promise<{ | ||
devices: { | ||
name: string; | ||
deviceId: string; | ||
}[]; | ||
}>; | ||
export declare const onBLEConnectionStateChange: (option: Callback, ...rest: any[]) => void; | ||
export declare const offBLEConnectionStateChange: (option: Callback, ...rest: any[]) => void; | ||
export declare const onBluetoothAdapterStateChange: (option: Callback, ...rest: any[]) => void; | ||
export declare const notifyBLECharacteristicValueChange: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const readBLECharacteristicValue: (option: { | ||
deviceId: string; | ||
serviceId: string; | ||
characteristicId: string; | ||
}, ...rest: any[]) => Promise<void>; | ||
export declare const getBLEMTU: (option: { | ||
deviceId: string; | ||
writeType?: "write" | "writeNoResponse" | undefined; | ||
}, ...rest: any[]) => Promise<{ | ||
mtu: number; | ||
}>; | ||
export declare const setBLEMTU: (option: { | ||
deviceId: string; | ||
mtu: number; | ||
}, ...rest: any[]) => Promise<{ | ||
mtu: number; | ||
}>; | ||
export declare const getBluetoothAdapterState: () => Promise<any>; | ||
export declare const onBluetoothDeviceFound: (option: Callback, ...rest: any[]) => void; | ||
export declare const offBluetoothDeviceFound: (option: Callback, ...rest: any[]) => void; | ||
export declare const getBluetoothDevices: () => Promise<any>; | ||
export declare const onBLECharacteristicValueChange: (option: Callback, ...rest: any[]) => void; | ||
export declare const offBLECharacteristicValueChange: (option: Callback, ...rest: any[]) => void; | ||
export declare const writeBLECharacteristicValue: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const createBLEPeripheralServer: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const openBluetoothAdapter: (option?: { | ||
mode?: string | undefined; | ||
} | undefined, ...rest: any[]) => Promise<void>; | ||
export declare const closeBluetoothAdapter: () => Promise<void>; | ||
export declare const connectSocket: (() => any) | ((option?: any, ...rest: any[]) => any); | ||
export declare const login: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getUserInfo: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const createUDPSocket: (() => any) | ((option?: any, ...rest: any[]) => any); | ||
export declare const scanCode: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getSetting: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getLocalIPAddress: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const startWifi: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const stopWifi: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const getConnectedWifi: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const request: (() => Promise<any>) | ((option?: any, ...rest: any[]) => Promise<any>); | ||
export declare const onAppHide: (option: Callback, ...rest: any[]) => void; | ||
export declare const offAppHide: (option: Callback, ...rest: any[]) => void; | ||
export declare const onAppShow: (option: Callback, ...rest: any[]) => void; | ||
export declare const offAppShow: (option: Callback, ...rest: any[]) => void; | ||
export declare const navigateToMiniProgram: (() => Promise<void>) | ((option?: any, ...rest: any[]) => Promise<void>); | ||
export declare const navigateTo: (() => Promise<void>) | ((option?: any, ...rest: any[]) => Promise<void>); | ||
export declare const redirectTo: (() => Promise<void>) | ((option?: any, ...rest: any[]) => Promise<void>); | ||
export declare const navigateBack: (() => Promise<void>) | ((option?: any, ...rest: any[]) => Promise<void>); | ||
export declare const reLaunch: (() => Promise<void>) | ((option?: any, ...rest: any[]) => Promise<void>); | ||
export declare const setStorageSync: (key: string, value: any) => void; | ||
export declare const getStorageSync: (key: string) => any; | ||
export declare const removeStorageSync: (key: string) => void; | ||
export declare const showToast: (() => void) | ((option?: any, ...rest: any[]) => void); | ||
export declare const env: any; | ||
export {}; |
35972
442