@atomicservice/ascf-base 1.0.17 → 1.0.18-beta.1
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/dist/hianalytics/ha.esm.js +1 -0
- package/dist/hianalytics/ha.min.js +1 -0
- package/dist/index.d.mts +73 -8
- package/dist/index.d.ts +73 -8
- package/dist/index.js +92 -74
- package/dist/index.mjs +92 -74
- package/dist/reporter/reporter-process.js +1 -0
- package/dist/schemas/app.schema.json +39 -0
- package/dist/schemas/ascf.config.schema.json +9 -4
- package/dist/templates/ascfProject/entry/oh-package.json5 +1 -1
- package/dist/templates/ascfTaro/package.json +1 -1
- package/dist/templates/ascfUniapp/package.json +1 -1
- package/package.json +7 -8
- package/dist/templates/ascfTaro/ascf-project/AppScope/app.json5 +0 -11
- package/dist/templates/ascfTaro/ascf-project/AppScope/resources/base/element/string.json +0 -8
- package/dist/templates/ascfTaro/ascf-project/AppScope/resources/base/media/app_icon.png +0 -0
- package/dist/templates/ascfTaro/ascf-project/build-profile.json5 +0 -55
- package/dist/templates/ascfTaro/ascf-project/code-linter.json5 +0 -20
- package/dist/templates/ascfTaro/ascf-project/entry/build-profile.json5 +0 -28
- package/dist/templates/ascfTaro/ascf-project/entry/hvigorfile.ts +0 -6
- package/dist/templates/ascfTaro/ascf-project/entry/obfuscation-rules.txt +0 -23
- package/dist/templates/ascfTaro/ascf-project/entry/oh-package-lock.json5 +0 -21
- package/dist/templates/ascfTaro/ascf-project/entry/oh-package.json5 +0 -11
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/ets/abilitystage/AbilityStage.ets +0 -7
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/ets/entryability/EntryAbility.ets +0 -4
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/ets/pages/Index.ets +0 -10
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/module.json5 +0 -65
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/base/element/color.json +0 -8
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/base/element/string.json +0 -16
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/base/media/startIcon.png +0 -0
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/base/profile/main_pages.json +0 -5
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/en_US/element/string.json +0 -16
- package/dist/templates/ascfTaro/ascf-project/entry/src/main/resources/zh_CN/element/string.json +0 -16
- package/dist/templates/ascfTaro/ascf-project/entry/src/mock/mock-config.json5 +0 -2
- package/dist/templates/ascfTaro/ascf-project/entry/src/ohosTest/ets/test/Ability.test.ets +0 -35
- package/dist/templates/ascfTaro/ascf-project/entry/src/ohosTest/ets/test/List.test.ets +0 -5
- package/dist/templates/ascfTaro/ascf-project/entry/src/ohosTest/module.json5 +0 -12
- package/dist/templates/ascfTaro/ascf-project/entry/src/test/List.test.ets +0 -5
- package/dist/templates/ascfTaro/ascf-project/entry/src/test/LocalUnit.test.ets +0 -33
- package/dist/templates/ascfTaro/ascf-project/hvigor/hvigor-config.json5 +0 -23
- package/dist/templates/ascfTaro/ascf-project/hvigorfile.ts +0 -10
- package/dist/templates/ascfTaro/ascf-project/oh-package-lock.json5 +0 -20
- package/dist/templates/ascfTaro/ascf-project/oh-package.json5 +0 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=function(e){return function(t){return function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}(t)===e}},t=e("function"),n=e("object"),i=e("array"),r=e("string"),o=e("number"),s=e("boolean"),a=e("undefined"),c=e("null");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function l(e,t,n){return t=p(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,m()?Reflect.construct(t,n||[],p(e).constructor):t.apply(e,n))}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,S(i.key),i)}}function f(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function g(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},v.apply(null,arguments)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}var T="baseinfotype",I="customEvent",U="elementEvent",_="clickEvent",C="HW_",D="HWBS_",x="id",N="idts",O="viewts",E="QuotaExceededError",R=Array.prototype,j="UTM",L=function(e,t){return R.includes&&e.includes===R.includes?e.includes(t):-1!==e.indexOf(t)},P=function(e,t,n){var i,r=R.forEach;if(r&&e.forEach===r)e.forEach(t,n);else if((i=e)&&"object"===w(i)&&isFinite(i.length)&&i.length>=0&&i.length===Math.floor(i.length)&&i.length<Math.pow(2,32))for(var o=0,s=e.length;o<s;o++)o in e&&t.call(n,e[o],o,e);else for(var a in e)Object.hasOwnProperty.call(e,a)&&t.call(n,e[a],a,e)},A=function(e){return P(R.slice.call(arguments,1),function(t){P(t,function(t,n){e[n]=t})}),e},M=function(e,t){return e.indexOf(t)},H=function(){var e=new Uint8Array(16),t=window;return(t.crypto||t.webkitCrypto||t.mozCrypto||t.oCrypto||t.msCrypto).getRandomValues(e),function(e,t){if(R.map&&e.map===R.map)return e.map(t);var n=[];return P(e,function(e,i,r){n.push(t(e,i,r))}),n}(e,function(e){return("0"+e.toString(16)).substr(-2)}).join("")},B=["token","ha_linker"];function X(e){return e.tagName.toLowerCase()}var q=function(e){var t=[];return P(e,function(e,n){i(e)?P(e,function(i,r){t.push(n+"="+e[r])}):t.push(n+"="+e)}),t.join("&")},F=function(){return!a(window.XMLHttpRequest)&&"withCredentials"in new XMLHttpRequest},J=navigator,W=function(){return J&&!a(J.sendBeacon)},z=function(e){var t=e.parentElement;if(!t)return null;var n=X(t);return"body"===n||"html"===n?null:"a"===n?t:z(t)},K=function(){return(new Date).getTime()},$=function(e){e.length},Q=function(){return window.haJsBridge||{}},Z=function(e){var t=null;try{if(Q().haGetDeviceInfo){var n=K(),i=Q().haGetDeviceInfo(e),o=K();t=r(i)?JSON.parse(i):i,$("get device info ".concat(e," use ").concat(o-n," ms. info: ").concat(JSON.stringify(t)))}}catch(e){console.error("json parse device info error.")}return t},G=window,Y={get:function(e){return G.localStorage.getItem(e)},set:function(e,t){try{G.localStorage.setItem(e,t)}catch(e){if(e.name===E)throw new Error(e.name);console.error(e)}},remove:function(e){G.localStorage.removeItem(e)},isSupport:function(){var e=!0;try{var t="__local_store_support__",n="testIsSupportStorage";this.set(t,n),this.get(t)!==n&&(e=!1),this.remove(t)}catch(t){e=!1}return e},length:function(){return G.localStorage.length},key:function(e){return G.localStorage.key(e)}},V=document,ee=function(e){var t=new RegExp("(^|;)[ ]*"+e+"=([^;]*)").exec(V.cookie);return t?decodeURIComponent(t[2]):null},te=function(e,t,n,i,r,o){if(e&&!/^(?:expires|max-age|path|domain|secure)$/i.test(e)){var s=[];if(s.push("".concat(e,"=").concat(encodeURIComponent(t))),n){var a=new Date;a.setTime(a.getTime()+n),s.push("expires=".concat(a.toUTCString()))}s.push("path=".concat(i||"/")),r&&s.push("domain=".concat(r)),!0===o&&s.push("secure"),V.cookie=s.join("; ")}},ne=function(e){var t=new Date;t.setTime(t.getTime()-1);var n=ee(e);c(n)||(V.cookie=e+"="+n+";expires="+t.toUTCString()+";path=/")};function ie(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e.addEventListener?e.addEventListener(t,n,i):e.attachEvent("on".concat(t),n)}var re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=k(e.split("?"),2),i=n[0],r=n[1];if(!r)return e;var o=r.split("&").filter(function(e){return!L(t,e.split("=")[0].toLocaleLowerCase())});return o.length?"".concat(i,"?").concat(o.join("&")):i},oe=function(e){var t={};e.includes("#")&&(e=e.split("#")[0]);var n=e.split("?")[1];if(!n)return t;for(var i=n.split("&"),r=0;r<i.length;++r){var o=k(i[r].split("="),2),s=o[0],a=o[1];t[decodeURIComponent(s)]=decodeURIComponent(a)}return t},se=Object.freeze({__proto__:null,deleteUrlQuery:re,getQueryParamsFromUrl:oe}),ae=document,ce=document,ue=window,le=function(){return f(function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];h(this,e),this.isH5=n,this.waitTime=0,this.waitTimeFlagTime=0,this.waitTimeFlag=!0,this.accessTime=K(),this.config={defaultCookie:{},useCookie:!1,isInit:!1,usedPageUrl:!0,intervalTime:18e5,batchSend:!1,useUtm:!1},this.globals={idsite:"",title:ce.title,id:"unknown",rid:"unknown",idts:K(),idvc:0,idn:"",di:{sessionId:"unknown"},refts:K(),viewts:K(),CXX:"",uid:"",cvar:"",pvid:""},this.customData={},P(se,function(e,n){t[n]=e}),ie(ue,"beforeunload",this.beforeUnloadHandler.bind(this)),ie(ce,"visibilitychange",this.stateChanged.bind(this)),this.updateSessionId()},[{key:"getQueryData",value:function(){var e=oe(ue.location.href),t={},n=!1;for(var i in e)i.toUpperCase().includes(j)&&(n=!0,t[i]=e[i]);if(n){var r=this.getStoreName(j,C);sessionStorage.setItem(r,JSON.stringify(t))}}},{key:"updateSessionId",value:function(){var e=Z("sessionId");e&&e.sessionId&&(this.globals.di.sessionId=e.sessionId)}},{key:"beforeUnloadHandler",value:function(){this.config.isInit&&this.config.useCookie&&te(this.getStoreName(O),K(),7776e6,"/"),this.stateChanged()}},{key:"getStoreName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C,n=arguments.length>2?arguments[2]:void 0;return e&&this.globals.idsite?"".concat(t).concat(e,"_").concat(this.globals.idsite,"_").concat((n||location.host).replace(/\./g,"_")):""}},{key:"handleSessionId",value:function(){var e=this.getStoreName("idn"),t=ee(e);t||(t=H()),this.globals.idn=t,this.config.useCookie&&te(e,t,this.config.intervalTime,"/")}},{key:"stateChanged",value:function(){"visible"===ce.visibilityState&&this.updateSessionId(),"hidden"===ce.visibilityState&&this.config.batchSend&&this.batchSendNow(),this.waitTimeFlag?this.waitTime+=K()-(this.waitTimeFlagTime||this.accessTime):this.waitTimeFlagTime=K(),this.waitTimeFlag=!this.waitTimeFlag}},{key:"getData",value:function(e,t,n){var i=ue.navigator.userAgent,r=this.globals,o=r.id,s=r.rid,a=r.di,c=r.CXX,u=r.idsite,l=r.uid,h=r.cvar,d=r.idts,f=r.idvc,g=r.idn,v=r.refts,p=r.viewts,y=n,m=this.getStoreName(j,C);return sessionStorage.getItem(m)&&(y.utmData=JSON.parse(sessionStorage.getItem(m))),{type:e,vf:o,rid:s,nsid:a.sessionId,rt:t.eventTime,ut:i.match(/AppleWebKit.*Mobile.*/)?-1!==M(i," wv")?2:1:0,cxx:c,idsite:u,suid:l,cvar:t.cvar||h,idts:d,idvc:f,idn:g,refts:v,viewts:p,hsv:"2.2.9-501",data:y}}},{key:"getFinalSendData",value:function(e){var t=new Date,i=this.globals,r=i.title,o=i.id,s=i.idsite,a=i.cvar,c=i.idts,u=i.idvc,l=i.idn,h=i.refts,d=i.viewts,f=i.rid,g=i.di,v=this.config.usedPageUrl,p={idsite:encodeURIComponent(s),rec:"1",r:"886244",h:t.getHours(),m:t.getMinutes(),s:t.getSeconds(),url:encodeURIComponent(this.deleteUrlQuery(v?ue.location.href:"/",B)),_id:encodeURIComponent(o),_rid:encodeURIComponent(f),_nsid:encodeURIComponent(g.sessionId),_idts:c,_idvc:u,_idn:l,urlref:this.deleteUrlQuery(ce.referrer,B),_refts:h,_viewts:d,scd:"24",vpr:"".concat(ue.screen.width," X ").concat(ue.screen.height),cvar:n(e.cvar||a)?encodeURIComponent(JSON.stringify(e.cvar||a)):encodeURIComponent(e.cvar||a),pdf:"1",qt:"0",data:this.isH5?JSON.stringify(e):encodeURIComponent(JSON.stringify(e))};return"$PageLeave"===e.type||e.type===_||e.type===U?A({link:encodeURIComponent(r)},p):A({action_name:encodeURIComponent(r)},p)}},{key:"initCookie",value:function(e){this.config.isInit=!0;var t=this.config,n=t.useCookie,i=t.defaultCookie.domain;if(n){if(i){var r=this.getStoreName(x,C),o=this.getStoreName(N,C);ne(r),ne(o)}var s=this.getStoreName(x,C,i),a=this.getStoreName(N,C,i),c=ee(s),u=ee(a);e&&e(s,c,a,u,i),c||(Y.isSupport()&&Y.get(s)?(c=Y.get(s),u=Y.get(a)||K()):(c=H(),u=K()),te(s,c,7776e6,"/",i),te(a,u,7776e6,"/",i)),this.globals.id=c,this.globals.idts=u||K();var l=this.getStoreName("refts"),h=ee(l);h||ce.referrer&&(h=K(),te(l,h,7776e6,"/")),this.globals.refts=h||K();var d=this.getStoreName(O),f=ee(d);this.globals.viewts=f||K();var g=this.getStoreName("idvc"),v=ee(g);v=v?Number(v)+1:Y.isSupport()&&Y.get(g)?Number(Y.get(g))+1:1,te(g,v,7776e6,"/"),this.globals.idvc=v,Y.isSupport()&&!Y.get(s)&&(Y.set(s,c),Y.set(a,u),Y.set(g,v))}else this.globals.id="unknown",this.globals.idts=K(),this.globals.refts=K(),this.globals.viewts=K(),this.globals.idvc=0;this.handleSessionId()}},{key:"setIdsite",value:function(e){return r(e)?new RegExp("^[a-zA-Z0-9_./][A-Za-z0-9_./]*$").test(e)?(this.globals.idsite=e,this.initCookie(),this):(console.error("idsite is invalid."),this):(console.error("idsite type should be string."),this)}},{key:"setAutoTrack",value:function(e,t,i){var r=this;if(!n(e))return this;var o=function(t,n){var i=new t(r);i.init(e),n&&n(i)};if(t)o(t,i);else if(ue.HAAutoTracker)o(ue.HAAutoTracker,i);else{var s=K();!function(e,t){var n=ae.createElement("script");n.type="text/javascript",n.readyState?n.onreadystatechange=function(){"loaded"!==n.readyState&&"complete"!==n.readyState||(n.onreadystatechange=null,t())}:n.onload=t,n.src=e,ae.getElementsByTagName("head")[0].appendChild(n)}(e.autotracker_url,function(){var e=K();$("[load+excute] HAWebSDK autotracker module use ".concat(e-s," ms.")),o(ue.HAAutoTracker,i)})}return this}}])}(),he=function(){return f(function e(t,n,i){h(this,e),this.core=t,this.dataType=n,this.serverUrl=i,this.state=0,this.keys=[],this.queue=[],this.intervalID=null,this.storageDataLength=0,this.getStorageDataLength=!1},[{key:"isH5",value:function(){return!0===this.core.isH5||void 0!==Q().haGetDeviceInfo}},{key:"init",value:function(){var e=this;if(this.core.config.batchSend){P(["batchSend"],function(t){var n=e[t];e[t]=function(){0===this.state?n.apply(this,arguments):this.queue.push([t,arguments])}}),!this.intervalID&&this.core.config.batchSend.interval&&(this.intervalID=setInterval(function(){e.batchSend()},this.core.config.batchSend.interval))}else this.intervalID&&clearInterval(this.intervalID)}},{key:"batchSend",value:function(){var e=this,t=this.getEventsToSendFromStorage();0!==t.length&&(this.state=1,this.onReport(this.core.getFinalSendData(t),function(t){e.state=0,200===t.status?(e.core.config.batchSend.retryTimes=10,P(e.keys,function(e){Y.remove(e)}),e.storageDataLength=e.storageDataLength-e.keys.length,e.keys=[],e.batchSend(),e.queue.length>0&&(e[e.queue[0][0]].apply(e,e.queue[0][1]),e.queue=e.queue.splice(0,1))):e.core.config.batchSend.retryTimes<=1?e.intervalID&&clearInterval(e.intervalID):e.core.config.batchSend.retryTimes--},!0))}},{key:"onceSend",value:function(e,t){this.onReport(this.core.getFinalSendData(e),t,!1)}},{key:"clearStorageData",value:function(){for(var e=0,t=[];e<Y.length();){var n=Y.key(e);this.getKeyType(n)&&t.push(n),e++}P(t,function(e){Y.remove(e)}),this.storageDataLength=0}},{key:"getKeyType",value:function(e){return 0===M(e,D)&&-1!==M(e,this.core.globals.idsite)}},{key:"addToStorage",value:function(e,t){try{var n=this.core.config.maxStorageLength;if(!isNaN(n)&&n>0){if(!this.getStorageDataLength){this.getStorageDataLength=!0;for(var i=0;i<Y.length();){var r=Y.key(i);this.getKeyType(r)&&this.storageDataLength++,i++}}if(this.storageDataLength>=n){for(var o=Math.ceil(this.storageDataLength/2),s=0,a=[];s<Y.length();){var c=Y.key(s);this.getKeyType(c)&&a.push(c),s++}a=a.sort(function(e,t){return JSON.parse(Y.get(e)).rt-JSON.parse(Y.get(t)).rt});for(var u=0;u<o;u++)Y.remove(a[u]),this.storageDataLength--}}var l=JSON.stringify(e);if(Q().haEncrypt){var h=K();l=Q().haEncrypt(l);var d=K();$("data encrypt use ".concat(d-h," ms. encrypted data: ").concat(l))}Y.set(this.core.getStoreName(H(),D),l),!isNaN(n)&&n>0&&this.storageDataLength++}catch(n){n.message===E&&(this.onceSend(e,t),this.batchSend())}}},{key:"getEventsToSendFromStorage",value:function(){var e=[],t=0;if(this.isH5())for(var n=0;n<Y.length();n++){var i=Y.key(n);if(this.getKeyType(i)){var r=Z("network");if(r&&!1===r.network||"false"===r.network)return e;break}}for(;t<Y.length();){var o=Y.key(t);if(this.getKeyType(o)){var s=Y.get(o);try{if(Q().haDecrypt){var a=K();if(!(s=Q().haDecrypt(s))){Y.remove(o);continue}var c=K();$("data decrypt use ".concat(c-a," ms. decrypted data: ").concat(s))}(s=JSON.parse(s)).dataType===this.dataType&&(this.keys.push(o),delete s.dataType,e.push(s))}catch(e){console.error("get storage error.",e)}if(this.keys.length===this.core.config.batchSend.maxLength)return e}t++}return e}},{key:"getServerUrl",value:function(){var e="",t=this.core,n=t.globals.idsite,i=t.config,r=i.debugMode,o=i.customUrlParams,s=i.serverUrl;return r&&(e="x_hasdk_debug=true"),e=e?e+"&idsite="+n:"idsite="+n,q(o)&&(e=e+"&"+q(o)),(this.serverUrl||s)+"?"+e}},{key:"onReport",value:function(e,t,n){if(this.core.globals.idsite)if(this.core.config.serverUrl)if(this.core.config.batchSend&&n)this.sendByAjax(e,t);else if(this.core.config.requestMode)switch(this.core.config.requestMode){case"beacon":this.sendByBeacon(e);break;case"ajax":F()?this.sendByAjax(e,t):this.sendByBeacon(e);break;case"img":this.sendByImg(e)}else this.core.config.isImg?this.sendByImg(e):W()?this.sendByBeacon(e):F()?this.sendByAjax(e,t):this.sendByImg(e);else console.error("serverUrl is empty");else console.error("idsite is empty")}},{key:"sendByAjax",value:function(e,n){var i=q(e),r=new XMLHttpRequest;r.open("POST",this.getServerUrl(),!0),A(this.core.config.defaultHeaders,{idsite:this.core.globals.idsite}),P(this.core.config.defaultHeaders,function(e,t){r.setRequestHeader(t,e)}),this.core.config.batchSend&&(r.timeout=this.core.config.batchSend.timeout),r.send(i),r.onreadystatechange=function(){r.readyState==r.DONE&&n&&t(n)&&n(r)}}},{key:"sendByImg",value:function(e){var t=q(e);this.core.config.debugMode&&(t="x_hasdk_debug=true&"+t);var n=new Image(1,1);n.onerror=function(){},n.src=this.core.config.serverUrl+"?"+t}},{key:"sendByBeacon",value:function(e){var t=q(e),n=new Blob([t],{type:"application/x-www-form-urlencoded;charset=UTF-8"});navigator.sendBeacon(this.getServerUrl(),n)}}])}(),de=document,fe=window,ge=function(){function e(){var t,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return h(this,e),(t=l(this,e,[n])).config.linker={},t.config.serverUrl="",t.config.requestMode="",t.config.isImg=!1,t.config.debugMode=!1,t.config.customUrlParams={},t.config.defaultHeaders={"Content-type":"application/x-www-form-urlencoded;charset=UTF-8"},t.config.maxStorageLength=0,t.defaultSender=new he(t),t.reportMap={},ie(de,"click",t.hrefIntercept.bind(t),!0),t}return y(e,le),f(e,[{key:"setMaxStorageLength",value:function(e){this.config.maxStorageLength=e}},{key:"urlAddLinker",value:function(e,t){if(!e)return e;var n=e.split("#"),i=n[0],r=n[1]?"#".concat(n[1]):"",o=i.replace(/(https|http):\/\/([^/?]+)(.*)/,"$2"),s=!1;if((this.config.linker.exclude&&(s=this.config.linker.exclude.includes(o)),this.config.linker.domains&&!s)&&this.config.linker.domains.filter(function(e){return new RegExp("".concat(e,"$"),"i").test(o)}).length){t&&t.preventDefault();var a=this.getStoreName(x,C,this.config.defaultCookie.domain),c={ts:K(),id:ee(a)};this.config.linker.ext&&(c.ext=this.config.linker.ext),i=M(i,"?")>-1?"".concat(i,"&ha_linker=").concat(fe.btoa(JSON.stringify(c))).concat(r):"".concat(i,"?ha_linker=").concat(fe.btoa(JSON.stringify(c))).concat(r)}return i}},{key:"hrefIntercept",value:function(e){var t=e.target||e.srcElement;if(!("a"===X(t))){var n=z(t);if(!n)return;t=n}var i=t.getAttribute("href");i&&(i=this.urlAddLinker(i,e),M(i,"ha_linker")>-1&&fe.open(i,t.getAttribute("target")||"_self"))}},{key:"initCookie",value:function(){var t,n,i,r,o,s=this;(t=e,n="initCookie",i=this,o=v(p(1&(r=3)?t.prototype:t),n,i),2&r&&"function"==typeof o?function(e){return o.apply(i,e)}:o)([function(e,t,n,i,r){var o=oe(de.location.href).ha_linker;if(o)try{var a=JSON.parse(fe.atob(o));!(K()-a.ts>(a.ext||1e4))&&a.id&&(t||(t=a.id,te(e,t,7776e6,"/",r),i=K(),te(n,i,7776e6,"/",r)),s.globals.rid=a.id)}catch(e){console.error("Invalid linker:"+e)}}])}},{key:"getSender",value:function(){var e=this,t=null;return P(this.reportMap,function(n){n.url===e.config.serverUrl&&(t=n.sender)}),t||this.defaultSender}},{key:"push",value:function(){for(var e=arguments,t=this,n=function(){var n=e[i],o=n.shift();setTimeout(function(){try{r(o)?t[o].apply(t,n):t.apply(t,n)}catch(e){console.error("Invalid method:"+o+", please check!")}},0)},i=0;i<arguments.length;++i)n();return this}},{key:"setOnReportUrl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;this.config.serverUrl=e;var n=e;return a(t)||(n=t),this.reportMap[n]||(this.reportMap[n]={url:e,sender:new he(this,n,e)},this.config.batchSend&&this.reportMap[n].sender.init()),this}},{key:"setTitle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.title=e,this}},{key:"setUserAccount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.id=e,this}},{key:"setCXX",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.CXX=e,this}},{key:"setUid",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.uid=e,this}},{key:"setPageData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.cvar=e,this}},{key:"setCustomData",value:function(e){return n(e)||t(e)?this.customData=e:console.error("The arguments of the setCustomData() method is invalid."),this}},{key:"setHttpHeader",value:function(e){return n(e)?(A(this.config.defaultHeaders,e),this):(console.error("custom header type should be object."),this)}},{key:"setIsUseCookie",value:function(e){if(!s(e))return console.error("useCookie type should be boolean"),this;if(this.config.useCookie=e,!this.config.useCookie){var t=de.cookie.split("; "),n=/^(HW_)(id|idts|idvc|idn|viewts|refts)_/;P(t,function(e){var t=e.split("=");n.test(t[0])&&ne(t[0])}),this.initCookie()}return this}},{key:"setIsUseUtm",value:function(e){return s(e)?(this.config.useUtm=e,e&&this.getQueryData(),this):(console.error("useUtm type should be boolean"),this)}},{key:"setReportMethod",value:function(e){return s(e)?(this.config.isImg=e,this):(console.error("isImg type should be boolean."),this)}},{key:"setSessionTimeoutDuration",value:function(e){return o(e)?(this.config.intervalTime=e,this):(console.error("intervalTime type should be number."),this)}},{key:"setDebugMode",value:function(e){return s(e)?(this.config.debugMode=e,this):(console.error("debugMode type should be boolean"),this)}},{key:"setCustomUrlParams",value:function(e){if(!n(e))return console.error("customUrlParams type should be object"),this;for(var t in e){if(L(["x_hasdk_debug","url","_id","_idts","_idvc","h","m","s","_rid"],t))return console.error("customUrlParams can'n include x_hasdk_debug, url, _id, _idts, _idvc, h, m, s, _rid"),this;var i=e[t];if(!i||!o(i)&&!r(i))return console.error("customUrlParams object value should be number or string"),this;if(!new RegExp("^[a-zA-Z0-9_./][A-Za-z0-9_./]*$").test(t)||!new RegExp("^[a-zA-Z_0-9_./][A-Za-z0-9_./]*$").test(i))return console.error("customUrlParams object include invalid key or value"),this;A(this.config.customUrlParams,g({},t,i))}return this}},{key:"setIstUseUrl",value:function(e){return s(e)?(this.config.usedPageUrl=e,this):(console.error("usedPageUrl type should be boolean."),this)}},{key:"setRequestMode",value:function(e){return"ajax"!==e||F()?"beacon"!==e||W()?(L(["beacon","ajax","img"],e)&&(this.config.requestMode=e),this):(console.error("navigator.sendBeacon() is not supported."),this):(console.error("XMLHttpRequest is not supported."),this)}},{key:"setBatchSend",value:function(e){if(!Y.isSupport())return console.error("localStorage is not supported, so batch send is not supported."),this;if(!F())return console.error("XMLHttpRequest is not supported, so batch send is not supported."),this;var t={timeout:6e3,interval:6e3,maxLength:6,retryTimes:10};return s(e)&&e?this.config.batchSend=t:n(e)&&(this.config.batchSend=A(t,e)),P(this.reportMap,function(e){e.sender&&e.sender.init()}),this}},{key:"batchSendNow",value:function(){return P(this.reportMap,function(e){e.sender&&e.sender.batchSend()}),this}},{key:"setLinker",value:function(e){return n(e)?i(e.domains)?e.exclude&&!i(e.exclude)?(console.error("custom exclude type should be Array."),this):(this.config.linker=e,this):(console.error("custom domains type should be Array."),this):(console.error("custom linker type should be object."),this)}},{key:"setUrlLinker",value:function(e){return this.urlAddLinker(e)}},{key:"setCookie",value:function(e){return n(e)?(this.config.defaultCookie=e,this):(console.error("custom cookie type should be object."),this)}},{key:"clearStorageData",value:function(){this.getSender().clearStorageData()}}])}(),ve=document,pe=window,ye=ve.documentElement,me=ve.body;var be=document,ke=window,Se=function(){function e(){var t;return h(this,e),(t=l(this,e)).config.baseinfotypeSwitch1=!1,t.switch1Num=0,t.config.baseinfotypeSwitch2=!1,t.switch2Num=0,t}return y(e,ge),f(e,[{key:"setBaseinfotypeSwitch",value:function(e){return s(e)?(this.config.baseinfotypeSwitch1=e,e&&0===this.switch1Num&&(this.switch1Num++,ie(be,"DOMContentLoaded",this.reportPageEntryEvent.bind(this))),this):(console.error("baseinfotypeSwitch1 type should be boolean."),this)}},{key:"setWindowCloseSwitch",value:function(e){return s(e)?(this.config.baseinfotypeSwitch2=e,e&&0===this.switch2Num&&(this.switch2Num++,ie(ke,"beforeunload",this.reportPageCloseEvent.bind(this))),this):(console.error("baseinfotypeSwitch2 type should be boolean."),this)}},{key:"sendPageinfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.waitTime=0,this.waitTimeFlagTime=0,this.waitTimeFlag=!0,this.accessTime=K(),this.config.baseinfotypeSwitch1=!0,this.reportPageEntryEvent(e,t),this}},{key:"sendPageClose",value:function(){return this.config.baseinfotypeSwitch2=!0,this.reportPageCloseEvent(),this}},{key:"sendData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4?arguments[4]:void 0,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s={eventTime:K(),eventName:e,eventLabel:t,customData:n,cvar:i};return this.execReport(I,s,r,o),this}},{key:"sendClickData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4?arguments[4]:void 0,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s={eventTime:K(),eventName:e,eventLabel:t,customData:n,cvar:i};return this.execReport(_,s,r,o),this}},{key:"bindclick",value:function(e,t,n,i,r){var o=this,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=e===be?be:be.getElementById(e);return a?(ie(a,t,function(t){var c=t.screenX,u=t.screenY,l=t.clientX,h=t.clientY,d=pe.innerHeight||ye.clientHeight||me.clientHeight||0,f=pe.innerWidth||ye.clientWidth||me.clientWidth||0,g={eventTime:K(),elementId:e,cls:a.className,data:n,cvar:i,position:{res:"".concat(c,"X").concat(u),vpr:"".concat(l,"X").concat(h),doc:"".concat(f,"X").concat(d)}};o.execReport(U,g,r,s)}),this):this}},{key:"reportPageEntryEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.execReport(T,{eventTime:K()},e,t)}},{key:"reportPageCloseEvent",value:function(){this.execReport(T,{eventTime:K()})}},{key:"execReport",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.handleSessionId();var r=this.getEventData(e,t),o=this.getSender();this.config.batchSend&&!i?(r.dataType=o.dataType,o.addToStorage(r,n)):o.onceSend(r,n)}},{key:"getEventData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.currentUrl,i=void 0===n?ke.location.href:n,r={url:re(this.config.usedPageUrl?i:"/",B),title:this.globals.title,at:this.accessTime,rf:re(be.referrer,B)};e===T?(r.res="".concat(ke.screen.width," X ").concat(ke.screen.height),r.cwt=t.eventTime,r.dt=this.waitTime):e===I||e===_?(r.en=t.eventName,r.el=t.eventLabel,r.cd=t.customData,r.custom_properties=this.customData):e===U&&(r.ei=t.elementId===be?"#document":t.elementId,r.ec=t.cls,r.ps=t.position,r.data=t.data||"");var o=this.getData(e,t,r);return o.pvid=this.globals.pvid,o}}])}(),we=K(),Te=new Se,Ie=K();$("[excute] hawebsdk use ".concat(Ie-we," ms."));export{Te as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
!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)._hasdk=t()}(this,function(){"use strict";var e=function(e){return function(t){return function(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}(t)===e}},t=e("function"),n=e("object"),i=e("array"),r=e("string"),o=e("number"),s=e("boolean"),a=e("undefined"),c=e("null");function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function l(e,t,n){return t=p(t),function(e,t){if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}(e,m()?Reflect.construct(t,n||[],p(e).constructor):t.apply(e,n))}function h(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,S(i.key),i)}}function f(e,t,n){return t&&d(e.prototype,t),n&&d(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function g(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function v(){return v="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(e,t,n){var i=function(e,t){for(;!{}.hasOwnProperty.call(e,t)&&null!==(e=p(e)););return e}(e,t);if(i){var r=Object.getOwnPropertyDescriptor(i,t);return r.get?r.get.call(arguments.length<3?e:n):r.value}},v.apply(null,arguments)}function p(e){return p=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},p(e)}function y(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&b(e,t)}function m(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(m=function(){return!!e})()}function b(e,t){return b=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},b(e,t)}function k(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o,s,a=[],c=!0,u=!1;try{if(o=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;c=!1}else for(;!(c=(i=o.call(n)).done)&&(a.push(i.value),a.length!==t);c=!0);}catch(e){u=!0,r=e}finally{try{if(!c&&null!=n.return&&(s=n.return(),Object(s)!==s))return}finally{if(u)throw r}}return a}}(e,t)||function(e,t){if(e){if("string"==typeof e)return u(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function S(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,t||"default");if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}function w(e){return w="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},w(e)}var T="baseinfotype",I="customEvent",U="elementEvent",_="clickEvent",C="HW_",D="HWBS_",x="id",N="idts",O="viewts",E="QuotaExceededError",j=Array.prototype,R="UTM",L=function(e,t){return j.includes&&e.includes===j.includes?e.includes(t):-1!==e.indexOf(t)},P=function(e,t,n){var i,r=j.forEach;if(r&&e.forEach===r)e.forEach(t,n);else if((i=e)&&"object"===w(i)&&isFinite(i.length)&&i.length>=0&&i.length===Math.floor(i.length)&&i.length<Math.pow(2,32))for(var o=0,s=e.length;o<s;o++)o in e&&t.call(n,e[o],o,e);else for(var a in e)Object.hasOwnProperty.call(e,a)&&t.call(n,e[a],a,e)},A=function(e){return P(j.slice.call(arguments,1),function(t){P(t,function(t,n){e[n]=t})}),e},M=function(e,t){return e.indexOf(t)},H=function(){var e=new Uint8Array(16),t=window;return(t.crypto||t.webkitCrypto||t.mozCrypto||t.oCrypto||t.msCrypto).getRandomValues(e),function(e,t){if(j.map&&e.map===j.map)return e.map(t);var n=[];return P(e,function(e,i,r){n.push(t(e,i,r))}),n}(e,function(e){return("0"+e.toString(16)).substr(-2)}).join("")},B=["token","ha_linker"];function X(e){return e.tagName.toLowerCase()}var q=function(e){var t=[];return P(e,function(e,n){i(e)?P(e,function(i,r){t.push(n+"="+e[r])}):t.push(n+"="+e)}),t.join("&")},F=function(){return!a(window.XMLHttpRequest)&&"withCredentials"in new XMLHttpRequest},J=navigator,W=function(){return J&&!a(J.sendBeacon)},z=function(e){var t=e.parentElement;if(!t)return null;var n=X(t);return"body"===n||"html"===n?null:"a"===n?t:z(t)},K=function(){return(new Date).getTime()},$=function(e){e.length},Q=function(){return window.haJsBridge||{}},Z=function(e){var t=null;try{if(Q().haGetDeviceInfo){var n=K(),i=Q().haGetDeviceInfo(e),o=K();t=r(i)?JSON.parse(i):i,$("get device info ".concat(e," use ").concat(o-n," ms. info: ").concat(JSON.stringify(t)))}}catch(e){console.error("json parse device info error.")}return t},G=window,Y={get:function(e){return G.localStorage.getItem(e)},set:function(e,t){try{G.localStorage.setItem(e,t)}catch(e){if(e.name===E)throw new Error(e.name);console.error(e)}},remove:function(e){G.localStorage.removeItem(e)},isSupport:function(){var e=!0;try{var t="__local_store_support__",n="testIsSupportStorage";this.set(t,n),this.get(t)!==n&&(e=!1),this.remove(t)}catch(t){e=!1}return e},length:function(){return G.localStorage.length},key:function(e){return G.localStorage.key(e)}},V=document,ee=function(e){var t=new RegExp("(^|;)[ ]*"+e+"=([^;]*)").exec(V.cookie);return t?decodeURIComponent(t[2]):null},te=function(e,t,n,i,r,o){if(e&&!/^(?:expires|max-age|path|domain|secure)$/i.test(e)){var s=[];if(s.push("".concat(e,"=").concat(encodeURIComponent(t))),n){var a=new Date;a.setTime(a.getTime()+n),s.push("expires=".concat(a.toUTCString()))}s.push("path=".concat(i||"/")),r&&s.push("domain=".concat(r)),!0===o&&s.push("secure"),V.cookie=s.join("; ")}},ne=function(e){var t=new Date;t.setTime(t.getTime()-1);var n=ee(e);c(n)||(V.cookie=e+"="+n+";expires="+t.toUTCString()+";path=/")};function ie(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];e.addEventListener?e.addEventListener(t,n,i):e.attachEvent("on".concat(t),n)}var re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],n=k(e.split("?"),2),i=n[0],r=n[1];if(!r)return e;var o=r.split("&").filter(function(e){return!L(t,e.split("=")[0].toLocaleLowerCase())});return o.length?"".concat(i,"?").concat(o.join("&")):i},oe=function(e){var t={};e.includes("#")&&(e=e.split("#")[0]);var n=e.split("?")[1];if(!n)return t;for(var i=n.split("&"),r=0;r<i.length;++r){var o=k(i[r].split("="),2),s=o[0],a=o[1];t[decodeURIComponent(s)]=decodeURIComponent(a)}return t},se=Object.freeze({__proto__:null,deleteUrlQuery:re,getQueryParamsFromUrl:oe}),ae=document,ce=document,ue=window,le=function(){return f(function e(){var t=this,n=arguments.length>0&&void 0!==arguments[0]&&arguments[0];h(this,e),this.isH5=n,this.waitTime=0,this.waitTimeFlagTime=0,this.waitTimeFlag=!0,this.accessTime=K(),this.config={defaultCookie:{},useCookie:!1,isInit:!1,usedPageUrl:!0,intervalTime:18e5,batchSend:!1,useUtm:!1},this.globals={idsite:"",title:ce.title,id:"unknown",rid:"unknown",idts:K(),idvc:0,idn:"",di:{sessionId:"unknown"},refts:K(),viewts:K(),CXX:"",uid:"",cvar:"",pvid:""},this.customData={},P(se,function(e,n){t[n]=e}),ie(ue,"beforeunload",this.beforeUnloadHandler.bind(this)),ie(ce,"visibilitychange",this.stateChanged.bind(this)),this.updateSessionId()},[{key:"getQueryData",value:function(){var e=oe(ue.location.href),t={},n=!1;for(var i in e)i.toUpperCase().includes(R)&&(n=!0,t[i]=e[i]);if(n){var r=this.getStoreName(R,C);sessionStorage.setItem(r,JSON.stringify(t))}}},{key:"updateSessionId",value:function(){var e=Z("sessionId");e&&e.sessionId&&(this.globals.di.sessionId=e.sessionId)}},{key:"beforeUnloadHandler",value:function(){this.config.isInit&&this.config.useCookie&&te(this.getStoreName(O),K(),7776e6,"/"),this.stateChanged()}},{key:"getStoreName",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:C,n=arguments.length>2?arguments[2]:void 0;return e&&this.globals.idsite?"".concat(t).concat(e,"_").concat(this.globals.idsite,"_").concat((n||location.host).replace(/\./g,"_")):""}},{key:"handleSessionId",value:function(){var e=this.getStoreName("idn"),t=ee(e);t||(t=H()),this.globals.idn=t,this.config.useCookie&&te(e,t,this.config.intervalTime,"/")}},{key:"stateChanged",value:function(){"visible"===ce.visibilityState&&this.updateSessionId(),"hidden"===ce.visibilityState&&this.config.batchSend&&this.batchSendNow(),this.waitTimeFlag?this.waitTime+=K()-(this.waitTimeFlagTime||this.accessTime):this.waitTimeFlagTime=K(),this.waitTimeFlag=!this.waitTimeFlag}},{key:"getData",value:function(e,t,n){var i=ue.navigator.userAgent,r=this.globals,o=r.id,s=r.rid,a=r.di,c=r.CXX,u=r.idsite,l=r.uid,h=r.cvar,d=r.idts,f=r.idvc,g=r.idn,v=r.refts,p=r.viewts,y=n,m=this.getStoreName(R,C);return sessionStorage.getItem(m)&&(y.utmData=JSON.parse(sessionStorage.getItem(m))),{type:e,vf:o,rid:s,nsid:a.sessionId,rt:t.eventTime,ut:i.match(/AppleWebKit.*Mobile.*/)?-1!==M(i," wv")?2:1:0,cxx:c,idsite:u,suid:l,cvar:t.cvar||h,idts:d,idvc:f,idn:g,refts:v,viewts:p,hsv:"2.2.9-501",data:y}}},{key:"getFinalSendData",value:function(e){var t=new Date,i=this.globals,r=i.title,o=i.id,s=i.idsite,a=i.cvar,c=i.idts,u=i.idvc,l=i.idn,h=i.refts,d=i.viewts,f=i.rid,g=i.di,v=this.config.usedPageUrl,p={idsite:encodeURIComponent(s),rec:"1",r:"886244",h:t.getHours(),m:t.getMinutes(),s:t.getSeconds(),url:encodeURIComponent(this.deleteUrlQuery(v?ue.location.href:"/",B)),_id:encodeURIComponent(o),_rid:encodeURIComponent(f),_nsid:encodeURIComponent(g.sessionId),_idts:c,_idvc:u,_idn:l,urlref:this.deleteUrlQuery(ce.referrer,B),_refts:h,_viewts:d,scd:"24",vpr:"".concat(ue.screen.width," X ").concat(ue.screen.height),cvar:n(e.cvar||a)?encodeURIComponent(JSON.stringify(e.cvar||a)):encodeURIComponent(e.cvar||a),pdf:"1",qt:"0",data:this.isH5?JSON.stringify(e):encodeURIComponent(JSON.stringify(e))};return"$PageLeave"===e.type||e.type===_||e.type===U?A({link:encodeURIComponent(r)},p):A({action_name:encodeURIComponent(r)},p)}},{key:"initCookie",value:function(e){this.config.isInit=!0;var t=this.config,n=t.useCookie,i=t.defaultCookie.domain;if(n){if(i){var r=this.getStoreName(x,C),o=this.getStoreName(N,C);ne(r),ne(o)}var s=this.getStoreName(x,C,i),a=this.getStoreName(N,C,i),c=ee(s),u=ee(a);e&&e(s,c,a,u,i),c||(Y.isSupport()&&Y.get(s)?(c=Y.get(s),u=Y.get(a)||K()):(c=H(),u=K()),te(s,c,7776e6,"/",i),te(a,u,7776e6,"/",i)),this.globals.id=c,this.globals.idts=u||K();var l=this.getStoreName("refts"),h=ee(l);h||ce.referrer&&(h=K(),te(l,h,7776e6,"/")),this.globals.refts=h||K();var d=this.getStoreName(O),f=ee(d);this.globals.viewts=f||K();var g=this.getStoreName("idvc"),v=ee(g);v=v?Number(v)+1:Y.isSupport()&&Y.get(g)?Number(Y.get(g))+1:1,te(g,v,7776e6,"/"),this.globals.idvc=v,Y.isSupport()&&!Y.get(s)&&(Y.set(s,c),Y.set(a,u),Y.set(g,v))}else this.globals.id="unknown",this.globals.idts=K(),this.globals.refts=K(),this.globals.viewts=K(),this.globals.idvc=0;this.handleSessionId()}},{key:"setIdsite",value:function(e){return r(e)?new RegExp("^[a-zA-Z0-9_./][A-Za-z0-9_./]*$").test(e)?(this.globals.idsite=e,this.initCookie(),this):(console.error("idsite is invalid."),this):(console.error("idsite type should be string."),this)}},{key:"setAutoTrack",value:function(e,t,i){var r=this;if(!n(e))return this;var o=function(t,n){var i=new t(r);i.init(e),n&&n(i)};if(t)o(t,i);else if(ue.HAAutoTracker)o(ue.HAAutoTracker,i);else{var s=K();!function(e,t){var n=ae.createElement("script");n.type="text/javascript",n.readyState?n.onreadystatechange=function(){"loaded"!==n.readyState&&"complete"!==n.readyState||(n.onreadystatechange=null,t())}:n.onload=t,n.src=e,ae.getElementsByTagName("head")[0].appendChild(n)}(e.autotracker_url,function(){var e=K();$("[load+excute] HAWebSDK autotracker module use ".concat(e-s," ms.")),o(ue.HAAutoTracker,i)})}return this}}])}(),he=function(){return f(function e(t,n,i){h(this,e),this.core=t,this.dataType=n,this.serverUrl=i,this.state=0,this.keys=[],this.queue=[],this.intervalID=null,this.storageDataLength=0,this.getStorageDataLength=!1},[{key:"isH5",value:function(){return!0===this.core.isH5||void 0!==Q().haGetDeviceInfo}},{key:"init",value:function(){var e=this;if(this.core.config.batchSend){P(["batchSend"],function(t){var n=e[t];e[t]=function(){0===this.state?n.apply(this,arguments):this.queue.push([t,arguments])}}),!this.intervalID&&this.core.config.batchSend.interval&&(this.intervalID=setInterval(function(){e.batchSend()},this.core.config.batchSend.interval))}else this.intervalID&&clearInterval(this.intervalID)}},{key:"batchSend",value:function(){var e=this,t=this.getEventsToSendFromStorage();0!==t.length&&(this.state=1,this.onReport(this.core.getFinalSendData(t),function(t){e.state=0,200===t.status?(e.core.config.batchSend.retryTimes=10,P(e.keys,function(e){Y.remove(e)}),e.storageDataLength=e.storageDataLength-e.keys.length,e.keys=[],e.batchSend(),e.queue.length>0&&(e[e.queue[0][0]].apply(e,e.queue[0][1]),e.queue=e.queue.splice(0,1))):e.core.config.batchSend.retryTimes<=1?e.intervalID&&clearInterval(e.intervalID):e.core.config.batchSend.retryTimes--},!0))}},{key:"onceSend",value:function(e,t){this.onReport(this.core.getFinalSendData(e),t,!1)}},{key:"clearStorageData",value:function(){for(var e=0,t=[];e<Y.length();){var n=Y.key(e);this.getKeyType(n)&&t.push(n),e++}P(t,function(e){Y.remove(e)}),this.storageDataLength=0}},{key:"getKeyType",value:function(e){return 0===M(e,D)&&-1!==M(e,this.core.globals.idsite)}},{key:"addToStorage",value:function(e,t){try{var n=this.core.config.maxStorageLength;if(!isNaN(n)&&n>0){if(!this.getStorageDataLength){this.getStorageDataLength=!0;for(var i=0;i<Y.length();){var r=Y.key(i);this.getKeyType(r)&&this.storageDataLength++,i++}}if(this.storageDataLength>=n){for(var o=Math.ceil(this.storageDataLength/2),s=0,a=[];s<Y.length();){var c=Y.key(s);this.getKeyType(c)&&a.push(c),s++}a=a.sort(function(e,t){return JSON.parse(Y.get(e)).rt-JSON.parse(Y.get(t)).rt});for(var u=0;u<o;u++)Y.remove(a[u]),this.storageDataLength--}}var l=JSON.stringify(e);if(Q().haEncrypt){var h=K();l=Q().haEncrypt(l);var d=K();$("data encrypt use ".concat(d-h," ms. encrypted data: ").concat(l))}Y.set(this.core.getStoreName(H(),D),l),!isNaN(n)&&n>0&&this.storageDataLength++}catch(n){n.message===E&&(this.onceSend(e,t),this.batchSend())}}},{key:"getEventsToSendFromStorage",value:function(){var e=[],t=0;if(this.isH5())for(var n=0;n<Y.length();n++){var i=Y.key(n);if(this.getKeyType(i)){var r=Z("network");if(r&&!1===r.network||"false"===r.network)return e;break}}for(;t<Y.length();){var o=Y.key(t);if(this.getKeyType(o)){var s=Y.get(o);try{if(Q().haDecrypt){var a=K();if(!(s=Q().haDecrypt(s))){Y.remove(o);continue}var c=K();$("data decrypt use ".concat(c-a," ms. decrypted data: ").concat(s))}(s=JSON.parse(s)).dataType===this.dataType&&(this.keys.push(o),delete s.dataType,e.push(s))}catch(e){console.error("get storage error.",e)}if(this.keys.length===this.core.config.batchSend.maxLength)return e}t++}return e}},{key:"getServerUrl",value:function(){var e="",t=this.core,n=t.globals.idsite,i=t.config,r=i.debugMode,o=i.customUrlParams,s=i.serverUrl;return r&&(e="x_hasdk_debug=true"),e=e?e+"&idsite="+n:"idsite="+n,q(o)&&(e=e+"&"+q(o)),(this.serverUrl||s)+"?"+e}},{key:"onReport",value:function(e,t,n){if(this.core.globals.idsite)if(this.core.config.serverUrl)if(this.core.config.batchSend&&n)this.sendByAjax(e,t);else if(this.core.config.requestMode)switch(this.core.config.requestMode){case"beacon":this.sendByBeacon(e);break;case"ajax":F()?this.sendByAjax(e,t):this.sendByBeacon(e);break;case"img":this.sendByImg(e)}else this.core.config.isImg?this.sendByImg(e):W()?this.sendByBeacon(e):F()?this.sendByAjax(e,t):this.sendByImg(e);else console.error("serverUrl is empty");else console.error("idsite is empty")}},{key:"sendByAjax",value:function(e,n){var i=q(e),r=new XMLHttpRequest;r.open("POST",this.getServerUrl(),!0),A(this.core.config.defaultHeaders,{idsite:this.core.globals.idsite}),P(this.core.config.defaultHeaders,function(e,t){r.setRequestHeader(t,e)}),this.core.config.batchSend&&(r.timeout=this.core.config.batchSend.timeout),r.send(i),r.onreadystatechange=function(){r.readyState==r.DONE&&n&&t(n)&&n(r)}}},{key:"sendByImg",value:function(e){var t=q(e);this.core.config.debugMode&&(t="x_hasdk_debug=true&"+t);var n=new Image(1,1);n.onerror=function(){},n.src=this.core.config.serverUrl+"?"+t}},{key:"sendByBeacon",value:function(e){var t=q(e),n=new Blob([t],{type:"application/x-www-form-urlencoded;charset=UTF-8"});navigator.sendBeacon(this.getServerUrl(),n)}}])}(),de=document,fe=window,ge=function(e){function c(){var e,t=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return h(this,c),(e=l(this,c,[t])).config.linker={},e.config.serverUrl="",e.config.requestMode="",e.config.isImg=!1,e.config.debugMode=!1,e.config.customUrlParams={},e.config.defaultHeaders={"Content-type":"application/x-www-form-urlencoded;charset=UTF-8"},e.config.maxStorageLength=0,e.defaultSender=new he(e),e.reportMap={},ie(de,"click",e.hrefIntercept.bind(e),!0),e}return y(c,e),f(c,[{key:"setMaxStorageLength",value:function(e){this.config.maxStorageLength=e}},{key:"urlAddLinker",value:function(e,t){if(!e)return e;var n=e.split("#"),i=n[0],r=n[1]?"#".concat(n[1]):"",o=i.replace(/(https|http):\/\/([^/?]+)(.*)/,"$2"),s=!1;if((this.config.linker.exclude&&(s=this.config.linker.exclude.includes(o)),this.config.linker.domains&&!s)&&this.config.linker.domains.filter(function(e){return new RegExp("".concat(e,"$"),"i").test(o)}).length){t&&t.preventDefault();var a=this.getStoreName(x,C,this.config.defaultCookie.domain),c={ts:K(),id:ee(a)};this.config.linker.ext&&(c.ext=this.config.linker.ext),i=M(i,"?")>-1?"".concat(i,"&ha_linker=").concat(fe.btoa(JSON.stringify(c))).concat(r):"".concat(i,"?ha_linker=").concat(fe.btoa(JSON.stringify(c))).concat(r)}return i}},{key:"hrefIntercept",value:function(e){var t=e.target||e.srcElement;if(!("a"===X(t))){var n=z(t);if(!n)return;t=n}var i=t.getAttribute("href");i&&(i=this.urlAddLinker(i,e),M(i,"ha_linker")>-1&&fe.open(i,t.getAttribute("target")||"_self"))}},{key:"initCookie",value:function(){var e,t,n,i,r,o=this;(e=c,t="initCookie",n=this,r=v(p(1&(i=3)?e.prototype:e),t,n),2&i&&"function"==typeof r?function(e){return r.apply(n,e)}:r)([function(e,t,n,i,r){var s=oe(de.location.href).ha_linker;if(s)try{var a=JSON.parse(fe.atob(s));!(K()-a.ts>(a.ext||1e4))&&a.id&&(t||(t=a.id,te(e,t,7776e6,"/",r),i=K(),te(n,i,7776e6,"/",r)),o.globals.rid=a.id)}catch(e){console.error("Invalid linker:"+e)}}])}},{key:"getSender",value:function(){var e=this,t=null;return P(this.reportMap,function(n){n.url===e.config.serverUrl&&(t=n.sender)}),t||this.defaultSender}},{key:"push",value:function(){for(var e=arguments,t=this,n=function(){var n=e[i],o=n.shift();setTimeout(function(){try{r(o)?t[o].apply(t,n):t.apply(t,n)}catch(e){console.error("Invalid method:"+o+", please check!")}},0)},i=0;i<arguments.length;++i)n();return this}},{key:"setOnReportUrl",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;this.config.serverUrl=e;var n=e;return a(t)||(n=t),this.reportMap[n]||(this.reportMap[n]={url:e,sender:new he(this,n,e)},this.config.batchSend&&this.reportMap[n].sender.init()),this}},{key:"setTitle",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.title=e,this}},{key:"setUserAccount",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.id=e,this}},{key:"setCXX",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.CXX=e,this}},{key:"setUid",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.uid=e,this}},{key:"setPageData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return this.globals.cvar=e,this}},{key:"setCustomData",value:function(e){return n(e)||t(e)?this.customData=e:console.error("The arguments of the setCustomData() method is invalid."),this}},{key:"setHttpHeader",value:function(e){return n(e)?(A(this.config.defaultHeaders,e),this):(console.error("custom header type should be object."),this)}},{key:"setIsUseCookie",value:function(e){if(!s(e))return console.error("useCookie type should be boolean"),this;if(this.config.useCookie=e,!this.config.useCookie){var t=de.cookie.split("; "),n=/^(HW_)(id|idts|idvc|idn|viewts|refts)_/;P(t,function(e){var t=e.split("=");n.test(t[0])&&ne(t[0])}),this.initCookie()}return this}},{key:"setIsUseUtm",value:function(e){return s(e)?(this.config.useUtm=e,e&&this.getQueryData(),this):(console.error("useUtm type should be boolean"),this)}},{key:"setReportMethod",value:function(e){return s(e)?(this.config.isImg=e,this):(console.error("isImg type should be boolean."),this)}},{key:"setSessionTimeoutDuration",value:function(e){return o(e)?(this.config.intervalTime=e,this):(console.error("intervalTime type should be number."),this)}},{key:"setDebugMode",value:function(e){return s(e)?(this.config.debugMode=e,this):(console.error("debugMode type should be boolean"),this)}},{key:"setCustomUrlParams",value:function(e){if(!n(e))return console.error("customUrlParams type should be object"),this;for(var t in e){if(L(["x_hasdk_debug","url","_id","_idts","_idvc","h","m","s","_rid"],t))return console.error("customUrlParams can'n include x_hasdk_debug, url, _id, _idts, _idvc, h, m, s, _rid"),this;var i=e[t];if(!i||!o(i)&&!r(i))return console.error("customUrlParams object value should be number or string"),this;if(!new RegExp("^[a-zA-Z0-9_./][A-Za-z0-9_./]*$").test(t)||!new RegExp("^[a-zA-Z_0-9_./][A-Za-z0-9_./]*$").test(i))return console.error("customUrlParams object include invalid key or value"),this;A(this.config.customUrlParams,g({},t,i))}return this}},{key:"setIstUseUrl",value:function(e){return s(e)?(this.config.usedPageUrl=e,this):(console.error("usedPageUrl type should be boolean."),this)}},{key:"setRequestMode",value:function(e){return"ajax"!==e||F()?"beacon"!==e||W()?(L(["beacon","ajax","img"],e)&&(this.config.requestMode=e),this):(console.error("navigator.sendBeacon() is not supported."),this):(console.error("XMLHttpRequest is not supported."),this)}},{key:"setBatchSend",value:function(e){if(!Y.isSupport())return console.error("localStorage is not supported, so batch send is not supported."),this;if(!F())return console.error("XMLHttpRequest is not supported, so batch send is not supported."),this;var t={timeout:6e3,interval:6e3,maxLength:6,retryTimes:10};return s(e)&&e?this.config.batchSend=t:n(e)&&(this.config.batchSend=A(t,e)),P(this.reportMap,function(e){e.sender&&e.sender.init()}),this}},{key:"batchSendNow",value:function(){return P(this.reportMap,function(e){e.sender&&e.sender.batchSend()}),this}},{key:"setLinker",value:function(e){return n(e)?i(e.domains)?e.exclude&&!i(e.exclude)?(console.error("custom exclude type should be Array."),this):(this.config.linker=e,this):(console.error("custom domains type should be Array."),this):(console.error("custom linker type should be object."),this)}},{key:"setUrlLinker",value:function(e){return this.urlAddLinker(e)}},{key:"setCookie",value:function(e){return n(e)?(this.config.defaultCookie=e,this):(console.error("custom cookie type should be object."),this)}},{key:"clearStorageData",value:function(){this.getSender().clearStorageData()}}])}(le),ve=document,pe=window,ye=ve.documentElement,me=ve.body;var be=document,ke=window,Se=function(e){function t(){var e;return h(this,t),(e=l(this,t)).config.baseinfotypeSwitch1=!1,e.switch1Num=0,e.config.baseinfotypeSwitch2=!1,e.switch2Num=0,e}return y(t,e),f(t,[{key:"setBaseinfotypeSwitch",value:function(e){return s(e)?(this.config.baseinfotypeSwitch1=e,e&&0===this.switch1Num&&(this.switch1Num++,ie(be,"DOMContentLoaded",this.reportPageEntryEvent.bind(this))),this):(console.error("baseinfotypeSwitch1 type should be boolean."),this)}},{key:"setWindowCloseSwitch",value:function(e){return s(e)?(this.config.baseinfotypeSwitch2=e,e&&0===this.switch2Num&&(this.switch2Num++,ie(ke,"beforeunload",this.reportPageCloseEvent.bind(this))),this):(console.error("baseinfotypeSwitch2 type should be boolean."),this)}},{key:"sendPageinfo",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.waitTime=0,this.waitTimeFlagTime=0,this.waitTimeFlag=!0,this.accessTime=K(),this.config.baseinfotypeSwitch1=!0,this.reportPageEntryEvent(e,t),this}},{key:"sendPageClose",value:function(){return this.config.baseinfotypeSwitch2=!0,this.reportPageCloseEvent(),this}},{key:"sendData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4?arguments[4]:void 0,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s={eventTime:K(),eventName:e,eventLabel:t,customData:n,cvar:i};return this.execReport(I,s,r,o),this}},{key:"sendClickData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4?arguments[4]:void 0,o=arguments.length>5&&void 0!==arguments[5]&&arguments[5],s={eventTime:K(),eventName:e,eventLabel:t,customData:n,cvar:i};return this.execReport(_,s,r,o),this}},{key:"bindclick",value:function(e,t,n,i,r){var o=this,s=arguments.length>5&&void 0!==arguments[5]&&arguments[5],a=e===be?be:be.getElementById(e);return a?(ie(a,t,function(t){var c=t.screenX,u=t.screenY,l=t.clientX,h=t.clientY,d=pe.innerHeight||ye.clientHeight||me.clientHeight||0,f=pe.innerWidth||ye.clientWidth||me.clientWidth||0,g={eventTime:K(),elementId:e,cls:a.className,data:n,cvar:i,position:{res:"".concat(c,"X").concat(u),vpr:"".concat(l,"X").concat(h),doc:"".concat(f,"X").concat(d)}};o.execReport(U,g,r,s)}),this):this}},{key:"reportPageEntryEvent",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.execReport(T,{eventTime:K()},e,t)}},{key:"reportPageCloseEvent",value:function(){this.execReport(T,{eventTime:K()})}},{key:"execReport",value:function(e,t,n){var i=arguments.length>3&&void 0!==arguments[3]&&arguments[3];this.handleSessionId();var r=this.getEventData(e,t),o=this.getSender();this.config.batchSend&&!i?(r.dataType=o.dataType,o.addToStorage(r,n)):o.onceSend(r,n)}},{key:"getEventData",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=t.currentUrl,i=void 0===n?ke.location.href:n,r={url:re(this.config.usedPageUrl?i:"/",B),title:this.globals.title,at:this.accessTime,rf:re(be.referrer,B)};e===T?(r.res="".concat(ke.screen.width," X ").concat(ke.screen.height),r.cwt=t.eventTime,r.dt=this.waitTime):e===I||e===_?(r.en=t.eventName,r.el=t.eventLabel,r.cd=t.customData,r.custom_properties=this.customData):e===U&&(r.ei=t.elementId===be?"#document":t.elementId,r.ec=t.cls,r.ps=t.position,r.data=t.data||"");var o=this.getData(e,t,r);return o.pvid=this.globals.pvid,o}}])}(ge),we=K(),Te=new Se,Ie=K();return $("[excute] hawebsdk use ".concat(Ie-we," ms.")),Te});
|
package/dist/index.d.mts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as winston from 'winston';
|
|
2
2
|
import * as child_process from 'child_process';
|
|
3
3
|
import { ChildProcessWithoutNullStreams } from 'child_process';
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
|
|
6
|
+
declare function collectErrorMessage(msg: string): void;
|
|
7
|
+
declare function getErrorMessages(): string[];
|
|
8
|
+
declare function clearErrorMessages(): void;
|
|
9
|
+
declare function setReportEnabled(enabled: boolean): void;
|
|
10
|
+
declare function isReportEnabled(): boolean;
|
|
6
11
|
declare const ASCF_LOG_FILE: string;
|
|
7
|
-
declare function setLoggerConfig(val:
|
|
8
|
-
declare function configureLogger(config: any): void;
|
|
12
|
+
declare function setLoggerConfig(val: string, extraTransports?: winston.transport[], enableConsole?: boolean): void;
|
|
9
13
|
declare function setLogLevelGetter(getLogLevel: () => string): void;
|
|
10
14
|
declare function getLogLevelGetter(): () => string;
|
|
11
15
|
declare class Logger {
|
|
12
16
|
categories: string;
|
|
13
|
-
logger: log4js.Logger;
|
|
14
|
-
fileLogger: log4js.Logger | undefined;
|
|
15
17
|
constructor(categories: string);
|
|
16
|
-
doLog(level:
|
|
18
|
+
doLog(level: string, message: any, args: any[], isExit?: boolean, isJson?: boolean): void;
|
|
17
19
|
info(message: any, ...args: any[]): void;
|
|
18
20
|
warn(message: any, ...args: any[]): void;
|
|
19
21
|
debug(message: any, ...args: any[]): void;
|
|
20
22
|
error(message: any, ...args: any[]): void;
|
|
21
23
|
fatal(message: any, ...args: any[]): void;
|
|
24
|
+
logJson(message: any, ...args: any[]): void;
|
|
22
25
|
}
|
|
23
|
-
declare function getLogger(categories:
|
|
26
|
+
declare function getLogger(categories: string): Logger;
|
|
27
|
+
declare function flushReporter(): Promise<void>;
|
|
24
28
|
|
|
25
29
|
declare const FASTAPP_LOADER_PKG_NAME = "com.huawei.fastapp.dev";
|
|
26
30
|
declare const LEGACY_DEVICE = "legacy";
|
|
@@ -30,6 +34,7 @@ declare const DEBUG_TYPE_SERVICE = "service";
|
|
|
30
34
|
declare const HARMONY_OS = "HarmonyOS";
|
|
31
35
|
declare const HDC_CONNECTOR = "hdc";
|
|
32
36
|
declare const ADB_CONNECTOR = "adb";
|
|
37
|
+
declare const BUILD_TARGET_AI = "AtomicServiceAI";
|
|
33
38
|
declare const V8_PORT = "9229";
|
|
34
39
|
|
|
35
40
|
type BuildModeType = 'debug' | 'release';
|
|
@@ -39,6 +44,7 @@ type BuilderOptions = {
|
|
|
39
44
|
deviceId?: string;
|
|
40
45
|
buildMode?: BuildModeType;
|
|
41
46
|
deviceType?: BuildDeviceType;
|
|
47
|
+
buildTarget?: string;
|
|
42
48
|
subCmd: string;
|
|
43
49
|
};
|
|
44
50
|
type DebuggerOptions = {
|
|
@@ -154,6 +160,7 @@ declare const TOOLS_DIR_OSX = "/Applications/DevEco-Studio.app/Contents/tools";
|
|
|
154
160
|
declare const TOOLS_DIR_WIN = "C:\\Program Files\\Huawei\\DevEco Studio\\tools";
|
|
155
161
|
declare const TOOLS_DIR_OPENHARMONY = "/data/app";
|
|
156
162
|
declare const DEFAULT_TOOLS_DIR: string;
|
|
163
|
+
declare function getEnvPath(): string;
|
|
157
164
|
declare function getDevEcoToolsDir(): string;
|
|
158
165
|
declare function getPath(...args: any[]): string;
|
|
159
166
|
declare function getNodePath(): string;
|
|
@@ -215,6 +222,12 @@ declare const BUILD_MODE_DEBUG = "debug";
|
|
|
215
222
|
declare const BUILD_MODE_RELEASE = "release";
|
|
216
223
|
declare function normalizeBuildMode(buildMode?: boolean | string): string;
|
|
217
224
|
declare const optArgIf: (key: string, value?: any, def?: any) => any[];
|
|
225
|
+
/**
|
|
226
|
+
* 判断模块是否为 HAR(静态共享包)
|
|
227
|
+
* @param srcPath 模块的 srcPath(如 entry、feature 等目录的绝对路径)
|
|
228
|
+
* @returns true if HAR, false otherwise(包括文件不存在、解析失败等异常情况)
|
|
229
|
+
*/
|
|
230
|
+
declare function isHarModule(srcPath: string): boolean;
|
|
218
231
|
|
|
219
232
|
declare function parseJsonSafe<T>(jsonStr: any, def: T): T;
|
|
220
233
|
declare function parseJsonFile<T>(filepath: any, def: T): T;
|
|
@@ -328,8 +341,13 @@ declare function fetchHttpsJson(url: string, options: any): Promise<any>;
|
|
|
328
341
|
declare function downloadApk(url: string, outputDir: string, vscodeProgress: any, options: any): Promise<string>;
|
|
329
342
|
|
|
330
343
|
declare const ASCF_CACHE_DIR: string;
|
|
344
|
+
declare const ASCF_TOOLS_DIR: string;
|
|
345
|
+
declare const HM_TOOLS_DIR: string;
|
|
346
|
+
declare function installDevtools(outputDir: string): Promise<string | undefined>;
|
|
347
|
+
declare function installDeveco(): Promise<string | undefined>;
|
|
331
348
|
declare function installAscfTools(): Promise<string>;
|
|
332
349
|
declare function installAscfConsole(outputDir: string): Promise<string | undefined>;
|
|
350
|
+
declare function installFlexuiDevserver(outputDir: string): Promise<string | undefined>;
|
|
333
351
|
|
|
334
352
|
/**
|
|
335
353
|
* 启动热加载服务的异步函数。
|
|
@@ -446,4 +464,51 @@ declare const debugPort: DebugPort;
|
|
|
446
464
|
declare function getEncryptPassword(storePath: string, password: string): string;
|
|
447
465
|
declare function getDecryptPassword(storePath: string, hexEncryptedMsg: string): string;
|
|
448
466
|
|
|
449
|
-
|
|
467
|
+
declare function detectDevice(): {
|
|
468
|
+
udid: string;
|
|
469
|
+
deviceName: string;
|
|
470
|
+
} | null;
|
|
471
|
+
declare function handleDevices(args: any): Promise<void>;
|
|
472
|
+
declare function getDevices(): Promise<any>;
|
|
473
|
+
|
|
474
|
+
declare function handleApplyCert(args: any): Promise<void>;
|
|
475
|
+
declare function handleListCert(args: any): Promise<void>;
|
|
476
|
+
|
|
477
|
+
declare function handleApplyP7b(args: any): Promise<void>;
|
|
478
|
+
|
|
479
|
+
declare function handleFingerprints(args: any): Promise<void>;
|
|
480
|
+
|
|
481
|
+
declare function getConfig(): {
|
|
482
|
+
clientId: string | undefined;
|
|
483
|
+
clientSecret: string | undefined;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* 从项目目录读取 app.json5 获取 app.bundleName
|
|
487
|
+
* @param {string} projectRoot - 项目根目录路径
|
|
488
|
+
* @returns {string|null} appId (bundleName)
|
|
489
|
+
*/
|
|
490
|
+
declare function getAppIdFromProject(projectRoot: string): string | null;
|
|
491
|
+
|
|
492
|
+
declare class Reporter {
|
|
493
|
+
private child;
|
|
494
|
+
private uniqueId;
|
|
495
|
+
private extraInfo;
|
|
496
|
+
private initialized;
|
|
497
|
+
private getChild;
|
|
498
|
+
init(): void;
|
|
499
|
+
collect(category: string, logInfo: string, level: string): void;
|
|
500
|
+
flush(): Promise<void>;
|
|
501
|
+
flushSync(onFlushed: () => void): void;
|
|
502
|
+
destroy(): void;
|
|
503
|
+
}
|
|
504
|
+
declare const reporter: Reporter;
|
|
505
|
+
|
|
506
|
+
declare function sanitize(text: string): string;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Get cache directory path for the current platform
|
|
510
|
+
* Supports: Windows, macOS, Linux
|
|
511
|
+
*/
|
|
512
|
+
declare function cachedir(id: string): string;
|
|
513
|
+
|
|
514
|
+
export { $async, ADB_CONNECTOR, ASCF_CACHE_DIR, ASCF_LOG_FILE, ASCF_TOOLS_DIR, AscfBuilder, AscfDebugger, AsyncResult, AtomicServiceAppIconChecker, BUILD_MODE_DEBUG, BUILD_MODE_RELEASE, BUILD_TARGET_AI, BuildProcessFactory, DEBUG_TYPE_SERVICE, DEBUG_TYPE_VIEW, DEFAULT_TOOLS_DIR, DebuggerProcessFactory, ERROR_MSG, FAIL, FASTAPP_LOADER_PKG_NAME, HARMONY_OS, HDC_CONNECTOR, HM_TOOLS_DIR, HOS_DEVICE, IS_MACOS, IS_OPENHARMONY, IS_WIN32, LEGACY_DEVICE, TOOLS_DIR_OPENHARMONY, TOOLS_DIR_OSX, TOOLS_DIR_WIN, type TemplateContext, TemplateEngine, type TemplateEngineOptions, type TemplateFile, type TemplateInfo, V8_PORT, ascfCompile, ascfConvert, ascfGenCert, ascfGenP12, ascfRun, buildAscfPara, cachedir, clearAscfDepDirCache, clearErrorMessages, collectErrorMessage, copyDirectory, createAscfComponent, createAscfPage, createAscfProject, createServiceWidget, debugPort, deepMerge, detectDevice, type deviceType, devicesLegacyShared, downloadApk, execSafe, fetchHttpsJson, fetchJson, findAvailablePort, fixHvigorPath, flushReporter, fportCmd, fportListCmd, fportRmCmd, getAdbPath, getAppIdFromProject, getAscfDebuggerPidFile, getAscfDepDir, getBuildProfile, getBundleInfo, getCmdAndArgs, getConfig, getDebugServerInfo, getDebugees, getDecryptPassword, getDevEcoSdkHome, getDevEcoToolsDir, getDeviceName, getDevices, getDevicesCmd, getEncryptPassword, getEnvPath, getErrorMessages, getHdcPath, getHvigorwPath, getJavaBinPath, getLegacyDeviceName, getLegacyHosVersion, getLegacyPackInfo, getLegacyProcess, getLogLevelGetter, getLogger, getNodeBinPath, getNodeDirPath, getNodePath, getNpmPath, getOhpmPath, getPath, getPid, getProjectConfig, getSpkInfo, handleApplyCert, handleApplyP7b, handleDevices, handleFingerprints, handleListCert, hasHvigor, hdcDeviceShared, hdcShared, installAscfConsole, installAscfTools, installDeveco, installDevtools, installFlexuiDevserver, installSpkShared, isAscfProject, isDirectoryExists, isHarModule, isMpProject, isObject, isPortReachable, isReportEnabled, listTargets, maskLast4, mergeJson, normalizeBuildMode, openInBrowser, optArgIf, parseJsonFile, parseJsonSafe, portManagerShared, reporter, rportCmd, rportRmCmd, runAdbCmdAsync, sanitize, setLogLevelGetter, setLoggerConfig, setReportEnabled, startDebugServerCmd, startHostPkg, startServer, stopDebugServer, tryAdbPortReversing, tryHdcPortReversing };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,30 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as winston from 'winston';
|
|
2
2
|
import * as child_process from 'child_process';
|
|
3
3
|
import { ChildProcessWithoutNullStreams } from 'child_process';
|
|
4
4
|
import * as http from 'http';
|
|
5
5
|
|
|
6
|
+
declare function collectErrorMessage(msg: string): void;
|
|
7
|
+
declare function getErrorMessages(): string[];
|
|
8
|
+
declare function clearErrorMessages(): void;
|
|
9
|
+
declare function setReportEnabled(enabled: boolean): void;
|
|
10
|
+
declare function isReportEnabled(): boolean;
|
|
6
11
|
declare const ASCF_LOG_FILE: string;
|
|
7
|
-
declare function setLoggerConfig(val:
|
|
8
|
-
declare function configureLogger(config: any): void;
|
|
12
|
+
declare function setLoggerConfig(val: string, extraTransports?: winston.transport[], enableConsole?: boolean): void;
|
|
9
13
|
declare function setLogLevelGetter(getLogLevel: () => string): void;
|
|
10
14
|
declare function getLogLevelGetter(): () => string;
|
|
11
15
|
declare class Logger {
|
|
12
16
|
categories: string;
|
|
13
|
-
logger: log4js.Logger;
|
|
14
|
-
fileLogger: log4js.Logger | undefined;
|
|
15
17
|
constructor(categories: string);
|
|
16
|
-
doLog(level:
|
|
18
|
+
doLog(level: string, message: any, args: any[], isExit?: boolean, isJson?: boolean): void;
|
|
17
19
|
info(message: any, ...args: any[]): void;
|
|
18
20
|
warn(message: any, ...args: any[]): void;
|
|
19
21
|
debug(message: any, ...args: any[]): void;
|
|
20
22
|
error(message: any, ...args: any[]): void;
|
|
21
23
|
fatal(message: any, ...args: any[]): void;
|
|
24
|
+
logJson(message: any, ...args: any[]): void;
|
|
22
25
|
}
|
|
23
|
-
declare function getLogger(categories:
|
|
26
|
+
declare function getLogger(categories: string): Logger;
|
|
27
|
+
declare function flushReporter(): Promise<void>;
|
|
24
28
|
|
|
25
29
|
declare const FASTAPP_LOADER_PKG_NAME = "com.huawei.fastapp.dev";
|
|
26
30
|
declare const LEGACY_DEVICE = "legacy";
|
|
@@ -30,6 +34,7 @@ declare const DEBUG_TYPE_SERVICE = "service";
|
|
|
30
34
|
declare const HARMONY_OS = "HarmonyOS";
|
|
31
35
|
declare const HDC_CONNECTOR = "hdc";
|
|
32
36
|
declare const ADB_CONNECTOR = "adb";
|
|
37
|
+
declare const BUILD_TARGET_AI = "AtomicServiceAI";
|
|
33
38
|
declare const V8_PORT = "9229";
|
|
34
39
|
|
|
35
40
|
type BuildModeType = 'debug' | 'release';
|
|
@@ -39,6 +44,7 @@ type BuilderOptions = {
|
|
|
39
44
|
deviceId?: string;
|
|
40
45
|
buildMode?: BuildModeType;
|
|
41
46
|
deviceType?: BuildDeviceType;
|
|
47
|
+
buildTarget?: string;
|
|
42
48
|
subCmd: string;
|
|
43
49
|
};
|
|
44
50
|
type DebuggerOptions = {
|
|
@@ -154,6 +160,7 @@ declare const TOOLS_DIR_OSX = "/Applications/DevEco-Studio.app/Contents/tools";
|
|
|
154
160
|
declare const TOOLS_DIR_WIN = "C:\\Program Files\\Huawei\\DevEco Studio\\tools";
|
|
155
161
|
declare const TOOLS_DIR_OPENHARMONY = "/data/app";
|
|
156
162
|
declare const DEFAULT_TOOLS_DIR: string;
|
|
163
|
+
declare function getEnvPath(): string;
|
|
157
164
|
declare function getDevEcoToolsDir(): string;
|
|
158
165
|
declare function getPath(...args: any[]): string;
|
|
159
166
|
declare function getNodePath(): string;
|
|
@@ -215,6 +222,12 @@ declare const BUILD_MODE_DEBUG = "debug";
|
|
|
215
222
|
declare const BUILD_MODE_RELEASE = "release";
|
|
216
223
|
declare function normalizeBuildMode(buildMode?: boolean | string): string;
|
|
217
224
|
declare const optArgIf: (key: string, value?: any, def?: any) => any[];
|
|
225
|
+
/**
|
|
226
|
+
* 判断模块是否为 HAR(静态共享包)
|
|
227
|
+
* @param srcPath 模块的 srcPath(如 entry、feature 等目录的绝对路径)
|
|
228
|
+
* @returns true if HAR, false otherwise(包括文件不存在、解析失败等异常情况)
|
|
229
|
+
*/
|
|
230
|
+
declare function isHarModule(srcPath: string): boolean;
|
|
218
231
|
|
|
219
232
|
declare function parseJsonSafe<T>(jsonStr: any, def: T): T;
|
|
220
233
|
declare function parseJsonFile<T>(filepath: any, def: T): T;
|
|
@@ -328,8 +341,13 @@ declare function fetchHttpsJson(url: string, options: any): Promise<any>;
|
|
|
328
341
|
declare function downloadApk(url: string, outputDir: string, vscodeProgress: any, options: any): Promise<string>;
|
|
329
342
|
|
|
330
343
|
declare const ASCF_CACHE_DIR: string;
|
|
344
|
+
declare const ASCF_TOOLS_DIR: string;
|
|
345
|
+
declare const HM_TOOLS_DIR: string;
|
|
346
|
+
declare function installDevtools(outputDir: string): Promise<string | undefined>;
|
|
347
|
+
declare function installDeveco(): Promise<string | undefined>;
|
|
331
348
|
declare function installAscfTools(): Promise<string>;
|
|
332
349
|
declare function installAscfConsole(outputDir: string): Promise<string | undefined>;
|
|
350
|
+
declare function installFlexuiDevserver(outputDir: string): Promise<string | undefined>;
|
|
333
351
|
|
|
334
352
|
/**
|
|
335
353
|
* 启动热加载服务的异步函数。
|
|
@@ -446,4 +464,51 @@ declare const debugPort: DebugPort;
|
|
|
446
464
|
declare function getEncryptPassword(storePath: string, password: string): string;
|
|
447
465
|
declare function getDecryptPassword(storePath: string, hexEncryptedMsg: string): string;
|
|
448
466
|
|
|
449
|
-
|
|
467
|
+
declare function detectDevice(): {
|
|
468
|
+
udid: string;
|
|
469
|
+
deviceName: string;
|
|
470
|
+
} | null;
|
|
471
|
+
declare function handleDevices(args: any): Promise<void>;
|
|
472
|
+
declare function getDevices(): Promise<any>;
|
|
473
|
+
|
|
474
|
+
declare function handleApplyCert(args: any): Promise<void>;
|
|
475
|
+
declare function handleListCert(args: any): Promise<void>;
|
|
476
|
+
|
|
477
|
+
declare function handleApplyP7b(args: any): Promise<void>;
|
|
478
|
+
|
|
479
|
+
declare function handleFingerprints(args: any): Promise<void>;
|
|
480
|
+
|
|
481
|
+
declare function getConfig(): {
|
|
482
|
+
clientId: string | undefined;
|
|
483
|
+
clientSecret: string | undefined;
|
|
484
|
+
};
|
|
485
|
+
/**
|
|
486
|
+
* 从项目目录读取 app.json5 获取 app.bundleName
|
|
487
|
+
* @param {string} projectRoot - 项目根目录路径
|
|
488
|
+
* @returns {string|null} appId (bundleName)
|
|
489
|
+
*/
|
|
490
|
+
declare function getAppIdFromProject(projectRoot: string): string | null;
|
|
491
|
+
|
|
492
|
+
declare class Reporter {
|
|
493
|
+
private child;
|
|
494
|
+
private uniqueId;
|
|
495
|
+
private extraInfo;
|
|
496
|
+
private initialized;
|
|
497
|
+
private getChild;
|
|
498
|
+
init(): void;
|
|
499
|
+
collect(category: string, logInfo: string, level: string): void;
|
|
500
|
+
flush(): Promise<void>;
|
|
501
|
+
flushSync(onFlushed: () => void): void;
|
|
502
|
+
destroy(): void;
|
|
503
|
+
}
|
|
504
|
+
declare const reporter: Reporter;
|
|
505
|
+
|
|
506
|
+
declare function sanitize(text: string): string;
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* Get cache directory path for the current platform
|
|
510
|
+
* Supports: Windows, macOS, Linux
|
|
511
|
+
*/
|
|
512
|
+
declare function cachedir(id: string): string;
|
|
513
|
+
|
|
514
|
+
export { $async, ADB_CONNECTOR, ASCF_CACHE_DIR, ASCF_LOG_FILE, ASCF_TOOLS_DIR, AscfBuilder, AscfDebugger, AsyncResult, AtomicServiceAppIconChecker, BUILD_MODE_DEBUG, BUILD_MODE_RELEASE, BUILD_TARGET_AI, BuildProcessFactory, DEBUG_TYPE_SERVICE, DEBUG_TYPE_VIEW, DEFAULT_TOOLS_DIR, DebuggerProcessFactory, ERROR_MSG, FAIL, FASTAPP_LOADER_PKG_NAME, HARMONY_OS, HDC_CONNECTOR, HM_TOOLS_DIR, HOS_DEVICE, IS_MACOS, IS_OPENHARMONY, IS_WIN32, LEGACY_DEVICE, TOOLS_DIR_OPENHARMONY, TOOLS_DIR_OSX, TOOLS_DIR_WIN, type TemplateContext, TemplateEngine, type TemplateEngineOptions, type TemplateFile, type TemplateInfo, V8_PORT, ascfCompile, ascfConvert, ascfGenCert, ascfGenP12, ascfRun, buildAscfPara, cachedir, clearAscfDepDirCache, clearErrorMessages, collectErrorMessage, copyDirectory, createAscfComponent, createAscfPage, createAscfProject, createServiceWidget, debugPort, deepMerge, detectDevice, type deviceType, devicesLegacyShared, downloadApk, execSafe, fetchHttpsJson, fetchJson, findAvailablePort, fixHvigorPath, flushReporter, fportCmd, fportListCmd, fportRmCmd, getAdbPath, getAppIdFromProject, getAscfDebuggerPidFile, getAscfDepDir, getBuildProfile, getBundleInfo, getCmdAndArgs, getConfig, getDebugServerInfo, getDebugees, getDecryptPassword, getDevEcoSdkHome, getDevEcoToolsDir, getDeviceName, getDevices, getDevicesCmd, getEncryptPassword, getEnvPath, getErrorMessages, getHdcPath, getHvigorwPath, getJavaBinPath, getLegacyDeviceName, getLegacyHosVersion, getLegacyPackInfo, getLegacyProcess, getLogLevelGetter, getLogger, getNodeBinPath, getNodeDirPath, getNodePath, getNpmPath, getOhpmPath, getPath, getPid, getProjectConfig, getSpkInfo, handleApplyCert, handleApplyP7b, handleDevices, handleFingerprints, handleListCert, hasHvigor, hdcDeviceShared, hdcShared, installAscfConsole, installAscfTools, installDeveco, installDevtools, installFlexuiDevserver, installSpkShared, isAscfProject, isDirectoryExists, isHarModule, isMpProject, isObject, isPortReachable, isReportEnabled, listTargets, maskLast4, mergeJson, normalizeBuildMode, openInBrowser, optArgIf, parseJsonFile, parseJsonSafe, portManagerShared, reporter, rportCmd, rportRmCmd, runAdbCmdAsync, sanitize, setLogLevelGetter, setLoggerConfig, setReportEnabled, startDebugServerCmd, startHostPkg, startServer, stopDebugServer, tryAdbPortReversing, tryHdcPortReversing };
|