aegis-mp-sdk 1.24.56 → 1.24.57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/lib/aegis.min.js +3 -3
- package/lib/packages/core/src/interface/config.d.ts +1 -0
- package/lib/packages/core/src/interface/log.d.ts +2 -1
- package/lib/packages/core/src/util/index.d.ts +2 -0
- package/lib/packages/hippy-sdk/src/aegis.d.ts +3 -0
- package/lib/packages/hippy-sdk/src/plugins/device.d.ts +13 -0
- package/lib/packages/hippy-sdk/src/plugins/index.d.ts +2 -1
- package/lib/packages/mp-sdk/src/util/hack-api.d.ts +7 -3
- package/lib/packages/mp-sdk/src/util/hack-network.d.ts +17 -0
- package/lib/packages/mp-sdk/src/util/hack-wsConnect.d.ts +21 -0
- package/lib/packages/mp-sdk/src/util/index.d.ts +5 -0
- package/lib/packages/web-sdk/src/util/hack-websocket.d.ts +14 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -395,6 +395,7 @@ Aegis 通过劫持 `wx.request || qq.request` 进行接口测速。
|
|
|
395
395
|
| delay | 可选,number,默认 1000 ms。<br>上报节流时间,在该时间段内的上报将会合并到一个上报请求中。 |
|
|
396
396
|
| repeat | 可选,number,默认 5。<br>重复上报次数,对于同一个错误超过多少次不上报。 |
|
|
397
397
|
| enableHttp2 | 可选,boolean,默认 false。<br> 上报数据是否支持 HTTP2,默认没有开启,以后会考虑改成默认开启。 |
|
|
398
|
+
| websocketHack | 可选,boolean,默认 false <br>是否开启websocket监控。 |
|
|
398
399
|
| offlineLog | 可选,boolean,默认 false。<br>是否使用离线日志 |
|
|
399
400
|
| offlineLogExp | 可选,number,默认 3。<br>离线日志过期天数 |
|
|
400
401
|
| url | 可选,string,默认 '//aegis.qq.com/collect'。<br>日志上报地址 |
|
package/lib/aegis.min.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* =================================================================
|
|
3
|
-
* aegis-mp-sdk@1.24.
|
|
3
|
+
* aegis-mp-sdk@1.24.57 (c) 2022 TencentCloud Real User Monitoring.
|
|
4
4
|
* Author pumpkincai.
|
|
5
|
-
* Last Release Time Fri
|
|
5
|
+
* Last Release Time Fri May 27 2022 15:26:25 GMT+0800 (GMT+08:00).
|
|
6
6
|
* Released under the MIT License.
|
|
7
7
|
* Thanks for supporting RUM & Aegis!
|
|
8
8
|
* =================================================================
|
|
9
9
|
**/
|
|
10
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t()}(this,function(){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function e(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,s=o.length;r<s;r++){var a=o[r],u=Object.getOwnPropertyDescriptor(i,a);null!=u&&u.enumerable&&(t[a]=i[a])}return t}});var r=(t.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},t.prototype.on=function(e,t,n){if(void 0===n&&(n=0),this){var i=this.eventsList[e];return(i||(this.eventsList[e]=[],i=this.eventsList[e]),-1!==this.indexOf(i,t))?this:(i.push({name:e,type:n||0,callback:t}),this)}},t.prototype.one=function(e,t){this.on(e,t,1)},t.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(!n)return null;if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}return null}},t.prototype.clear=function(){this.eventsList={}},t),o=function(t){try{return encodeURIComponent(decodeURIComponent(t))}catch(e){return t}};function t(){var s=this;this.emit=function(e,t){if(s){var n;if(null!=(i=s.eventsList[e])&&i.length)for(var i=i.slice(),o=0;o<i.length;o++){n=i[o];try{var r=n.callback.apply(s,[t]);if(1===n.type&&s.remove(e,n.callback),!1===r)break}catch(e){throw e}}return s}},this.eventsList={}}(W={})[W.number=-1]="number",W.string="";function u(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function l(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function p(e,t,n){var i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler)){var o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||{};return{code:void 0===(r=o.code)?"unknown":r,isErr:o.isErr}}"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(i=null==t?void 0:t.ret)||void 0===i?void 0:i.join)&&(y=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==y.indexOf(e.toLowerCase())});return s.length?{code:""+(r=Number(e[s[0]])),isErr:0!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}var d,a,c,h,g,y=["ret","retcode","code","errcode"],m=function(e){if("string"==typeof e)return e;try{return(JSON.stringify(e,(i=[],o=[],function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){var n=i.indexOf(t);if(-1!==n)return"[Circular "+o[n]+"]";i.push(t),o.push(e||"root")}return t}),4)||"undefined").replace(/"/gim,"")}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}var i,o},v=function(n,i){void 0===i&&(i=3);var o,r,s,a="";return Array.isArray(n)?(a+="[",o=n.length,n.forEach(function(e,t){a+="object"==typeof e&&1<i?v(e,i-1):O(e),a+=t===o-1?"":","}),a+="]"):n instanceof Object?(a="{",r=Object.keys(n),s=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<i?a+='"'+e+'":'+v(n[e],i-1):a+=b(e,n[e]),a+=t===s-1||t<s-1&&void 0===n[r[t+1]]?"":","}),a+="}"):a+=n,a},b=function(e,t){var n=typeof t,i="";return"string"==n||"object"==n?i+='"'+e+'":"'+t+'"':"function"==typeof t?i+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?i+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(i+='"'+e+'": '+t),i},O=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},n=function(e,t){var n,i={fetch:[],static:[]},o={};return Array.isArray(e)?e.forEach(function(e){var t;null===(t=i[e.type])||void 0===t||t.push(e)}):null===(n=i[e.type])||void 0===n||n.push(e),o.payload=JSON.stringify(f({duration:i},t)),o};(Z=d=d||{}).INFO_ALL="-1",Z.API_RESPONSE="1",Z.INFO="2",Z.ERROR="4",Z.PROMISE_ERROR="8",Z.AJAX_ERROR="16",Z.SCRIPT_ERROR="32",Z.IMAGE_ERROR="64",Z.CSS_ERROR="128",Z.CONSOLE_ERROR="256",Z.MEDIA_ERROR="512",Z.RET_ERROR="1024",Z.REPORT="2048",Z.PV="4096",Z.EVENT="8192",Z.PAGE_NOT_FOUND_ERROR="16384",(te=a=a||{})[te.android=1]="android",te[te.ios=2]="ios",te[te.windows=3]="windows",te[te.macos=4]="macos",te[te.linux=5]="linux",te[te.devtools=6]="devtools",te[te.other=100]="other",(ne=c=c||{})[ne.unknown=100]="unknown",ne[ne.wifi=1]="wifi",ne[ne.net2g=2]="net2g",ne[ne.net3g=3]="net3g",ne[ne.net4g=4]="net4g",ne[ne.net5g=5]="net5g",ne[ne.net6g=6]="net6g",(ie=h=h||{}).LOG="log",ie.SPEED="speed",ie.PERFORMANCE="performance",ie.OFFLINE="offline",ie.WHITE_LIST="whiteList",ie.VITALS="vitals",ie.PV="pv",ie.CUSTOM_PV="customPV",ie.EVENT="event",ie.CUSTOM="custom",ie.SDK_ERROR="sdkError",ie.SET_DATA="setData",(ce=g=g||{}).production="production",ce.gray="gray",ce.pre="pre",ce.daily="daily",ce.local="local",ce.test="test",ce.others="others";function w(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&i<t})})}function R(e){e.level===d.INFO_ALL&&(e.level=d.INFO)}function P(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function E(i){return function(e,t){i.lifeCycle.emit("afterRequest",e);var n=i.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function x(){}function S(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function T(){try{var e=getCurrentPages(),t=e[e.length-1]||{},n=(i=t.options,Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"");return t.route?t.route+n:""}catch(e){return""}var i}function L(e){return C?C.addCallback(e):C=new se(e),C}var C,N,k,U,A=function(i,o){return function(e,t){var n=o.logCreated;if("function"!=typeof n)return i("beforeWrite",e),t(e);e=e.filter(function(e){return!1!==n(e)});return i("beforeWrite",e),t(e)}},j=function(n,i){var o,r=[],s=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){if(Array.isArray(e)?r=r.concat(e):r.push(e),i&&r.length>=i||n.sendNow&&0<r.length)return r=w(r),t(r.splice(0,r.length)),void(o&&clearTimeout(o));o&&clearTimeout(o),o=setTimeout(function(){o=null,0<(r=w(r)).length&&t(r.splice(0,r.length))},s.delay)}},I=function(e,t){return Array.isArray(e)?t(e.map(function(e){return f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(m).join(" ")})})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:m(e.msg)})])},_=function(s){var e,a=!1,u=!1,t=!1,l=[];return s.lifeCycle.on("onConfigChange",function(){e&&clearTimeout(e),e=setTimeout(function(){var e,n;!t&&s.config&&(t=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:h.WHITE_LIST,success:function(e){u=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i;if(0===n){if(a=o.is_in_white_list,s.isWhiteList=a,o.shutdown)return void s.destroy();0<=o.rate&&o.rate<=1&&(s.config.random=o.rate,s.isGetSample=!1)}s.isWhiteList&&l.length?M(s)(l.splice(0),function(){}):!s.isWhiteList&&l.length&&(l.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),u=!0}})}],h.WHITE_LIST)(null),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){l.length=0}),function(e,t){var n;a||null!==(n=null===(n=s.config)||void 0===n?void 0:n.api)&&void 0!==n&&n.reportRequest?t(e.concat(l.splice(0)).map(function(e){return R(e),e})):(e=e.filter(function(e){return e.level!==d.INFO&&e.level!==d.API_RESPONSE?(R(e),!0):(u||(l.push(e),200<=l.length&&(l.length=200)),!1)})).length&&t(e)}},q=function(i){return setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:h.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.PV)(null)},100),function(e,t){t(e)}},D=function(o){var r={};return function(e,t){var n,i;o.speedSample?(i="object"==typeof o.repeat?o.repeat:{repeat:o.repeat},n=+i.speed||+i.repeat||5,Array.isArray(e)?(i=e.filter(function(e){var t=!r[e.url]||r[e.url]<n;return r[e.url]=1+~~r[e.url],t})).length&&t(i):(!r[e.url]||r[e.url]<n)&&(r[e.url]=1+~~r[e.url],t(e))):t(e)}},F=function(i){var o={};return function(e,t){var n="number"==typeof i.repeat?i.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==d.ERROR&&e.level!==d.PROMISE_ERROR&&e.level!==d.AJAX_ERROR&&e.level!==d.SCRIPT_ERROR&&e.level!==d.IMAGE_ERROR&&e.level!==d.CSS_ERROR&&e.level!==d.MEDIA_ERROR||(o[e.msg]=o[e.msg]||0,o[e.msg]+=1,!(o[e.msg]>n))}))}},M=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:(t=e,t=(Array.isArray(t)?t:[t]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:d.INFO,msg:""})}),(t=Array.isArray(t)?t:[t]).map(function(t,n){return Object.getOwnPropertyNames(t).map(function(e){return o(e)+"["+n+"]="+(void 0===t[e]?"":o(t[e]))}).join("&")}).join("&")+(t.length?"&count="+t.length:"")),method:"post",contentType:"application/x-www-form-urlencoded",type:h.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},fail:function(e){"403 forbidden"===e&&i.destroy()}});var t}],h.LOG)(e)}},H=function(i){return function(e){i.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||i.config.ext1||"",ext2:e.ext2||i.config.ext2||"",ext3:e.ext3||i.config.ext3||""}});t({url:i.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:h.EVENT,log:e,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.EVENT)(e)}},B=function(n){return function(e){return n.sendPipeline([function(e,t){t({url:n.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:h.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&n.destroy()}})}],h.CUSTOM)(e)}},V=function(r,s){return function(e,t){var n=Array.isArray(e),i=n?e:[e];r.lifeCycle.emit("beforeRequest",e);var o=r.config.beforeRequest;(i="function"==typeof o?i.map(function(t){try{var e=o({logs:t,logType:s});return(null==e?void 0:e.logType)===s&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):i).length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],i=[];return!(i="string"==typeof t?[t]:t)||i.length<=0||(i.forEach(function(t){e.forEach(function(e){null!=e&&e[t]&&n.push(t)})}),0<n.length&&(e=e.map(function(e){var t={};return n.forEach(function(e){t[e]=""}),f(f({},t),e)}))),e}(i,["ext1","ext2","ext3"]),t(n?i:i[0]))}},J=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||x)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=x),n(e,function(e){return null==i?void 0:i(e,t)})}})},G=(Object.defineProperty(ve.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.56"},enumerable:!1,configurable:!0}),Object.defineProperty(ve.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),d},enumerable:!1,configurable:!0}),ve.prototype.init=function(e){this.setConfig(e);for(var t=0;t<ve.installedPlugins.length;t++)try{ve.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},ve.prototype.setConfig=function(e){Object.assign(this.config,e);var t=this.config,n=t.id,i=t.uin,o=t.version,r=t.ext1,s=t.ext2,a=t.ext3,e=t.aid,t=t.env,u=void 0===t?"production":t,t=this.bean.id!==n||this.bean.uin!==i||this.bean.aid!==e;return this.bean.id=n||"",this.bean.uin=i||"",this.bean.version=o||"1.24.56",this.bean.aid=e||"",this.bean.env=function(){switch(u){case g.production:case g.gray:case g.pre:case g.daily:case g.local:case g.test:case g.others:return 1;default:return}}()?u:g.others,r&&(this.bean.ext1=encodeURIComponent(r)),s&&(this.bean.ext2=encodeURIComponent(s)),a&&(this.bean.ext3=encodeURIComponent(a)),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},ve.use=function(e){-1===ve.installedPlugins.indexOf(e)&&e.aegisPlugin&&ve.installedPlugins.push(e)},ve.unuse=function(e){e=ve.installedPlugins.indexOf(e);-1!==e&&ve.installedPlugins.splice(e,1)},ve.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.INFO}),this.normalLogPipeline(n)},ve.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.INFO_ALL}),this.normalLogPipeline(n)},ve.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},ve.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:d.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:d.ERROR}),this.normalLogPipeline(n)},ve.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},ve.prototype.reportPv=function(n){var i,o=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),i=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+o.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:o.config.url+"/"+n+"?"+i,addBean:!1,type:h.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],h.CUSTOM_PV)(null))},ve.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?this.eventPipeline(e):console.warn("reportEvent params error"))},ve.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},ve.prototype.reportT=function(e){var t=e.name,n=e.duration,i=e.ext1,o=void 0===i?"":i,r=e.ext2,i=void 0===r?"":r,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof i&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,i,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},ve.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},ve.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},ve.prototype.submitCustomTime=function(e,t,n,i,o,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:i||this.config.ext2,ext3:o||this.config.ext3,from:r||void 0})},ve.prototype.extendBean=function(e,t){this.bean[e]=t},ve.prototype.sendPipeline=function(e,t){var n,r=this;return J(s([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},V(n=this,t)],e,[P(this),function(i,o){r.request(i,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,o({isErr:!1,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.success)||void 0===e||e.call.apply(e,s([i],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];10<=++r.failRequestCount&&r.destroy(),o({isErr:!0,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.fail)||void 0===e||e.call.apply(e,s([i],t))})},E(this)]))},ve.prototype.send=function(e,o,r){var t=this;return J([P(this),function(n,i){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:n.type,logs:n.log}),null==o||o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:n.type,logs:n.log}),null==r||r.apply(void 0,e)})},E(this)])(e)},ve.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},ve.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(m(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.56)",addBean:!1,method:"get",type:h.SDK_ERROR,log:e})}],h.SDK_ERROR)(e)},ve.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=ve.instances.indexOf(this);-1!==i&&ve.instances.splice(i,1);for(var o=ve.installedPlugins.length-1;0<=o;o--)try{ve.installedPlugins[o].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var r=this;r.constructor!==Object&&S(r,this),r=Object.getPrototypeOf(r););0===ve.instances.length&&(e=Object.getPrototypeOf(this).constructor,S(e),S(ve))}},ve.version="1.24.56",ve.instances=[],ve.logType=d,ve.environment=g,ve.installedPlugins=[],ve),W=(me.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},me.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},me.prototype.countInstance=function(){return this.instances.length},me.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},me.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},me.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},me.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},me.prototype.exist=function(e){return-1===this.instances.indexOf(e)},me.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null===(t=null===(t=this.option)||void 0===t?void 0:t.init)||void 0===t||t.call(this.option,this.getConfig(e)))},me.prototype.triggerOnNewAegis=function(e){var t;null===(t=null===(t=this.option)||void 0===t?void 0:t.onNewAegis)||void 0===t||t.call(this.option,e,this.getConfig(e))},me),$=wx||qq,K="",z=function(e){return function(e,t){if("string"==typeof e){if(e===t)return 1;for(var n=e.split("."),i=t.split("."),o=Math.max(n.length,i.length),r=0;r<o;r++){var s=~~n[r],a=~~i[r];if(s<a)return;if(a<s)return 1}}}(K=K||$.getSystemInfoSync().SDKVersion,"1.1.1")&&$.canIUse?$.canIUse(e):!!$[e]},Q=new W({name:"offlineLog",onNewAegis:function(o){if($.getFileSystemManager)try{var e=o.config,t=e.id,r=void 0===t?"":t,n=e.uin,s=void 0===n?0:n,i=e.offlineUrl,a=void 0===i?"":i,u=e.offlineLogLimit,l=new X({limit:u});o.lifeCycle.on("beforeWrite",function(e){l.save2Offline(e=void 0===e?[]:e,o.config)}),l.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(s||i)&&o.send({url:a+"/offlineAuto",type:h.OFFLINE,log:h.OFFLINE},function(e){var n=(null==e?void 0:e.data).secretKey;n&&(t||l.getLogs({id:r,uin:s},function(e,t){e?console.error(e):o.send({url:a+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:s,aid:i},method:"post",type:h.OFFLINE,log:t},function(){l.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),X=(ye.prototype.getLogs=function(e,t){var n=this.fileSystem,i=this.filePath;n.readFile({filePath:i,encoding:"utf8",fail:function(e){console.error(e)},success:function(e){e=e.data,e=(void 0===e?"":e).toString().split("\n").filter(function(e){return e}).map(function(e){return JSON.parse(e)});t(null,e)}})},ye.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var s=this.fileSystem,a=this.filePath,u=this.limitSize;s.readFile({filePath:a,encoding:"utf8",success:function(e){e=e.data,e=void 0===e?"":e;if((e=e.toString()+o).length>u){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>u);i--);s.writeFile({filePath:a,data:n,success:r})}else s.appendFile({data:o,filePath:a,encoding:"utf8",success:r,fail:function(e){console.error(e)}})}})},ye),Y=function(e){for(var t,n={unknown:/unknown|none/i,wifi:/wifi/i,net2g:/2g/i,net3g:/3g/i,net4g:/4g/i,net5g:/5g/i,net6g:/6g/i},i=c.unknown,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=c[r];break}}return i},Z=new W({name:"device",onNewAegis:function(u){return e=this,l=function(){return n=this,i=function(e){return this.setSystemInfo(u),this.refreshNetwork(u),this.setNetworkChange(u),[2]},a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!((s=0<(s=a.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=i.call(n,a)}catch(e){t=[6,e],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var n,i,o,r,s,a,t},new(a=(a=s=void 0)||Promise)(function(n,t){function i(e){try{r(l.next(e))}catch(e){t(e)}}function o(e){try{r(l.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((l=l.apply(e,s||[])).next())});var e,s,a,l},setSystemInfo:function(s){var a=this;try{z("getSystemInfo")&&$.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,r=void 0===r?0:r,e=e.screenHeight,e=void 0===e?0:e;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",Math.round(o)+" * "+Math.round(i)),s.extendBean("sr",Math.round(r)+" * "+Math.round(e))}})}catch(s){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=a.other,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=a[r];break}}return i},setNetworkChange:function(t){z("onNetworkStatusChange")&&$.onNetworkStatusChange(function(e){e=Y(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){z("getNetworkType")&&$.getNetworkType({success:function(e){e=Y(e.networkType);t.extendBean("netType",e)}})},refreshNetwork:function(e){var t=this;this.timer&&clearTimeout(this.timer),this.setNetworkType(e),this.timer=setTimeout(function(){t.refreshNetwork(e)},1e4)}}),ee=$.request,te=(e(ge,U=G),Object.defineProperty(ge.prototype,"getBean",{get:function(){var t=this;return this.bean?Object.getOwnPropertyNames(this.bean).map(function(e){return e+"="+t.bean[e]}).join("&")+"&from="+encodeURIComponent(T()):"from="+encodeURIComponent(T())},enumerable:!1,configurable:!0}),ge.prototype.initOfflineLog=function(){ge.use(Q)},ge.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},ge.prototype.reportPv=function(e){var t,n=this;e&&(t=Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&")+"&from="+encodeURIComponent(T()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:h.CUSTOM_PV,log:h.CUSTOM_PV},function(){},function(){}))},ge.sessionID="session-"+Date.now(),ge.asyncPluginIndex=0,ge),ne=new W({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){$.getStorage({key:"AEGIS_ID",success:function(e){t(e.data)},fail:function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});$.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),ie=(he.prototype.addCallback=function(e){e&&this.callbacks.push(e)},he.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},he.prototype.successHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.success)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.success)||void 0===e||e.call(i,n,i)},he.prototype.failHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.fail)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.fail)||void 0===e||e.call(i,n,i)},he.prototype.completeHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.complete)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.complete)||void 0===e||e.call(i,n,i)},he.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},he),oe=wx||qq,re=oe.request,se=(e(de,k=ie),de.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(oe,"request",{get:function(){return e.hackHandler.bind(e)}})},de.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e);return re(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},de),ae=wx||qq,ue=null===(ce=ae.cloud)||void 0===ce?void 0:ce.callFunction,le=(e(pe,N=ie),pe.prototype.defineApiProperty=function(){var e=this;ae.cloud&&ae.cloud.callFunction&&Object.defineProperty(ae.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},pe.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){ue(f(f({},o),{success:function(e){i.successHandler(e,o),t(e)},fail:function(e){i.failHandler(e,o),n(e)},complete:function(e){i.completeHandler(e,o)}}))})},pe),G=new W({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(s){var a=this;L({success:function(e,t){var n,i,o,r;s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(n={method:t.method||"get",url:u(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:l(t.url),type:"fetch"},r=null===(i=s.api)||void 0===i?void 0:i.apiDetail,i=(o=p(e.data,s.api,{url:t.url,ctx:e})||{}).code,o=o.isErr,r="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(r?m(t.data):"")+" \n \nres duration: "+n.duration+"ms \n \nres status: "+(e.statusCode||0)+" \n \nres retcode: "+i+" \n \nres data: "+(r?v(e.data):""),a.publishNormalLog({msg:r,level:d.API_RESPONSE,ctx:e}),n.ret=i,n.isErr=+o,a.publishSpeedLog(n),o&&a.publishNormalLog({msg:r,level:d.RET_ERROR,ctx:e}))},fail:function(e,t){s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(t={method:t.method||"get",url:u(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:l(t.url),type:"fetch"},a.publishSpeedLog(t))}})},overrideCallFunction:function(u){var l=this;new le({success:function(e,t){var n={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:200,type:"fetch",errMsg:e.errMsg,isHttps:!0},i=null===(a=u.api)||void 0===a?void 0:a.apiDetail,o="req url: "+n.url+"\n \nreq type: "+n.type+"\n \nres duration: "+n.duration+"ms \n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?v(e.result):"")+"\n ";l.publishNormalLog({msg:o,level:d.API_RESPONSE,ctx:e});var r,s,a=!1,a=(s="function"==typeof(null===(i=u.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(r=(t=u.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=t.isErr)&&t):(r=(s=p(e.result,u.api,{url:n.url,ctx:e})||{}).code,s.isErr),n.ret=r,s);n.isErr=+a,l.publishSpeedLog(n),a&&l.publishNormalLog({msg:o,level:d.RET_ERROR,ctx:e})},fail:function(e,t){e={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,type:"fetch",errMsg:e.errMsg,isHttps:!0};l.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),ce=new W({name:"onError",onNewAegis:function(e){this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;"function"==typeof $.onError&&$.onError(function(e){e&&t.publishErrorLog({msg:e,level:d.ERROR})}),z("onUnhandledRejection")&&$.onUnhandledRejection(function(e){e=e.reason;e&&(-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:d.PROMISE_ERROR}))}),z("onPageNotFound")&&$.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:d.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(u){var l=this,c=u.config;L({complete:function(e,t){var n,i,o=e.errMsg,r=e.statusCode,s=e.data,a=null===(n=c.api)||void 0===n?void 0:n.apiDetail;c.hostUrl&&-1<(null===(i=t.url)||void 0===i?void 0:i.indexOf(c.hostUrl))||(n="",-1<o.indexOf("timeout")||-1<o.indexOf("超时")?n="timeout":400<=r?n="error":(-1<o.indexOf("fail")||!r||r<0)&&(n="failed"),n&&(i="wx.cloud.callFunction."+t.url,e=p(e.data,u.config.api,{url:i,ctx:e}).code,l.publishErrorLog({msg:"AJAX_ERROR: request "+n+"\n \nres status: "+(r||0)+"\n \nres retcode: "+e+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n \nres data: "+(a?m(s):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(a?m(t.data):"")+"\n \nerrMsg: "+o.slice(0,1e3),level:d.AJAX_ERROR})))}})}}),ie=new W({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;$.getPerformance&&$.getPerformance().createObserver(function(e){e.getEntries().forEach(function(e){!e.duration||e.duration<=0||"script"===e.entryType&&t.publishAssetLog(e)})}).observe({entryTypes:["script"]})},generateLog:function(e){return{url:u(e.path||e.moduleName)+"js",method:"get",duration:Number(e.duration.toFixed(2)),status:200,type:"static",isHttps:!0,urlQuery:"",domainLookup:0,connectTime:0}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),fe=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],W=new W({name:"pagePerformance",onNewAegis:function(e){try{z("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(r){var s=this,e=$.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t=e.getEntries(),n={},i=t.find(function(e){return"appLaunch"===e.name&&0<e.duration}),o=t.find(function(e){return"firstRender"===e.name&&0<e.duration}),e=t.find(function(e){return"evaluateScript"===e.name&&0<e.duration}),t=t.find(function(e){return"route"===e.name&&0<e.duration});i&&(n.appLaunch=i.duration),o&&(n.firstScreenTiming=o.duration),e&&(n.scriptEvaluateTiming=e.duration),t&&(n.pageRouteTiming=t.duration),s.publish(n,r)});null==e||e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,i,o=[],r=n.config,s=-1===(null===(e=n.config.performanceUrl)||void 0===e?void 0:e.indexOf("?"))?"?":"&";for(i in t)o.push(i+"="+t[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:h.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:h.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;$.onAppRoute&&$.onAppRoute(function(e){"appLaunch"!==e.openType&&(t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:h.PV})}),t.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:d.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,a,u,n,r,s,l,c=this,i=t.config,i=i.setDataReportConfig||(null===(e=i.pagePerformance)||void 0===e?void 0:e.setDataReportConfig)||{};!0!==i.disabled&&(e=i.timeThreshold,o=!1!==i.withDataPaths,a=e&&0<+e?+e:30,u=J([j(t,10),function(e){e=e.map(function(e){return{component:e.from,duration:e.duration,fields:e.dataPaths&&e.dataPaths.length?e.dataPaths.sort().join(";"):void 0,size:e.size}});t.send({url:t.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:h.SET_DATA,log:e})}]),n=Page,r=Component,s=function(e,t){var r,s,n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,n=i-n;isNaN(n)||n<a||(n={from:e.is,duration:n},o&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:(t=t,s=0,null!=(r=e)&&r.data?(t.forEach(function(e){for(var t=r.data[e[0]],n=1,i=e.length;n<i;n++)t[e[n]]&&(t=t[e[n]]);var o="";try{o=JSON.stringify(t)}catch(e){o=""}s+=2*(void 0===o?"":o).replace(/[\u4e00-\u9fa5]/g,"aa").length}),s=Math.min(s,10485760)):s)}),u(n))},l=function(i){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(i[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(i[0][t])}catch(e){n=""}return e+"\n"+n},"");c.publishNormalLog({msg:e,level:d.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var i;"function"!=typeof t[e]||fe.includes(e)||(i=t[e],t[e]=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return"tap"===(null===(e=null==t?void 0:t[0])||void 0===e?void 0:e.type)&&l(t),null==i?void 0:i.apply(this,t)})}),n(t)},Component=function(e){var n,i;e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==n?void 0:n.call(this)}):(i=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==i?void 0:i.call(this)});var t=e.methods;return t&&"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).forEach(function(e){var i;"function"==typeof t[e]&&(i=t[e],t[e]=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return"tap"===(null===(e=null==t?void 0:t[0])||void 0===e?void 0:e.type)&&l(t),null==i?void 0:i.apply(this,t)})}),r(e)})}});function pe(){return null!==N&&N.apply(this,arguments)||this}function de(){return null!==k&&k.apply(this,arguments)||this}function he(e){this.callbacks=[],this.isOverride=!1,this.isOverride||this.override(),this.callbacks.push(e)}function ge(e){var i,c=U.call(this,e)||this;c.originRequest=ee,c.speedLogPipeline=J([D(c.config),j(c),function(t,n){z("getNetworkType")?$.getNetworkType({success:function(e){e=Y(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)},function(e,t){c.lifeCycle.emit("beforeReportSpeed",e);var n=c.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},V(i=c,h.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:n(e,c.bean)})}]),c.requestQueue=[],c.requesting=!1,c.request=function(e,t,n){if(e.url&&c.bean.id)if(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(c.bean.aid))){if(!(c.requesting||z("getNetworkType")&&void 0===c.bean.netType)){c.requesting=!0;var i,o=e.url;c.config.whiteListUrl===o&&(i=t,t=function(e){null==i||i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+c.getBean);var r=e.method||"get",s=function(){c.requesting=!1;var e=c.requestQueue.shift();e&&c.request(e.options,e.success,e.fail)},a=e,u=c.config.onBeforeRequest;if(!(a=u?u(e,c):a)||!a.url){var l="";return a||(l="Sending request blocked",console.log(l)),a.url||(l="Please handle the parameters reasonably, options.url is necessary",console.warn(l)),null==n||n(l),s(),!1}l=c.config.enableHttp2||!1;return"get"===r?(o=function(e,n){if("string"!=typeof e)return"";if("object"==typeof n&&n){var t=Object.getOwnPropertyNames(n).map(function(e){var t=n[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI");return e+(-1===e.indexOf("?")?"?":"&")+t}return e}(o,a.data),c.originRequest(f({url:o,enableHttp2:l,success:t,fail:n,complete:s},e.requestConfig))):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest(f({url:o,enableHttp2:l,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s},e.requestConfig))),!0}c.requestQueue.push({options:e,success:t,fail:n})}else c.requestQueue.push({options:e,success:t,fail:n})};try{e.offlineLog&&c.initOfflineLog(),c.init(e),c.extendBean("sessionId",ge.sessionID),c.extendBean("referer",(z("getLaunchOptionsSync")?$.getLaunchOptionsSync():{scene:""}).scene||"")}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),c.sendSDKError(e)}return c}function ye(e){var o,r,s=this,t=void 0===e?{}:e,e=t.path,e=void 0===e?"/.aegis.offline.log":e,t=t.limit,t=void 0===t?2e4:t;this.offlineBuffer=[],this.insertLog=(o=null,r=[],function(e){r=r.concat(e),o=o||setTimeout(function(){o=null;var e,t=s.fileSystem,n=s.filePath,i=r.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";i&&(e=function(e){e?s.checkLimit(i,function(){r=[]}):t.writeFile({data:i,filePath:n,encoding:"utf8",fail:function(e){console.error(e)},success:function(){r=[]}})},t.access({path:n,success:function(){e(!0)},fail:function(){e()}}))},2e3)}),this.ready=function(e){s.fileSystem?setTimeout(function(){e(null)},0):(e(new Error("getFileSystemManager file")),s.offlineLog=!1)},this.clearLogs=function(){var e=s.fileSystem,t=s.filePath;e.writeFile({filePath:t,data:"",fail:function(){e.unlinkSync(t)}})},this.save2Offline=function(e,t){e=(e=!Array.isArray(e)?[e]:e).map(function(e){return"string"==typeof e&&(e={msg:e}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e[0]),i=1;i<e.length;i++){var o=e[i];if(null!==o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n}({id:t.id,uin:t.uin,time:+Date.now(),version:t.version,from:T()},e)});s.fileSystem?s.insertLog(e):(s.fileSystem||s.offlineBuffer.length||s.ready(function(e){e?console.error(e):s.offlineBuffer.length&&(s.addLogs(s.offlineBuffer),s.offlineBuffer=[])}),s.offlineBuffer=s.offlineBuffer.concat(e))},this.addLogs=function(e){s.fileSystem&&s.insertLog(e)},this.filePath=$.env.USER_DATA_PATH+e,this.fileSystem=$.getFileSystemManager(),this.limitSize=t}function me(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function ve(e){var n,t,o=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new r,this.bean={},this.normalLogPipeline=J([j(this,5),I,function(e,t){var i=n.config;t(e=e.map(function(e){var t,n=i.maxLength||204800;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null===(t=e.msg)||void 0===t?void 0:t.substring(0,n)}catch(t){e.msg=m(e.msg).substring(0,i.maxLength)}return e}))},F((n=this).config),A(this.lifeCycle.emit,this.config),q(this),_(this),function(e,t){try{var n=JSON.parse(JSON.stringify(e));o.lifeCycle.emit("beforeReport",n);var i=o.config.beforeReport;(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)}catch(e){}},M(this)]),this.eventPipeline=J([j(this,5),H(this)]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=J([j(this,5),B(this)]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),ve.instances.push(this)}return te.use(ce),te.use(G),te.use(ne),te.use(ie),te.use(W),te.use(Z),te});
|
|
10
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).Aegis=t()}(this,function(){"use strict";var i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function e(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var f=function(){return(f=Object.assign||function(e){for(var t,n=1,i=arguments.length;n<i;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};function s(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;for(var i=Array(e),o=0,t=0;t<n;t++)for(var r=arguments[t],s=0,a=r.length;s<a;s++,o++)i[o]=r[s];return i}Object.assign||Object.defineProperty(Object,"assign",{enumerable:!1,configurable:!0,writable:!0,value:function(e){if(null==e)throw new TypeError("Cannot convert first argument to object");for(var t=Object(e),n=1;n<arguments.length;n++)if(null!=(i=arguments[n]))for(var i=Object(i),o=Object.keys(Object(i)),r=0,s=o.length;r<s;r++){var a=o[r],l=Object.getOwnPropertyDescriptor(i,a);null!=l&&l.enumerable&&(t[a]=i[a])}return t}});var r=(t.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},t.prototype.on=function(e,t,n){if(void 0===n&&(n=0),this){var i=this.eventsList[e];return(i||(this.eventsList[e]=[],i=this.eventsList[e]),-1!==this.indexOf(i,t))?this:(i.push({name:e,type:n||0,callback:t}),this)}},t.prototype.one=function(e,t){this.on(e,t,1)},t.prototype.remove=function(e,t){if(this){var n=this.eventsList[e];if(!n)return null;if(t)return n.length&&(t=this.indexOf(n,t),n.splice(t,1)),this;try{delete this.eventsList[e]}catch(e){}return null}},t.prototype.clear=function(){this.eventsList={}},t);function t(){var s=this;this.emit=function(e,t){if(s){var n;if(null!=(i=s.eventsList[e])&&i.length)for(var i=i.slice(),o=0;o<i.length;o++){n=i[o];try{var r=n.callback.apply(s,[t]);if(1===n.type&&s.remove(e,n.callback),!1===r)break}catch(e){throw e}}return s}},this.eventsList={}}(z={})[z.number=-1]="number",z.string="";function l(e,t){return"string"==typeof e?e.split("?")[t?1:0]||"":e}function u(e){return"string"==typeof e&&e.startsWith("//")?"undefined"!=typeof location&&"https:"===location.protocol:/^https/.test(e)}function c(e,t,n){var i;try{if("function"==typeof(null==t?void 0:t.retCodeHandler)){var o=t.retCodeHandler(e,null==n?void 0:n.url,null==n?void 0:n.ctx)||{};return{code:void 0===(r=o.code)?"unknown":r,isErr:o.isErr}}"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(i=null==t?void 0:t.ret)||void 0===i?void 0:i.join)&&(m=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==m.indexOf(e.toLowerCase())});return s.length?{code:""+(r=Number(e[s[0]])),isErr:0!==r}:{code:"unknown",isErr:!1}}catch(e){return{code:"unknown",isErr:!1}}}function n(){var n=new WeakSet;return function(e,t){if(t instanceof Error)return"Error.message: "+t.message+" \n Error.stack: "+t.stack;if("object"==typeof t&&null!==t){if(n.has(t))return"[Circular "+(e||"root")+"]";n.add(t)}return t}}var p,a,d,h,g,m=["ret","retcode","code","errcode"],v=function(e){if("string"==typeof e)return e;try{return e instanceof Error?(JSON.stringify(e,n(),4)||"undefined").replace(/"/gim,""):JSON.stringify(e,n(),4)||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},o=function(e){if("string"==typeof e)return e;try{return JSON.stringify(e,n())||"undefined"}catch(e){return"error happen when aegis stringify: \n "+e.message+" \n "+e.stack}},y=function(n,i){void 0===i&&(i=3);var o,r,s,a="";return Array.isArray(n)?(a+="[",o=n.length,n.forEach(function(e,t){a+="object"==typeof e&&1<i?y(e,i-1):O(e),a+=t===o-1?"":","}),a+="]"):n instanceof Object?(a="{",r=Object.keys(n),s=r.length,r.forEach(function(e,t){"object"==typeof n[e]&&1<i?a+='"'+e+'":'+y(n[e],i-1):a+=b(e,n[e]),a+=t===s-1||t<s-1&&void 0===n[r[t+1]]?"":","}),a+="}"):a+=n,a},b=function(e,t){var n=typeof t,i="";return"string"==n||"object"==n?i+='"'+e+'":"'+t+'"':"function"==typeof t?i+='"'+e+'":"function '+t.name+'"':"symbol"==typeof t?i+='"'+e+'":"symbol"':"number"!=typeof t&&"boolean"!=n||(i+='"'+e+'": '+t),i},O=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},w=function(e,t){var n,i={fetch:[],static:[]},o={};return Array.isArray(e)?e.forEach(function(e){var t;null===(t=i[e.type])||void 0===t||t.push(e)}):null===(n=i[e.type])||void 0===n||n.push(e),o.payload=JSON.stringify(f({duration:i},t)),o};(ne=p=p||{}).INFO_ALL="-1",ne.API_RESPONSE="1",ne.INFO="2",ne.ERROR="4",ne.PROMISE_ERROR="8",ne.AJAX_ERROR="16",ne.SCRIPT_ERROR="32",ne.IMAGE_ERROR="64",ne.CSS_ERROR="128",ne.CONSOLE_ERROR="256",ne.MEDIA_ERROR="512",ne.RET_ERROR="1024",ne.REPORT="2048",ne.PV="4096",ne.EVENT="8192",ne.PAGE_NOT_FOUND_ERROR="16384",ne.WEBSOCKET_ERROR="32768",(oe=a=a||{})[oe.android=1]="android",oe[oe.ios=2]="ios",oe[oe.windows=3]="windows",oe[oe.macos=4]="macos",oe[oe.linux=5]="linux",oe[oe.devtools=6]="devtools",oe[oe.other=100]="other",(re=d=d||{})[re.unknown=100]="unknown",re[re.wifi=1]="wifi",re[re.net2g=2]="net2g",re[re.net3g=3]="net3g",re[re.net4g=4]="net4g",re[re.net5g=5]="net5g",re[re.net6g=6]="net6g",(se=h=h||{}).LOG="log",se.SPEED="speed",se.PERFORMANCE="performance",se.OFFLINE="offline",se.WHITE_LIST="whiteList",se.VITALS="vitals",se.PV="pv",se.CUSTOM_PV="customPV",se.EVENT="event",se.CUSTOM="custom",se.SDK_ERROR="sdkError",se.SET_DATA="setData",(ve=g=g||{}).production="production",ve.gray="gray",ve.pre="pre",ve.daily="daily",ve.local="local",ve.test="test",ve.others="others";function E(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return n.url===e.url&&200===n.status&&i<t})})}function R(e){e.level===p.INFO_ALL&&(e.level=p.INFO)}function P(o){return function(e,t){o.lifeCycle.emit("modifyRequest",e);var n=o.config.modifyRequest;if("function"==typeof n)try{var i=n(e);"object"==typeof i&&"url"in i&&(e=i)}catch(e){console.error(e)}t(e)}}function S(i){return function(e,t){i.lifeCycle.emit("afterRequest",e);var n=i.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)}}function T(){}function x(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]="sendPipeline"===e?function(){return function(){}}:function(){}:t[e]=function(){})})}function k(){try{var e=getCurrentPages(),t=e[e.length-1]||{},n=(i=t.options,Object.keys(i).length?"?"+Object.keys(i).map(function(e){return e+"="+i[e]}).join("&"):"");return t.route?t.route+n:""}catch(e){return""}var i}function N(e,t){if("string"==typeof e&&"string"==typeof t){if(e===t)return 1;for(var n=e.split("."),i=t.split("."),o=Math.max(n.length,i.length),r=0;r<o;r++){var s=~~n[r],a=~~i[r];if(s<a)return;if(a<s)return 1}}}function L(e){var t=e.apiName,n=fe[t];return n?n.hackReq.addCallback(e):(n=wx[t],fe[t]={hackReq:new pe(e),originApi:n}),fe[t]}var C,A,U,j,q,I=function(i,o){return function(e,t){var n=o.logCreated;if("function"!=typeof n)return i("beforeWrite",e),t(e);e=e.filter(function(e){return!1!==n(e)});return i("beforeWrite",e),t(e)}},_=function(n,i){var o,r=[],s=n.config;return n.lifeCycle.on("destroy",function(){r.length=0}),function(e,t){if(Array.isArray(e)?r=r.concat(e):r.push(e),i&&r.length>=i||n.sendNow&&0<r.length)return r=E(r),t(r.splice(0,r.length)),void(o&&clearTimeout(o));o&&clearTimeout(o),o=setTimeout(function(){o=null,0<(r=E(r)).length&&t(r.splice(0,r.length))},s.delay)}},F=function(e,t){return Array.isArray(e)?t(e.map(function(e){return f(f({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(v).join(" ")})})):t([f(f({},e),{msg:"string"==typeof e.msg?e.msg:v(e.msg)})])},M=function(s){var e,a=!1,l=!1,t=!1,u=[];return s.lifeCycle.on("onConfigChange",function(){e&&clearTimeout(e),e=setTimeout(function(){var e,n;!t&&s.config&&(t=!0,e=s.config.whiteListUrl,(n=void 0===e?"":e)&&s.sendPipeline([function(e,t){t({url:n,type:h.WHITE_LIST,success:function(e){l=!0;try{var t=e.data||JSON.parse(e),n=t.retcode,i=t.result,o=void 0===i?{}:i;if(0===n){if(a=o.is_in_white_list,s.isWhiteList=a,o.shutdown)return void s.destroy();0<=o.rate&&o.rate<=1&&(s.config.random=o.rate,s.isGetSample=!1)}s.isWhiteList&&u.length?J(s)(u.splice(0),function(){}):!s.isWhiteList&&u.length&&(u.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},fail:function(e){"403 forbidden"===e&&s.destroy(),l=!0}})}],h.WHITE_LIST)(null),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){u.length=0}),function(e,t){var n;a||null!==(n=null===(n=s.config)||void 0===n?void 0:n.api)&&void 0!==n&&n.reportRequest?t(e.concat(u.splice(0)).map(function(e){return R(e),e})):(e=e.filter(function(e){return e.level!==p.INFO&&e.level!==p.API_RESPONSE?(R(e),!0):(l||(u.push(e),200<=u.length&&(u.length=200)),!1)})).length&&t(e)}},H=function(i){return setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:h.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.PV)(null)},100),function(e,t){t(e)}},D=function(o){var r={};return function(e,t){var n,i;o.speedSample?(i="object"==typeof o.repeat?o.repeat:{repeat:o.repeat},n=+i.speed||+i.repeat||5,Array.isArray(e)?(i=e.filter(function(e){var t=!r[e.url]||r[e.url]<n;return r[e.url]=1+~~r[e.url],t})).length&&t(i):(!r[e.url]||r[e.url]<n)&&(r[e.url]=1+~~r[e.url],t(e))):t(e)}},B=function(i){var o={};return function(e,t){var n="number"==typeof i.repeat?i.repeat:5;if(0===n)return t(e);t(e.filter(function(e){return e.level!==p.ERROR&&e.level!==p.PROMISE_ERROR&&e.level!==p.AJAX_ERROR&&e.level!==p.SCRIPT_ERROR&&e.level!==p.IMAGE_ERROR&&e.level!==p.CSS_ERROR&&e.level!==p.MEDIA_ERROR||(o[e.msg]=o[e.msg]||0,o[e.msg]+=1,!(o[e.msg]>n))}))}},J=function(i){return function(e){return i.sendPipeline([function(e,n){return n({url:i.config.url||"",data:function(e){if(!e||0===e.length)return"{}";e=Array.isArray(e)?e:[e];var t=Object.keys(e[0]),n={};return t.forEach(function(t){n[t]=e.map(function(e){return e[t]})}),n.count=e.length,o(n)}((t=e,(Array.isArray(t)?t:[t]).map(function(n){return Object.getOwnPropertyNames(n).reduce(function(e,t){return"ctx"!==t&&(e[t]=n[t]),e},{level:p.INFO,msg:""})}))),method:"post",contentType:"application/json",type:h.LOG,log:e,requestConfig:{timeout:5e3},success:function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},fail:function(e){"403 forbidden"===e&&i.destroy()}});var t}],h.LOG)(e)}},V=function(i){return function(e){i.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||i.config.ext1||"",ext2:e.ext2||i.config.ext2||"",ext3:e.ext3||i.config.ext3||""}});t({url:i.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:h.EVENT,log:e,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],h.EVENT)(e)}},W=function(n){return function(e){return n.sendPipeline([function(e,t){t({url:n.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:h.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&n.destroy()}})}],h.CUSTOM)(e)}},G=function(r,s){return function(e,t){var n=Array.isArray(e),i=n?e:[e];r.lifeCycle.emit("beforeRequest",e);var o=r.config.beforeRequest;(i="function"==typeof o?i.map(function(t){try{var e=o({logs:t,logType:s});return(null==e?void 0:e.logType)===s&&null!=e&&e.logs?e.logs:!1!==e&&t}catch(e){return t}}).filter(function(e){return!1!==e}):i).length&&(i=function(e,t){if(!Array.isArray(e)||e.length<=1)return e;var n=[],i=[];return!(i="string"==typeof t?[t]:t)||i.length<=0||(i.forEach(function(t){e.forEach(function(e){null!=e&&e[t]&&n.push(t)})}),0<n.length&&(e=e.map(function(e){var t={};return n.forEach(function(e){t[e]=""}),f(f({},t),e)}))),e}(i,["ext1","ext2","ext3","level","trace","tag","seq"]),t(n?i:i[0]))}},K=function(n){if(!n||!n.reduce||!n.length)throw new TypeError("createPipeline need at least one function param");return 1===n.length?function(e,t){n[0](e,t||T)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=T),n(e,function(e){return null==i?void 0:i(e,t)})}})},$=(Object.defineProperty(xe.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.57"},enumerable:!1,configurable:!0}),Object.defineProperty(xe.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),p},enumerable:!1,configurable:!0}),xe.prototype.init=function(e){this.setConfig(e);for(var t=0;t<xe.installedPlugins.length;t++)try{xe.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},xe.prototype.setConfig=function(e){Object.assign(this.config,e);var t=this.config,n=t.id,i=t.uin,o=t.version,r=t.ext1,s=t.ext2,a=t.ext3,l=t.aid,e=t.env,u=void 0===e?"production":e,e=t.pageUrl,t=this.bean.id!==n||this.bean.uin!==i||this.bean.aid!==l;return this.bean.id=n||"",this.bean.uin=i||"",this.bean.version=o||"1.24.57",this.bean.aid=l||"",this.bean.env=function(){switch(u){case g.production:case g.gray:case g.pre:case g.daily:case g.local:case g.test:case g.others:return 1;default:return}}()?u:g.others,e&&this.extendBean("from",encodeURIComponent(e)),r&&this.extendBean("ext1",encodeURIComponent(r)),s&&this.extendBean("ext2",encodeURIComponent(s)),a&&this.extendBean("ext3",encodeURIComponent(a)),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},xe.use=function(e){-1===xe.installedPlugins.indexOf(e)&&e.aegisPlugin&&xe.installedPlugins.push(e)},xe.unuse=function(e){e=xe.installedPlugins.indexOf(e);-1!==e&&xe.installedPlugins.splice(e,1)},xe.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.INFO}),this.normalLogPipeline(n)},xe.prototype.infoAll=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.INFO_ALL,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.INFO_ALL}),this.normalLogPipeline(n)},xe.prototype.report=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.REPORT,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0])),this.normalLogPipeline(n)},xe.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n={level:p.ERROR,msg:e};1===e.length&&e[0].msg&&Object.assign(n,f({},e[0]),{level:p.ERROR}),this.normalLogPipeline(n)},xe.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},xe.prototype.reportPv=function(n){var i,o=this;n&&(console.warn("reportPv is deprecated, please use reportEvent"),i=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+o.bean[e]}).join("&"),this.sendPipeline([function(e,t){t({url:o.config.url+"/"+n+"?"+i,addBean:!1,type:h.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],h.CUSTOM_PV)(null))},xe.prototype.reportEvent=function(e){e&&((e="string"==typeof e?{name:e,ext1:this.config.ext1||"",ext2:this.config.ext2||"",ext3:this.config.ext3||""}:e).name?this.eventPipeline(e):console.warn("reportEvent params error"))},xe.prototype.reportTime=function(e,t){if("object"==typeof e)return this.reportT(e);"string"==typeof e?"number"==typeof t?t<0||6e4<t?console.warn("reportTime: duration must between 0 and 60000"):this.submitCustomTime(e,t):console.warn("reportTime: second param must be number"):console.warn("reportTime: first param must be a string")},xe.prototype.reportT=function(e){var t=e.name,n=e.duration,i=e.ext1,o=void 0===i?"":i,r=e.ext2,i=void 0===r?"":r,r=e.ext3,r=void 0===r?"":r,e=e.from;if("string"==typeof t&&"number"==typeof n&&"string"==typeof o&&"string"==typeof i&&"string"==typeof r){if(!(n<0||6e4<n))return this.submitCustomTime(t,n,o,i,r,void 0===e?"":e);console.warn("reportTime: duration must between 0 and 60000")}else console.warn("reportTime: params error")},xe.prototype.time=function(e){"string"==typeof e?this.timeMap[e]?console.warn("Timer "+e+" already exists"):this.timeMap[e]=Date.now():console.warn("time: first param must be a string")},xe.prototype.timeEnd=function(e){"string"==typeof e?this.timeMap[e]?(this.submitCustomTime(e,Date.now()-this.timeMap[e]),delete this.timeMap[e]):console.warn("Timer "+e+" does not exist"):console.warn("timeEnd: first param must be a string")},xe.prototype.submitCustomTime=function(e,t,n,i,o,r){this.customTimePipeline({name:e,duration:t,ext1:n||this.config.ext1,ext2:i||this.config.ext2,ext3:o||this.config.ext3,from:r||void 0})},xe.prototype.extendBean=function(e,t){this.bean[e]=t},xe.prototype.sendPipeline=function(e,t){var n,r=this;return K(s([function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),!n.isHidden||!n.isGetSample)if(n.isGetSample)n.isHidden||t(e);else{if(n.isGetSample=!0,Math.random()<n.config.random)return n.isHidden=!1,t(e);n.isHidden=!0}},G(n=this,t)],e,[P(this),function(i,o){r.request(i,function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];r.failRequestCount=0,o({isErr:!1,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.success)||void 0===e||e.call.apply(e,s([i],t))},function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];10<=++r.failRequestCount&&r.destroy(),o({isErr:!0,result:t,logType:null==i?void 0:i.type,logs:null==i?void 0:i.log}),null===(e=null==i?void 0:i.fail)||void 0===e||e.call.apply(e,s([i],t))})},S(this)]))},xe.prototype.send=function(e,o,r){var t=this;return K([P(this),function(n,i){t.request(n,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:n.type,logs:n.log}),null==o||o.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:n.type,logs:n.log}),null==r||r.apply(void 0,e)})},S(this)])(e)},xe.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},xe.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(v(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.57)",addBean:!1,method:"get",type:h.SDK_ERROR,log:e})}],h.SDK_ERROR)(e)},xe.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=xe.instances.indexOf(this);-1!==i&&xe.instances.splice(i,1);for(var o=xe.installedPlugins.length-1;0<=o;o--)try{xe.installedPlugins[o].unpatch(this)}catch(e){this.sendSDKError(e)}if(this.lifeCycle.emit("destroy"),this.lifeCycle.clear(),e)t=this,n=Object.getOwnPropertyDescriptors(t),Object.keys(n).forEach(function(e){n[e].writable&&(t[e]=null)}),Object.setPrototypeOf(this,null);else{for(var r=this;r.constructor!==Object&&x(r,this),r=Object.getPrototypeOf(r););0===xe.instances.length&&(e=Object.getPrototypeOf(this).constructor,x(e),x(xe))}},xe.version="1.24.57",xe.instances=[],xe.logType=p,xe.environment=g,xe.installedPlugins=[],xe),z=(Te.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},Te.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&(this.instances.splice(e,1),0===this.instances.length&&this.uninstall())},Te.prototype.countInstance=function(){return this.instances.length},Te.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},Te.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},Te.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},Te.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},Te.prototype.exist=function(e){return-1===this.instances.indexOf(e)},Te.prototype.triggerInit=function(e){var t;this.inited||(this.inited=!0,null===(t=null===(t=this.option)||void 0===t?void 0:t.init)||void 0===t||t.call(this.option,this.getConfig(e)))},Te.prototype.triggerOnNewAegis=function(e){var t;null===(t=null===(t=this.option)||void 0===t?void 0:t.onNewAegis)||void 0===t||t.call(this.option,e,this.getConfig(e))},Te),X=wx||qq,Q="",Y=function(e){return Q=Q||X.getSystemInfoSync().SDKVersion,N(Q,"1.1.1")&&X.canIUse?X.canIUse(e):!!X[e]},Z=new z({name:"offlineLog",onNewAegis:function(o){if(X.getFileSystemManager)try{var e=o.config,t=e.id,r=void 0===t?"":t,n=e.uin,s=void 0===n?0:n,i=e.offlineUrl,a=void 0===i?"":i,l=e.offlineLogLimit,u=new ee({limit:l});o.lifeCycle.on("beforeWrite",function(e){u.save2Offline(e=void 0===e?[]:e,o.config)}),u.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(s||i)&&o.send({url:a+"/offlineAuto",type:h.OFFLINE,log:h.OFFLINE},function(e){var n=(null==e?void 0:e.data).secretKey;n&&(t||u.getLogs({id:r,uin:s},function(e,t){e?console.error(e):o.send({url:a+"/offlineLog",data:{logs:t,secretKey:n,id:r,uin:s,aid:i},method:"post",type:h.OFFLINE,log:t},function(){u.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),ee=(Se.prototype.getLogs=function(e,t){var n=this.fileSystem,i=this.filePath;n.readFile({filePath:i,encoding:"utf8",fail:function(e){console.error(e)},success:function(e){e=e.data,e=(void 0===e?"":e).toString().split("\n").filter(function(e){return e}).map(function(e){return JSON.parse(e)});t(null,e)}})},Se.prototype.checkLimit=function(o,r){void 0===r&&(r=function(){});var s=this.fileSystem,a=this.filePath,l=this.limitSize;s.readFile({filePath:a,encoding:"utf8",success:function(e){e=e.data,e=void 0===e?"":e;if((e=e.toString()+o).length>l){for(var t=e.split("\n"),n="",i=t.length-1;0<=i&&!(t[i]&&(n=t[i]+"\n"+n).length>l);i--);s.writeFile({filePath:a,data:n,success:r})}else s.appendFile({data:o,filePath:a,encoding:"utf8",success:r,fail:function(e){console.error(e)}})}})},Se),te=function(e){for(var t,n={unknown:/unknown|none/i,wifi:/wifi/i,net2g:/2g/i,net3g:/3g/i,net4g:/4g/i,net5g:/5g/i,net6g:/6g/i},i=d.unknown,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=d[r];break}}return i},ne=new z({name:"device",onNewAegis:function(l){return e=this,u=function(){return n=this,i=function(e){return this.setSystemInfo(l),this.refreshNetwork(l),this.setNetworkChange(l),[2]},a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]},t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t;function e(t){return function(e){return function(t){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,r&&(s=2&t[0]?r.return:t[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,t[1])).done)return s;switch(r=0,(t=s?[2&t[0],s.value]:t)[0]){case 0:case 1:s=t;break;case 4:return a.label++,{value:t[1],done:!1};case 5:a.label++,r=t[1],t=[0];continue;case 7:t=a.ops.pop(),a.trys.pop();continue;default:if(!((s=0<(s=a.trys).length&&s[s.length-1])||6!==t[0]&&2!==t[0])){a=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){a.label=t[1];break}if(6===t[0]&&a.label<s[1]){a.label=s[1],s=t;break}if(s&&a.label<s[2]){a.label=s[2],a.ops.push(t);break}s[2]&&a.ops.pop(),a.trys.pop();continue}t=i.call(n,a)}catch(e){t=[6,e],r=0}finally{o=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var n,i,o,r,s,a,t},new(a=(a=s=void 0)||Promise)(function(n,t){function i(e){try{r(u.next(e))}catch(e){t(e)}}function o(e){try{r(u.throw(e))}catch(e){t(e)}}function r(e){var t;e.done?n(e.value):((t=e.value)instanceof a?t:new a(function(e){e(t)})).then(i,o)}r((u=u.apply(e,s||[])).next())});var e,s,a,u},setSystemInfo:function(s){var a=this;try{Y("getSystemInfo")&&X.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,r=void 0===r?0:r,e=e.screenHeight,e=void 0===e?0:e;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",Math.round(o)+" * "+Math.round(i)),s.extendBean("sr",Math.round(r)+" * "+Math.round(e))}})}catch(s){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=a.other,o=0;o<Object.keys(n).length;o++){var r=Object.keys(n)[o];if(null!==(t=n[r])&&void 0!==t&&t.test(e)){i=a[r];break}}return i},setNetworkChange:function(t){Y("onNetworkStatusChange")&&X.onNetworkStatusChange(function(e){e=te(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){Y("getNetworkType")&&X.getNetworkType({success:function(e){e=te(e.networkType);t.extendBean("netType",e)}})},refreshNetwork:function(e){var t=this;this.timer&&clearTimeout(this.timer),this.setNetworkType(e),this.timer=setTimeout(function(){t.refreshNetwork(e)},1e4)}}),ie=X.request,oe=(e(Pe,q=$),Object.defineProperty(Pe.prototype,"getBean",{get:function(){var t=this;return this.bean?Object.getOwnPropertyNames(this.bean).map(function(e){return e+"="+t.bean[e]}).join("&")+"&from="+encodeURIComponent(k()):"from="+encodeURIComponent(k())},enumerable:!1,configurable:!0}),Pe.prototype.initOfflineLog=function(){Pe.use(Z)},Pe.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},Pe.prototype.reportPv=function(e){var t,n=this;e&&(t=Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&")+"&from="+encodeURIComponent(k()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:h.CUSTOM_PV,log:h.CUSTOM_PV},function(){},function(){}))},Pe.sessionID="session-"+Date.now(),Pe.asyncPluginIndex=0,Pe),re=new z({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){X.getStorage({key:"AEGIS_ID",success:function(e){t(e.data)},fail:function(){var e="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)});X.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),se=(Re.prototype.addCallback=function(e){e&&this.callbacks.push(e)},Re.prototype.prefixHandler=function(e){return f(f({},e),{aegisRequestStartTime:+new Date})},Re.prototype.successHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.success)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.success)||void 0===e||e.call(i,n,i)},Re.prototype.failHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.fail)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.fail)||void 0===e||e.call(i,n,i)},Re.prototype.completeHandler=function(n,i){var e;this.callbacks.forEach(function(e){var t;try{null===(t=e.complete)||void 0===t||t.call(e,n,i)}catch(e){}}),null===(e=i.complete)||void 0===e||e.call(i,n,i)},Re.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},Re),ae=wx||qq,le=null===(ve=ae.cloud)||void 0===ve?void 0:ve.callFunction,ue=(e(Ee,j=se),Ee.prototype.defineApiProperty=function(){var e=this;ae.cloud&&ae.cloud.callFunction&&Object.defineProperty(ae.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},Ee.prototype.hackHandler=function(e){var i=this,o=this.prefixHandler(e);return new Promise(function(t,n){le(f(f({},o),{success:function(e){i.successHandler(e,o),t(e)},fail:function(e){i.failHandler(e,o),n(e)},complete:function(e){i.completeHandler(e,o)}}))})},Ee),ce=wx||qq,fe={},pe=(e(we,U=se),we.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ce,this.apiName,{get:function(){return e.hackHandler.bind(e)}})},we.prototype.hackHandler=function(e){var t=this,n=this.prefixHandler(e),e=null===(e=fe[this.apiName])||void 0===e?void 0:e.originApi;return null==e?void 0:e(f(f({},n),{success:function(e){t.successHandler(e,n)},fail:function(e){t.failHandler(e,n)},complete:function(e){t.completeHandler(e,n)}}))},we),$=new z({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(s){var a=this;L({apiName:"request",success:function(e,t){var n,i,o,r;s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(n={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:u(t.url),type:"fetch"},r=null===(i=s.api)||void 0===i?void 0:i.apiDetail,i=(o=c(e.data,s.api,{url:t.url,ctx:e})||{}).code,o=o.isErr,r="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(r?v(t.data):"")+" \n \nres duration: "+n.duration+"ms \n \nres status: "+(e.statusCode||0)+" \n \nres retcode: "+i+" \n \nres data: "+(r?y(e.data):""),a.publishNormalLog({msg:r,level:p.API_RESPONSE,ctx:e}),n.ret=i,n.isErr=+o,a.publishSpeedLog(n),o&&a.publishNormalLog({msg:r,level:p.RET_ERROR,ctx:e}))},fail:function(e,t){s.hostUrl&&-1<t.url.indexOf(s.hostUrl)||(t={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:u(t.url),type:"fetch"},a.publishSpeedLog(t))}})},overrideCallFunction:function(l){var u=this;new ue({apiName:"callFunction",success:function(e,t){var n={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:200,type:"fetch",errMsg:e.errMsg,isHttps:!0},i=null===(a=l.api)||void 0===a?void 0:a.apiDetail,o="req url: "+n.url+"\n \nreq type: "+n.type+"\n \nres duration: "+n.duration+"ms \n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?y(e.result):"")+"\n ";u.publishNormalLog({msg:o,level:p.API_RESPONSE,ctx:e});var r,s,a=!1,a=(s="function"==typeof(null===(i=l.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(r=(t=l.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,void 0!==(t=t.isErr)&&t):(r=(s=c(e.result,l.api,{url:n.url,ctx:e})||{}).code,s.isErr),n.ret=r,s);n.isErr=+a,u.publishSpeedLog(n),a&&u.publishNormalLog({msg:o,level:p.RET_ERROR,ctx:e})},fail:function(e,t){e={method:"call",url:"wx.cloud.callFunction."+t.name,duration:Date.now()-t.aegisRequestStartTime,status:0,type:"fetch",errMsg:e.errMsg,isHttps:!0};u.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),de=wx||qq,he=de.connectSocket,ge=(Oe.prototype.addConfig=function(e){var t=e.send,e=e.onError;t&&this.sends.push(t),e&&this.onErrors.push(e)},Oe.prototype.toHack=function(t){var o=this;this.onErrors.forEach(function(e){t.onError(e)});var n=t.send;return Object.defineProperty(t,"send",{get:function(){return function(i){return new Promise(function(e){n(f(f({},i),{fail:function(n){o.sends.forEach(function(e){var t;null===(t=e.fail)||void 0===t||t.call(e,n,i)}),e(n)}}))})}}}),t},Oe),me=(e(be,A=se),be.prototype.addTaskConf=function(e){this.taskHack.addConfig(e)},be.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(de,"connectSocket",{get:function(){return e.hackHandler.bind(e)}})},be.prototype.hackHandler=function(e){var i,o=this,r=this.prefixHandler(e);return new Promise(function(t,n){i=he(f(f({},r),{success:function(e){o.successHandler(e,r),t(e)},fail:function(e){o.failHandler(e,r),n(e)},complete:function(e){o.completeHandler(e,r)}})),o.taskHack.toHack(i)}),i},be),ve=new z({name:"onError",onNewAegis:function(e){var t=X.getSystemInfoSync().SDKVersion;this.listenError(),this.hackNetWork(e),e.config.websocketHack&&N(t,"1.7.0")&&this.hackWsConnect()},listenError:function(){var t=this;"function"==typeof X.onError&&X.onError(function(e){e&&t.publishErrorLog({msg:e,level:p.ERROR})}),Y("onUnhandledRejection")&&X.onUnhandledRejection(function(e){e=e.reason;e&&(-1<JSON.stringify(e).indexOf("request:fail")||t.publishErrorLog({msg:e,level:p.PROMISE_ERROR}))}),Y("onPageNotFound")&&X.onPageNotFound(function(e){e&&t.publishErrorLog({msg:e,level:p.PAGE_NOT_FOUND_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackNetWork:function(e){for(var n=this,i=e.config,t=0,o=[{apiName:"request",complete:function(e,t){return n.requestCompleteError(e,t,i)}},{apiName:"uploadFile",complete:function(e,t){return n.uploadFileCompleteError(e,t,i)}},{apiName:"downloadFile",complete:function(e,t){return n.downloadFileCompleteError(e,t,i)}}];t<o.length;t++){var r=o[t],s=r.apiName,r=r.complete;L({apiName:s,complete:r})}},requestCompleteError:function(e,t,n){var i,o=e.errMsg,r=e.statusCode;n.hostUrl&&-1<(null===(i=t.url)||void 0===i?void 0:i.indexOf(n.hostUrl))||(r=this.getErrorType({errMsg:o,statusCode:r}))&&this.publishNetWorkError({apiName:"request",opts:t,res:e,config:n,type:r})},downloadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,r=e.filePath,s=e.tempFilePath,e=this.getErrorType({errMsg:i,statusCode:o});e&&(n=null===(n=n.api)||void 0===n?void 0:n.apiDetail,this.publishErrorLog({msg:"AJAX_ERROR: downloadFile "+e+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"ms\n \nres filePath: "+r+"\n \nres tempFilePath: "+s+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(n?v(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:p.AJAX_ERROR}))},uploadFileCompleteError:function(e,t,n){var i=e.errMsg,o=e.statusCode,o=this.getErrorType({errMsg:i,statusCode:o});o&&this.publishNetWorkError({apiName:"uploadFile",opts:t,res:e,config:n,type:o})},publishNetWorkError:function(e){var t=e.apiName,n=e.opts,i=e.res,o=e.config,r=e.type,s=i.errMsg,a=i.statusCode,l=i.data,e=null===(u=o.api)||void 0===u?void 0:u.apiDetail,u="wx.cloud.callFunction."+n.url,i=c(l,o.api,{url:u,ctx:i}).code;this.publishErrorLog({msg:"AJAX_ERROR: "+t+" "+r+"\n \nres status: "+(a||0)+"\n \nres retcode: "+i+"\n \nres duration: "+(Date.now()-n.aegisRequestStartTime)+"ms\n \nres data: "+(e?v(l):"")+"\n \nreq url: "+n.url+"\n \nreq method: "+(n.method||"get")+"\n \nreq param: "+(e?v(n.data):"")+"\n \nerrMsg: "+s.slice(0,1e3),level:p.AJAX_ERROR})},getErrorType:function(e){var t=e.errMsg,n=e.statusCode,e="";return-1<t.indexOf("timeout")||-1<t.indexOf("超时")?e="timeout":400<=n?e="error":(-1<t.indexOf("fail")||!n||n<0)&&(e="failed"),e},hackWsConnect:function(){var e,t,n=this;L({apiName:"sendSocketMessage",fail:function(e){n.publishSocketError(e)}}),e=(t={connectCallback:{fail:function(e){n.publishSocketError(e)}},taskOpt:{onError:function(e){n.publishSocketError(e)},send:{fail:function(e){n.publishSocketError(e)}}}}).connectCallback,t=t.taskOpt,C?C.addCallback(e):C=new me(e),t&&C.addTaskConf(t)},publishSocketError:function(e){e&&this.publishErrorLog({msg:e.errMsg,level:p.WEBSOCKET_ERROR})}}),se=new z({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;X.getPerformance&&X.getPerformance().createObserver(function(e){e=e.getEntries();null==e||e.forEach(function(e){"number"!=typeof e.duration||e.duration<=0||t.publishAssetLog(e)})}).observe({entryTypes:["resource"]})},generateLog:function(e){return{url:""+l(e.uri),method:"get",duration:Math.round(100*e.duration)/100,status:200,type:"static",isHttps:!0,urlQuery:"",domainLookup:0,connectTime:0}},publishAssetLog:function(t){var n=this;this.$walk(function(e){e.speedLogPipeline(n.generateLog(t))})}}),ye=["onLaunch","onHide","onError","onLoad","onReady","onShow","onUnload"],z=new z({name:"pagePerformance",pageNavigationStartTime:{},onNewAegis:function(e){try{Y("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(f){var p=this,e=X.getPerformance(),e=null==e?void 0:e.createObserver(function(e){var t,n,i={},o=null===(t=e.getEntriesByName("appLaunch"))||void 0===t?void 0:t[0],r=null===(a=e.getEntriesByName("firstRender"))||void 0===a?void 0:a[0],s=null===(l=e.getEntriesByName("evaluateScript"))||void 0===l?void 0:l[0],a=null===(t=e.getEntriesByName("route"))||void 0===t?void 0:t[0],l=null===(t=null===(l=e.getEntriesByName("firstPaint"))||void 0===l?void 0:l[0])||void 0===t?void 0:t.startTime,u=null===(n=(null===(t=e.getEntriesByName("firstPaint"))||void 0===t?void 0:t[0])||(null===(n=e.getEntriesByName("route"))||void 0===n?void 0:n[0])||(null===(u=e.getEntriesByName("appLaunch"))||void 0===u?void 0:u[0]))||void 0===n?void 0:n.pageId,c=null===(c=(null===(n=e.getEntriesByName("route"))||void 0===n?void 0:n[0])||(null===(c=e.getEntriesByName("appLaunch"))||void 0===c?void 0:c[0]))||void 0===c?void 0:c.startTime;u&&(p.pageNavigationStartTime[u]=null,c&&(p.pageNavigationStartTime[u]=c)),o&&(i.appLaunch=o.duration),r&&(i.firstScreenTiming=r.duration),s&&(i.scriptEvaluateTiming=s.duration),a&&(i.pageRouteTiming=a.duration),l&&c?i.firstPaintTiming=Math.max(l-c,0):l&&p.pageNavigationStartTime[u]&&(i.firstPaintTiming=Math.max(l-p.pageNavigationStartTime[u],0)),p.publish(i,f)});null==e||e.observe({entryTypes:["navigation","render","script"]})},publish:function(t,n){var e,i,o=[],r=n.config,s=-1===(null===(e=n.config.performanceUrl)||void 0===e?void 0:e.indexOf("?"))?"?":"&";for(i in t)o.push(i+"="+t[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:h.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:h.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;X.onAppRoute&&X.onAppRoute(function(e){"appLaunch"!==e.openType&&(t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:h.PV})}),t.reportPageLoaded(e))})},reportPageLoaded:function(e){e="infoType: behaviorBacktracking\ndataType: pageLoadAndRoute\npageLoadedPath: "+e.path+"\nopenType: "+e.openType;this.publishNormalLog({msg:e,level:p.INFO})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},reportSetDataTiming:function(t){var e,o,a,l,n,r,s,u,c=this,i=t.config,i=i.setDataReportConfig||(null===(e=i.pagePerformance)||void 0===e?void 0:e.setDataReportConfig)||{};!0!==i.disabled&&(e=i.timeThreshold,o=!1!==i.withDataPaths,a=e&&0<+e?+e:30,l=K([_(t,10),function(e){e=e.map(function(e){return{component:e.from,duration:e.duration,fields:e.dataPaths&&e.dataPaths.length?e.dataPaths.sort().join(";"):void 0,size:e.size}});t.send({url:t.config.setDataReportUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:h.SET_DATA,log:e})}]),n=Page,r=Component,s=function(e,t){var r,s,n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=t.dataPaths,t=void 0===t?[]:t,n=i-n;isNaN(n)||n<a||(n={from:e.is,duration:n},o&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30),size:(t=t,s=0,null!=(r=e)&&r.data?(t.forEach(function(e){for(var t=r.data[e[0]],n=1,i=e.length;n<i;n++)t[e[n]]&&(t=t[e[n]]);var o="";try{o=JSON.stringify(t)}catch(e){o=""}s+=2*(void 0===o?"":o).replace(/[\u4e00-\u9fa5]/g,"aa").length}),s=Math.min(s,10485760)):s)}),l(n))},u=function(i){var e="infoType: behaviorBacktracking\ndataType: tapEvent"+Object.keys(i[0]).reduce(function(e,t){var n="";try{n=t+": "+JSON.stringify(i[0][t])}catch(e){n=""}return e+"\n"+n},"");c.publishNormalLog({msg:e,level:p.INFO})},Page=function(t){var e=t.onReady;return t.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==e?void 0:e.call(this)},Object.keys(t).forEach(function(e){var n;"function"!=typeof t[e]||ye.includes(e)||(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&u(e),null==n?void 0:n.apply(this,e)})}),n(t)},Component=function(e){var n,i;e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==n?void 0:n.call(this)}):(i=e.attached,e.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:o},function(e){s(t,e)}),null==i?void 0:i.call(this)});var t=e.methods;return t&&"[object Object]"===Object.prototype.toString.call(t)&&Object.keys(t).forEach(function(e){var n;"function"==typeof t[e]&&(n=t[e],t[e]=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return null!=e&&e[0]&&"tap"===e[0].type&&u(e),null==n?void 0:n.apply(this,e)})}),r(e)})}});function be(e){e=A.call(this,e)||this;return e.taskHack=new ge,e}function Oe(){this.onErrors=[],this.sends=[]}function we(){return null!==U&&U.apply(this,arguments)||this}function Ee(){return null!==j&&j.apply(this,arguments)||this}function Re(e){this.callbacks=[],this.isOverride=!1;var t=e.apiName;this.apiName=t,this.isOverride||this.override(),this.callbacks.push(e)}function Pe(e){var i,c=q.call(this,e)||this;c.originRequest=ie,c.speedLogPipeline=K([D(c.config),_(c),function(t,n){Y("getNetworkType")?X.getNetworkType({success:function(e){e=te(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)},function(e,t){c.lifeCycle.emit("beforeReportSpeed",e);var n=c.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},G(i=c,h.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:w(e,c.bean)})}]),c.requestQueue=[],c.requesting=!1,c.request=function(e,t,n){if(e.url&&c.bean.id)if(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(c.bean.aid))){if(!(c.requesting||Y("getNetworkType")&&void 0===c.bean.netType)){c.requesting=!0;var i,o=e.url;c.config.whiteListUrl===o&&(i=t,t=function(e){null==i||i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+c.getBean);var r=e.method||"get",s=function(){c.requesting=!1;var e=c.requestQueue.shift();e&&c.request(e.options,e.success,e.fail)},a=e,l=c.config.onBeforeRequest;if(!(a=l?l(e,c):a)||!a.url){var u="";return a&&a.url||(u="Sending request blocked. Please handle the parameters reasonably, options.url is necessary",console.log(u)),null==n||n(u),s(),!1}u=c.config.enableHttp2||!1;return"get"===r?(o=function(e,n){if("string"!=typeof e)return"";if("object"==typeof n&&n){var t=Object.getOwnPropertyNames(n).map(function(e){var t=n[e];return e+"="+("string"==typeof t?encodeURIComponent(t):encodeURIComponent(JSON.stringify(t)))}).join("&").replace(/eval/gi,"evaI");return e+(-1===e.indexOf("?")?"?":"&")+t}return e}(o,a.data),c.originRequest(f({url:o,enableHttp2:u,success:t,fail:n,complete:s},e.requestConfig))):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest(f({url:o,enableHttp2:u,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s},e.requestConfig))),!0}c.requestQueue.push({options:e,success:t,fail:n})}else c.requestQueue.push({options:e,success:t,fail:n})};try{e.offlineLog&&c.initOfflineLog(),c.init(e),c.extendBean("sessionId",Pe.sessionID),c.extendBean("referer",(Y("getLaunchOptionsSync")?X.getLaunchOptionsSync():{scene:""}).scene||"")}catch(e){console.warn(e),console.log("%cThe above error occurred in the process of initializing Aegis, which will affect your normal use of Aegis.\nIt is recommended that you contact us for feedback and thank you for your support.","color: red"),c.sendSDKError(e)}return c}function Se(e){var o,r,s=this,t=void 0===e?{}:e,e=t.path,e=void 0===e?"/.aegis.offline.log":e,t=t.limit,t=void 0===t?2e4:t;this.offlineBuffer=[],this.insertLog=(o=null,r=[],function(e){r=r.concat(e),o=o||setTimeout(function(){o=null;var e,t=s.fileSystem,n=s.filePath,i=r.map(function(e){return JSON.stringify(e)}).join("\n")+"\n";i&&(e=function(e){e?s.checkLimit(i,function(){r=[]}):t.writeFile({data:i,filePath:n,encoding:"utf8",fail:function(e){console.error(e)},success:function(){r=[]}})},t.access({path:n,success:function(){e(!0)},fail:function(){e()}}))},2e3)}),this.ready=function(e){s.fileSystem?setTimeout(function(){e(null)},0):(e(new Error("getFileSystemManager file")),s.offlineLog=!1)},this.clearLogs=function(){var e=s.fileSystem,t=s.filePath;e.writeFile({filePath:t,data:"",fail:function(){e.unlinkSync(t)}})},this.save2Offline=function(e,t){e=(e=!Array.isArray(e)?[e]:e).map(function(e){return"string"==typeof e&&(e={msg:e}),function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(0===e.length)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(e[0]),i=1;i<e.length;i++){var o=e[i];if(null!==o)for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(n[r]=o[r])}return n}({id:t.id,uin:t.uin,time:+Date.now(),version:t.version,from:k()},e)});s.fileSystem?s.insertLog(e):(s.fileSystem||s.offlineBuffer.length||s.ready(function(e){e?console.error(e):s.offlineBuffer.length&&(s.addLogs(s.offlineBuffer),s.offlineBuffer=[])}),s.offlineBuffer=s.offlineBuffer.concat(e))},this.addLogs=function(e){s.fileSystem&&s.insertLog(e)},this.filePath=X.env.USER_DATA_PATH+e,this.fileSystem=X.getFileSystemManager(),this.limitSize=t}function Te(e){this.aegisPlugin=!0,this.name="",this.instances=[],this.inited=!1,e.$walk=this.walk.bind(this),e.$getConfig=this.getConfig.bind(this),this.option=e,this.name=e.name}function xe(e){var n,t,o=this;this.isGetSample=!1,this.isHidden=!1,this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,onClose:!0,hostUrl:"https://aegis.qq.com",websocketHack:!1,env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:"",setDataReportUrl:""},this.isWhiteList=!1,this.lifeCycle=new r,this.bean={},this.normalLogPipeline=K([_(this,5),F,function(e,t){var i=n.config;t(e=e.map(function(e){var t,n=i.maxLength||204800;try{if(!e.msg||e.msg.length<=n)return e;e.msg=null===(t=e.msg)||void 0===t?void 0:t.substring(0,n)}catch(t){e.msg=v(e.msg).substring(0,i.maxLength)}return e}))},B((n=this).config),I(this.lifeCycle.emit,this.config),H(this),M(this),function(e,t){try{var n=JSON.parse(JSON.stringify(e));o.lifeCycle.emit("beforeReport",n);var i=o.config.beforeReport;(e="function"==typeof i?e.filter(function(e){return!1!==i(e)}):e).length&&t(e)}catch(e){}},J(this)]),this.eventPipeline=K([_(this,5),V(this)]),this.timeMap={},this.failRequestCount=0,this.customTimePipeline=K([_(this,5),W(this)]),this.config=(t=this.config,void 0===(e=e.hostUrl)&&(e="https://aegis.qq.com"),t.url=t.url||e+"/collect",t.offlineUrl=t.offlineUrl||e+"/offline",t.whiteListUrl=t.whiteListUrl||e+"/collect/whitelist",t.pvUrl=t.pvUrl||e+"/collect/pv",t.eventUrl=t.eventUrl||e+"/collect/events",t.speedUrl=t.speedUrl||e+"/speed",t.customTimeUrl=t.customTimeUrl||e+"/speed/custom",t.performanceUrl=t.performanceUrl||e+"/speed/performance",t.webVitalsUrl=t.webVitalsUrl||e+"/speed/webvitals",t.setDataReportUrl=t.SetDataReportUrl||e+"/speed/miniProgramData",t),xe.instances.push(this)}return oe.use(ve),oe.use($),oe.use(re),oe.use(se),oe.use(z),oe.use(ne),oe});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { NormalLog, SpeedLog, Config } from '../interface';
|
|
2
2
|
export { EventEmitter, InterfaceEventEmitter } from './event-emitter';
|
|
3
3
|
export declare const buildLogParam: (logs: NormalLog | NormalLog[]) => string;
|
|
4
|
+
export declare const buildLog2Json: (logs: NormalLog | NormalLog[]) => string;
|
|
4
5
|
interface P {
|
|
5
6
|
[k: string]: any;
|
|
6
7
|
}
|
|
@@ -29,6 +30,7 @@ export declare const tryToGetRetCode: (obj: any, api?: Record<string, any> | und
|
|
|
29
30
|
*/
|
|
30
31
|
export declare const judgeIsErrorRet: (config: Config, ret: string) => boolean;
|
|
31
32
|
export declare const stringifyPlus: (target: any) => string;
|
|
33
|
+
export declare const stringify: (target: any) => string;
|
|
32
34
|
export declare const stringifyObj: (obj: any, deep?: number) => string;
|
|
33
35
|
/**
|
|
34
36
|
* 获取xhr相关资源
|
|
@@ -8,6 +8,9 @@ export interface HippyConfig extends Config {
|
|
|
8
8
|
dbConfig?: any;
|
|
9
9
|
offlineLogExp?: number;
|
|
10
10
|
reqCallback?: (data?: unknown, options?: unknown) => {};
|
|
11
|
+
userAgent?: string;
|
|
12
|
+
useSDKReportNetwork?: boolean;
|
|
13
|
+
getNetworkType?: Function;
|
|
11
14
|
}
|
|
12
15
|
export default class Aegis extends Core {
|
|
13
16
|
static sessionID: string;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Plugin } from "../../../core/src";
|
|
2
|
+
export declare enum NetworkType {
|
|
3
|
+
unknown = 100,
|
|
4
|
+
wifi = 1,
|
|
5
|
+
net2g = 2,
|
|
6
|
+
net3g = 3,
|
|
7
|
+
net4g = 4,
|
|
8
|
+
net5g = 5,
|
|
9
|
+
net6g = 6
|
|
10
|
+
}
|
|
11
|
+
declare const _default: Plugin<import("../../../core/src").default>;
|
|
12
|
+
export default _default;
|
|
13
|
+
export declare const getNetworkType: (callback: Function) => void;
|
|
@@ -1,17 +1,22 @@
|
|
|
1
|
+
export declare type WxApi = keyof typeof wx;
|
|
2
|
+
export declare type CloudApi = 'callFunction';
|
|
3
|
+
export declare type HackApi = WxApi | CloudApi;
|
|
1
4
|
export interface ReqOption {
|
|
2
5
|
aegisRequestStartTime: number;
|
|
6
|
+
apiName: HackApi;
|
|
3
7
|
}
|
|
4
8
|
export interface HackApiCallback<RequestOption = any, SucessRes = any, FailRes = any> {
|
|
9
|
+
apiName?: HackApi;
|
|
5
10
|
onStart?: (options: RequestOption) => void;
|
|
6
11
|
success?: (res: SucessRes, options: RequestOption) => void;
|
|
7
12
|
fail?: (err: FailRes, options: RequestOption) => void;
|
|
8
13
|
complete?: (err: SucessRes | FailRes, options: RequestOption) => void;
|
|
9
14
|
}
|
|
10
|
-
declare type HackApiCallbackOption = ReqOption & HackApiCallback;
|
|
15
|
+
export declare type HackApiCallbackOption = ReqOption & HackApiCallback;
|
|
11
16
|
export default abstract class HackApiCore<T extends HackApiCallbackOption, U extends HackApiCallback> {
|
|
17
|
+
apiName?: string;
|
|
12
18
|
private callbacks;
|
|
13
19
|
private isOverride;
|
|
14
|
-
abstract apiName: string;
|
|
15
20
|
constructor(cb: U);
|
|
16
21
|
addCallback(cb: U): void;
|
|
17
22
|
protected prefixHandler(opts: T): T & {
|
|
@@ -23,4 +28,3 @@ export default abstract class HackApiCore<T extends HackApiCallbackOption, U ext
|
|
|
23
28
|
private override;
|
|
24
29
|
protected abstract defineApiProperty(): void;
|
|
25
30
|
}
|
|
26
|
-
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import HackApiCore, { HackApiCallback, HackApiCallbackOption, WxApi } from './hack-api';
|
|
2
|
+
declare type HackApiMap = {
|
|
3
|
+
[x in WxApi]?: {
|
|
4
|
+
originApi: Function;
|
|
5
|
+
hackReq: HackNetWork<any, any>;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const originApiMap: HackApiMap;
|
|
9
|
+
export declare class HackNetWork<T extends HackApiCallbackOption, U extends HackApiCallback> extends HackApiCore<T, U> {
|
|
10
|
+
protected defineApiProperty(): void;
|
|
11
|
+
private hackHandler;
|
|
12
|
+
}
|
|
13
|
+
export declare const hackNetWork: <T extends HackApiCallbackOption, U extends HackApiCallback<any, any, any>>(option: U) => {
|
|
14
|
+
originApi: Function;
|
|
15
|
+
hackReq: HackNetWork<any, any>;
|
|
16
|
+
} | undefined;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import HackApiCore, { ReqOption, HackApiCallback } from './hack-api';
|
|
2
|
+
export declare type ConnectOption = ReqOption & WechatMiniprogram.ConnectSocketOption;
|
|
3
|
+
export declare type HackConnectCallback = HackApiCallback<ConnectOption, WechatMiniprogram.ConnectSocketSuccessCallback, WechatMiniprogram.GeneralCallbackResult>;
|
|
4
|
+
declare type TaskHackConf = {
|
|
5
|
+
onError: WechatMiniprogram.UDPSocketOnErrorCallback;
|
|
6
|
+
send: HackApiCallback;
|
|
7
|
+
};
|
|
8
|
+
declare type HackWsConnectOpt = {
|
|
9
|
+
connectCallback: HackConnectCallback;
|
|
10
|
+
taskOpt?: TaskHackConf;
|
|
11
|
+
};
|
|
12
|
+
export declare class HackWsConnect extends HackApiCore<ConnectOption, HackConnectCallback> {
|
|
13
|
+
apiName: 'connectSocket';
|
|
14
|
+
private taskHack;
|
|
15
|
+
constructor(props: HackConnectCallback);
|
|
16
|
+
addTaskConf(conf: TaskHackConf): void;
|
|
17
|
+
protected defineApiProperty(): void;
|
|
18
|
+
private hackHandler;
|
|
19
|
+
}
|
|
20
|
+
export declare const toHackWsConnect: (option: HackWsConnectOpt) => HackWsConnect;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare type WsError = {
|
|
2
|
+
readyState: number;
|
|
3
|
+
msg: string;
|
|
4
|
+
connectUrl: string;
|
|
5
|
+
};
|
|
6
|
+
declare type EmitError = (e: WsError) => void;
|
|
7
|
+
export declare type HackWsConfig = {
|
|
8
|
+
key: string;
|
|
9
|
+
onErr: EmitError;
|
|
10
|
+
sendErr: EmitError;
|
|
11
|
+
};
|
|
12
|
+
export declare const unHackWs: (conf: HackWsConfig) => void;
|
|
13
|
+
declare const hackWebSocket: (config: HackWsConfig) => void;
|
|
14
|
+
export default hackWebSocket;
|