aegis-mp-sdk 1.24.49 → 1.24.50

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/lib/aegis.min.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * =================================================================
3
- * aegis-mp-sdk@1.24.49 (c) 2021 Tencent Application Monitor.
2
+ * ====================================================================
3
+ * @tencent/aegis-mp-sdk@1.24.49 (c) 2021 Tencent Application Monitor.
4
4
  * Author pumpkincai.
5
- * Last Release Time Tue Oct 26 2021 13:20:43 GMT+0800 (GMT+08:00).
5
+ * Last Release Time Tue Dec 07 2021 17:42:24 GMT+0800 (GMT+08:00).
6
6
  * Released under the MIT License.
7
7
  * Thanks for supporting TAM & Aegis!
8
- * =================================================================
8
+ * ====================================================================
9
9
  **/
10
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Aegis={})}(this,function(e){"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 t(e,t){function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var r=function(){return(r=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)};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 s=(n.prototype.indexOf=function(e,t){for(var n=0;n<e.length;n++)if(e[n].callback===t)return n;return-1},n.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)}},n.prototype.one=function(e,t){this.on(e,t,1)},n.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}},n.prototype.clear=function(){this.eventsList={}},n),o=function(t){try{return encodeURIComponent(decodeURIComponent(t))}catch(e){return t}};function n(){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={}}(J={})[J.number=-1]="number",J.string="";function a(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){var n;try{"string"==typeof e&&(e=JSON.parse(e)),"function"==typeof(null===(n=null==t?void 0:t.ret)||void 0===n?void 0:n.join)&&(m=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var i=Object.getOwnPropertyNames(e).filter(function(e){return-1!==m.indexOf(e.toLowerCase())});return i.length?""+e[i[0]]:"unknown"}catch(e){return"unknown"}}function l(e,t){var n=(n=null===(n=e.api)||void 0===n?void 0:n.errCode)&&[].concat(n),e=(e=null===(e=e.api)||void 0===e?void 0:e.code)&&[].concat(e);return n&&-1!==n.indexOf(t)||e&&-1===e.indexOf(t)||!n&&!e&&"0"!==t&&"unknown"!==t}function f(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}var p,d,h,g,m=["ret","retcode","code","errcode"],y=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(r({duration:i},t)),o};(W=p=p||{}).INFO_ALL="-1",W.API_RESPONSE="1",W.INFO="2",W.ERROR="4",W.PROMISE_ERROR="8",W.AJAX_ERROR="16",W.SCRIPT_ERROR="32",W.IMAGE_ERROR="64",W.CSS_ERROR="128",W.CONSOLE_ERROR="256",W.MEDIA_ERROR="512",W.RET_ERROR="1024",W.REPORT="2048",W.PV="4096",W.EVENT="8192",($=d=d||{})[$.android=1]="android",$[$.ios=2]="ios",$[$.windows=3]="windows",$[$.macos=4]="macos",$[$.linux=5]="linux",$[$.devtools=6]="devtools",$[$.other=100]="other",(K=h=h||{})[K.unknown=100]="unknown",K[K.wifi=1]="wifi",K[K.net2g=2]="net2g",K[K.net3g=3]="net3g",K[K.net4g=4]="net4g",K[K.net5g=5]="net5g",K[K.net6g=6]="net6g",(ee=g=g||{}).LOG="log",ee.SPEED="speed",ee.PERFORMANCE="performance",ee.OFFLINE="offline",ee.WHITE_LIST="whiteList",ee.VITALS="vitals",ee.PV="pv",ee.CUSTOM_PV="customPV",ee.EVENT="event",ee.CUSTOM="custom",ee.SDK_ERROR="sdkError";function v(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return i!==t&&n.url===e.url&&200===n.status})})}function b(e){e.level===p.INFO_ALL&&(e.level=p.INFO)}function w(){}function O(t,n){Object.getOwnPropertyNames(t).forEach(function(e){"function"==typeof t[e]&&"constructor"!==e&&(n?n[e]=function(){}:t[e]=function(){})})}function R(){try{var e=getCurrentPages();return(e[e.length-1]||{}).route||""}catch(e){return""}}function P(e){return new X(e)}var x,E,S,T=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)}},L=function(e,n){var i,o=[],r=e.config;return e.lifeCycle.on("destroy",function(){o.length=0}),function(e,t){if(o.push(e),n&&o.length>=n)return o=v(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=v(o)).length&&t(o.splice(0,o.length))},r.delay)}},C=function(e,t){return Array.isArray(e)?t(e.map(function(e){return r(r({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(f).join(" ")})})):t(r(r({},e),{msg:"string"==typeof e.msg?e.msg:f(e.msg)}))},k=function(s){var e,a=!1,u=!1,t=!1,c=[];return s.lifeCycle.on("onConfigChange",function(){e&&clearTimeout(e),e=setTimeout(function(){var e;!t&&s.config&&(t=!0,(e=void 0===(e=s.config.whiteListUrl)?"":e)&&s.send({url:e,type:g.WHITE_LIST},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.isWhiteList&&c.length?j(s)(c.splice(0),function(){}):!s.isWhiteList&&c.length&&(c.length=0);var r=s.config.onWhitelist;"function"==typeof r&&r(a)}catch(e){}},function(e){"403 forbidden"===e&&s.destroy(),u=!0}),t=!1)},s.config.uin?50:500)}),s.lifeCycle.on("destroy",function(){c.length=0}),function(e,t){a?t(e.concat(c.splice(0)).map(function(e){return b(e),e})):(e=e.filter(function(e){return e.level!==p.INFO&&e.level!==p.API_RESPONSE?(b(e),!0):(u||(c.push(e),200<=c.length&&(c.length=200)),!1)})).length&&t(e)}},N=function(t){return setTimeout(function(){var e=t.config.pvUrl,e=void 0===e?"":e;e&&t.send({url:e,type:g.PV},function(){},function(e){"403 forbidden"===e&&t.destroy()})},100),function(e,t){t(e)}},U=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)}},A=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,n){return i.send({url:i.config.url||"",data:(t=e,(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:g.LOG,log:e},function(){var t=i.config.onReport;"function"==typeof t&&e.forEach(function(e){t(e)}),"function"==typeof n&&n([])},function(e){"403 forbidden"===e&&i.destroy()});var t}},I=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||w)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=w),n(e,function(e){return null==i?void 0:i(e,t)})}})},_=(Object.defineProperty(ae.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.49"},enumerable:!1,configurable:!0}),Object.defineProperty(ae.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),p},enumerable:!1,configurable:!0}),ae.prototype.init=function(e){this.setConfig(e);for(var t=0;t<ae.installedPlugins.length;t++)try{ae.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},ae.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=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.49",this.bean.aid=e||"",r&&(this.bean.ext1=r),s&&(this.bean.ext2=s),a&&(this.bean.ext3=a),t&&this.lifeCycle.emit("onConfigChange",this.config),this.config},ae.use=function(e){-1===ae.installedPlugins.indexOf(e)&&e.aegisPlugin&&ae.installedPlugins.push(e)},ae.unuse=function(e){e=ae.installedPlugins.indexOf(e);-1!==e&&ae.installedPlugins.splice(e,1)},ae.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,r({},e[0]),{level:p.INFO}),this.normalLogPipeline(n)},ae.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,r({},e[0]),{level:p.INFO_ALL}),this.normalLogPipeline(n)},ae.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,r({},e[0])),this.normalLogPipeline(n)},ae.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,r({},e[0]),{level:p.ERROR}),this.normalLogPipeline(n)},ae.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},ae.prototype.reportPv=function(e){var t,n=this;e&&(console.warn("reportPv is deprecated, please use reportEvent"),t=""+Object.getOwnPropertyNames(this.bean).filter(function(e){return"id"!==e}).map(function(e){return e+"="+n.bean[e]}).join("&"),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1,type:g.CUSTOM_PV},function(){},function(e){"403 forbidden"===e&&n.destroy()}))},ae.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"))},ae.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")},ae.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")},ae.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")},ae.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")},ae.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})},ae.prototype.extendBean=function(e,t){this.bean[e]=t},ae.prototype.send=function(o,r,s){var i,a,u,e=this;I([(a=o.type,function(e,t){if(!e)return t(e);e=Array.isArray(e)?e:[e],i.lifeCycle.emit("beforeRequest",e);var n=i.config.beforeRequest;(e="function"==typeof n?e.filter(function(e){return!1!==n({logs:e,logType:a})}):e).length&&t(e)}),function(n,i){e.request(o,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!1,result:e,logType:o.type,logs:n}),null==r||r.apply(void 0,e)},function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];i({isErr:!0,result:e,logType:o.type,logs:n}),null==s||s.apply(void 0,e)})},(u=i=this,function(e,t){u.lifeCycle.emit("afterRequest",e);var n=u.config.afterRequest;"function"==typeof n&&!1===n(e)||t(e)})])(o.log)},ae.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},ae.prototype.sendSDKError=function(e){this.send({url:this.config.url+"?id=1085&msg[0]="+encodeURIComponent(f(e))+"&level[0]=2&from="+this.config.id+"&count=1&version="+this.config.id+"(1.24.49)",addBean:!1,method:"get",type:g.SDK_ERROR})},ae.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=ae.instances.indexOf(this);-1!==i&&ae.instances.splice(i,1);for(var o=ae.installedPlugins.length-1;0<=o;o--)try{ae.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&&O(r,this),r=Object.getPrototypeOf(r););0===ae.instances.length&&(e=Object.getPrototypeOf(this).constructor,O(e),O(ae))}},ae.version="1.24.49",ae.instances=[],ae.logType=p,ae.installedPlugins=[],ae),q=(se.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},se.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},se.prototype.countInstance=function(){return this.instances.length},se.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},se.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},se.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},se.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},se.prototype.exist=function(e){return-1===this.instances.indexOf(e)},se.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)))},se.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))},se),F=wx||qq,M=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}}}(F.getSystemInfoSync().SDKVersion,"1.1.1")&&F.canIUse?F.canIUse(e):!!F[e]},D=new q({name:"offlineLog",onNewAegis:function(o){if(F.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,c=new H({limit:u});o.lifeCycle.on("beforeWrite",function(e){c.save2Offline(e=void 0===e?[]:e,o.config)}),c.ready(function(t){var e=(o.bean||{}).aid,i=void 0===e?"":e;!t&&r&&(s||i)&&o.send({url:a+"/offlineAuto"},function(e){var n=(null==e?void 0:e.data).secretKey;n&&(t||c.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"},function(){c.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),H=(re.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)}})},re.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)}})}})},re),B=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=h.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=h[r];break}}return i},J=new q({name:"device",onNewAegis:function(u){return e=this,c=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(c.next(e))}catch(e){t(e)}}function o(e){try{r(c.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((c=c.apply(e,s||[])).next())});var e,s,a,c},setSystemInfo:function(n){var i=this;try{M("getSystemInfo")&&F.getSystemInfo({success:function(e){var t=e.platform,e=e.model;n.extendBean("platform",i.getPlatFormType(t)),n.extendBean("model",e)}})}catch(n){}},getPlatFormType:function(e){for(var t,n={android:/android/i,ios:/ios/i,windows:/windows/i,macos:/mac/i,devtools:/devtools/i},i=d.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=d[r];break}}return i},setNetworkChange:function(t){M("onNetworkStatusChange")&&F.onNetworkStatusChange(function(e){e=B(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){M("getNetworkType")&&F.getNetworkType({success:function(e){e=B(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)}}),V=F.request,W=(t(oe,S=_),Object.defineProperty(oe.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(R()):"from="+encodeURIComponent(R())},enumerable:!1,configurable:!0}),oe.prototype.initOfflineLog=function(){oe.use(D)},oe.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},oe.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(R()),this.send({url:this.config.url+"/"+e+"?"+t,addBean:!1},function(){},function(){}))},oe.sessionID="session-"+Date.now(),oe.asyncPluginIndex=0,oe),$=new q({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){F.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)});F.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),K=(ie.prototype.prefixHandler=function(e){e.aegisRequestStartTime=Date.now()},ie.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)},ie.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)},ie.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)},ie.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},ie),G=wx||qq,Q=G.request,X=(t(ne,E=K),ne.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(G,"request",{get:function(){return e.hackHandler.bind(e)}})},ne.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){Q(r(r({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},ne),z=wx||qq,Y=null===(ee=z.cloud)||void 0===ee?void 0:ee.callFunction,Z=(t(te,x=K),te.prototype.defineApiProperty=function(){var e=this;z.cloud&&z.cloud.callFunction&&Object.defineProperty(z.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},te.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){Y(r(r({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},te),_=new q({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(r){var s=this;P({success:function(e,t){var n={method:t.method||"get",url:a(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:u(t.url),type:"fetch"},i=null===(o=r.api)||void 0===o?void 0:o.apiDetail,o="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(i?f(t.data):"")+" \n \nres duration: "+n.duration+" \n \nres status: "+(e.statusCode||0)+" \n \nres data: "+(i?JSON.stringify(e.data):"");s.publishNormalLog({msg:o,level:p.API_RESPONSE}),s.publishSpeedLog(n);("function"==typeof(null===(i=r.api)||void 0===i?void 0:i.retCodeHandler)?(t=(i=r.api.retCodeHandler(e.data,t.url,t,e)||{}).code,i=void 0!==(i=i.isErr)&&i,n.ret=void 0===t?0:t,i):(e=c(e.data,r.api),n.ret=e,l(r,e)))&&s.publishNormalLog({msg:o,level:p.RET_ERROR})},fail:function(e,t){t={method:t.method||"get",url:a(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:u(t.url),type:"fetch"};s.publishSpeedLog(t)}})},overrideCallFunction:function(r){var s=this;new Z({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===(o=r.api)||void 0===o?void 0:o.apiDetail,o="req url: "+n.url+"\n \nreq type: "+n.type+"\n \nres duration: "+n.duration+"\n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?JSON.stringify(e.result):"")+"\n ";s.publishNormalLog({msg:o,level:p.API_RESPONSE}),s.publishSpeedLog(n);("function"==typeof(null===(i=r.api)||void 0===i?void 0:i.retCodeCloudFunctionHandler)?(t=(i=r.api.retCodeCloudFunctionHandler(e.result,t.name,t,e)||{}).code,i=void 0!==(i=i.isErr)&&i,n.ret=t,i):(e=c(e.result,r.api),n.ret=e,l(r,e)))&&s.publishNormalLog({msg:o,level:p.RET_ERROR})},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};s.publishSpeedLog(e)}})},publishSpeedLog:function(t){this.$walk(function(e){e.speedLogPipeline(t)})},publishNormalLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})}}),ee=new q({name:"onError",onNewAegis:function(e){e=e.config;this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;F.onError(function(e){e&&t.publishErrorLog({msg:e,level:p.ERROR})}),M("onUnhandledRejection")&&F.onUnhandledRejection(function(e){e=e.reason;e&&t.publishErrorLog({msg:e,level:p.PROMISE_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(s){var a=this;P({complete:function(e,t){var n,i=e.errMsg,o=e.statusCode,r=e.data,e=null===(e=s.api)||void 0===e?void 0:e.apiDetail;s.hostUrl&&-1<(null===(n=t.url)||void 0===n?void 0:n.indexOf(s.hostUrl))||(n="",-1<i.indexOf("timeout")?n="timeout":-1<i.indexOf("fail")||!o||o<0?n="failed":400<=o&&(n="error"),n&&a.publishErrorLog({msg:"AJAX_ERROR: request "+n+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"\n \nres data: "+(e?f(r):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(e?f(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:p.AJAX_ERROR}))}})}}),K=new q({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;F.getPerformance&&F.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:a(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))})}}),q=new q({name:"pagePerformance",onNewAegis:function(e){try{M("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(r){var s=this,e=F.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(e,t){var n,i,o=[],r=this.$getConfig(t),s=-1===(null===(n=t.config.performanceUrl)||void 0===n?void 0:n.indexOf("?"))?"?":"&";for(i in e)o.push(i+"="+e[i]);"function"==typeof r.urlHandler?this.$walk(function(e){e.send({url:t.config.performanceUrl+s+o.join("&")+"&from="+(encodeURIComponent(r.urlHandler())||window.location.href),beanFilter:["from"],type:g.PERFORMANCE})}):this.$walk(function(e){e.send({url:t.config.performanceUrl+s+o.join("&"),type:g.PERFORMANCE})})},setPagePV:function(e){var t=this;F.onAppRoute&&F.onAppRoute(function(e){"appLaunch"!==e.openType&&t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:g.PV})})})},reportSetDataTiming:function(t){var o=I([L(t,5),function(e){e=e.map(function(e){return{component:e.from,duration:e.duration,fields:e.dataPaths.sort().join(";")}});t.send({url:t.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:g.CUSTOM,log:e})}]),n=Page,i=Component,r=t.config.updatePerformanceReportThreshold;(!r||isNaN(+r)||r<5)&&(r=5),Page=function(e){var t=e.onReady;return e.onReady=function(){var i=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:!0},function(e){var t=e.updateStartTimestamp,n=e.updateEndTimestamp,e=e.dataPaths,e=void 0===e?[]:e,t=n-t;isNaN(t)||t<r||(e={duration:t,from:i.is,dataPaths:e},o(e))}),null==t?void 0:t.call(this)},n(e)},Component=function(e){var t=e.attached;return e.attached=function(){var i=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:!0},function(e){var t=e.updateStartTimestamp,n=e.updateEndTimestamp,e=e.dataPaths,t=n-t;isNaN(t)||t<r||(e={duration:t,from:i.is,dataPaths:e},o(e))}),null==t?void 0:t.call(this)},i(e)}}});function te(){return null!==x&&x.apply(this,arguments)||this}function ne(){return null!==E&&E.apply(this,arguments)||this}function ie(e){this.isOverride=!1,this.callbacks=[],this.isOverride||this.override(),this.callbacks.push(e)}function oe(e){var i,l=S.call(this,e)||this;l.originRequest=V,l.speedLogPipeline=I([U(l.config),L(l),(i=l,function(t,n){M("getNetworkType")?F.getNetworkType({success:function(e){e=B(e.networkType);i.extendBean("netType",e),n(t)}}):n(t)}),function(e,t){l.lifeCycle.emit("beforeReportSpeed",e);var n=l.config.beforeReportSpeed;if((e="function"==typeof n?e.filter(function(e){return!1!==n(e)}):e).length)return t(e)},function(e){l.send({url:""+l.config.speedUrl,method:"post",data:y(e,l.bean)})}]),l.requestQueue=[],l.requesting=!1,l.request=function(e,t,n){if(e.url&&l.bean.id)if(/^\w{8}-\w{4}-\w{4}-\w{4}-\w{12}$/.test(String(l.bean.aid))){if(!(l.requesting||M("getNetworkType")&&void 0===l.bean.netType)){l.requesting=!0;var i,o=e.url;l.config.whiteListUrl===o&&(i=t,t=function(e){null==i||i(JSON.stringify(e.data))}),!1!==e.addBean&&(o=o+(-1===o.indexOf("?")?"?":"&")+l.getBean);var r=e.method||"get",s=function(){l.requesting=!1;var e=l.requestQueue.shift();e&&l.send(e.options,e.success,e.fail)},a=e,u=l.config.onBeforeRequest;if(!(a=u?u(e,l):a)||!a.url){var c="";return a||(c="Sending request blocked",console.log(c)),a.url||(c="Please handle the parameters reasonably, options.url is necessary",console.warn(c)),null==n||n(c),s(),!1}c=l.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),l.originRequest({url:o,enableHttp2:c,success:t,fail:n,complete:s})):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),l.originRequest({url:o,enableHttp2:c,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s})),!0}l.requestQueue.push({options:e,success:t,fail:n})}else l.requestQueue.push({options:e,success:t,fail:n})};try{e.offlineLog&&l.initOfflineLog(),l.init(e),l.extendBean("sessionId",oe.sessionID),l.extendBean("referer",(M("getLaunchOptionsSync")?F.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"),l.sendSDKError(e)}return l}function re(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:R()},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=F.env.USER_DATA_PATH+e,this.fileSystem=F.getFileSystemManager(),this.limitSize=t}function se(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 ae(e){var n,t,o=this;this.config={version:0,delay:1e3,onError:!0,repeat:5,random:1,aid:!0,device:!0,pagePerformance:!0,webVitals:!0,speedSample:!0,hostUrl:"https://aegis.qq.com",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:""},this.isWhiteList=!1,this.lifeCycle=new s,this.bean={},this.normalLogPipeline=I([L(this,5),C,function(e,t){if("number"!=typeof n.config.random&&(console.warn("random must in [0, 1], default is 1."),n.config.random=1),Math.random()<n.config.random)return t(e)},A((n=this).config),T(this.lifeCycle.emit,this.config),N(this),k(this),function(e,t){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)},j(this)]),this.eventPipeline=I([L(this,5),function(e){var t=e.map(function(e){return{name:e.name,ext1:e.ext1||o.config.ext1||"",ext2:e.ext2||o.config.ext2||"",ext3:e.ext3||o.config.ext3||""}});return o.send({url:o.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(t)),type:g.EVENT,log:e},function(){},function(e){"403 forbidden"===e&&o.destroy()})}]),this.timeMap={},this.customTimePipeline=I([L(this,5),function(e){return o.send({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:g.CUSTOM,log:e},function(){},function(e){"403 forbidden"===e&&o.destroy()})}]),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),ae.instances.push(this)}W.use(ee),W.use(_),W.use($),W.use(K),W.use(q),W.use(J),e.HackCloud=Z,e.default=W,Object.defineProperty(e,"__esModule",{value:!0})});
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 a=function(){return(a=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 n=(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={}}(V={})[V.number=-1]="number",V.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)&&(v=[].concat(t.ret.map(function(e){return e.toLowerCase()})));var r,s=Object.getOwnPropertyNames(e).filter(function(e){return-1!==v.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 f(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}var p,d,h,g,m,v=["ret","retcode","code","errcode"],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):w(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},w=function(e){var t=typeof e;return""+("undefined"==t||"symbol"==t||"function"==t?"null":"string"==t||"object"==t?'"'+e+'"':e)},r=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(a({duration:i},t)),o};(Q=p=p||{}).INFO_ALL="-1",Q.API_RESPONSE="1",Q.INFO="2",Q.ERROR="4",Q.PROMISE_ERROR="8",Q.AJAX_ERROR="16",Q.SCRIPT_ERROR="32",Q.IMAGE_ERROR="64",Q.CSS_ERROR="128",Q.CONSOLE_ERROR="256",Q.MEDIA_ERROR="512",Q.RET_ERROR="1024",Q.REPORT="2048",Q.PV="4096",Q.EVENT="8192",(z=d=d||{})[z.android=1]="android",z[z.ios=2]="ios",z[z.windows=3]="windows",z[z.macos=4]="macos",z[z.linux=5]="linux",z[z.devtools=6]="devtools",z[z.other=100]="other",(Y=h=h||{})[Y.unknown=100]="unknown",Y[Y.wifi=1]="wifi",Y[Y.net2g=2]="net2g",Y[Y.net3g=3]="net3g",Y[Y.net4g=4]="net4g",Y[Y.net5g=5]="net5g",Y[Y.net6g=6]="net6g",(Z=g=g||{}).LOG="log",Z.SPEED="speed",Z.PERFORMANCE="performance",Z.OFFLINE="offline",Z.WHITE_LIST="whiteList",Z.VITALS="vitals",Z.PV="pv",Z.CUSTOM_PV="customPV",Z.EVENT="event",Z.CUSTOM="custom",Z.SDK_ERROR="sdkError",(se=m=m||{}).production="production",se.gray="gray",se.pre="pre",se.daily="daily",se.local="local",se.others="others";function O(e){return e.filter(function(n,i){return"static"!==n.type||!e.find(function(e,t){return i!==t&&n.url===e.url&&200===n.status})})}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 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 S(){}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 T(){try{var e=getCurrentPages();return(e[e.length-1]||{}).route||""}catch(e){return""}}function L(e){return C?C.addCallback(e):C=new ne(e),C}var C,k,N,U,j=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)}},A=function(e,n){var i,o=[],r=e.config;return e.lifeCycle.on("destroy",function(){o.length=0}),function(e,t){if(o.push(e),n&&o.length>=n)return o=O(o),t(o.splice(0,o.length)),void(i&&clearTimeout(i));i&&clearTimeout(i),i=setTimeout(function(){i=null,0<(o=O(o)).length&&t(o.splice(0,o.length))},r.delay)}},I=function(e,t){return Array.isArray(e)?t(e.map(function(e){return a(a({},e),{msg:"string"==typeof e.msg?e.msg:[].concat(e.msg).map(f).join(" ")})})):t(a(a({},e),{msg:"string"==typeof e.msg?e.msg:f(e.msg)}))},_=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:g.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?D(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}})}],g.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.reportRequst?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)}},q=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!==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))}))}},D=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(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:g.LOG,log:e,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}],g.LOG)(e)}},H=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]=""}),a(a({},t),e)}))),e}(i,["ext1","ext2","ext3"]),t(n?i:i[0]))}},M=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||S)}:n.reduce(function(n,i){return function(e,t){return void 0===t&&(t=S),n(e,function(e){return null==i?void 0:i(e,t)})}})},B=(Object.defineProperty(de.prototype,"__version__",{get:function(){return console.warn("__version__ has discard, please use version"),"1.24.49"},enumerable:!1,configurable:!0}),Object.defineProperty(de.prototype,"LogType",{get:function(){return console.warn("LogType has discard, please use logType"),p},enumerable:!1,configurable:!0}),de.prototype.init=function(e){this.setConfig(e);for(var t=0;t<de.installedPlugins.length;t++)try{de.installedPlugins[t].patch(this)}catch(e){this.sendSDKError(e)}this.lifeCycle.emit("onInited")},de.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,l=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.49",this.bean.aid=e||"",this.bean.env=function(){switch(l){case m.production:case m.gray:case m.pre:case m.daily:case m.local:case m.others:return 1;default:return}}()?l:m.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},de.use=function(e){-1===de.installedPlugins.indexOf(e)&&e.aegisPlugin&&de.installedPlugins.push(e)},de.unuse=function(e){e=de.installedPlugins.indexOf(e);-1!==e&&de.installedPlugins.splice(e,1)},de.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,a({},e[0]),{level:p.INFO}),this.normalLogPipeline(n)},de.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,a({},e[0]),{level:p.INFO_ALL}),this.normalLogPipeline(n)},de.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,a({},e[0])),this.normalLogPipeline(n)},de.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,a({},e[0]),{level:p.ERROR}),this.normalLogPipeline(n)},de.prototype.speedLogPipeline=function(e){throw new Error('You need to override "speedLogPipeline" method')},de.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:g.CUSTOM_PV,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.CUSTOM_PV)(null))},de.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"))},de.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")},de.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")},de.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")},de.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")},de.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})},de.prototype.extendBean=function(e,t){this.bean[e]=t},de.prototype.sendPipeline=function(e,t){var n,r=this;return M(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}},H(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];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];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)]))},de.prototype.send=function(e,o,r){var t=this;return M([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)},de.prototype.request=function(e,t,n){throw new Error('You need to override "request" method')},de.prototype.sendSDKError=function(e){var n=this;this.sendPipeline([function(e,t){t({url:n.config.url+"?id=1085&msg[0]="+encodeURIComponent(f(e))+"&level[0]=2&from="+n.config.id+"&count=1&version="+n.config.id+"(1.24.49)",addBean:!1,method:"get",type:g.SDK_ERROR,log:e})}],g.SDK_ERROR)(e)},de.prototype.destroy=function(e){void 0===e&&(e=!1);var t,n,i=de.instances.indexOf(this);-1!==i&&de.instances.splice(i,1);for(var o=de.installedPlugins.length-1;0<=o;o--)try{de.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===de.instances.length&&(e=Object.getPrototypeOf(this).constructor,x(e),x(de))}},de.version="1.24.49",de.instances=[],de.logType=p,de.environment=m,de.installedPlugins=[],de),V=(pe.prototype.patch=function(e){this.canUse(e)&&this.exist(e)&&(this.instances.push(e),this.triggerInit(e),this.triggerOnNewAegis(e))},pe.prototype.unpatch=function(e){e=this.instances.indexOf(e);-1!==e&&this.instances.splice(e,1)},pe.prototype.countInstance=function(){return this.instances.length},pe.prototype.uninstall=function(){var e;null===(e=null===(e=this.option)||void 0===e?void 0:e.destroy)||void 0===e||e.apply(this)},pe.prototype.walk=function(n){var i=this;this.instances.forEach(function(e){var t=i.canUse(e);t&&n(e,t)})},pe.prototype.canUse=function(e){e=this.getConfig(e);return!(!e||"object"!=typeof e)||!!e},pe.prototype.getConfig=function(e){return null===(e=e.config)||void 0===e?void 0:e[this.name]},pe.prototype.exist=function(e){return-1===this.instances.indexOf(e)},pe.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)))},pe.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))},pe),J=wx||qq,W=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}}}(J.getSystemInfoSync().SDKVersion,"1.1.1")&&J.canIUse?J.canIUse(e):!!J[e]},G=new V({name:"offlineLog",onNewAegis:function(o){if(J.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 $({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:g.OFFLINE,log:g.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:g.OFFLINE,log:t},function(){u.clearLogs()})}))})})}catch(o){console.error(o)}else console.warn("[aegis-mp-sdk]unsupport getFileSystemManager offline log not work!")}}),$=(fe.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)}})},fe.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)}})}})},fe),K=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=h.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=h[r];break}}return i},Q=new V({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{W("getSystemInfo")&&J.getSystemInfo({success:function(e){var t=e.platform,n=e.model,i=e.windowHeight,o=e.windowWidth,r=e.screenWidth,e=e.screenHeight;s.extendBean("platform",a.getPlatFormType(t)),s.extendBean("model",n),s.extendBean("vp",o+" * "+i),s.extendBean("sr",r+" * "+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=d.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=d[r];break}}return i},setNetworkChange:function(t){W("onNetworkStatusChange")&&J.onNetworkStatusChange(function(e){e=K(e.networkType);t.extendBean("netType",e)})},setNetworkType:function(t){W("getNetworkType")&&J.getNetworkType({success:function(e){e=K(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)}}),X=J.request,z=(e(ce,U=B),Object.defineProperty(ce.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}),ce.prototype.initOfflineLog=function(){ce.use(G)},ce.prototype.uploadLogs=function(e,t){this.lifeCycle.emit("uploadLogs",e=void 0===e?{}:e,t=void 0===t?{}:t)},ce.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:g.CUSTOM_PV,log:g.CUSTOM_PV},function(){},function(){}))},ce.sessionID="session-"+Date.now(),ce.asyncPluginIndex=0,ce),Y=new V({name:"aid",onNewAegis:function(t){this.initAid(function(e){t.bean.aid=e,t.config.aid=e})},initAid:function(t){J.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)});J.setStorage({key:"AEGIS_ID",data:e,success:function(){t(e)}})}})}}),Z=(ue.prototype.addCallback=function(e){e&&this.callbacks.push(e)},ue.prototype.prefixHandler=function(e){e.aegisRequestStartTime=Date.now()},ue.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)},ue.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)},ue.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)},ue.prototype.override=function(){try{this.defineApiProperty()}catch(e){console.warn("cannot override `"+this.apiName+"`, error is: "+e)}finally{this.isOverride=!0}},ue),ee=wx||qq,te=ee.request,ne=(e(le,N=Z),le.prototype.defineApiProperty=function(){var e=this;Object.defineProperty(ee,"request",{get:function(){return e.hackHandler.bind(e)}})},le.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){te(a(a({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},le),ie=wx||qq,oe=null===(se=ie.cloud)||void 0===se?void 0:se.callFunction,re=(e(ae,k=Z),ae.prototype.defineApiProperty=function(){var e=this;ie.cloud&&ie.cloud.callFunction&&Object.defineProperty(ie.cloud,"callFunction",{get:function(){return e.hackHandler.bind(e)}})},ae.prototype.hackHandler=function(i){var o=this;return this.prefixHandler(i),new Promise(function(t,n){oe(a(a({},i),{success:function(e){o.successHandler(e,i),t(e)},fail:function(e){o.failHandler(e,i),n(e)},complete:function(e){o.completeHandler(e,i)}}))})},ae),B=new V({name:"reportApiSpeed",override:!1,onNewAegis:function(e){this.override||(this.override=!0,this.hackRequest(e.config),this.overrideCallFunction(e.config))},hackRequest:function(o){var r=this;L({success:function(e,t){var n={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:e.statusCode||0,isHttps:u(t.url),type:"fetch"},i=null===(i=o.api)||void 0===i?void 0:i.apiDetail,i="req url: "+n.url+" \n \nreq method: "+n.method+" \n \nreq param: "+(i?f(t.data):"")+" \n \nres duration: "+n.duration+" \n \nres status: "+(e.statusCode||0)+" \n \nres data: "+(i?y(e.data):"");r.publishNormalLog({msg:i,level:p.API_RESPONSE});t=c(e.data,o.api,{url:t.url,ctx:e})||{},e=t.code,t=t.isErr;n.ret=e,n.isErr=+t,r.publishSpeedLog(n),t&&r.publishNormalLog({msg:i,level:p.RET_ERROR})},fail:function(e,t){t={method:t.method||"get",url:l(t.url),duration:Date.now()-t.aegisRequestStartTime,status:0,isHttps:u(t.url),type:"fetch"};r.publishSpeedLog(t)}})},overrideCallFunction:function(l){var u=this;new re({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+"\n \nres errMsg: "+n.errMsg+"\n \nres data: "+(i?y(e.result):"")+"\n ";u.publishNormalLog({msg:o,level:p.API_RESPONSE});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})},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)})}}),se=new V({name:"onError",onNewAegis:function(e){e=e.config;this.listenError(),this.hackRequest(e)},listenError:function(){var t=this;J.onError(function(e){e&&t.publishErrorLog({msg:e,level:p.ERROR})}),W("onUnhandledRejection")&&J.onUnhandledRejection(function(e){e=e.reason;e&&t.publishErrorLog({msg:e,level:p.PROMISE_ERROR})})},publishErrorLog:function(t){this.$walk(function(e){e.normalLogPipeline(t)})},hackRequest:function(s){var a=this;L({complete:function(e,t){var n,i=e.errMsg,o=e.statusCode,r=e.data,e=null===(e=s.api)||void 0===e?void 0:e.apiDetail;s.hostUrl&&-1<(null===(n=t.url)||void 0===n?void 0:n.indexOf(s.hostUrl))||(n="",-1<i.indexOf("timeout")?n="timeout":-1<i.indexOf("fail")||!o||o<0?n="failed":400<=o&&(n="error"),n&&a.publishErrorLog({msg:"AJAX_ERROR: request "+n+"\n \nres status: "+(o||0)+"\n \nres duration: "+(Date.now()-t.aegisRequestStartTime)+"\n \nres data: "+(e?f(r):"")+"\n \nreq url: "+t.url+"\n \nreq method: "+(t.method||"get")+"\n \nreq param: "+(e?f(t.data):"")+"\n \nerrMsg: "+i.slice(0,1e3),level:p.AJAX_ERROR}))}})}}),Z=new V({name:"reportAssetSpeed",isStart:!1,onNewAegis:function(e){this.isStart||(this.isStart=!0,this.start(e))},start:function(){var t=this;J.getPerformance&&J.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:l(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))})}}),V=new V({name:"pagePerformance",onNewAegis:function(e){try{W("getPerformance")&&this.reportPerformance(e),this.setPagePV(e),this.reportSetDataTiming(e)}catch(e){}},reportPerformance:function(r){var s=this,e=J.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=this.$getConfig(n),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:g.PERFORMANCE,log:t})}):this.$walk(function(e){e.send({url:n.config.performanceUrl+s+o.join("&"),type:g.PERFORMANCE,log:t})})},setPagePV:function(e){var t=this;J.onAppRoute&&J.onAppRoute(function(e){"appLaunch"!==e.openType&&t.$walk(function(e){e.send({url:""+e.config.pvUrl,type:g.PV})})})},reportSetDataTiming:function(t){function o(e,t){var n=t.updateStartTimestamp,i=t.updateEndTimestamp,t=void 0===(t=t.dataPaths)?[]:t,n=i-n;isNaN(n)||n<l||(n={from:e.is,duration:n},a&&0<t.length&&Object.assign(n,{dataPaths:t.slice(0,30)}),r(n))}var e,r=M([A(t,5),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}});t.send({url:t.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({miniProgramData:e})),type:g.CUSTOM,log:e})}]),i=Page,s=Component,n=null===(e=null===(n=t.config)||void 0===n?void 0:n.setDataReportConfig)||void 0===e?void 0:e.timeThreshold,a=!1!==(null===(e=null===(e=t.config)||void 0===e?void 0:e.setDataReportConfig)||void 0===e?void 0:e.withDataPaths),l=Boolean(n&&!isNaN(+n)&&5<n)?+n:5;Page=function(e){var n=e.onReady;return e.onReady=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:a},function(e){o(t,e)}),null==n?void 0:n.call(this)},i(e)},Component=function(e){var n,i;return e.lifetimes&&e.lifetimes.attached?(n=e.lifetimes.attached,e.lifetimes.attached=function(){var t=this;return"function"==typeof this.setUpdatePerformanceListener&&this.setUpdatePerformanceListener({withDataPaths:a},function(e){o(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:a},function(e){o(t,e)}),null==i?void 0:i.call(this)}),s(e)}}});function ae(){return null!==k&&k.apply(this,arguments)||this}function le(){return null!==N&&N.apply(this,arguments)||this}function ue(e){this.callbacks=[],this.isOverride=!1,this.isOverride||this.override(),this.callbacks.push(e)}function ce(e){var i,c=U.call(this,e)||this;c.originRequest=X,c.speedLogPipeline=M([q(c.config),A(c),function(t,n){W("getNetworkType")?J.getNetworkType({success:function(e){e=K(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)},H(i=c,g.SPEED),function(e){c.send({url:""+c.config.speedUrl,method:"post",data:r(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||W("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||(u="Sending request blocked",console.log(u)),a.url||(u="Please handle the parameters reasonably, options.url is necessary",console.warn(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({url:o,enableHttp2:u,success:t,fail:n,complete:s})):("string"==typeof a.data&&(a.data=a.data.replace(/eval/gi,"evaI")),c.originRequest({url:o,enableHttp2:u,header:a.contentType?{"content-type":a.contentType}:void 0,method:"POST",data:a.data,success:t,fail:n,complete:s})),!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",ce.sessionID),c.extendBean("referer",(W("getLaunchOptionsSync")?J.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 fe(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=J.env.USER_DATA_PATH+e,this.fileSystem=J.getFileSystemManager(),this.limitSize=t}function pe(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 de(e){var i,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,hostUrl:"https://aegis.qq.com",env:"production",url:"",offlineUrl:"",whiteListUrl:"",pvUrl:"",speedUrl:"",customTimeUrl:"",performanceUrl:"",webVitalsUrl:"",eventUrl:""},this.isWhiteList=!1,this.lifeCycle=new n,this.bean={},this.normalLogPipeline=M([A(this,5),I,F(this.config),j(this.lifeCycle.emit,this.config),(i=this,setTimeout(function(){var e=i.config.pvUrl,n=void 0===e?"":e;n&&i.sendPipeline([function(e,t){t({url:n,type:g.PV,fail:function(e){"403 forbidden"===e&&i.destroy()}})}],g.PV)(null)},100),function(e,t){t(e)}),_(this),function(e,t){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)},D(this)]),this.eventPipeline=M([A(this,5),function(e){o.sendPipeline([function(e,t){var n=e.map(function(e){return{name:e.name,ext1:e.ext1||o.config.ext1||"",ext2:e.ext2||o.config.ext2||"",ext3:e.ext3||o.config.ext3||""}});t({url:o.config.eventUrl+"?payload="+encodeURIComponent(JSON.stringify(n)),type:g.EVENT,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.EVENT)(e)}]),this.timeMap={},this.customTimePipeline=M([A(this,5),function(e){return o.sendPipeline([function(e,t){t({url:o.config.customTimeUrl+"?payload="+encodeURIComponent(JSON.stringify({custom:e})),type:g.CUSTOM,log:e,fail:function(e){"403 forbidden"===e&&o.destroy()}})}],g.CUSTOM)(e)}]),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),de.instances.push(this)}return z.use(se),z.use(B),z.use(Y),z.use(Z),z.use(V),z.use(Q),z});
@@ -1,13 +1,17 @@
1
1
  import { InterfaceEventEmitter } from './util';
2
- import { Config, LogType, SendOption, SendSuccess, SendFail, SpeedLog, ReportTimeLog, EventLog } from './interface';
2
+ import { Config, LogType, Environment, SendOption, SendSuccess, SendFail, SpeedLog, ReportTimeLog, SendType, EventLog } from './interface';
3
3
  import Plugin from './plugin';
4
+ import { Pipe } from './pipes';
4
5
  export default class Core {
5
6
  static version: string;
6
7
  static instances: Core[];
7
8
  constructor(config: Config);
8
9
  get __version__(): string;
10
+ isGetSample: boolean;
11
+ isHidden: boolean;
9
12
  static logType: typeof LogType;
10
13
  get LogType(): typeof LogType;
14
+ static environment: typeof Environment;
11
15
  config: Config;
12
16
  isWhiteList: boolean;
13
17
  lifeCycle: InterfaceEventEmitter;
@@ -36,7 +40,8 @@ export default class Core {
36
40
  private submitCustomTime;
37
41
  private customTimePipeline;
38
42
  extendBean(key: string, value: any): void;
39
- send(options: SendOption, success?: SendSuccess, fail?: SendFail): void;
43
+ sendPipeline(pipes: Pipe[], type: SendType): import("./pipes").Pipeline<any, any>;
44
+ send(options: SendOption, success?: SendSuccess, fail?: SendFail): any;
40
45
  request(_options: SendOption, _success?: SendSuccess, _fail?: SendFail): void;
41
46
  sendSDKError(err: any): void;
42
47
  destroy(force?: boolean): void;
@@ -7,6 +7,7 @@ export interface Config {
7
7
  aid?: boolean | string;
8
8
  onError?: boolean;
9
9
  device?: boolean;
10
+ env?: string;
10
11
  version?: number | string;
11
12
  delay?: number;
12
13
  repeat?: number | object;
@@ -0,0 +1,9 @@
1
+ export declare enum Environment {
2
+ production = "production",
3
+ gray = "gray",
4
+ pre = "pre",
5
+ daily = "daily",
6
+ local = "local",
7
+ others = "others"
8
+ }
9
+ export declare const isEnvironment: (val: string) => boolean;
@@ -1,3 +1,4 @@
1
1
  export { Config } from './config';
2
2
  export { NormalLog, SpeedLog, StaticAssetsLog, PagePerformanceLog, LogType, ReportTimeLog, EventLog, PlatTypeNum, NetworkTypeNum, } from './log';
3
3
  export { SendOption, SendSuccess, SendFail, SendType, } from './send';
4
+ export { Environment, } from './env';
@@ -8,6 +8,9 @@ export interface SendOption {
8
8
  beanFilter?: string[];
9
9
  type?: SendType;
10
10
  log?: any;
11
+ success?: (data: any) => void;
12
+ fail?: (err: any) => void;
13
+ sendBeacon?: boolean;
11
14
  }
12
15
  export declare enum SendType {
13
16
  LOG = "log",
@@ -7,8 +7,9 @@ export { createPvPipe } from './pv';
7
7
  export { createSpeedRepeatLimitPipe, createErrorLogLimitPipe } from './repeat-limit';
8
8
  export { reportPipe } from './report';
9
9
  export { beforeRequestHooks } from './beforeRequestHooks';
10
+ export { modifyRequestHooks } from './modifyRequestHooks';
10
11
  export { afterRequestHooks } from './afterRequestHooks';
11
12
  export declare type Pipe<M = any, N = any> = (msg: M, resolve: Resolve<N>) => void;
12
13
  export declare type Resolve<M> = (msg: M) => void;
13
14
  export declare type Pipeline<M = any, N = any> = (msg: M, end?: Resolve<N>) => any;
14
- export declare const createPipeline: (pipeArr: [Pipe, ...Pipe[]]) => Pipeline;
15
+ export declare const createPipeline: (pipeArr: Pipe[]) => Pipeline;
@@ -0,0 +1,3 @@
1
+ import Core from '../core';
2
+ import { Pipe } from './index';
3
+ export declare const modifyRequestHooks: (aegis: Core) => Pipe;
@@ -15,7 +15,15 @@ export declare const formatUrl: (url: string, isGetQuery?: boolean | undefined)
15
15
  export declare const urlIsHttps: (url: string) => boolean;
16
16
  export declare const isNative: (Ctor: any) => boolean;
17
17
  export declare const isRequestAsset: (contentType: string) => boolean;
18
- export declare const tryToGetRetCode: (obj: any, api?: Record<string, any> | undefined) => string;
18
+ interface TryToGetRetCodeRsp {
19
+ code: string;
20
+ isErr: boolean;
21
+ }
22
+ interface TryToGetRetCodeParams {
23
+ url?: string;
24
+ ctx?: any;
25
+ }
26
+ export declare const tryToGetRetCode: (obj: any, api?: Record<string, any> | undefined, params?: TryToGetRetCodeParams | undefined) => TryToGetRetCodeRsp;
19
27
  /**
20
28
  * 判断cgi返回的code是否为错误code
21
29
  */
@@ -51,3 +59,4 @@ export declare class PayloadFetch {
51
59
  }
52
60
  export declare const generateAid: () => string;
53
61
  export declare const speedShim: (logs: SpeedLog | SpeedLog[], bean: any) => any;
62
+ export declare const completionLogsKeys: (logs: any, keys: string[] | string) => any;
@@ -1,4 +1,3 @@
1
1
  import Aegis from './aegis';
2
2
  export default Aegis;
3
3
  export { MpConfig } from './aegis';
4
- export { HackCloud } from './util/hack-cloud';
@@ -9,10 +9,11 @@ export interface HackApiCallback<RequestOption = any, SucessRes = any, FailRes =
9
9
  }
10
10
  declare type HackApiCallbackOption = ReqOption & HackApiCallback;
11
11
  export default abstract class HackApiCore<T extends HackApiCallbackOption, U extends HackApiCallback> {
12
- private isOverride;
13
12
  private callbacks;
13
+ private isOverride;
14
14
  abstract apiName: string;
15
15
  constructor(cb: U);
16
+ addCallback(cb: U): void;
16
17
  protected prefixHandler(opts: T): void;
17
18
  protected successHandler<R>(res: R, opts: T): void;
18
19
  protected failHandler<R>(res: R, opts: T): void;
@@ -37,7 +37,7 @@ export default class Aegis extends Core {
37
37
  fail?: SendFail;
38
38
  }[];
39
39
  requesting: boolean;
40
- request(options: SendOption, success?: SendSuccess, fail?: SendFail): void;
40
+ request(options: SendOption, success?: SendSuccess, fail?: SendFail): boolean | void;
41
41
  speedLogPipeline: import("../../core/src").Pipeline<any, any>;
42
42
  private static asyncPlugin;
43
43
  static useAsyncPlugin(url: string, options?: AsyncPluginOption): void;
@@ -1,4 +1,4 @@
1
- import { Plugin } from "../../../core/src";
1
+ import Core, { Plugin } from "../../../core/src";
2
2
  declare global {
3
3
  interface Navigator {
4
4
  connection: any;
@@ -13,6 +13,6 @@ export declare enum NetworkTypeNum {
13
13
  net5g = 5,
14
14
  net6g = 6
15
15
  }
16
- declare const _default: Plugin<import("../../../core/src").default>;
16
+ declare const _default: Plugin<Core>;
17
17
  export default _default;
18
18
  export declare const getNetworkType: (callback: Function) => void;
@@ -3,3 +3,5 @@ export declare const speedShim: (logs: SpeedLog | SpeedLog[], bean: any) => Form
3
3
  export declare const loadScript: (url: string, name?: string | undefined, cb?: Function | undefined) => void;
4
4
  export declare const canUseResourceTiming: () => boolean;
5
5
  export declare const canUseWebVitals: () => boolean;
6
+ export declare type OnHiddenCallback = (event: Event) => void;
7
+ export declare const onHidden: (cb: OnHiddenCallback, once?: boolean | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aegis-mp-sdk",
3
- "version": "1.24.49",
3
+ "version": "1.24.50",
4
4
  "description": "aegis sdk for wechat and qq mini program",
5
5
  "author": "tickli <tickli@tencent.com>",
6
6
  "homepage": "",