qcloud-iotexplorer-appdev-sdk
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -1,2 +0,2 @@ | ||
import{__awaiter,__rest}from"tslib";import{LoginManager,IotWebsocket,requestTokenApi}from"./modules";import{EventEmitter,base64,delay,noop,logger,genVerifyLoginFailError,isVerifyLoginError,normalizeError,envDetect}from"./utils";import*as utils from"./utils";import*as constants from"./constants";const ReportLevel={INFO:0,WARN:1,ERROR:2};export class AppDevSdk extends EventEmitter{constructor(e){var{getAccessToken:t,appKey:i="",apiPlatform:s="",debug:r=!1,apiUrl:o}=e,n=e.wsConfig,a=void 0===n?{}:n,{autoReconnect:c=!0,disconnectWhenAppHide:l=!0,connectWhenAppShow:d=!0}=a,h=__rest(a,["autoReconnect","disconnectWhenAppHide","connectWhenAppShow"]),{reporter:g,defaultUin:u="unknown"}=e;super(),this.isManuallyClose=!1,this._defaultFamilyIdPromise=null,this.constants=constants,this.utils=utils,this._defaultUin=u,this._apiUrl=o,logger.config({debug:r});const p=g||noop;this.reporter={info:(e,t={})=>{try{p(e,Object.assign({level:ReportLevel.INFO},t))}catch(e){logger.warn(e)}},warn:(e,t={})=>{try{p(e,Object.assign({level:ReportLevel.WARN},t))}catch(e){logger.warn(e)}},error:(e,t={})=>{try{p(e,Object.assign({level:ReportLevel.ERROR},t))}catch(e){logger.warn(e)}}},this.ws=new IotWebsocket(this,Object.assign(Object.assign({},h),{apiPlatform:s})),this.loginManager=new LoginManager(this,{getAccessToken:t,appKey:i}),this._apiPlatform=s,this.ws.on("error",e=>{logger.debug("websocket error",e),this.emit(constants.EventTypes.WsError,e),c&&this._reconnectWs()}),this.ws.on("close",({code:e,reason:t}={})=>{logger.debug("websocket close",{code:e,reason:t}),this.emit(constants.EventTypes.WsClose,{code:e,reason:t}),c&&this._onWebsocketClose()}),this.ws.on("push",e=>this._handlePushEvent(e)),envDetect.isMiniProgram&&(wx.onAppHide(()=>{l&&(this.isManuallyClose=!0,this.ws.disconnect({reason:"appHide"}))}),wx.onAppShow(()=>{d&&this.isLogin&&this.ws.connect()}))}get userInfo(){return this.loginManager.userInfo}get isLogin(){return this.loginManager.isLogin}get userId(){return this.loginManager.userId}get uin(){return this.loginManager.userId}get nickName(){return this.loginManager.nickName}init(e){return __awaiter(this,void 0,void 0,(function*(){return e||(e={}),e.reload&&(this._initPromise=null),this._initPromise||(this._initPromise=new Promise((e,t)=>__awaiter(this,void 0,void 0,(function*(){try{yield this.loginManager.login(),yield this.ws.connect(),e()}catch(e){t(normalizeError(e)),this._initPromise=null}}))))}))}getDefaultFamilyId(){return this._defaultFamilyIdPromise||(this._defaultFamilyIdPromise=new Promise((e,t)=>__awaiter(this,void 0,void 0,(function*(){try{const{FamilyList:t,Total:i}=yield this.requestApi("AppGetFamilyList",{Offset:0,Limit:100});if(!i){const{Data:{FamilyId:t}}=yield this.requestApi("AppCreateFamily",{Name:this.loginManager.nickName});return e(t)}e(t[0].FamilyId)}catch(e){t(e),this._defaultFamilyIdPromise=null}}))))}sendWebsocketMessage(e,t={}){return __awaiter(this,void 0,void 0,(function*(){return yield this.init(),this.ws.send(e,t)}))}connectWebsocket(){return __awaiter(this,void 0,void 0,(function*(){yield this.init(),yield this.ws.connect()}))}disconnectWebsocket(e){this.ws.disconnect(e)}subscribeDevices(e){return __awaiter(this,void 0,void 0,(function*(){this.ws.connect((e||[]).map(e=>"string"==typeof e?e:e&&e.DeviceId?e.DeviceId:void 0).filter(Boolean))}))}requestApi(e,t={},i={}){var{doNotRetry:s=!1,needLogin:r=!0,doNotReport:o=!1}=i,n=__rest(i,["doNotRetry","needLogin","doNotReport"]);return __awaiter(this,void 0,void 0,(function*(){try{r&&(yield this.loginManager.checkLogin());const{accessToken:i,userId:s}=this.loginManager;t&&"default"===t.FamilyId&&(t.FamilyId=yield this.getDefaultFamilyId());const a=Object.assign({uin:s},t);return i&&(a.AccessToken=i),this._apiPlatform&&(a.Platform=this._apiPlatform),yield requestTokenApi(e,a,Object.assign({reporter:this.reporter,doNotReport:o,url:this._apiUrl},n))}catch(i){if(logger.debug("requestApi fail",i),isVerifyLoginError(i)){if(s)return Promise.reject(genVerifyLoginFailError(i));try{yield this.loginManager.reLogin()}catch(e){return logger.error("reLogin fail",e),Promise.reject(genVerifyLoginFailError(i))}return this.requestApi(e,t,Object.assign({doNotRetry:!0},n))}return Promise.reject(normalizeError(i))}}))}_handlePushEvent(e){e||(e={}),this.emit(constants.EventTypes.WsPush,e);let{action:t,params:i}=e;i||(i={});let{DeviceId:s,Type:r,SubType:o,Payload:n,Time:a}=i;const c=new Date(a).getTime();switch(n&&(n=JSON.parse(base64.decode(n))),logger.debug("websocket push payload",n),t){case"DeviceChange":switch(r){case"Property":case"Shadow":case"Template":switch(o){case"Report":{const e={};try{if(n){let{type:t,state:i,method:s,params:r}=n;if(t&&"update"===t&&i&&i.reported&&(s="report",r=i.reported),r||(r={}),"report"===s)for(const t in r)e[t]={Value:r[t],lastUpdate:c}}}catch(e){logger.error("handle report event error",e)}this.emit(constants.EventTypes.WsReport,{deviceId:s,deviceData:e});break}case"Push":{const e={};try{if(n){let{type:t,payload:i,method:r,params:o}=n;if(t&&"delta"===t&&i&&i.state&&(r="control",o=i.state),"control"===r&&o){for(let t in o)e[t]={Value:o[t],LastUpdate:c};this.emit(constants.EventTypes.WsControl,{deviceId:s,deviceData:e})}}}catch(e){logger.error(e)}break}}break;case"StatusChange":{const e="Online"===o?1:0;this.emit(constants.EventTypes.WsStatusChange,{deviceId:s,deviceStatus:e})}}}}_onWebsocketClose(){if(!this.isManuallyClose)return this._reconnectWs();this.isManuallyClose=!1}_reconnectWs(){return __awaiter(this,void 0,void 0,(function*(){try{logger.debug("websocket reconnecting in 2 seconds"),yield delay(2e3),yield this.ws.connect()}catch(e){return logger.error("error when reconnect ws",e),Promise.reject(e)}}))}}AppDevSdk.utils=utils,AppDevSdk.constants=constants; | ||
import{__awaiter as e,__rest as t}from"tslib";import{LoginManager as i,IotWebsocket as s,requestTokenApi as n}from"./modules";import{EventEmitter as o,base64 as r,delay as a,noop as c,logger as l,genVerifyLoginFailError as d,isVerifyLoginError as h,normalizeError as u,envDetect as p}from"./utils";import*as g from"./utils";import*as m from"./constants";const y=0,f=1,v=2;export class AppDevSdk extends o{constructor(e){var{getAccessToken:n,appKey:o="",apiPlatform:r="",debug:a=!1,apiUrl:d}=e,h=e.wsConfig,u=void 0===h?{}:h,{autoReconnect:w=!0,disconnectWhenAppHide:b=!0,connectWhenAppShow:P=!0}=u,k=t(u,["autoReconnect","disconnectWhenAppHide","connectWhenAppShow"]),{reporter:I,defaultUin:_="unknown"}=e;super(),this.isManuallyClose=!1,this._defaultFamilyIdPromise=null,this.constants=m,this.utils=g,this._defaultUin=_,this._apiUrl=d,l.config({debug:a});const A=I||c;this.reporter={info:(e,t={})=>{try{A(e,Object.assign({level:y},t))}catch(e){l.warn(e)}},warn:(e,t={})=>{try{A(e,Object.assign({level:f},t))}catch(e){l.warn(e)}},error:(e,t={})=>{try{A(e,Object.assign({level:v},t))}catch(e){l.warn(e)}}},this.ws=new s(this,Object.assign(Object.assign({},k),{apiPlatform:r})),this.loginManager=new i(this,{getAccessToken:n,appKey:o}),this._apiPlatform=r,this.ws.on("error",e=>{l.debug("websocket error",e),this.emit(m.EventTypes.WsError,e),w&&this._reconnectWs()}),this.ws.on("close",({code:e,reason:t}={})=>{l.debug("websocket close",{code:e,reason:t}),this.emit(m.EventTypes.WsClose,{code:e,reason:t}),w&&this._onWebsocketClose()}),this.ws.on("push",e=>this._handlePushEvent(e)),p.isMiniProgram&&(wx.onAppHide(()=>{b&&(this.isManuallyClose=!0,this.ws.disconnect({reason:"appHide"}))}),wx.onAppShow(()=>{P&&this.isLogin&&this.ws.connect()}))}get userInfo(){return this.loginManager.userInfo}get isLogin(){return this.loginManager.isLogin}get userId(){return this.loginManager.userId}get uin(){return this.loginManager.userId}get nickName(){return this.loginManager.nickName}init(t){return e(this,void 0,void 0,(function*(){return t||(t={}),t.reload&&(this._initPromise=null),this._initPromise||(this._initPromise=new Promise((t,i)=>e(this,void 0,void 0,(function*(){try{yield this.loginManager.login(),yield this.ws.connect(),t()}catch(e){i(u(e)),this._initPromise=null}}))))}))}getDefaultFamilyId(){return this._defaultFamilyIdPromise||(this._defaultFamilyIdPromise=new Promise((t,i)=>e(this,void 0,void 0,(function*(){try{const{FamilyList:e,Total:i}=yield this.requestApi("AppGetFamilyList",{Offset:0,Limit:100});if(!i){const{Data:{FamilyId:e}}=yield this.requestApi("AppCreateFamily",{Name:this.loginManager.nickName});return t(e)}t(e[0].FamilyId)}catch(e){i(e),this._defaultFamilyIdPromise=null}}))))}sendWebsocketMessage(t,i={}){return e(this,void 0,void 0,(function*(){return yield this.init(),this.ws.send(t,i)}))}connectWebsocket(){return e(this,void 0,void 0,(function*(){yield this.init(),yield this.ws.connect()}))}disconnectWebsocket(e){this.ws.disconnect(e)}subscribeDevices(t){return e(this,void 0,void 0,(function*(){this.ws.connect((t||[]).map(e=>"string"==typeof e?e:e&&e.DeviceId?e.DeviceId:void 0).filter(Boolean))}))}requestApi(i,s={},o={}){var{doNotRetry:r=!1,needLogin:a=!0,doNotReport:c=!1}=o,p=t(o,["doNotRetry","needLogin","doNotReport"]);return e(this,void 0,void 0,(function*(){try{a&&(yield this.loginManager.checkLogin());const{accessToken:e,userId:t}=this.loginManager;s&&"default"===s.FamilyId&&(s.FamilyId=yield this.getDefaultFamilyId());const o=Object.assign({uin:t},s);return e&&(o.AccessToken=e),this._apiPlatform&&(o.Platform=this._apiPlatform),yield n(i,o,Object.assign({reporter:this.reporter,doNotReport:c,url:this._apiUrl},p))}catch(e){if(l.debug("requestApi fail",e),h(e)){if(r)return Promise.reject(d(e));try{yield this.loginManager.reLogin()}catch(t){return l.error("reLogin fail",t),Promise.reject(d(e))}return this.requestApi(i,s,Object.assign({doNotRetry:!0},p))}return Promise.reject(u(e))}}))}_handlePushEvent(e){e||(e={}),this.emit(m.EventTypes.WsPush,e);let{action:t,params:i}=e;i||(i={});let{DeviceId:s,Type:n,SubType:o,Payload:a,Time:c}=i;const d=new Date(c).getTime();switch(a&&(a=JSON.parse(r.decode(a))),l.debug("websocket push payload",a),t){case"DeviceChange":switch(n){case"Property":case"Shadow":case"Template":switch(o){case"Report":{const e={};try{if(a){let{type:t,state:i,method:s,params:n}=a;if(t&&"update"===t&&i&&i.reported&&(s="report",n=i.reported),n||(n={}),"report"===s)for(const t in n)e[t]={Value:n[t],lastUpdate:d}}}catch(e){l.error("handle report event error",e)}this.emit(m.EventTypes.WsReport,{deviceId:s,deviceData:e});break}case"Push":{const e={};try{if(a){let{type:t,payload:i,method:n,params:o}=a;if(t&&"delta"===t&&i&&i.state&&(n="control",o=i.state),"control"===n&&o){for(let t in o)e[t]={Value:o[t],LastUpdate:d};this.emit(m.EventTypes.WsControl,{deviceId:s,deviceData:e})}}}catch(e){l.error(e)}break}}break;case"StatusChange":{const e="Online"===o?1:0;this.emit(m.EventTypes.WsStatusChange,{deviceId:s,deviceStatus:e})}}}}_onWebsocketClose(){if(!this.isManuallyClose)return this._reconnectWs();this.isManuallyClose=!1}_reconnectWs(){return e(this,void 0,void 0,(function*(){try{l.debug("websocket reconnecting in 2 seconds"),yield a(2e3),yield this.ws.connect()}catch(e){return l.error("error when reconnect ws",e),Promise.reject(e)}}))}}AppDevSdk.utils=g,AppDevSdk.constants=m; | ||
//# sourceMappingURL=AppDevSdk.js.map |
@@ -1,2 +0,2 @@ | ||
import{__awaiter}from"tslib";import{appendParams,cutoffLong,shortid,EventEmitter,WebSocket,logger}from"../utils";const defaultOptions={url:"wss://iot.cloud.tencent.com/ws/explorer",heartbeatInterval:6e4};export class IotWebsocket extends EventEmitter{constructor(e,t){super(),this.sdk=e,this.requestHandlerMap=new Map,this.options=Object.assign({},defaultOptions,t),this._connected=!1,this._subscribeDeviceIdList=[],this._heartBeatTimer=null}isConnected(){return!!this._connected}doConnectWs(){return __awaiter(this,void 0,void 0,(function*(){return this._doConnectWsPromise||(this._doConnectWsPromise=new Promise((e,t)=>__awaiter(this,void 0,void 0,(function*(){const s=e=>{t(e),this.emit("error",e),this.disconnect(),this.sdk.reporter.error("websocket-error",{error:e})};try{const{url:t}=this.options;this.ws=new WebSocket(appendParams(t,{uin:this.sdk.loginManager.userId})),this.ws.onOpen(()=>{this._connected=!0,this.emit("connect"),e(),logger.debug("websocket connected"),this.sdk.reporter.info("websocket-connect")}),this.ws.onError(s),this.ws.onMessage(({data:e})=>{this.emit("message",e);try{e=JSON.parse(e)}catch(t){return void logger.warn("onMessage parse event.data error: "+e)}e.push?(this.emit("push",e),this.sdk.reporter.info("websocket-push",{data:e})):void 0!==e.reqId&&this.requestHandlerMap.has(e.reqId)?this.requestHandlerMap.get(e.reqId)(null,e):this.sdk.reporter.info("websocket-onmessage",{data:e})}),this.ws.onClose(e=>__awaiter(this,void 0,void 0,(function*(){logger.debug("websocket closed"),this.disconnect(e),this.emit("close",e),this.sdk.reporter.info("websocket-close",{data:e})})))}catch(e){s(e)}}))))}))}connect(e){return __awaiter(this,void 0,void 0,(function*(){return e&&(this._subscribeDeviceIdList=e),yield this.sdk.loginManager.checkLogin(),!this.isConnected()&&this._subscribeDeviceIdList.length&&(yield this.doConnectWs()),this.activePush()}))}disconnect(e){this.ws&&(this.ws.close(e),this._connected=!1,this._doConnectWsPromise=null,this.ws=null,clearInterval(this._heartBeatTimer),this._heartBeatTimer=null)}send(e,t={},{reqId:s}={}){return __awaiter(this,void 0,void 0,(function*(){if(s||(s=shortid()),this.ws){let i=Date.now();this.ws.send({data:JSON.stringify({action:e,reqId:s,params:t})});const r={reqBody:cutoffLong(JSON.stringify(t)),action:e,reqId:s};let o;try{return yield Promise.race([new Promise((e,t)=>{this.requestHandlerMap.set(s,(s,n)=>{if(r.timeCost=Date.now()-i,!s)return n.data||!n.error&&!n.error_message?(this.sdk.reporter.info("websocket-response",Object.assign(Object.assign({},r),{resBody:cutoffLong(JSON.stringify(n.data))})),e(n.data)):(o="error",void t({code:n.error,msg:n.error_message}));t(s),o="fail"})}),new Promise((e,t)=>{setTimeout(()=>{t({code:"TIMEOUT"}),o="timeout"},2e4)})])}catch(e){this.sdk.reporter.info("websocket-"+o,Object.assign(Object.assign({},r),{error:e,timeCost:Date.now()-i}))}finally{this.requestHandlerMap.delete(s)}}else logger.warn("Try send ws message but no ws instance",e,t)}))}sendWsHeatBeat(){if(this._subscribeDeviceIdList&&this._subscribeDeviceIdList.length)return this.sdk.requestApi("AppDeviceTraceHeartBeat",{DeviceIds:this._subscribeDeviceIdList})}activePush(){const{isLogin:e,accessToken:t,appKey:s}=this.sdk.loginManager;e&&t&&this._subscribeDeviceIdList&&(this.sdk.reporter.info(`websocket activepush(${this._subscribeDeviceIdList.join(";")})`,{data:{DeviceIds:this._subscribeDeviceIdList,Platform:"weapp",AccessToken:t}}),this.send("ActivePush",{DeviceIds:this._subscribeDeviceIdList,Platform:"weapp",AccessToken:t,AppKey:s}),this.sendWsHeatBeat(),clearInterval(this._heartBeatTimer),this._heartBeatTimer=setInterval(()=>this.sendWsHeatBeat(),this.options.heartbeatInterval))}} | ||
import{__awaiter as e}from"tslib";import{appendParams as s,cutoffLong as t,shortid as i,EventEmitter as r,WebSocket as o,logger as n}from"../utils";const c={url:"wss://iot.cloud.tencent.com/ws/explorer",heartbeatInterval:6e4};export class IotWebsocket extends r{constructor(e,s){super(),this.sdk=e,this.requestHandlerMap=new Map,this.options=Object.assign({},c,s),this._connected=!1,this._subscribeDeviceIdList=[],this._heartBeatTimer=null}isConnected(){return!!this._connected}doConnectWs(){return e(this,void 0,void 0,(function*(){return this._doConnectWsPromise||(this._doConnectWsPromise=new Promise((t,i)=>e(this,void 0,void 0,(function*(){const r=e=>{i(e),this.emit("error",e),this.disconnect(),this.sdk.reporter.error("websocket-error",{error:e})};try{const{url:i}=this.options;this.ws=new o(s(i,{uin:this.sdk.loginManager.userId})),this.ws.onOpen(()=>{this._connected=!0,this.emit("connect"),t(),n.debug("websocket connected"),this.sdk.reporter.info("websocket-connect")}),this.ws.onError(r),this.ws.onMessage(({data:e})=>{this.emit("message",e);try{e=JSON.parse(e)}catch(s){return void n.warn("onMessage parse event.data error: "+e)}e.push?(this.emit("push",e),this.sdk.reporter.info("websocket-push",{data:e})):void 0!==e.reqId&&this.requestHandlerMap.has(e.reqId)?this.requestHandlerMap.get(e.reqId)(null,e):this.sdk.reporter.info("websocket-onmessage",{data:e})}),this.ws.onClose(s=>e(this,void 0,void 0,(function*(){n.debug("websocket closed"),this.disconnect(s),this.emit("close",s),this.sdk.reporter.info("websocket-close",{data:s})})))}catch(e){r(e)}}))))}))}connect(s){return e(this,void 0,void 0,(function*(){return s&&(this._subscribeDeviceIdList=s),yield this.sdk.loginManager.checkLogin(),!this.isConnected()&&this._subscribeDeviceIdList.length&&(yield this.doConnectWs()),this.activePush()}))}disconnect(e){this.ws&&(this.ws.close(e),this._connected=!1,this._doConnectWsPromise=null,this.ws=null,clearInterval(this._heartBeatTimer),this._heartBeatTimer=null)}send(s,r={},{reqId:o}={}){return e(this,void 0,void 0,(function*(){if(o||(o=i()),this.ws){let e=Date.now();this.ws.send({data:JSON.stringify({action:s,reqId:o,params:r})});const i={reqBody:t(JSON.stringify(r)),action:s,reqId:o};let n;try{return yield Promise.race([new Promise((s,r)=>{this.requestHandlerMap.set(o,(o,c)=>{if(i.timeCost=Date.now()-e,!o)return c.data||!c.error&&!c.error_message?(this.sdk.reporter.info("websocket-response",Object.assign(Object.assign({},i),{resBody:t(JSON.stringify(c.data))})),s(c.data)):(n="error",void r({code:c.error,msg:c.error_message}));r(o),n="fail"})}),new Promise((e,s)=>{setTimeout(()=>{s({code:"TIMEOUT"}),n="timeout"},2e4)})])}catch(s){this.sdk.reporter.info("websocket-"+n,Object.assign(Object.assign({},i),{error:s,timeCost:Date.now()-e}))}finally{this.requestHandlerMap.delete(o)}}else n.warn("Try send ws message but no ws instance",s,r)}))}sendWsHeatBeat(){if(this._subscribeDeviceIdList&&this._subscribeDeviceIdList.length)return this.sdk.requestApi("AppDeviceTraceHeartBeat",{DeviceIds:this._subscribeDeviceIdList})}activePush(){const{isLogin:e,accessToken:s,appKey:t}=this.sdk.loginManager;e&&s&&this._subscribeDeviceIdList&&(this.sdk.reporter.info(`websocket activepush(${this._subscribeDeviceIdList.join(";")})`,{data:{DeviceIds:this._subscribeDeviceIdList,Platform:"weapp",AccessToken:s}}),this.send("ActivePush",{DeviceIds:this._subscribeDeviceIdList,Platform:"weapp",AccessToken:s,AppKey:t}),this.sendWsHeatBeat(),clearInterval(this._heartBeatTimer),this._heartBeatTimer=setInterval(()=>this.sendWsHeatBeat(),this.options.heartbeatInterval))}} | ||
//# sourceMappingURL=IotWebsocket.js.map |
@@ -1,2 +0,2 @@ | ||
import{__awaiter}from"tslib";import{EventEmitter,storage,genVerifyLoginFailError,isVerifyLoginError,logger}from"../utils";const accessTokenStorageKey="__qcloud-iotexplorer-appdev-sdk-accessToken";export class LoginManager extends EventEmitter{constructor(e,{getAccessToken:i,appKey:t}){super(),this.accessToken="",this.isLogin=!1,this.sdk=e,this.getAccessToken=i,this.appKey=t}login(){return __awaiter(this,void 0,void 0,(function*(){let e=!1;try{let i=yield storage.getItem(accessTokenStorageKey);if(i)e=!0;else{const e=yield this.getAccessToken(),{Token:t}=e;console.log("Token",t),i=t}this.accessToken=i,this.isLogin=!0,storage.setItem(accessTokenStorageKey,i);const{Data:t}=yield this.sdk.requestApi("AppGetUser",{},{isTokenApi:!0});this.userInfo=t}catch(i){return isVerifyLoginError(i)&&(yield this.logout(),e)?(logger.debug("Cached Token expired, retrying..."),this.login()):Promise.reject(i)}}))}get userId(){return this.userInfo?this.userInfo.UserID:this.sdk._defaultUin}get nickName(){return this.userInfo?this.userInfo.NickName:""}checkLogin(){if(!this.isLogin)throw genVerifyLoginFailError()}logout(){return __awaiter(this,void 0,void 0,(function*(){yield storage.removeItem(accessTokenStorageKey),this.accessToken="",this.isLogin=!1}))}reLogin(){return __awaiter(this,void 0,void 0,(function*(){yield this.logout(),yield this.login()}))}} | ||
import{__awaiter as e}from"tslib";import{EventEmitter as i,storage as s,genVerifyLoginFailError as t,isVerifyLoginError as o,logger as n}from"../utils";const r="__qcloud-iotexplorer-appdev-sdk-accessToken";export class LoginManager extends i{constructor(e,{getAccessToken:i,appKey:s}){super(),this.accessToken="",this.isLogin=!1,this.sdk=e,this.getAccessToken=i,this.appKey=s}login(){return e(this,void 0,void 0,(function*(){let e=!1;try{let i=yield s.getItem(r);if(i)e=!0;else{const e=yield this.getAccessToken(),{Token:s}=e;console.log("Token",s),i=s}this.accessToken=i,this.isLogin=!0,s.setItem(r,i);const{Data:t}=yield this.sdk.requestApi("AppGetUser",{},{isTokenApi:!0});this.userInfo=t}catch(i){return o(i)&&(yield this.logout(),e)?(n.debug("Cached Token expired, retrying..."),this.login()):Promise.reject(i)}}))}get userId(){return this.userInfo?this.userInfo.UserID:this.sdk._defaultUin}get nickName(){return this.userInfo?this.userInfo.NickName:""}checkLogin(){if(!this.isLogin)throw t()}logout(){return e(this,void 0,void 0,(function*(){yield s.removeItem(r),this.accessToken="",this.isLogin=!1}))}reLogin(){return e(this,void 0,void 0,(function*(){yield this.logout(),yield this.login()}))}} | ||
//# sourceMappingURL=LoginManager.js.map |
@@ -1,2 +0,2 @@ | ||
import{__awaiter,__rest}from"tslib";import{shortid,appendParams,cutoffLong,request,normalizeError,pify}from"../utils";import{isMiniProgram}from"../utils/env-detect";const defaultUrl="https://iot.cloud.tencent.com/api/exploreropen/tokenapi";export const requestTokenApi=(e,o={},r={})=>__awaiter(void 0,void 0,void 0,(function*(){var{uin:t,AccessToken:i}=o,s=__rest(o,["uin","AccessToken"]),{method:n="POST",reporter:c,doNotReport:a=!1,isSecureApi:d=!1,isTokenApi:p=!1,url:m}=r,u=__rest(r,["method","reporter","doNotReport","isSecureApi","isTokenApi","url"]);const l=shortid(),f=Date.now();let g,h=!1;try{const o={uin:t,cmd:e};if(s=Object.assign({},s,{Action:e,RequestId:l,AccessToken:i}),m=m||defaultUrl,d){if(!isMiniProgram)throw new Error("secure api 仅支持在小程序中调用");m+="appsecureapi",o.cmd=e;const{code:r}=yield pify(wx.login)();s.JsCode=r}else p?(m+="tokenapi",o.cmd=e):m+=e;let r;m=appendParams(m,o),g=Object.assign({url:m,data:s,method:n},u);try{const{data:e}=yield request(g);r=e}catch(e){throw h=!0,e}const{code:w,msg:_,data:q={}}=r;if(w){if(q&&q.Error)throw{code:q.Error.Code,msg:q.Error.Message,reqId:l};throw{code:w,msg:_,reqId:l}}return c.info("cgi-response",{reqBody:cutoffLong(JSON.stringify(s)),action:e,timeCost:Date.now()-f,doNotReport:a,code:w,msg:_,reqId:l}),q}catch(o){const r=normalizeError(o);return c.info(h?"cgi-fail":"cgi-error",{action:e,timeCost:Date.now()-f,doNotReport:a,error:r,reqId:l}),Promise.reject(o)}})); | ||
import{__awaiter as e,__rest as o}from"tslib";import{shortid as t,appendParams as r,cutoffLong as i,request as c,normalizeError as s,pify as n}from"../utils";import{isMiniProgram as d}from"../utils/env-detect";export const requestTokenApi=(p,a={},m={})=>e(void 0,void 0,void 0,(function*(){var{uin:e,AccessToken:u}=a,l=o(a,["uin","AccessToken"]),{method:f="POST",reporter:g,doNotReport:h=!1,isSecureApi:w=!1,isTokenApi:A=!1,url:k}=m,q=o(m,["method","reporter","doNotReport","isSecureApi","isTokenApi","url"]);const T=t(),y=Date.now();let v,I=!1;try{const o={uin:e,cmd:p};if(l=Object.assign({},l,{Action:p,RequestId:T,AccessToken:u}),k=k||"https://iot.cloud.tencent.com/api/exploreropen/tokenapi",w){if(!d)throw new Error("secure api 仅支持在小程序中调用");k+="appsecureapi",o.cmd=p;const{code:e}=yield n(wx.login)();l.JsCode=e}else A?(k+="tokenapi",o.cmd=p):k+=p;let t;k=r(k,o),v=Object.assign({url:k,data:l,method:f},q);try{const{data:e}=yield c(v);t=e}catch(e){throw I=!0,e}const{code:s,msg:a,data:m={}}=t;if(s){if(m&&m.Error)throw{code:m.Error.Code,msg:m.Error.Message,reqId:T};throw{code:s,msg:a,reqId:T}}return g.info("cgi-response",{reqBody:i(JSON.stringify(l)),action:p,timeCost:Date.now()-y,doNotReport:h,code:s,msg:a,reqId:T}),m}catch(e){const o=s(e);return g.info(I?"cgi-fail":"cgi-error",{action:p,timeCost:Date.now()-y,doNotReport:h,error:o,reqId:T}),Promise.reject(e)}})); | ||
//# sourceMappingURL=requestTokenApi.js.map |
@@ -1,2 +0,2 @@ | ||
import{__rest}from"tslib";import{isPlainObject}from"./utillib";import{ErrorCode}from"../constants";export const normalizeError=r=>{if(r)if(isPlainObject(r))if(r.errMsg)if(["auth deny","scope unauthorized"].some(e=>String(r.errMsg).indexOf(e)>-1))if(0===r.errMsg.indexOf("getUserInfo"))Object.assign(r,{code:ErrorCode.GET_USERINFO_NEED_AUTH,msg:"尚未开启微信基本信息授权,请授权后使用"});else{const[e]=r.errMsg.split(":");Object.assign(r,{code:ErrorCode.WX_API_NEED_AUTH,msg:`小程序接口(${e})需要用户授权,请授权后使用`})}else Object.assign(r,{code:ErrorCode.WX_API_FAIL,msg:"小程序接口调用失败,请稍后再试"});else isVerifyLoginError(r)&&(r=genVerifyLoginFailError(r));else r instanceof Error&&(r={code:ErrorCode.INTERNAL_ERROR,msg:r.message,stack:r.stack,error:r});return r};export const genVerifyLoginFailError=r=>{r||(r={});const{code:e,msg:o}=r,i=__rest(r,["code","msg"]);return Object.assign({code:ErrorCode.VERIFY_LOGIN_FAIL,msg:"登录态验证失败,请重新登录"},i)};export const isVerifyLoginError=r=>r&&String(r.code||"").indexOf("InvalidAccessToken")>-1;export const handleVerifyLoginError=r=>{if(isVerifyLoginError(r))throw genVerifyLoginFailError(r)}; | ||
import{__rest as r}from"tslib";import{isPlainObject as e}from"./utillib";import{ErrorCode as o}from"../constants";export const normalizeError=r=>{if(r)if(e(r))if(r.errMsg)if(["auth deny","scope unauthorized"].some(e=>String(r.errMsg).indexOf(e)>-1))if(0===r.errMsg.indexOf("getUserInfo"))Object.assign(r,{code:o.GET_USERINFO_NEED_AUTH,msg:"尚未开启微信基本信息授权,请授权后使用"});else{const[e]=r.errMsg.split(":");Object.assign(r,{code:o.WX_API_NEED_AUTH,msg:`小程序接口(${e})需要用户授权,请授权后使用`})}else Object.assign(r,{code:o.WX_API_FAIL,msg:"小程序接口调用失败,请稍后再试"});else isVerifyLoginError(r)&&(r=genVerifyLoginFailError(r));else r instanceof Error&&(r={code:o.INTERNAL_ERROR,msg:r.message,stack:r.stack,error:r});return r};export const genVerifyLoginFailError=e=>{e||(e={});const{code:i,msg:s}=e,n=r(e,["code","msg"]);return Object.assign({code:o.VERIFY_LOGIN_FAIL,msg:"登录态验证失败,请重新登录"},n)};export const isVerifyLoginError=r=>r&&String(r.code||"").indexOf("InvalidAccessToken")>-1;export const handleVerifyLoginError=r=>{if(isVerifyLoginError(r))throw genVerifyLoginFailError(r)}; | ||
//# sourceMappingURL=errorHelper.js.map |
@@ -1,2 +0,2 @@ | ||
const{defineProperty:defineProperty,create:create}=Object,{hasOwnProperty:hasOwnProperty}=Object.prototype,descriptor={configurable:!0,enumerable:!1,writable:!0,value:null},namespace="__ee__";function callable(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}export class EventEmitter{on(e,t){let r;return callable(t),hasOwnProperty.call(this,"__ee__")?r=this.__ee__:(r=descriptor.value=create(null),defineProperty(this,"__ee__",descriptor),descriptor.value=null),r[e]?r[e].push(t):r[e]=[t],this}once(e,t){let r;return callable(t),this.on.call(this,e,r=(...n)=>{this.off.call(undefined,e,r),t.apply(this,n)}),this}off(e,t){if(!hasOwnProperty.call(this,"__ee__"))return this;const r=this.__ee__;if(!r[e])return this;if(t){const n=r[e]||[],i=n.indexOf(t);i>-1&&n.splice(i,1)}else r[e].length=0;return this}emit(e,...t){if(!hasOwnProperty.call(this,"__ee__"))return;const r=this.__ee__[e];r&&r.length&&r.forEach(e=>e.apply(this,t))}} | ||
const{defineProperty:e,create:t}=Object,{hasOwnProperty:n}=Object.prototype,i={configurable:!0,enumerable:!1,writable:!0,value:null};function l(e){if("function"!=typeof e)throw new TypeError(e+" is not a function");return e}export class EventEmitter{on(r,s){let _;return l(s),n.call(this,"__ee__")?_=this.__ee__:(_=i.value=t(null),e(this,"__ee__",i),i.value=null),_[r]?_[r].push(s):_[r]=[s],this}once(e,t){let n;return l(t),this.on.call(this,e,n=(...i)=>{this.off.call(undefined,e,n),t.apply(this,i)}),this}off(e,t){if(!n.call(this,"__ee__"))return this;const i=this.__ee__;if(!i[e])return this;if(t){const n=i[e]||[],l=n.indexOf(t);l>-1&&n.splice(l,1)}else i[e].length=0;return this}emit(e,...t){if(!n.call(this,"__ee__"))return;const i=this.__ee__[e];i&&i.length&&i.forEach(e=>e.apply(this,t))}} | ||
//# sourceMappingURL=event-emmiter.js.map |
@@ -1,2 +0,2 @@ | ||
import shortid from"./shortid";import{WebSocket}from"./WebSocket";import*as envDetect from"./env-detect";import tips from"./tips";export{Base64 as base64}from"js-base64";export{storage}from"./storage";export{EventEmitter}from"./event-emmiter";export{pify}from"./pify";export*from"./request";export*from"./utillib";export*from"./errorHelper";export*from"./logger";export{shortid,WebSocket,envDetect,tips}; | ||
import r from"./shortid";import{WebSocket as e}from"./WebSocket";import*as o from"./env-detect";import t from"./tips";export{Base64 as base64}from"js-base64";export{storage}from"./storage";export{EventEmitter}from"./event-emmiter";export{pify}from"./pify";export*from"./request";export*from"./utillib";export*from"./errorHelper";export*from"./logger";export{r as shortid,e as WebSocket,o as envDetect,t as tips}; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import{noop}from"./utillib";export var LogLevel;!function(e){e.Debug="Debug",e.Info="Info",e.Warn="Warn",e.Error="Error"}(LogLevel||(LogLevel={}));const defaultLogger={[LogLevel.Debug]:console.log,[LogLevel.Info]:console.info,[LogLevel.Warn]:console.warn,[LogLevel.Error]:console.error};class Logger{constructor(){this.options={debug:!1}}_getLogger(e){return e in LogLevel||(e=LogLevel.Debug),this.options.debug?defaultLogger[e].bind(console,`[${e}]`):noop}config(e){Object.assign(this.options,e)}get info(){return this._getLogger(LogLevel.Info)}get debug(){return this._getLogger(LogLevel.Debug)}get warn(){return this._getLogger(LogLevel.Warn)}get error(){return this._getLogger(LogLevel.Error)}}export const logger=new Logger; | ||
import{noop as e}from"./utillib";export var LogLevel;!function(e){e.Debug="Debug",e.Info="Info",e.Warn="Warn",e.Error="Error"}(LogLevel||(LogLevel={}));const o={[LogLevel.Debug]:console.log,[LogLevel.Info]:console.info,[LogLevel.Warn]:console.warn,[LogLevel.Error]:console.error};export const logger=new class{constructor(){this.options={debug:!1}}_getLogger(r){return r in LogLevel||(r=LogLevel.Debug),this.options.debug?o[r].bind(console,`[${r}]`):e}config(e){Object.assign(this.options,e)}get info(){return this._getLogger(LogLevel.Info)}get debug(){return this._getLogger(LogLevel.Debug)}get warn(){return this._getLogger(LogLevel.Warn)}get error(){return this._getLogger(LogLevel.Error)}}; | ||
//# sourceMappingURL=logger.js.map |
@@ -1,2 +0,2 @@ | ||
const store={},blockingList=[],startBlocking=()=>{let s;const o=new Promise(o=>{s=o});return blockingList.push({promise:o,resolve:s}),o},resolveFirstBlock=()=>{blockingList.length&&(blockingList[0].resolve(),blockingList.shift())};export{resolveFirstBlock,startBlocking}; | ||
const e=[],s=()=>{let s;const o=new Promise(e=>{s=e});return e.push({promise:o,resolve:s}),o},o=()=>{e.length&&(e[0].resolve(),e.shift())};export{o as resolveFirstBlock,s as startBlocking}; | ||
//# sourceMappingURL=request-manager.js.map |
@@ -1,2 +0,2 @@ | ||
import{__awaiter,__rest}from"tslib";import querystring from"query-string";import jsonp from"jsonp";import{isBrowser}from"../env-detect";import{startBlocking,resolveFirstBlock}from"./request-manager";import{pify}from"../pify";import{appendParams,jsonp2json}from"../utillib";const maxConcurrentNum=10;let currentRequestingNum=0,jsonpcallbackCounter=0;function requestXHR(e,t={},r={}){return new Promise((s,o)=>{try{if("jsonp"===r.dataType)return jsonp(e,{},(e,t)=>e?o({code:"timeout"}):s(t));let{method:a,headers:n={},responseType:i="json"}=r;a=(a||"get").toUpperCase(),Object.assign(n,{"Content-type":"application/json"});const p=new window.XMLHttpRequest;p.responseType=i,p.timeout=1e4,p.onreadystatechange=()=>{4===p.readyState&&(200===p.status?s({data:p.response}):o({code:p.status,msg:p.statusText}))},"GET"===a?e=`url${-1===e.indexOf("?")?"?":"&"}${querystring.stringify(t)}`:"POST"===a&&(t=JSON.stringify(t)),p.open(a,e,!0),Object.keys(n).forEach(e=>{p.setRequestHeader(e,n[e])}),p.send("POST"===a?t:null)}catch(e){console.error(e),o(e)}})}function requestWeapp(e){return __awaiter(this,void 0,void 0,(function*(){try{for(;currentRequestingNum>=10;)yield startBlocking();if(currentRequestingNum++,"jsonp"===e.dataType){e.method="GET";let t=e.callback||"jsonpcallback"+ ++jsonpcallbackCounter;e.url=appendParams(e.url,{callback:t});const r=yield pify(wx.request)(e);return 200===r.statusCode&&r.data&&"string"==typeof r.data&&(r.data=jsonp2json(r.data)),r}return yield pify(wx.request)(e)}catch(e){return Promise.reject(e)}finally{currentRequestingNum--,resolveFirstBlock()}}))}export const request=e=>__awaiter(void 0,void 0,void 0,(function*(){var{url:t,data:r,header:s={},method:o="GET",dataType:a,responseType:n}=e,i=__rest(e,["url","data","header","method","dataType","responseType"]);return isBrowser?requestXHR(t,r,{headers:s,method:o,responseType:n,dataType:a}):requestWeapp(Object.assign({url:t,data:r,header:s,method:o,dataType:a,responseType:n},i))})); | ||
import{__awaiter as e,__rest as t}from"tslib";import r from"query-string";import o from"jsonp";import{isBrowser as a}from"../env-detect";import{startBlocking as s,resolveFirstBlock as n}from"./request-manager";import{pify as d}from"../pify";import{appendParams as i,jsonp2json as p}from"../utillib";let u=0,c=0;export const request=l=>e(void 0,void 0,void 0,(function*(){var{url:y,data:m,header:f={},method:T="GET",dataType:h,responseType:g}=l,j=t(l,["url","data","header","method","dataType","responseType"]);return a?function(e,t={},a={}){return new Promise((s,n)=>{try{if("jsonp"===a.dataType)return o(e,{},(e,t)=>e?n({code:"timeout"}):s(t));let{method:d,headers:i={},responseType:p="json"}=a;d=(d||"get").toUpperCase(),Object.assign(i,{"Content-type":"application/json"});const u=new window.XMLHttpRequest;u.responseType=p,u.timeout=1e4,u.onreadystatechange=()=>{4===u.readyState&&(200===u.status?s({data:u.response}):n({code:u.status,msg:u.statusText}))},"GET"===d?e=`url${-1===e.indexOf("?")?"?":"&"}${r.stringify(t)}`:"POST"===d&&(t=JSON.stringify(t)),u.open(d,e,!0),Object.keys(i).forEach(e=>{u.setRequestHeader(e,i[e])}),u.send("POST"===d?t:null)}catch(e){console.error(e),n(e)}})}(y,m,{headers:f,method:T,responseType:g,dataType:h}):function(t){return e(this,void 0,void 0,(function*(){try{for(;u>=10;)yield s();if(u++,"jsonp"===t.dataType){t.method="GET";let e=t.callback||"jsonpcallback"+ ++c;t.url=i(t.url,{callback:e});const r=yield d(wx.request)(t);return 200===r.statusCode&&r.data&&"string"==typeof r.data&&(r.data=p(r.data)),r}return yield d(wx.request)(t)}catch(e){return Promise.reject(e)}finally{u--,n()}}))}(Object.assign({url:y,data:m,header:f,method:T,dataType:h,responseType:g},j))})); | ||
//# sourceMappingURL=request.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var alphabet,previousSeed,shuffled,randomFromSeed=require("./random/random-from-seed"),ORIGINAL="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function reset(){shuffled=!1}function setCharacters(e){if(e){if(e!==alphabet){if(e.length!==ORIGINAL.length)throw new Error("Custom alphabet for shortid must be "+ORIGINAL.length+" unique characters. You submitted "+e.length+" characters: "+e);var t=e.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(t.length)throw new Error("Custom alphabet for shortid must be "+ORIGINAL.length+" unique characters. These characters were not unique: "+t.join(", "));alphabet=e,reset()}}else alphabet!==ORIGINAL&&(alphabet=ORIGINAL,reset())}function characters(e){return setCharacters(e),alphabet}function setSeed(e){randomFromSeed.seed(e),previousSeed!==e&&(reset(),previousSeed=e)}function shuffle(){alphabet||setCharacters(ORIGINAL);for(var e,t=alphabet.split(""),r=[],a=randomFromSeed.nextValue();t.length>0;)a=randomFromSeed.nextValue(),e=Math.floor(a*t.length),r.push(t.splice(e,1)[0]);return r.join("")}function getShuffled(){return shuffled||(shuffled=shuffle())}function lookup(e){return getShuffled()[e]}function get(){return alphabet||ORIGINAL}module.exports={get:get,characters:characters,seed:setSeed,lookup:lookup,shuffled:getShuffled}; | ||
var e,t,r,n=require("./random/random-from-seed"),u="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_-";function o(){r=!1}function i(t){if(t){if(t!==e){if(t.length!==u.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. You submitted "+t.length+" characters: "+t);var r=t.split("").filter((function(e,t,r){return t!==r.lastIndexOf(e)}));if(r.length)throw new Error("Custom alphabet for shortid must be "+u.length+" unique characters. These characters were not unique: "+r.join(", "));e=t,o()}}else e!==u&&(e=u,o())}function s(){return r||(r=function(){e||i(u);for(var t,r=e.split(""),o=[],s=n.nextValue();r.length>0;)s=n.nextValue(),t=Math.floor(s*r.length),o.push(r.splice(t,1)[0]);return o.join("")}())}module.exports={get:function(){return e||u},characters:function(t){return i(t),e},seed:function(e){n.seed(e),t!==e&&(o(),t=e)},lookup:function(e){return s()[e]},shuffled:s}; | ||
//# sourceMappingURL=alphabet.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var counter,previousSeconds,generate=require("./generate"),alphabet=require("./alphabet"),REDUCE_TIME=1459707606518,version=6;function build(e){var r="",n=Math.floor(.001*(Date.now()-REDUCE_TIME));return n===previousSeconds?counter++:(counter=0,previousSeconds=n),r+=generate(version),r+=generate(e),counter>0&&(r+=generate(counter)),r+=generate(n)}module.exports=build; | ||
var e,r,a=require("./generate");require("./alphabet");module.exports=function(t){var o="",n=Math.floor(.001*(Date.now()-1459707606518));return n===r?e++:(e=0,r=n),o+=a(6),o+=a(t),e>0&&(o+=a(e)),o+=a(n)}; | ||
//# sourceMappingURL=build.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var alphabet=require("./alphabet"),random=require("./random/random-byte"),format=require("./nanoid-format");function generate(r){for(var e,a=0,t="";!e;)t+=format(random,alphabet.get(),1),e=r<Math.pow(16,a+1),a++;return t}module.exports=generate; | ||
var r=require("./alphabet"),e=require("./random/random-byte"),a=require("./nanoid-format");module.exports=function(o){for(var t,n=0,u="";!t;)u+=a(e,r.get(),1),t=o<Math.pow(16,n+1),n++;return u}; | ||
//# sourceMappingURL=generate.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var alphabet=require("./alphabet"),build=require("./build"),isValid=require("./is-valid"),clusterWorkerId=require("./util/cluster-worker-id")||0;function seed(e){return alphabet.seed(e),module.exports}function worker(e){return clusterWorkerId=e,module.exports}function characters(e){return void 0!==e&&alphabet.characters(e),alphabet.shuffled()}function generate(){return build(clusterWorkerId)}module.exports=generate,module.exports.generate=generate,module.exports.seed=seed,module.exports.worker=worker,module.exports.characters=characters,module.exports.isValid=isValid; | ||
var e=require("./alphabet"),r=require("./build"),u=require("./is-valid"),o=require("./util/cluster-worker-id")||0;function t(){return r(o)}module.exports=t,module.exports.generate=t,module.exports.seed=function(r){return e.seed(r),module.exports},module.exports.worker=function(e){return o=e,module.exports},module.exports.characters=function(r){return void 0!==r&&e.characters(r),e.shuffled()},module.exports.isValid=u; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var alphabet=require("./alphabet");function isShortId(e){return!(!e||"string"!=typeof e||e.length<6)&&!new RegExp("[^"+alphabet.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(e)}module.exports=isShortId; | ||
var e=require("./alphabet");module.exports=function(t){return!(!t||"string"!=typeof t||t.length<6)&&!new RegExp("[^"+e.get().replace(/[|\\{}()[\]^$+*?.-]/g,"\\$&")+"]").test(t)}; | ||
//# sourceMappingURL=is-valid.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var randomByte,crypto="object"==typeof window&&(window.crypto||window.msCrypto);randomByte=crypto&&crypto.getRandomValues?function(o){return crypto.getRandomValues(new Uint8Array(o))}:function(o){for(var t=[],r=0;r<o;r++)t.push(Math.floor(256*Math.random()));return t},module.exports=randomByte; | ||
var o,n="object"==typeof window&&(window.crypto||window.msCrypto);o=n&&n.getRandomValues?function(o){return n.getRandomValues(new Uint8Array(o))}:function(o){for(var n=[],r=0;r<o;r++)n.push(Math.floor(256*Math.random()));return n},module.exports=o; | ||
//# sourceMappingURL=random-byte.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";var seed=1;function getNextValue(){return(seed=(9301*seed+49297)%233280)/233280}function setSeed(e){seed=e}module.exports={nextValue:getNextValue,seed:setSeed}; | ||
var e=1;module.exports={nextValue:function(){return(e=(9301*e+49297)%233280)/233280},seed:function(n){e=n}}; | ||
//# sourceMappingURL=random-from-seed.js.map |
@@ -1,2 +0,2 @@ | ||
"use strict";module.exports=0; | ||
module.exports=0; | ||
//# sourceMappingURL=cluster-worker-id.js.map |
@@ -1,2 +0,2 @@ | ||
import{__awaiter}from"tslib";import{pify}from"./pify";import{isBrowser,isMiniProgram}from"./env-detect";export const storage={getItem(r){return __awaiter(this,void 0,void 0,(function*(){try{if(isMiniProgram){const{data:e}=yield pify(wx.getStorage)({key:r});return e}if(isBrowser)return localStorage.getItem(r)}catch(r){return null}}))},setItem(r,e){return __awaiter(this,void 0,void 0,(function*(){try{isMiniProgram?yield pify(wx.setStorage)({key:r,data:e}):isBrowser&&localStorage.setItem(r,e)}catch(r){console.error("setStorage error",r)}}))},removeItem(r){return __awaiter(this,void 0,void 0,(function*(){try{isMiniProgram?yield pify(wx.removeStorage)({key:r}):isBrowser&&localStorage.removeItem(r)}catch(r){console.error("removeStorage error",r)}}))}}; | ||
import{__awaiter as e}from"tslib";import{pify as t}from"./pify";import{isBrowser as r,isMiniProgram as o}from"./env-detect";export const storage={getItem(i){return e(this,void 0,void 0,(function*(){try{if(o){const{data:e}=yield t(wx.getStorage)({key:i});return e}if(r)return localStorage.getItem(i)}catch(e){return null}}))},setItem(i,a){return e(this,void 0,void 0,(function*(){try{o?yield t(wx.setStorage)({key:i,data:a}):r&&localStorage.setItem(i,a)}catch(e){console.error("setStorage error",e)}}))},removeItem(i){return e(this,void 0,void 0,(function*(){try{o?yield t(wx.removeStorage)({key:i}):r&&localStorage.removeItem(i)}catch(e){console.error("removeStorage error",e)}}))}}; | ||
//# sourceMappingURL=storage.js.map |
@@ -7,3 +7,3 @@ /// <reference types="miniprogram-api-typings" /> | ||
showModal(options: WechatMiniprogram.ShowModalOption): Promise<boolean>; | ||
hideModal(): void; | ||
hideModal(): any; | ||
/** | ||
@@ -20,3 +20,3 @@ * @param content | ||
}): any; | ||
showError(err: any, opts: any): any; | ||
showError(err: any, opts: any): Promise<any>; | ||
/** | ||
@@ -43,7 +43,7 @@ * 获取错误信息 | ||
}): Promise<unknown>; | ||
hide(): void; | ||
hideLoading(): void; | ||
hideToast(): any; | ||
hideInfo(): void; | ||
hide(): Promise<void>; | ||
hideLoading(): Promise<void>; | ||
hideToast(): Promise<void>; | ||
hideInfo(): Promise<any>; | ||
}; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
import{__awaiter,__rest}from"tslib";import{themeColorMap}from"../constants";import{pify}from"./pify";import{delay,isPlainObject}from"./utillib";let hasModalShow=!1;const codeReg=/\((\d+)\).+/;export default{showModal(t){return __awaiter(this,void 0,void 0,(function*(){this.hideToast(),hasModalShow=!0;const e=yield pify(wx.showModal)(Object.assign({confirmColor:themeColorMap.primary,cancelColor:themeColorMap.weak},t)).then(({confirm:t})=>!!t).catch(()=>!1);return hasModalShow=!1,e}))},hideModal(){hasModalShow=!1},alert(t,e={}){return __awaiter(this,void 0,void 0,(function*(){return"boolean"==typeof(yield this.showModal(Object.assign({content:t,showCancel:!1},e)))}))},confirm(t,e="",o={}){return __awaiter(this,void 0,void 0,(function*(){return this.showModal(Object.assign({title:t,content:e},o))}))},showLoading:(t="加载中…",e)=>(t.endsWith("…")||t.endsWith("...")||(t+="…"),pify(wx.showLoading)(Object.assign({title:t},e))),showInfo(t,e={}){var{duration:o=1500}=e,i=__rest(e,["duration"]);return this.show(Object.assign({title:t,mode:"none",duration:o},i))},showError(t,e){if(t&&t.errMsg&&/cancel/.test(t.errMsg))return;this.hideToast();let o="";return t&&(o=this.getErrorMsg(t,e),o)?this.showInfo(o,Object.assign(Object.assign({},e),{duration:3e3})):void 0},getErrorMsg:(t,{defaultMsg:e="",errMsgKey:o="msg"}={})=>(()=>{if(!t)return;let i="";return"string"==typeof t?t:(console.log(t,t.stack),isPlainObject(t)&&(i=t[o]||t.Message||t.msg||t.message||t.errMsg||"连接服务器失败,请稍后再试",t.reqId?i+=`(${t.reqId})`:t.code&&!codeReg.test(i)&&(i+=`(${t.code})`)),i||(i=e||"连接服务器失败,请稍后再试"),i)})(),show({text:t,title:e,icon:o,image:i,duration:r,mask:s,mode:a,waitForHide:n=!1}){if(!o&&a&&(o=a),t&&!e&&(e=t),wx.showToast({title:e,icon:o,image:i,duration:r,mask:s}),n)return delay(r)},hide(){this.hideLoading(),this.hideInfo()},hideLoading(){wx.hideLoading()},hideToast(){return this.hideInfo()},hideInfo(){wx.hideToast()}}; | ||
import{__awaiter as t,__rest as i}from"tslib";import{themeColorMap as o}from"../constants";import{pify as e}from"./pify";import{delay as r,isPlainObject as n}from"./utillib";const s=/\((\d+)\).+/;export default{showModal(i){return t(this,void 0,void 0,(function*(){yield this.hideToast();return yield e(wx.showModal)(Object.assign({confirmColor:o.primary,cancelColor:o.weak},i)).then(({confirm:t})=>!!t).catch(()=>!1)}))},hideModal(){return this.hideToast()},alert(i,o={}){return t(this,void 0,void 0,(function*(){return"boolean"==typeof(yield this.showModal(Object.assign({content:i,showCancel:!1},o)))}))},confirm(i,o="",e={}){return t(this,void 0,void 0,(function*(){return this.showModal(Object.assign({title:i,content:o},e))}))},showLoading:(t="加载中…",i)=>(t.endsWith("…")||t.endsWith("...")||(t+="…"),e(wx.showLoading)(Object.assign({title:t},i))),showInfo(t,o={}){var{duration:e=1500}=o,r=i(o,["duration"]);return this.show(Object.assign({title:t,mode:"none",duration:e},r))},showError(i,o){return t(this,void 0,void 0,(function*(){if(i&&i.errMsg&&/cancel/.test(i.errMsg))return;yield this.hideToast();let t="";return i&&(t=this.getErrorMsg(i,o),t)?this.showInfo(t,Object.assign(Object.assign({},o),{duration:3e3})):void 0}))},getErrorMsg:(t,{defaultMsg:i="",errMsgKey:o="msg"}={})=>(()=>{if(!t)return;let e="";return"string"==typeof t?t:(console.log(t,t.stack),n(t)&&(e=t[o]||t.Message||t.msg||t.message||t.errMsg||"连接服务器失败,请稍后再试",t.reqId?e+=`(${t.reqId})`:t.code&&!s.test(e)&&(e+=`(${t.code})`)),e||(e=i||"连接服务器失败,请稍后再试"),e)})(),show({text:t,title:i,icon:o,image:e,duration:n,mask:s,mode:d,waitForHide:a=!1}){if(!o&&d&&(o=d),t&&!i&&(i=t),wx.showToast({title:i,icon:o,image:e,duration:n,mask:s}),a)return r(n)},hide(){return t(this,void 0,void 0,(function*(){yield this.hideLoading(),yield this.hideInfo()}))},hideLoading(){return t(this,void 0,void 0,(function*(){try{yield e(wx.hideLoading)()}catch(t){}}))},hideToast(){return t(this,void 0,void 0,(function*(){try{yield e(wx.hideToast())()}catch(t){}}))},hideInfo(){return t(this,void 0,void 0,(function*(){return this.hideToast()}))}}; | ||
//# sourceMappingURL=tips.js.map |
@@ -1,2 +0,2 @@ | ||
import{__rest}from"tslib";import{themeColorMap}from"../constants";import{logger}from"./logger";export const appendParams=(e,t={})=>{const o=[];return Object.keys(t).forEach(e=>{let r=t[e];if(void 0!==r){if(isPlainObject(r))try{r=JSON.stringify(r)}catch(e){}o.push(`${e}=${encodeURIComponent(r)}`)}}),o.length?(e.indexOf("?")>-1?e+"&":e+"?")+o.join("&"):e};export const delay=e=>new Promise(t=>setTimeout(t,e));export function genPromise(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}export const noop=()=>{};export const getErrorMsg=e=>{if(!e)return;let t="";return"string"==typeof e?e:(t=e.msg||e.Message||e.message||e.errMsg||"连接服务器失败,请稍后再试",e.reqId&&(t+=`(${e.reqId})`),t||(t="连接服务器失败,请稍后再试"),t)};export const isPlainObject=e=>{if("object"!=(void 0===e?"undefined":typeof e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t};export let hasModalShow=!1;export const showModal=(e,t="",o)=>{var{confirmText:r="确定",confirmColor:n=themeColorMap.primary,cancelText:s="取消",cancelColor:c=themeColorMap.weak}=o,i=__rest(o,["confirmText","confirmColor","cancelText","cancelColor"]);return wx.hideToast(),hasModalShow=!0,new Promise((o,r)=>{wx.showModal(Object.assign(Object.assign({title:e,content:t},i),{success({confirm:e}){o(!!e)},fail(){o(!1)},complete(){hasModalShow=!1}}))})};export function cutoffLong(e,t=4096,o=10,r=20){try{return function e(t,o,n){return t?"string"==typeof t&&t.length>o?t.substr(0,o)+`... (${t.length-o} characters truncated)`:Array.isArray(t)?t.length>n?t.slice(0,n).map(t=>e(t,o,n)).concat(`... (${t.length-n} items truncated)`):t:"object"==typeof t?Object.keys(t).reduce((s,c,i,l)=>(i<r?s[c]=e(t[c],o,n):i===r&&(s[l.length-r+" keys truncated"]=1),s),{}):t:t}(e,t,o)}catch(t){return logger.debug("cutoffLong fail",t),e}}export function jsonp2json(e){const t=e.indexOf("(");let o={};if(t>-1)try{"'"===(e=e.substring(t+1,e.length-1))[0]&&"'"===e[e.length-1]&&(e=e.substring(1,e.length-1)),o=JSON.parse(e)}catch(e){console.error(e)}return o} | ||
import{__rest as e}from"tslib";import{themeColorMap as t}from"../constants";import{logger as o}from"./logger";export const appendParams=(e,t={})=>{const o=[];return Object.keys(t).forEach(e=>{let r=t[e];if(void 0!==r){if(isPlainObject(r))try{r=JSON.stringify(r)}catch(e){}o.push(`${e}=${encodeURIComponent(r)}`)}}),o.length?(e.indexOf("?")>-1?e+"&":e+"?")+o.join("&"):e};export const delay=e=>new Promise(t=>setTimeout(t,e));export function genPromise(){let e,t;return{promise:new Promise((o,r)=>{e=o,t=r}),resolve:e,reject:t}}export const noop=()=>{};export const getErrorMsg=e=>{if(!e)return;let t="";return"string"==typeof e?e:(t=e.msg||e.Message||e.message||e.errMsg||"连接服务器失败,请稍后再试",e.reqId&&(t+=`(${e.reqId})`),t||(t="连接服务器失败,请稍后再试"),t)};export const isPlainObject=e=>{if("object"!=(void 0===e?"undefined":typeof e)||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t};export let hasModalShow=!1;export const showModal=(o,r="",n)=>{var{confirmText:c="确定",confirmColor:s=t.primary,cancelText:i="取消",cancelColor:a=t.weak}=n,l=e(n,["confirmText","confirmColor","cancelText","cancelColor"]);return wx.hideToast(),hasModalShow=!0,new Promise((e,t)=>{wx.showModal(Object.assign(Object.assign({title:o,content:r},l),{success({confirm:t}){e(!!t)},fail(){e(!1)},complete(){hasModalShow=!1}}))})};export function cutoffLong(e,t=4096,r=10,n=20){try{return function e(t,o,r){return t?"string"==typeof t&&t.length>o?t.substr(0,o)+`... (${t.length-o} characters truncated)`:Array.isArray(t)?t.length>r?t.slice(0,r).map(t=>e(t,o,r)).concat(`... (${t.length-r} items truncated)`):t:"object"==typeof t?Object.keys(t).reduce((c,s,i,a)=>(i<n?c[s]=e(t[s],o,r):i===n&&(c[a.length-n+" keys truncated"]=1),c),{}):t:t}(e,t,r)}catch(t){return o.debug("cutoffLong fail",t),e}}export function jsonp2json(e){const t=e.indexOf("(");let o={};if(t>-1)try{"'"===(e=e.substring(t+1,e.length-1))[0]&&"'"===e[e.length-1]&&(e=e.substring(1,e.length-1)),o=JSON.parse(e)}catch(e){console.error(e)}return o} | ||
//# sourceMappingURL=utillib.js.map |
@@ -1,2 +0,2 @@ | ||
import*as envDetect from"./env-detect";export class WebSocket{constructor(e){this.url=e,this.ws=null,this.initWs()}initWs(){envDetect.isMiniProgram?this.ws=wx.connectSocket({url:this.url}):this.ws=new window.WebSocket(this.url)}send({data:e}){envDetect.isMiniProgram?this.ws.send({data:e}):this.ws.send(e)}close({code:e=1e3,reason:s}={}){envDetect.isMiniProgram?this.ws.close({code:e,reason:s,success(e){console.log("res",e)},fail(e){console.log("error",e)}}):this.ws.close(e,s)}onOpen(e){envDetect.isMiniProgram?this.ws.onOpen(e):this.ws.addEventListener("open",e)}onClose(e){envDetect.isMiniProgram?this.ws.onClose(e):this.ws.addEventListener("close",e)}onMessage(e){envDetect.isMiniProgram?this.ws.onMessage(e):this.ws.addEventListener("message",e)}onError(e){envDetect.isMiniProgram?this.ws.onError(e):this.ws.addEventListener("error",e)}} | ||
import*as s from"./env-detect";export class WebSocket{constructor(s){this.url=s,this.ws=null,this.initWs()}initWs(){s.isMiniProgram?this.ws=wx.connectSocket({url:this.url}):this.ws=new window.WebSocket(this.url)}send({data:e}){s.isMiniProgram?this.ws.send({data:e}):this.ws.send(e)}close({code:e=1e3,reason:i}={}){s.isMiniProgram?this.ws.close({code:e,reason:i,success(s){console.log("res",s)},fail(s){console.log("error",s)}}):this.ws.close(e,i)}onOpen(e){s.isMiniProgram?this.ws.onOpen(e):this.ws.addEventListener("open",e)}onClose(e){s.isMiniProgram?this.ws.onClose(e):this.ws.addEventListener("close",e)}onMessage(e){s.isMiniProgram?this.ws.onMessage(e):this.ws.addEventListener("message",e)}onError(e){s.isMiniProgram?this.ws.onError(e):this.ws.addEventListener("error",e)}} | ||
//# sourceMappingURL=WebSocket.js.map |
@@ -7,3 +7,3 @@ /// <reference types="miniprogram-api-typings" /> | ||
showModal(options: WechatMiniprogram.ShowModalOption): Promise<boolean>; | ||
hideModal(): void; | ||
hideModal(): any; | ||
/** | ||
@@ -20,3 +20,3 @@ * @param content | ||
}): any; | ||
showError(err: any, opts: any): any; | ||
showError(err: any, opts: any): Promise<any>; | ||
/** | ||
@@ -43,7 +43,7 @@ * 获取错误信息 | ||
}): Promise<unknown>; | ||
hide(): void; | ||
hideLoading(): void; | ||
hideToast(): any; | ||
hideInfo(): void; | ||
hide(): Promise<void>; | ||
hideLoading(): Promise<void>; | ||
hideToast(): Promise<void>; | ||
hideInfo(): Promise<any>; | ||
}; | ||
export default _default; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),constants_1=require("../constants"),pify_1=require("./pify"),utillib_1=require("./utillib"),hasModalShow=!1,codeReg=/\((\d+)\).+/;exports.default={showModal:function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){var i;return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return this.hideToast(),hasModalShow=!0,[4,pify_1.pify(wx.showModal)(tslib_1.__assign({confirmColor:constants_1.themeColorMap.primary,cancelColor:constants_1.themeColorMap.weak},t)).then((function(t){return!!t.confirm})).catch((function(){return!1}))];case 1:return i=o.sent(),hasModalShow=!1,[2,i]}}))}))},hideModal:function(){hasModalShow=!1},alert:function(t,i){return void 0===i&&(i={}),tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(o){switch(o.label){case 0:return[4,this.showModal(Object.assign({content:t,showCancel:!1},i))];case 1:return[2,"boolean"==typeof o.sent()]}}))}))},confirm:function(t,i,o){return void 0===i&&(i=""),void 0===o&&(o={}),tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){return[2,this.showModal(Object.assign({title:t,content:i},o))]}))}))},showLoading:function(t,i){return void 0===t&&(t="加载中…"),t.endsWith("…")||t.endsWith("...")||(t+="…"),pify_1.pify(wx.showLoading)(tslib_1.__assign({title:t},i))},showInfo:function(t,i){void 0===i&&(i={});var o=i.duration,e=void 0===o?1500:o,n=tslib_1.__rest(i,["duration"]);return this.show(tslib_1.__assign({title:t,mode:"none",duration:e},n))},showError:function(t,i){if(!(t&&t.errMsg&&/cancel/.test(t.errMsg))){this.hideToast();var o="";return t&&(o=this.getErrorMsg(t,i))?this.showInfo(o,tslib_1.__assign(tslib_1.__assign({},i),{duration:3e3})):void 0}},getErrorMsg:function(t,i){var o=void 0===i?{}:i,e=o.defaultMsg,n=void 0===e?"":e,s=o.errMsgKey,r=void 0===s?"msg":s;return function(){if(t){var i="";return"string"==typeof t?t:(console.log(t,t.stack),utillib_1.isPlainObject(t)&&(i=t[r]||t.Message||t.msg||t.message||t.errMsg||"连接服务器失败,请稍后再试",t.reqId?i+="("+t.reqId+")":t.code&&!codeReg.test(i)&&(i+="("+t.code+")")),i||(i=n||"连接服务器失败,请稍后再试"),i)}}()},show:function(t){var i=t.text,o=t.title,e=t.icon,n=t.image,s=t.duration,r=t.mask,a=t.mode,d=t.waitForHide,u=void 0!==d&&d;if(!e&&a&&(e=a),i&&!o&&(o=i),wx.showToast({title:o,icon:e,image:n,duration:s,mask:r}),u)return utillib_1.delay(s)},hide:function(){this.hideLoading(),this.hideInfo()},hideLoading:function(){wx.hideLoading()},hideToast:function(){return this.hideInfo()},hideInfo:function(){wx.hideToast()}}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var tslib_1=require("tslib"),constants_1=require("../constants"),pify_1=require("./pify"),utillib_1=require("./utillib"),codeReg=/\((\d+)\).+/;exports.default={showModal:function(t){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(i){switch(i.label){case 0:return[4,this.hideToast()];case 1:return i.sent(),[4,pify_1.pify(wx.showModal)(tslib_1.__assign({confirmColor:constants_1.themeColorMap.primary,cancelColor:constants_1.themeColorMap.weak},t)).then((function(t){return!!t.confirm})).catch((function(){return!1}))];case 2:return[2,i.sent()]}}))}))},hideModal:function(){return this.hideToast()},alert:function(t,i){return void 0===i&&(i={}),tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(e){switch(e.label){case 0:return[4,this.showModal(Object.assign({content:t,showCancel:!1},i))];case 1:return[2,"boolean"==typeof e.sent()]}}))}))},confirm:function(t,i,e){return void 0===i&&(i=""),void 0===e&&(e={}),tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(n){return[2,this.showModal(Object.assign({title:t,content:i},e))]}))}))},showLoading:function(t,i){return void 0===t&&(t="加载中…"),t.endsWith("…")||t.endsWith("...")||(t+="…"),pify_1.pify(wx.showLoading)(tslib_1.__assign({title:t},i))},showInfo:function(t,i){void 0===i&&(i={});var e=i.duration,n=void 0===e?1500:e,r=tslib_1.__rest(i,["duration"]);return this.show(tslib_1.__assign({title:t,mode:"none",duration:n},r))},showError:function(t,i){return tslib_1.__awaiter(this,void 0,void 0,(function(){var e;return tslib_1.__generator(this,(function(n){switch(n.label){case 0:return t&&t.errMsg&&/cancel/.test(t.errMsg)?[2]:[4,this.hideToast()];case 1:return n.sent(),e="",t&&(e=this.getErrorMsg(t,i))?[2,this.showInfo(e,tslib_1.__assign(tslib_1.__assign({},i),{duration:3e3}))]:[2]}}))}))},getErrorMsg:function(t,i){var e=void 0===i?{}:i,n=e.defaultMsg,r=void 0===n?"":n,s=e.errMsgKey,o=void 0===s?"msg":s;return function(){if(t){var i="";return"string"==typeof t?t:(console.log(t,t.stack),utillib_1.isPlainObject(t)&&(i=t[o]||t.Message||t.msg||t.message||t.errMsg||"连接服务器失败,请稍后再试",t.reqId?i+="("+t.reqId+")":t.code&&!codeReg.test(i)&&(i+="("+t.code+")")),i||(i=r||"连接服务器失败,请稍后再试"),i)}}()},show:function(t){var i=t.text,e=t.title,n=t.icon,r=t.image,s=t.duration,o=t.mask,a=t.mode,u=t.waitForHide,c=void 0!==u&&u;if(!n&&a&&(n=a),i&&!e&&(e=i),wx.showToast({title:e,icon:n,image:r,duration:s,mask:o}),c)return utillib_1.delay(s)},hide:function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return[4,this.hideLoading()];case 1:return t.sent(),[4,this.hideInfo()];case 2:return t.sent(),[2]}}))}))},hideLoading:function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,pify_1.pify(wx.hideLoading)()];case 1:return t.sent(),[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},hideToast:function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,pify_1.pify(wx.hideToast())()];case 1:return t.sent(),[3,3];case 2:return t.sent(),[3,3];case 3:return[2]}}))}))},hideInfo:function(){return tslib_1.__awaiter(this,void 0,void 0,(function(){return tslib_1.__generator(this,(function(t){return[2,this.hideToast()]}))}))}}; | ||
//# sourceMappingURL=tips.js.map |
{ | ||
"name": "qcloud-iotexplorer-appdev-sdk", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
20
0
221698
176
1355