diff --git a/assets/Script/GameManager.ts b/assets/Script/GameManager.ts index ec416f8..cdd1553 100644 --- a/assets/Script/GameManager.ts +++ b/assets/Script/GameManager.ts @@ -278,6 +278,7 @@ export default class GameManager extends cc.Component { readUserData(retryCount = 0) { //@ts-ignore if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { + MiniGameSdk.API.tencent_Init(); MiniGameSdk.API.shushu_Init(); this.nowTime = Date.now(); // 最大重试次数 @@ -306,6 +307,7 @@ export default class GameManager extends cc.Component { if (data.data.openid) { cc.fx.GameConfig.GM_INFO.openid = data.data.openid; cc.fx.StorageMessage.setStorage("openid", cc.fx.GameConfig.GM_INFO.openid); + MiniGameSdk.API.tencent_SetOpenId(cc.fx.GameConfig.GM_INFO.openid); } console.log("系统信息________:", data.data.version); @@ -835,7 +837,7 @@ export default class GameManager extends cc.Component { cc.fx.GameTool.shushu_Track("register", data); MiniGameSdk.API.shushu_SetSuperProperties(time, false); - + MiniGameSdk.API.tencent_OnRegister(); } /** 主循环,判断是否各项加载完成进入游戏 */ update(dt) { @@ -844,9 +846,98 @@ export default class GameManager extends cc.Component { MiniGameSdk.API.shushu_Login(); MiniGameSdk.API.yinli_Init(); MiniGameSdk.API.yinli_Login(); + this.setWX(); if (this.register_time != 0) MiniGameSdk.API.shushu_userSet(this.register_time); this.startGame(); } } + setWX() { + //@ts-ignore + if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { // 判断是否在微信环境 + //@ts-ignore + wx.setPreferredFramesPerSecond(60); + // // 设置转发按钮点击后的回调 + + let iphoneArr = [ + "https://mmocgame.qpic.cn/wechatgame/Lf3SBqy9XpNkakoIZygRzXqww3HTibq6VyibazqmicwibjCS3YpgqbZtkdyABm4Y1wAr/0", + "https://mmocgame.qpic.cn/wechatgame/TWKuFxnCn7ksT3KXfhCC4yOfZeD4b0hrptDSJ2DFmwz02Yc8SppcwyPAOoS1MsMr/0", + "https://mmocgame.qpic.cn/wechatgame/dibaH2x79o1wSwBDymhyzXwfcyicaDb6R5icrFIO7251T4NgxIzXRXErHvAvn50vXFA/0", + "https://mmocgame.qpic.cn/wechatgame/Pgxad80d8ws3o69OicV3DTuTkcP81upQeJ0JBNS1xib3pzYLTF1ZqGY3niciaI7ICKlL/0", + "https://mmocgame.qpic.cn/wechatgame/SfB1vrRBIHKn9ffKFt5sib62yPLE31m2rCvk6DKlEicJNVZSoryEObD6ItwsQn4xibR/0", + "https://mmocgame.qpic.cn/wechatgame/OiaWk33I6QjgWiatrb5YVUq2p0QRmQgO6rLUWxEQDZ4ib9Ny4Pr8iaHnHI6WdxibY2nPL/0", + "https://mmocgame.qpic.cn/wechatgame/CG5xBibollws251aYD4msEPWCiafrcn4Fgtic4T2wME6sWmdfAUtfibgsWoxm59VadDD/0" + ] + let randomIphone = iphoneArr[Math.floor(Math.random() * iphoneArr.length)]; + let img = randomIphone; + // const title = + // 构建分享参数 + const shareParams = { + title: '快来一起玩这个超有趣的小游戏吧!', // 修改为默认分享标题 + imageUrl: 'https://example.com/default_share_image.jpg' // 修改为默认分享图片 + }; + //@ts-ignore + // 仅设置分享内容,不主动触发分享 + wx.onShareAppMessage(() => shareParams); + + + // 监听分享到朋友圈事件 + //@ts-ignore + wx.onShareTimeline(() => { + return { + title: '你想玩上怎样的游戏?' + }; + }); + //@ts-ignore + wx.showShareMenu(() => { + return { + title: '你想玩上怎样的游戏?', + imageUrl: img, + query: '' + }; + }); + + setTimeout(() => { + //@ts-ignore + wx.showShareMenu({ + menus: ['shareAppMessage', 'shareTimeline'] + }) + }, 2000); + + setTimeout(() => { + //@ts-ignore + wx.showShareMenu({ + menus: ['shareAppMessage', 'shareTimeline'] + }) + }, 4000); + + //@ts-ignore + wx.onAddToFavorites(() => { + console.log("收藏成功"); + MiniGameSdk.API.tencent_ADD_TO_WISHLIST(); + return { + title: '收藏标题', + imageUrl: '' // 图片 URL + } + }) + + // 设置分享到朋友圈 + //@ts-ignore + // wx.updateShareMenu({ + // withShareTicket: true, + // success: (data) => { + // console.log('更新分享菜单成功', data); + // }, + // fail: (data) => { + // console.log('更新分享菜单失败', data); + // }, + // complete: (data) => { + // console.log('更新分享菜单完成', data); + // } + // }); + //@ts-ignore + } + + } + } diff --git a/assets/Script/Sdk/MiniGameSdk.ts b/assets/Script/Sdk/MiniGameSdk.ts index 1556d46..fd1a68c 100644 --- a/assets/Script/Sdk/MiniGameSdk.ts +++ b/assets/Script/Sdk/MiniGameSdk.ts @@ -1,3 +1,4 @@ +import { SDK } from './index.js'; import Utils from "../module/Pay/Utils"; import { getProvinceName } from "../module/Position/GetPosition"; // import { getProvinceName } from "../module/Position/ProvinceLocator"; @@ -972,6 +973,7 @@ export namespace MiniGameSdk { private static _userInfo: any = null; private static _ta: any = null; private static _ge: any = null; + static _tencent: any; /** * 分享app给朋友,微信小游戏分享是没有onSuccess回调的。 * @param title 标题 @@ -1525,6 +1527,45 @@ export namespace MiniGameSdk { } } + //#region 腾讯平台SDK + /* + * 腾讯平台SDK初始化以及登录 + */ + static tencent_Init() { + //@ts-ignore + if ((typeof wx !== 'undefined' && wx !== null) || (typeof tt !== 'undefined' && tt !== null)) { + // console.log("开始接入腾讯平台"); + //getWechatGameVersion + // 初始化SDK + try { + API._tencent = new SDK({ + user_action_set_id: 1215720469, + secret_key: "26d13a9ee610ad406cb04b2b745df8a8", + appid: "wxdd145ced49158a1e", + auto_track: true, + }); + } catch (error) { + console.error(error); + } + } + } + + static tencent_Purchase(payAmount: number) { + if (API._tencent) API._tencent.onPurchase(payAmount); + } + + static tencent_SetOpenId(openId: string) { + if (API._tencent) API._tencent.setOpenId(cc.fx.GameConfig.GM_INFO.openid); + } + + static tencent_OnRegister() { + if (API._tencent) API._tencent.onRegister(); + } + + static tencent_ADD_TO_WISHLIST() { + if (API._tencent) API._tencent.onAddToWishlist(); + } + //#region 数数平台 /* * 数数平台初始化以及登录 diff --git a/assets/Script/Sdk/index.js b/assets/Script/Sdk/index.js new file mode 100644 index 0000000..91d9d28 --- /dev/null +++ b/assets/Script/Sdk/index.js @@ -0,0 +1,6 @@ +/** + * @dn-sdk/minigame v1.5.11 + * (c) 2026 + * @license ISC + */ +function t(t,e,n){return(e=v(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function e(t){return function(t){if(Array.isArray(t))return r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||n(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n-1?O:e.indexOf("IOS")>-1?I:e.indexOf("MAC")>-1?C:e.indexOf("WINDOWS")>-1?w:x}(i[0]),a=function(t){return!t||t.length<=0?"":2===t.length?t[1]:3===t.length&&"Windows"===t[0]?"".concat(t[1]," ").concat(t[2]):t[t.length-1]}(i);t={benchmark_level:e.benchmarkLevel,device_brand:e.brand,screen_height:Math.floor(e.screenHeight),screen_width:Math.floor(e.screenWidth),wx_lib_version:e.SDKVersion,wx_version:e.version,wx_platform:e.platform,device_model:e.model,os:o,os_version:a}}return t}}(),rt=function(){var t;return function(){try{if(t)return t;t||(t=tt.getSync(g)||""),t||(t=mt(),tt.setSync(g,t))}catch(t){}return t}}();var it=function(){var t="unknown",e=!1;return function(){if(!e)try{wx.getNetworkType({success:function(e){t=e.networkType},fail:function(){t="unknown"}}),wx.onNetworkStatusChange((function(e){t=e.networkType})),e=!0}catch(t){}return t}}();it();var ot=function(){var t="";return function(){return t||(t=tt.getSync(S)||""),t}}(),at=function(){var t;return function(){if(t)return t;try{var e=wx.getAccountInfoSync();return ht(e.miniProgram)?t=e.miniProgram:{}}catch(e){return{}}}}();function ut(t){var e=null==t?void 0:t.query;if(!ht(e))return"";var n="";return e.gdt_vid||[1045,1046,1084].indexOf(null==t?void 0:t.scene)>-1?n=Y:e.clue_token||e.clickid&&e.item_id?n=J:e.callback&&"kuaishou"===e.ksChannel?n=W:e.bd_vid||e.ai&&e.d&&e.q&&e.c?n=z:e.uctrackid?n=H:(e.trackid||e.imp||[1065,1069,1194].indexOf(null==t?void 0:t.scene)>-1&&(e.callback||e.u))&&(n=$),n}function ct(t,e){try{var n=nt(),r=at(),i={sdk_version:"1.5.11",sdk_name:"@dn-sdk/minigame",device_brand:null==n?void 0:n.device_brand,device_model:null==n?void 0:n.device_model,wx_version:null==n?void 0:n.wx_version,wx_lib_version:null==n?void 0:n.wx_lib_version,wx_platform:null==n?void 0:n.wx_platform,os:null==n?void 0:n.os,os_version:null==n?void 0:n.os_version,local_id:rt(),env_version:null==r?void 0:r.envVersion,appid:null==r?void 0:r.appId},o=Object.assign(i,t);wx.request({url:"https://api.datanexus.qq.com/data-nexus-trace/log",data:o,method:"POST",timeout:E.requestTimeout,success:function(t){"function"==typeof e&&200===(null==t?void 0:t.statusCode)&&e()}})}catch(n){xt.error(n)}}var st=function(){function t(){d(this,t)}return p(t,null,[{key:"revise",value:function(t){t>0&&!this.isRevised&&(this.offsetTime=t-Date.now(),this.isRevised=!0)}},{key:"getRevisedcurrentTimeMillis",value:function(){return this.isRevised?Date.now()+this.offsetTime:-1}}]),t}();function lt(t){return new Promise((function(e,n){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/config/get",data:t,timeout:E.requestTimeout,success:function(t){dt(t,e,"config/get",n),pt(t)},fail:function(t){ft(t,"config/get",n)}})}))}function dt(t,e,n,r){var i,o,a,u,c=null==t?void 0:t.statusCode,s=null==(i=null==t?void 0:t.data)?void 0:i.code;if(200!==c||0!==s){var l=s;200!==c&&(l="number"==typeof c?-1*c:-888),ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(n,", statusCode: ").concat(c,", code: ").concat(s,", traceid: ").concat(null==(a=null==t?void 0:t.data)?void 0:a.trace_id),code:l}),null==r||r(null==(u=null==t?void 0:t.data)?void 0:u.data)}else e(null==(o=t.data)?void 0:o.data)}function ft(t,e,n){ct({log_type:b.REQUEST_CONFIG_ERROR,message:"cgiName: ".concat(e," , message: ").concat(null==t?void 0:t.errMsg," "),code:"number"==typeof(null==t?void 0:t.errno)?-1*t.errno:-999}),null==n||n(t)}function pt(t){var e,n=1*(null==(e=null==t?void 0:t.header)?void 0:e["Server-Time"]);n>17266752e5&&st.revise(n)}st.offsetTime=0,st.isRevised=!1;var vt=Object.prototype.toString,ht=function(t){return"[object Object]"===vt.call(t)},_t=function(t){return"[object Array]"===vt.call(t)},gt=function(t){return"[object Function]"===vt.call(t)},yt=(new Date).getTime();function mt(){var t=(new Date).getTime(),e=Math.abs(1e3*(t-yt));return"xxxxxxxxxxxx4xxxyxxxxxxxxxxxxxxx".replace(/[xy]/g,(function(n){var r=16*Math.random();return t>0?(r=(t+r)%16|0,t=Math.floor(t/16)):(r=(e+r)%16|0,e=Math.floor(e/16)),("x"===n?r:3&r|8).toString(16).replace(/-/g,"")}))}var At=/^v?(?:\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+)(\.(?:[x*]|\d+))?(?:-[\da-z\-]+(?:\.[\da-z\-]+)*)?(?:\+[\da-z\-]+(?:\.[\da-z\-]+)*)?)?)?$/i,Rt=function(t){if("string"!=typeof t)throw new TypeError("Invalid argument expected string");if(!At.test(t))throw new Error("Invalid argument not valid semver ('".concat(t,"' received)"))},kt=function(t){return isNaN(Number(t))?t:Number(t)},St=function(t){var e=t.replace(/^v/,"").replace(/\+.*$/,""),n=function(t,e){return-1===t.indexOf(e)?t.length:t.indexOf(e)}(e,"-"),r=e.substring(0,n).split(".");return r.push(e.substring(n+1)),r},Tt=function(t,e){[t,e].forEach(Rt);for(var n=St(t),r=St(e),i=0;ia)return 1;if(a>o)return-1}var u=n[n.length-1],c=r[r.length-1];if(u&&c)for(var s=u.split(".").map(kt),l=c.split(".").map(kt),d=0;dl[d])return 1;if(l[d]>s[d])return-1}else if(u||c)return u?-1:1;return 0},Et=function(t){return ht(t)?(function(t){var e=["user_action_set_id","secret_key","appid","openid","unionid","user_unique_id","auto_track","auto_attr","on_report_fail","on_report_complete"];for(var n in t)e.includes(n)||xt.warn("Invalid property '".concat(n,"' found in config"))}(t),"number"!=typeof t.user_action_set_id?"user_action_set_id 参数需为 number 类型":t.user_action_set_id<=0?"user_action_set_id 参数需大于 0":"string"!=typeof t.secret_key?"secret_key 参数需为 string 类型":""===t.secret_key.trim()?"缺少 secret_key 参数":32!==t.secret_key.length?"secret_key 参数需为 32 位字符串":"string"!=typeof t.appid?"appid 参数需为 string 类型":""!==t.appid.trim()||"缺少 appid"):"初始化参数需为 object 类型"};function bt(t){return Ot()[t]}function Ot(){return E}function It(t,e){return Object.prototype.hasOwnProperty.call(t,e)}var wt=function(t){try{return t&&"string"==typeof t?-1===(t=t.replace(/\s/g,"")).indexOf(".")?t:t.split(".").slice(0,2).join("."):""}catch(e){return t}},Ct=function(){function t(){d(this,t)}return p(t,null,[{key:"error",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),i=1;i1?r-1:0),o=1;o1?r-1:0),o=1;o1?n-1:0),i=1;i1?r-1:0),o=1;o1e4&&(r=JSON.stringify({cut:1,scene:e.scene})),t={source_scene:e.scene,pkg_channel_id:e.query.wxgamepro||"",ad_trace_id:n,launch_options:r,channel:ut(e)}}catch(e){t={},xt.log("获取场景值和渠道号失败",e)}return t}}();function Dt(t,e,n){var r=n.value;return n.value=function(){for(var n=arguments.length,i=new Array(n),o=0;o1?void 0:r?Pt(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);return r&&o&&Mt(e,n,o),o},Ut=function(){function t(e){var n=e.userActionSetId,r=e.maxLength,i=void 0===r?500:r;d(this,t),this.lostActionMaps={},this.stack=[],this.localStorageKey="",this.localStorageKey="".concat(y,"_").concat(null==n?void 0:n.toString()),this.maxLength=i,this.userActionSetId=n,this.setTimeStamp(),this.init()}return p(t,[{key:"getItems",value:function(){return this.stack}},{key:"getStorage",value:function(){var t,e=(null==(t=tt)?void 0:t.getSync(this.localStorageKey))||"[]";return JSON.parse(e)}},{key:"reportLostNum",value:function(){var t=this,e=Object.assign({},this.lostActionMaps),n=[];for(var r in e){var i=null==r?void 0:r.split("_");n.push({queue_lost_session_id:i[0],queue_lost_timestamp:i[1],queue_lost_num:e[r]})}n.length&&(this.setTimeStamp(),n.forEach((function(e){var n=Object.assign({},{user_action_set_id:t.userActionSetId,log_type:b.QUEUE_LOST_NUM},e),r=null==e?void 0:e.queue_lost_session_id,i=null==e?void 0:e.queue_lost_timestamp,o="".concat(r,"_").concat(i);ct(n,(function(){It(t.lostActionMaps,o)&&(delete t.lostActionMaps[o],tt.setSync(A,JSON.stringify(t.lostActionMaps)))}))})))}},{key:"getLostMaps",value:function(){return this.lostActionMaps}},{key:"init",value:function(){var t=this,e=this.getStorage(),n=null==e?void 0:e.map((function(t){var e,n;return t.inner_status===(null==(e=T)?void 0:e.reporting)?Object.assign({},t,{inner_status:null==(n=T)?void 0:n.fail,is_retry:!0,retry_count:t.retry_count+1}):t}));this.stack=n,this.lostActionMaps=JSON.parse(tt.getSync(A)||"{}"),setTimeout((function(){t.reportLostNum()}),1e3)}},{key:"addItem",value:function(t){var e;null==(e=null==this?void 0:this.stack)||e.push(t)}},{key:"removeItems",value:function(t){var e,n=null==(e=null==this?void 0:this.stack)?void 0:e.filter((function(e){return!(null!=t&&t.includes(null==e?void 0:e.action_id))}));this.stack=n}},{key:"updateForReportFail",value:function(t){var e;this.stack=null==(e=this.stack)?void 0:e.map((function(e){var n;return null!=t&&t.includes(null==e?void 0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void 0:n.fail,retry_count:e.retry_count+1,is_retry:!0}):e}))}},{key:"updateForReporting",value:function(t){var e;this.stack=null==(e=this.stack)?void 0:e.map((function(e){var n;return null!=t&&t.includes(null==e?void 0:e.action_id)?Object.assign({},e,{inner_status:null==(n=T)?void 0:n.reporting}):e}))}},{key:"updateAllStack",value:function(t){this.stack=t}},{key:"updateToStorage",value:function(){tt.setSync(this.localStorageKey,JSON.stringify(this.stack))}},{key:"updateLostAction",value:function(t){if(t){var e="".concat(t,"_").concat(this.timeStamp),n=this.lostActionMaps[e]||0;this.lostActionMaps[e]=n+1,tt.setSync(A,JSON.stringify(this.lostActionMaps))}}},{key:"setTimeStamp",value:function(){this.timeStamp=Date.now().toString()}}]),t}();qt([Dt],Ut.prototype,"getItems",1),qt([Dt],Ut.prototype,"getStorage",1),qt([Dt],Ut.prototype,"reportLostNum",1),qt([Dt],Ut.prototype,"getLostMaps",1),qt([Dt],Ut.prototype,"init",1),qt([Dt],Ut.prototype,"addItem",1),qt([Dt],Ut.prototype,"removeItems",1),qt([Dt],Ut.prototype,"updateForReportFail",1),qt([Dt],Ut.prototype,"updateForReporting",1),qt([Dt],Ut.prototype,"updateAllStack",1),qt([Dt],Ut.prototype,"updateToStorage",1),qt([Dt],Ut.prototype,"updateLostAction",1);var jt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Gt=function(t,e,n,r){for(var i,o=r>1?void 0:r?Ft(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);return r&&o&&jt(e,n,o),o},Bt=function(t){i(n,Ut);var e=a(n);function n(t){var r,i=t.userActionSetId,o=t.maxLength,a=void 0===o?500:o,u=t.ogEvents,c=void 0===u?[]:u;return d(this,n),(r=e.call(this,{userActionSetId:i,maxLength:a})).ogEvents=c,r}return p(n,[{key:"getReportableActions",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:100,e=this.getItems(),n=[];return null==e||e.forEach((function(e){var r;(null==n?void 0:n.length)=this.maxLength){var r="队列长度超过最大限制".concat(this.maxLength,"条,SDK将按照行为优先级排序,丢弃优先级最低的行为事件");xt.warn(r),ct({user_action_set_id:this.userActionSetId,log_type:b.JS_QUEUE_LOG,message:"队列长度超过限制"});var i=this.sortQueue(t,n);xt.debug&&xt.info("超过".concat(this.maxLength,"条按优先级排序的队列:"),i.concat([]));var o=i.pop();this.updateAllStack(i),this.updateLostAction((null==o?void 0:o.session_id)||""),(null==o?void 0:o.action_id)===t.action_id&&(e={code:103,message:"缓存队列已满,主动丢弃行为"})}else this.addItem(t);return Nt.hasDirectGameMask||this.updateToStorage(),e}},{key:"removeActions",value:function(t){this.removeItems(t),this.updateToStorage()}},{key:"updateActionsForReportFail",value:function(t){this.updateForReportFail(t),this.updateToStorage()}},{key:"updateActionsForReporting",value:function(t){this.updateForReporting(t),this.updateToStorage()}},{key:"getReportableActionsLength",value:function(){var t=this.getItems().filter((function(t){var e;return(null==t?void 0:t.inner_status)!==(null==(e=T)?void 0:e.reporting)}));return null==t?void 0:t.length}},{key:"sortQueue",value:function(t,e){var n=this,r={},i=null==t?void 0:t.action_time,o=e.concat([t]),a=function(t){return r[t.action_id]||(r[t.action_id]=n.caculateWeight(i,t)),r[t.action_id]};return o.sort((function(t,e){return a(e)-a(t)}))}},{key:"caculateWeight",value:function(t,e){var n,r=0,i=this.formatWeight(t,null==e?void 0:e.action_time),o=i.ogWeight,a=i.sdkWeight,u=i.userWeight;null!=(n=this.ogEvents)&&n.includes(null==e?void 0:e.action_type)&&(r+=o),null!=e&&e.is_sdk_auto_track?r+=a:r+=u;var c=t-(null==e?void 0:e.action_time)+1;return r=c>0?r+1/c:r}},{key:"formatWeight",value:function(t,e){var n=N,r=D,i=L;return t-e>2592e6&&(n/=100,r/=100,i/=100),{ogWeight:n,sdkWeight:r,userWeight:i}}}]),n}();Gt([Dt],Bt.prototype,"getReportableActions",1),Gt([Dt],Bt.prototype,"addAction",1),Gt([Dt],Bt.prototype,"removeActions",1),Gt([Dt],Bt.prototype,"updateActionsForReportFail",1),Gt([Dt],Bt.prototype,"updateActionsForReporting",1),Gt([Dt],Bt.prototype,"getReportableActionsLength",1),Gt([Dt],Bt.prototype,"sortQueue",1),Gt([Dt],Bt.prototype,"caculateWeight",1),Gt([Dt],Bt.prototype,"formatWeight",1);var Vt=function(){function t(){d(this,t),this.events={}}return p(t,[{key:"subscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])?this.events[e].push(n):this.events[e]=[n]}},{key:"once",value:function(e,n){t.checkCallback(n),this.subscribe(this.onceEventName(e),n)}},{key:"unsubscribe",value:function(e,n){t.checkCallback(n),_t(this.events[e])&&(this.events[e]=this.events[e].filter((function(t){return t!==n}))),_t(this.events[this.onceEventName(e)])&&(this.events[this.onceEventName(e)]=this.events[this.onceEventName(e)].filter((function(t){return t!==n})))}},{key:"publish",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r1&&t.ticketInterval!==this.ticketInterval&&(this.ticketInterval=t.ticketInterval,Qt.publish(Z)),t.requestTimeout&&"number"==typeof t.requestTimeout&&t.requestTimeout>5e3&&(this.requestTimeout=t.requestTimeout)}}]),t}(),se=new ce,le=Jt,de=Wt,fe=Ht,pe=zt,ve=function(){var t=!0,e=!0,n=!0,r=!0,i=!0,o=!1;return function(){if(!o){o=!0;var a=tt.getSync(R);if((null==a?void 0:a.bg)===K?t=!0:(null==a?void 0:a.bg)===Q&&(t=!1),(null==a?void 0:a.fg)===K?e=!0:(null==a?void 0:a.fg)===Q&&(e=!1),(null==a?void 0:a.st)===K?n=!0:(null==a?void 0:a.st)===Q&&(n=!1),(null==a?void 0:a.ti)===K?r=!0:(null==a?void 0:a.ti)===Q&&(r=!1),xt.devLog("当前缓存开关 bgOn,fgOn,stOn,tiOn:",t,e,n,r),n&&Qt.publish(le),r){var u=function(){i&&Qt.publish(de)},c=setInterval(u,1e3*se.getTicketInterval());Qt.subscribe(Z,(function(){c&&clearInterval(c),c=setInterval(u,1e3*se.getTicketInterval())}))}wx.onShow((function(t){if(i=!0,e){var n="";try{(n=JSON.stringify(t)).length>1e4&&(n=JSON.stringify({cut:1,scene:t.scene}))}catch(t){}Qt.publish(fe,{enter_options:n})}})),wx.onHide((function(){if(i=!1,t){var e=0;0!==Nt.activeDuration&&(e=Date.now()-Nt.activeDuration,Nt.activeDuration=0),Qt.publish(pe,{duration:e>0?e:0})}}))}}}(),he="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function _e(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var ge,ye=_e((function(){var t,e=null;function n(t){return!!t&&("object"==l(t)||"function"==typeof t)}function r(t){if(null!==t&&!n(t))throw new TypeError("Object prototype may only be an Object or null: "+t)}var i=Object,o=!(!i.create&&{__proto__:null}instanceof i),a=i.create||(o?function(t){return r(t),{__proto__:t}}:function(t){if(r(t),null===t)throw new SyntaxError("Native Object.create is required to create objects with null prototype");var e=function(){};return e.prototype=t,new e}),u=function(){return null},c=i.getPrototypeOf||([].__proto__===Array.prototype?function(t){var e=t.__proto__;return n(e)?e:null}:u);return t=function(s,l){if(void 0===(this&&this instanceof t?this.constructor:void 0))throw new TypeError("Constructor Proxy requires 'new'");if(!n(s)||!n(l))throw new TypeError("Cannot create proxy with a non-object as target or handler");var d=function(){};e=function(){s=null,d=function(t){throw new TypeError("Cannot perform '".concat(t,"' on a proxy that has been revoked"))}},setTimeout((function(){e=null}),0);var f=l;for(var p in l={get:null,set:null,apply:null,construct:null},f){if(!(p in l))throw new TypeError("Proxy polyfill does not support trap '".concat(p,"'"));l[p]=f[p]}"function"==typeof f&&(l.apply=f.apply.bind(f));var v,h=c(s),_=!1,g=!1;"function"==typeof s?(v=function(){var t=this&&this.constructor===v,e=Array.prototype.slice.call(arguments);return d(t?"construct":"apply"),t&&l.construct?l.construct.call(this,s,e):!t&&l.apply?l.apply(s,this,e):t?(e.unshift(s),new(s.bind.apply(s,e))):s.apply(this,e)},_=!0):s instanceof Array?(v=[],g=!0):v=o||null!==h?a(h):{};var y=l.get?function(t){return d("get"),l.get(this,t,v)}:function(t){return d("get"),this[t]},m=l.set?function(t,e){d("set"),l.set(this,t,e,v)}:function(t,e){d("set"),this[t]=e},A=i.getOwnPropertyNames(s),R={};A.forEach((function(t){if(!_&&!g||!(t in v)){var e={enumerable:!!i.getOwnPropertyDescriptor(s,t).enumerable,get:y.bind(s,t),set:m.bind(s,t)};i.defineProperty(v,t,e),R[t]=!0}}));var k=!0;if(_||g){var S=i.setPrototypeOf||([].__proto__===Array.prototype?function(t,e){return r(e),t.__proto__=e,t}:u);h&&S(v,h)||(k=!1)}if(l.get||!k)for(var T in s)R[T]||i.defineProperty(v,T,{get:y.bind(s,T)});return i.seal(s),i.seal(v),v},t.revocable=function(n,r){return{proxy:new t(n,r),revoke:e}},t})),me={};try{ge||(ge=ye())}catch(h){Te(h)}function Ae(t,n,r,i){try{if(!ge||null==t||!t[n])return;t[n]=new ge(t[n],{apply:function(t,n,o){var a,u;i&&Se((function(){return i.apply(void 0,e(o))}));var c=!!(null!=(a=o[0])&&a.success||null!=(u=o[0])&&u.fail);c&&["success","fail"].forEach((function(t){if(o[0][t])try{o[0][t]=new ge(o[0][t],{apply:function(n,i,a){return Se((function(){return r.apply(void 0,[t,o[0]].concat(e(a)))})),n.apply(i,a)}})}catch(t){Te(t)}}));var s=t.apply(n,o);return!c&&s&&"[object Promise]"===Object.prototype.toString.call(s)?s.then((function(t){return Se((function(){return r("success",o[0],t)})),t})).catch((function(t){throw Se((function(){return r("fail",o[0],t)})),t})):s}})}catch(t){Te(t)}}function Re(t,n,r){try{if(!ge||null==t||!t[n])return;t[n]=new ge(t[n],{apply:function(t,n,i){var o="function"==typeof i[0];if(o)try{i[0]=new ge(i[0],{apply:function(t,n,i){var o=t.call.apply(t,[n].concat(e(i)));return Se((function(){return r(o)})),o}})}catch(t){Te(t)}var a=t.call.apply(t,[n].concat(e(i)));return o||Se((function(){return r(a)})),a}})}catch(t){Te(t)}}function ke(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2?arguments[2]:void 0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],o=arguments.length>4?arguments[4]:void 0;try{if(!ge||null==t||!t[n])return;t[n]=new ge(t[n],{apply:function(t,a,u){var c=t.call.apply(t,[a].concat(e(u)));return(!r||!me[n])&&(Se((function(){return null==o?void 0:o(c)})),i.forEach((function(t){var e=t.eventName,n=t.isAsync,r=t.proxyEvent;n?Ae(c,e,r):Re(c,e,r)}))),r&&(me[n]=!0),c}})}catch(t){Te(t)}}function Se(t){try{t()}catch(t){Te(t)}}function Te(t){ct({log_type:b.PROXY_ERROR,message:null==t?void 0:t.message,err_stack:null==t?void 0:t.stack})}var Ee=$t,be=oe,Oe=Xt,Ie=Zt,we=te,Ce=ne,xe=ie,Ne=re,Le=function(){var t=!1;return function(){t||(t=!0,Ae(wx,"login",(function(t){"success"===t&&Qt.publish(Ee)})),Re(wx,"onAddToFavorites",(function(){Qt.publish(be)})),Re(wx,"onShareTimeline",(function(){Qt.publish(Oe,{target:"TIME_LINE",trigger:"MENU"})})),Re(wx,"onShareAppMessage",(function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"MENU"})})),Re(wx,"shareAppMessage",(function(){Qt.publish(Oe,{target:"APP_MESSAGE",trigger:"BUTTON"})})),ke(wx,"createGameClubButton",!1,[{isAsync:!1,eventName:"onTap",proxyEvent:function(){Qt.publish(Ie)}}],(function(){Qt.publish(we)})),ke(wx,"getGameServerManager",!0,[{isAsync:!0,eventName:"createRoom",proxyEvent:function(t){"success"===t&&Qt.publish("CREATE_GAME_ROOM")}},{isAsync:!0,eventName:"joinRoom",proxyEvent:function(t){"success"===t&&Qt.publish(Ce)}}]),Ae(wx,"requestMidasPayment",(function(t,e){Qt.publish(Ne,{status:"success"===t?"SUCCESS":"FAIL",quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",payType:"Midas"})}),(function(t){Qt.publish(xe,{quantity:(null==t?void 0:t.buyQuantity)||0,mode:(null==t?void 0:t.mode)||"",platform:(null==t?void 0:t.platform)||"",no:(null==t?void 0:t.outTradeNo)||"",payType:"Midas"})})),Ae(wx,"requestMidasPaymentGameItem",(function(t,e){var n=(e||{}).signData;Qt.publish(Ne,{status:"success"===t?"SUCCESS":"FAIL",quantity:(null==n?void 0:n.buyQuantity)||0,mode:(null==n?void 0:n.mode)||"",platform:(null==n?void 0:n.platform)||"",no:(null==n?void 0:n.outTradeNo)||"",p:(null==n?void 0:n.goodsPrice)||0,productId:(null==n?void 0:n.productId)||"",payType:"MidasGameItem"})}),(function(t){var e=(t||{}).signData;Qt.publish(xe,{quantity:(null==e?void 0:e.buyQuantity)||0,mode:(null==e?void 0:e.mode)||"",platform:(null==e?void 0:e.platform)||"",no:(null==e?void 0:e.outTradeNo)||"",p:(null==e?void 0:e.goodsPrice)||0,productId:(null==e?void 0:e.productId)||"",payType:"MidasGameItem"})})))}}(),De=function(){function t(){d(this,t)}return p(t,null,[{key:"isEmpty",value:function(t){return null==t||"string"==typeof t&&""===t.trim()}},{key:"format",value:function(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r>16)+(e>>16)+(n>>16)<<16|65535&n}function r(t,e,r,i,o,a){return n(function(t,e){return t<>>32-e}(n(n(e,t),n(i,a)),o),r)}function i(t,e,n,i,o,a,u){return r(e&n|~e&i,t,e,o,a,u)}function o(t,e,n,i,o,a,u){return r(e&i|n&~i,t,e,o,a,u)}function a(t,e,n,i,o,a,u){return r(e^n^i,t,e,o,a,u)}function u(t,e,n,i,o,a,u){return r(n^(e|~i),t,e,o,a,u)}function c(t,e){t[e>>5]|=128<>>9<<4)]=e;var r,c,s,l,d,f=1732584193,p=-271733879,v=-1732584194,h=271733878;for(r=0;r>5]>>>e%32&255);return n}function l(t){var e,n=[];for(n[(t.length>>2)-1]=void 0,e=0;e>5]|=(255&t.charCodeAt(e/8))<>>4&15)+r.charAt(15&e);return i}function f(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return s(c(l(t),8*t.length))}(f(t))}function v(t,e){return function(t,e){var n,r,i=l(t),o=[],a=[];for(o[15]=a[15]=void 0,i.length>16&&(i=c(i,8*t.length)),n=0;n<16;n+=1)o[n]=909522486^i[n],a[n]=1549556828^i[n];return r=c(o.concat(l(e)),512+8*e.length),s(c(a.concat(r),640))}(f(t),f(e))}function h(t,e,n){return e?n?v(e,t):function(t,e){return d(v(t,e))}(e,t):n?p(t):function(t){return d(p(t))}(t)}t.exports?t.exports=h:e.md5=h}(he)}(je);var Fe=_e(je.exports),Ge="function"==typeof btoa,Be="function"==typeof Buffer;"function"==typeof TextDecoder&&new TextDecoder;var Ve,Ke="function"==typeof TextEncoder?new TextEncoder:void 0,Qe=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=");Ve={},Qe.forEach((function(t,e){return Ve[t]=e}));var Ye=String.fromCharCode.bind(String);"function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array);var Je=Ge?function(t){return btoa(t)}:Be?function(t){return Buffer.from(t,"binary").toString("base64")}:function(t){for(var e,n,r,i,o="",a=t.length%3,u=0;u255||(r=t.charCodeAt(u++))>255||(i=t.charCodeAt(u++))>255)throw new TypeError("invalid character found");o+=Qe[(e=n<<16|r<<8|i)>>18&63]+Qe[e>>12&63]+Qe[e>>6&63]+Qe[63&e]}return a?o.slice(0,a-3)+"===".substring(a):o},We=Be?function(t){return Buffer.from(t).toString("base64")}:function(t){for(var e=[],n=0,r=t.length;n>>6)+Ye(128|63&e):Ye(224|e>>>12&15)+Ye(128|e>>>6&63)+Ye(128|63&e);var e=65536+1024*(t.charCodeAt(0)-55296)+(t.charCodeAt(1)-56320);return Ye(240|e>>>18&7)+Ye(128|e>>>12&63)+Ye(128|e>>>6&63)+Ye(128|63&e)},ze=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,$e=Be?function(t){return Buffer.from(t,"utf8").toString("base64")}:Ke?function(t){return We(Ke.encode(t))}:function(t){return Je(function(t){return t.replace(ze,He)}(t))},Xe=function(t){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?function(t){return t.replace(/=/g,"").replace(/[+\/]/g,(function(t){return"+"==t?"-":"_"}))}($e(t)):$e(t)};function Ze(t){var e="",n=null==t?void 0:t.appid,r=null==t?void 0:t.secret_key,i=null==t?void 0:t.sdk_version,o=null==t?void 0:t.timestamp;if(!(n&&r&&i&&o&&32===r.length))return e;for(var a=Fe(i+n+o),u=0;u<32;u++){e+=u%2==0?r[u]:a[u]}return e}var tn=Object.defineProperty,en=Object.getOwnPropertyDescriptor,nn=function(t,e,n,r){for(var i,o=r>1?void 0:r?en(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);return r&&o&&tn(e,n,o),o},rn=function(){function t(e){var n=this;d(this,t),this.cgiBatchSize=E.cgiBatchSize,this.reportThreshold=E.reportThreshold,this.reportDelay=E.reportDelay,this.triggerExecuteSend=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=[];return function(){for(var i=arguments.length,o=new Array(i),a=0;a=this.reportThreshold)this.executeSend();else{var n=(null==(t=this.configManager)?void 0:t.getRealTimeActionList())||E.realTimeActionList;e.some((function(t){return n.indexOf(t.action_type)>-1&&!t.is_retry}))?this.executeSend():this.triggerExecuteSend()}this.startInspectTimer()}},{key:"flushSend",value:function(){this.executeSend()}},{key:"executeSend",value:function(){var e=this;if(!Nt.hasDirectGameMask)if(t.currentRequestCount>=t.requestConcurrency)this.isNeedContinueSend=!0;else{this.isNeedContinueSend=!1;var n=(t.requestConcurrency-t.currentRequestCount)*this.cgiBatchSize,r=this.queueManager.getReportableActions(n),i=this.getBaseInfo();if(!i.openid&&!i.unionid&&(xt.warn("请尽快调用 setOpenId 或 setUnionId 方法设置用户ID!"),r=r.filter((function(t){return null==t?void 0:t.ad_trace_id}))),!(r.length<=0)){n=0}));e.isNeedContinueSend&&n&&e.executeSend()})).catch((function(t){xt.error(t),e.reportLog({message:"executeSend catch: ".concat(t.message),log_type:b.JS_RUN_ERROR,err_stack:t.stack})}))}}}},{key:"generateActionReportParams",value:function(t){var e=[],n=[],r=this.getBaseInfo();return t.forEach((function(t){n.push(t.action_id);var r=Object.assign({},t);delete r.inner_status,e.push(r)})),{data:{info:r,actions:e},actionIdList:n}}},{key:"dealSuccessData",value:function(t,e,n){[51001,51003].indexOf(null==t?void 0:t.code)>-1?this.queueManager.updateActionsForReportFail(e):this.queueManager.removeActions(e),0!==(null==t?void 0:t.code)&&(this.reportLog({log_type:b.REQUEST_ERROR,code:null==t?void 0:t.code,message:"trace_id: ".concat(null==t?void 0:t.trace_id,",msg: ").concat(null==t?void 0:t.message)}),xt.error("上报失败:",t)),this.doTrackCallbackFn(this.onReportComplete,t,n),-1===[0,51001,51003].indexOf(null==t?void 0:t.code)&&this.doTrackCallbackFn(this.onReportFail,t,n)}},{key:"dealFailData",value:function(t,e,n){this.queueManager.updateActionsForReportFail(e),this.reportLog({log_type:b.REQUEST_ERROR,code:t.code,message:t.message}),xt.error("上报失败:",t),this.doTrackCallbackFn(this.onReportComplete,t,n)}},{key:"report",value:function(e){var n=this,r=e.data,i=e.actionIdList;return this.queueManager.updateActionsForReporting(i),xt.debug&&(xt.info("上报行为类型: ","【".concat(r.actions.map((function(t){return t.action_type})).join("、"),"】")),xt.info("上报请求参数: ",r)),new Promise((function(e){var o,a,u,c,s,d,f,p,v=Date.now();try{var h=Ze({appid:null==(o=null==r?void 0:r.info)?void 0:o.appid,secret_key:null==(a=null==r?void 0:r.info)?void 0:a.secret_key,sdk_version:null==(u=null==r?void 0:r.info)?void 0:u.sdk_version,timestamp:v}),_=Xe(JSON.stringify(r));f={"Client-Time":v,"Sign-Value":Fe(_+(null==(c=null==r?void 0:r.info)?void 0:c.user_action_set_id)+(null==(s=null==r?void 0:r.info)?void 0:s.secret_key)+h),"Sign-Version":E.signVersion,"content-type":"text/plain;charset=UTF-8"},p=_}catch(h){f={"Client-Time":v},p=r,n.reportLog({log_type:b.SIGN_ERROR,message:"sign error msg: ".concat(null==h?void 0:h.message),err_stack:null==h?void 0:h.stack}),xt.error(h)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-cgi/miniprogram",method:"POST",timeout:(null==(d=n.configManager)?void 0:d.getRequestTimeout())||E.requestTimeout,header:f,data:p,success:function(o){var a,u;xt.devLog("上报接口返回码:",null==(a=null==o?void 0:o.data)?void 0:a.code);var c=(null==(u=null==o?void 0:o.header)?void 0:u["Server-Time"])||-1;if(st.revise(c),t.currentRequestCount-=1,200===(null==o?void 0:o.statusCode))return n.dealSuccessData(null==o?void 0:o.data,i,r),void e((null==o?void 0:o.data).code);var s="";try{s="object"==l(null==o?void 0:o.data)?JSON.stringify(null==o?void 0:o.data):null==o?void 0:o.data}catch(t){xt.error(t)}var d={code:"number"==typeof(null==o?void 0:o.statusCode)?-1*o.statusCode:-888,message:"statusCode: ".concat(null==o?void 0:o.statusCode,", data: ").concat(s)};n.dealFailData(d,i,r),e(d.code)},fail:function(o){xt.devLog("上报失败:",o),t.currentRequestCount-=1;var a={code:"number"==typeof(null==o?void 0:o.errno)?-1*o.errno:-999,message:null==o?void 0:o.errMsg};n.dealFailData(a,i,r),e(a.code)}})}))}},{key:"startInspectTimer",value:function(){var e=this;clearTimeout(this.inspectTimer),this.inspectTimer=setTimeout((function(){t.currentRequestCount>=t.requestConcurrency&&(t.currentRequestCount=t.requestConcurrency-1),e.executeSend(),e.startInspectTimer()}),1e3*this.inspectDelay)}},{key:"doTrackCallbackFn",value:function(t,e,n){if("function"==typeof t)try{for(var r=[],i=0;i10?xt.error("网络请求最大并发量不能大于10"):t.requestConcurrency=e:xt.error("网络请求最大并发量需设置为数字")}}]),t}(),on=rn;on.currentRequestCount=0,on.requestConcurrency=E.requestConcurrency,nn([Dt],on.prototype,"batchSend",1),nn([Dt],on.prototype,"flushSend",1),nn([Dt],on.prototype,"executeSend",1);var an=Jt,un=Wt,cn=Ht,sn=zt,ln=$t,dn=oe,fn=Xt,pn=Zt,vn=te,hn=ne,_n=ie,gn=re,yn=ee,mn=function(){function e(){d(this,e)}return p(e,[{key:"install",value:function(e,n){var r=function(n){Qt.subscribe(n,function(n){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return function(i){var o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};Nt.hasDirectGameMask||("ENTER_FOREGROUND"===n&&(Nt.activeDuration=Date.now()),e.track(n,Object.assign(r||{},o,t(t({},xn,!0),Nn,i))))}}(n))};r(un),r(an),r(cn),r(sn),"all"===n&&(r(ln),r(dn),r(fn),r(vn),r(pn),r(yn),r(hn),r(_n),r(gn))}}]),e}(),An=function(){function e(){d(this,e),this.special_method_symbol=Symbol("special_method_symbol")}return p(e,[{key:"onPurchase",value:function(t){return"number"!=typeof t&&xt.warn("付费金额需要为数字"),t<=0&&xt.warn("付费金额需要大于0"),this.wrapTrack(j,{value:t})}},{key:"onEnterForeground",value:function(){return this.wrapTrack(P)}},{key:"onEnterBackground",value:function(){return this.wrapTrack(q)}},{key:"onAppStart",value:function(){return this.wrapTrack(M)}},{key:"onAppQuit",value:function(){return this.wrapTrack(F)}},{key:"onAddToWishlist",value:function(){return this.wrapTrack(U)}},{key:"wrapTrack",value:function(e,n){return this.track(e,Object.assign(n||{},t({},this.special_method_symbol,1)))}}]),e}(),Rn=function(t){i(n,An);var e=a(n);function n(){return d(this,n),e.apply(this,arguments)}return p(n,[{key:"onRegister",value:function(){return this.wrapTrack(G)}},{key:"onCreateRole",value:function(t){return t&&"string"!=typeof t&&xt.warn("角色名称需要为字符串"),this.wrapTrack(B,t?{name:t}:{})}},{key:"onTutorialFinish",value:function(){return this.wrapTrack(V)}}]),n}(),kn="(如果确认无误,请忽略该提示)",Sn=function(){var t=[];return{requestActionList:function(){try{lt({conf_name:"data_nexus_common",conf_key:"action_types"}).then((function(e){_t(e)&&(t=e)}))}catch(t){xt.error(t)}},getActionList:function(){return t}}}();function Tn(t,e){try{t.is_sdk_auto_track||(function(t){try{var e=Sn.getActionList();if(!e.includes(t)){var r,i=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=n(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var i=0,o=function(){};return{s:o,n:function(){return i>=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var a,u=!0,c=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){c=!0,a=t},f:function(){try{u||null==r.return||r.return()}finally{if(c)throw a}}}}(e);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(En(o,t)<=parseInt((.3*o.length).toString())){xt.warn("通过SDK上报的".concat(t,"行为名称可能有误,请检查该行为类型是否为腾讯广告提供的标准行为!").concat(kn));break}}}catch(t){i.e(t)}finally{i.f()}}}catch(e){xt.error(e)}}(t.action_type),"minigame"===e?function(t,e){var n,r,i;try{["PURCHASE","ADD_TO_CART"].includes(t.action_type)&&t.action_param&&It(t.action_param,"value")&&("number"!=typeof(null==(n=t.action_param)?void 0:n.value)?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要为数字!")):(null==(r=t.action_param)?void 0:r.value)<=0?xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数需要大于0!")):"minigame"===e&&(null==(i=t.action_param)?void 0:i.value)<100&&xt.warn("通过SDK上报的".concat(t.action_type,"行为携带的金额参数可能有误,金额的单位为‘分’,请检查金额是否正确!").concat(kn)))}catch(t){xt.error(t)}}(t,e):"miniprogram"===e&&function(t){try{var e=null==t?void 0:t.action_type,n=(null==t?void 0:t.action_param)||{};"PURCHASE"===e&&It(n,"value")&&("number"!=typeof(null==n?void 0:n.value)?xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要为数字!")):(null==n?void 0:n.value)<=0&&xt.warn("通过SDK上报的".concat(e,"行为携带的金额参数需要大于0!")))}catch(e){xt.error(e)}}(t))}catch(t){xt.error(t)}}function En(t,e){try{if(0===t.length)return e.length;if(0===e.length)return t.length;for(var n=[],r=0;r<=e.length;r++)n[r]=[r];for(var i=0;i<=t.length;i++)n[0][i]=i;for(var o=1;o<=e.length;o++)for(var a=1;a<=t.length;a++)e.charAt(o-1)===t.charAt(a-1)?n[o][a]=n[o-1][a-1]:n[o][a]=Math.min(n[o-1][a-1]+1,n[o][a-1]+1,n[o-1][a]+1);return n[e.length][t.length]}catch(n){xt.error(n)}}function bn(t){try{t&&!/^[a-zA-Z0-9_\-]+$/.test(t)&&xt.warn("通过SDK上报的openid:".concat(t,"可能有误,请检查openid是否正确!").concat(kn))}catch(t){xt.error(t)}}var On=Object.defineProperty,In=Object.getOwnPropertyDescriptor,wn=function(t,e,n,r){for(var i,o=r>1?void 0:r?In(e,n):e,a=t.length-1;a>=0;a--)(i=t[a])&&(o=(r?i(e,n,o):i(o))||o);return r&&o&&On(e,n,o),o},Cn=Symbol("initializedInstance"),xn=Symbol("autoTrack"),Nn=Symbol("actionTime"),Ln=function(e){i(r,Rn);var n=a(r);function r(t){var e;if(d(this,r),(e=n.call(this)).env="production",e.sdk_version="1.5.11",e.sdk_name="@dn-sdk/minigame",e.deviceInfo={},e.gameInfo={},e.session_id="",e.log_id=0,e.inited=!1,e.initErrMsg="",null==wx||!wx.createCanvas)return e.initErrMsg="不支持非微信小游戏中使用",xt.error(e.initErrMsg),u(e);var i=Ot();if(r[Cn].length>=i.maxSdkInstance)return e.initErrMsg="初始化超过上限",xt.error(e.initErrMsg),u(e);var o=Et(t),a=at();if(!0!==o)return e.initErrMsg=o,xt.error(o),u(e);var s=null==a?void 0:a.appId;if(s&&s!==t.appid)return e.initErrMsg="初始化传入的appid与当前小游戏appid不一致",xt.error(e.initErrMsg),u(e);e.config=t,It(t,"auto_track")||(e.config.auto_track=bt("autoTrack")),e.openid=t.openid,e.unionid=t.unionid,e.user_unique_id=t.user_unique_id,e.onReportComplete=t.on_report_complete,e.onReportFail=t.on_report_fail,e.saveValidOpenidToStorage();var l=t.user_action_set_id;return r[Cn].includes(l)?(e.initErrMsg="同个数据源[".concat(l,"]只能初始化一次"),xt.error(e.initErrMsg),e.reportLog({log_type:b.JS_RUN_ERROR,message:e.initErrMsg}),u(e)):(e.reportLog=e.reportLog.bind(c(e)),e.getTrackBaseInfo=e.getTrackBaseInfo.bind(c(e)),Nt.activeDuration=Date.now(),e.initDirectGameConfig(),e.deviceInfo=nt(),e.gameInfo=Lt(),e.session_id=mt(),e.queueManage=new Bt({userActionSetId:l,maxLength:i.maxQueueLength,ogEvents:Yt}),e.actionReporter=new on({getBaseInfo:e.getTrackBaseInfo,reportLog:e.reportLog,queueManager:e.queueManage,configManager:se,onReportComplete:e.onReportComplete,onReportFail:e.onReportFail}),e.inited=!0,r[Cn].push(l),e.useAutoTrack(),e.addDirectGameStatusListener(),e.doReportOnEnterBackground(),"release"===(null==a?void 0:a.envVersion)?(xt.info("初始化成功"),u(e)):(function(t){var e=t.conf_name,n=t.conf_key,r=t.sdk_version,i=t.default_download_url,o=t.fail_handler;lt({conf_name:e,conf_key:n}).then((function(t){if(ht(t)){var e=null==t?void 0:t.blackVersions,n=null==t?void 0:t.minVersion,a=null==t?void 0:t.bestVersion,u=null==t?void 0:t.downloadUrl,c=i;return u&&/^https/.test(u)&&(c=u),_t(e)&&(null==e?void 0:e.indexOf(r))>-1?(null==o||o(),void xt.error("初始化失败!当前SDK版本存在兼容问题,请尽快升级至最新版!下载地址:".concat(c))):n&&Tt(r,n)<0?(null==o||o(),void xt.error("初始化失败!当前SDK版本过低,请尽快升级至最新版!下载地址:".concat(c))):(a&&Tt(r,a)<0&&xt.warn("新版本SDK已上线,强烈建议您升级至最新版,尽早享受新特性!下载地址:".concat(c)),void xt.info("初始化成功"))}xt.info("初始化成功")})).catch((function(){xt.info("初始化成功")}))}({conf_name:"mini_game_sdk_common",conf_key:"version",sdk_version:e.sdk_version,default_download_url:"https://sr-home-1257214331.cos.ap-guangzhou.myqcloud.com/sdk/dn-sdk-minigame/dn-sdk-minigame.zip",fail_handler:function(){e.inited=!1}}),Sn.requestActionList(),bn(t.openid),u(e)))}return p(r,[{key:"getInitResult",value:function(){return{inited:this.inited,initErrMsg:this.initErrMsg}}},{key:"track",value:function(t,e){var n,r;if(!this.inited||!this.queueManage)return xt.error("上报失败,请先完成初始化"),{code:100,message:"未完成初始化或重复初始化导致初始化失败,请先完成初始化"};var i=Ue.validateActionType(t),o=Ue.validateActionParam(e);if(i&&o){!this.openid&&!this.unionid&&xt.warn("缺少 openid 或 unionid");var a=bt("actionParamMaxLength");if(JSON.stringify(e||{}).length>a)return xt.error("监测到超过".concat(a,"的上报日志:").concat(t," ").concat(e)),{code:102,message:"action_param 参数过大,不能超过 ".concat(a," 字符")};var u=!(null==e||!e[xn]),c=this.createAction(t,e||{},u);"release"!==(null==(n=at())?void 0:n.envVersion)&&Tn(c,"minigame");var s=this.queueManage.addAction(c);return null==(r=this.actionReporter)||r.batchSend(),s}return{code:101,message:"action_type 或 action_param 参数错误"}}},{key:"flush",value:function(){var t;null==(t=this.actionReporter)||t.flushSend()}},{key:"setOpenId",value:function(t){var e;if(t&&"string"==typeof t)return this.openid=t,this.gameInfo.ad_trace_id&&!tt.getSync(S)&&Qt.publish("START_APP"),this.flush(),this.saveValidOpenidToStorage(),"release"!==(null==(e=at())?void 0:e.envVersion)&&bn(t),{code:0,message:"成功"};var n="openid 格式错误";return xt.error(n),{code:101,message:n}}},{key:"setUnionId",value:function(t){if(t&&"string"==typeof t)return this.unionid=t,this.flush(),{code:0,message:"成功"};var e="unionid 格式错误";return xt.error(e),{code:101,message:e}}},{key:"setUserUniqueId",value:function(t){if(t&&"string"==typeof t)return this.user_unique_id=t,{code:0,message:"成功"};var e="user_unique_id 格式错误";return xt.error(e),{code:101,message:e}}},{key:"getStrategy",value:function(t,e){var n;if(this.inited)if("[object Object]"===Object.prototype.toString.call(t))if("[object Function]"===Object.prototype.toString.call(e)){try{if((null==(n=JSON.stringify(t))?void 0:n.length)>1e4)return void xt.error("获取托管策略的入参的字符串长度不能超过10000")}catch(t){xt.log("获取托管策略的入参解析异常:",t)}!function(t,e,n){try{var r,i,o=nt(),a={sys_info:{sdk_ver:"1.5.11",os:null==o?void 0:o.os,os_ver:null==o?void 0:o.os_version},info:{user_action_set_id:null==n?void 0:n.user_action_set_id,secret_key:null==n?void 0:n.secret_key,app_id:null==n?void 0:n.appid,sdk_version:"1.5.11"}},u=Object.assign(a,{custom_param:t}),c=Date.now();try{var s=Ze({appid:null==n?void 0:n.appid,secret_key:null==n?void 0:n.secret_key,sdk_version:null==n?void 0:n.sdk_version,timestamp:c}),d=Xe(JSON.stringify(u));r={"Client-Time":c,"Sign-Value":Fe(d+(null==n?void 0:n.user_action_set_id)+(null==n?void 0:n.secret_key)+s),"Sign-Version":E.signVersion,"content-type":"text/plain;charset=UTF-8"},i=d}catch(s){r={"Client-Time":c},i=u,xt.error(s)}wx.request({url:"https://api.datanexus.qq.com/data-nexus-action/sdk/v1/mini-game/hosting",method:"POST",timeout:E.requestTimeout,header:r,data:i,success:function(t){if(200!==(null==t?void 0:t.statusCode)){var n="";try{n="object"==l(null==t?void 0:t.data)?JSON.stringify(null==t?void 0:t.data):null==t?void 0:t.data}catch(t){xt.error(t)}var r={code:"number"==typeof(null==t?void 0:t.statusCode)?-1*t.statusCode:-888,message:"statusCode: ".concat(null==t?void 0:t.statusCode,", data: ").concat(n)};e(r)}else e(null==t?void 0:t.data)},fail:function(t){xt.devLog("获取托管策略失败:",t);var n={code:"number"==typeof(null==t?void 0:t.errno)?-1*t.errno:-999,message:null==t?void 0:t.errMsg};e(n)}})}catch(o){xt.error(o)}}(t,e,this.getTrackBaseInfo())}else xt.error("获取托管策略的回调函数需为 function 类型");else xt.error("获取托管策略的入参需为 object 类型");else xt.error("请先初始化SDK")}},{key:"doReportOnEnterBackground",value:function(){var t=this;wx.onHide((function(){var e,n;null==(e=t.actionReporter)||e.flushSend(),null==(n=t.queueManage)||n.reportLostNum()}))}},{key:"getTrackBaseInfo",value:function(){var t=at();return Object.assign({},this.deviceInfo,function(t,e){var n={};return e.forEach((function(e){It(t,e)&&(n[e]=t[e])})),n}(this.config,["user_action_set_id","appid","openid","secret_key","user_unique_id","unionid"]),{local_id:rt(),sdk_name:this.sdk_name,sdk_version:this.sdk_version,openid:this.openid||ot(),unionid:this.unionid,user_unique_id:this.user_unique_id,inner_param:{app_env_version:t.envVersion,app_version:t.version}})}},{key:"createAction",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];null!=e&&e[xn]&&delete e[xn];var r=Date.now();null!=e&&e[Nn]&&(r=null==e?void 0:e[Nn],delete e[Nn]);var i={action_id:mt(),action_param:e,action_time:r,action_type:t,is_retry:!1,is_sdk_auto_track:n,retry_count:0,revised_action_time:st.getRevisedcurrentTimeMillis(),log_id:++this.log_id,session_id:this.session_id,pkg_channel_id:this.gameInfo.pkg_channel_id,source_scene:this.gameInfo.source_scene,network_type:it(),ad_trace_id:this.gameInfo.ad_trace_id,channel:this.getChannelByActionType(t)};return null!=e&&e[this.special_method_symbol]&&(this.addActionInnerParam(i,"is_special_method",!0),delete e[this.special_method_symbol]),se.getChannelClaimActionList().indexOf(t)>-1&&this.gameInfo.launch_options&&this.addActionInnerParam(i,"launch_options",this.gameInfo.launch_options),i}},{key:"addActionInnerParam",value:function(e,n,r){e.inner_param&&ht(e.inner_param)?e.inner_param[n]=r:e.inner_param=t({},n,r)}},{key:"getChannelByActionType",value:function(t){var e="";return se.getChannelClaimActionList().indexOf(t)>-1?e=this.gameInfo.channel||"":se.getNoClaimActionList().indexOf(t)>-1&&(e=X),e}},{key:"reportLog",value:function(t){var e,n,r={user_action_set_id:null==(e=this.config)?void 0:e.user_action_set_id,appid:null==(n=this.config)?void 0:n.appid,session_id:this.session_id};ct(Object.assign(r,t))}},{key:"useAutoTrack",value:function(){var t;if(null!=(t=this.config)&&t.auto_track){var e=!0,n=tt.getSync(R);(null==n?void 0:n.ap)===K?e=!0:(null==n?void 0:n.ap)===Q&&(e=!1),"devtools"===nt().wx_platform&&(e=!0),(new mn).install(this,e?"all":"lifecycle"),ve(),e&&Le(),this.getAutoProxyRemoteConfig()}}},{key:"getAutoProxyRemoteConfig",value:function(){var t,e,n=nt();n.os&&n.os_version&&null!=(t=this.config)&&t.user_action_set_id&&function(t){return new Promise((function(e){wx.request({method:"POST",url:"https://api.datanexus.qq.com/data-nexus-config/v1/sdk/minigame/get",data:t,timeout:E.requestTimeout,success:function(t){dt(t,e,"minigame/get"),pt(t)},fail:function(t){ft(t,"minigame/get")}})}))}({conf_name:"MG",conf_param:{user_action_set_id:null==(e=this.config)?void 0:e.user_action_set_id,sdk_version:this.sdk_version,os_type:(null==n?void 0:n.os)||"",os_version:wt(n.os_version),device_brand:(null==n?void 0:n.device_brand)||"",weixin_lib_version:(null==n?void 0:n.wx_lib_version)||"",weixin_version:(null==n?void 0:n.wx_version)||""}}).then((function(t){ht(t)&&tt.setSync(R,t)}))}},{key:"saveValidOpenidToStorage",value:function(){this.openid&&function(t){return/^[a-zA-Z0-9_-]{28,30}$/.test(t)}(this.openid)&&tt.setSync(S,this.openid)}},{key:"initDirectGameConfig",value:function(){try{if(xt.log("wx.getDirectAdStatusSync方法是否存在:",wx.getDirectAdStatusSync),wx.getDirectAdStatusSync){var t=wx.getDirectAdStatusSync();xt.log("wx.getDirectAdStatusSync方法返回的值info:",t),t.isInMask&&t.isInDirectGameAd&&(Nt.hasDirectGameMask=!0,xt.log("SDK初始获取的直玩蒙层状态值:",Nt.hasDirectGameMask))}}catch(t){xt.log("获取直玩状态异常:",t)}}},{key:"addDirectGameStatusListener",value:function(){var t=this;try{xt.log("wx.onDirectAdStatusChange方法是否存在:",wx.onDirectAdStatusChange),wx.onDirectAdStatusChange&&wx.onDirectAdStatusChange((function(e){var n=e.isInMask,r=e.isEndByAbnormal;xt.log("wx.onDirectAdStatusChange方法返回的值res:",e),xt.log("状态切换前,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),Nt.hasDirectGameMask&&!n&&(Nt.hasDirectGameMask=!1,xt.log("状态切换后,SDK的直玩蒙层状态值:",Nt.hasDirectGameMask),t.gameInfo.ad_trace_id&&tt.setSync(m,t.gameInfo.ad_trace_id),Qt.publish("START_APP",{isEndByAbnormal:!!r}),Qt.publish("ENTER_FOREGROUND"))}))}catch(t){xt.log("监听直玩状态异常:",t)}}}],[{key:"setRequestConcurrency",value:function(t){on.setRequestConcurrency(t)}},{key:"setDebug",value:function(t){xt.debug=t}}]),r}(),Dn=Ln;Dn[Cn]=[],wn([Dt],Dn.prototype,"track",1),wn([Dt,function(t,e,n){var r=n.value;return n.value=function(){if(this.inited){for(var t=arguments.length,e=new Array(t),n=0;n; + is_sdk_auto_track: boolean; + session_id: string; + log_id: number; + action_id: string; + action_time: number; + revised_action_time: number; + is_retry: boolean; + retry_count: number; + ad_trace_id?: string; + page_url?: string; + page_title?: string; + component_name?: string; + source_scene?: number; + pkg_channel_id?: string; + /** + * 网络类型 + */ + network_type?: string; + inner_param?: Record; + channel?: string; +} +interface LogParams { + log_type: string; + code?: number; + message?: string; + err_stack?: string; + user_action_set_id?: number; + appid?: string; + local_id?: string; + session_id?: string; + sdk_name?: string; + sdk_version?: string; + page_url?: string; + framework?: string; + device_brand?: string; + device_model?: string; + wx_version?: string; + wx_lib_version?: string; + wx_platform?: string; + os?: string; + os_version?: string; +} +interface TrackResponse { + code: number; + message: string; + actionId?: string; +} + +interface QueueProps { + /** + * 数据源ID,用于本地存储队列key + */ + userActionSetId: number; + /** + * 队列长度 + */ + maxLength: number; +} +interface QueueManagerProps extends QueueProps { + /** + * OG事件列表 + */ + ogEvents: string[]; +} +interface IEvent extends ActionInfo { + inner_status?: string; +} + +/** + * 队列原子操作 + */ + +declare class Queue { + protected maxLength: any; + protected userActionSetId: any; + protected lostActionMaps: Record; + private stack; + private localStorageKey; + private timeStamp; + constructor({ userActionSetId, maxLength }: QueueProps); + getItems(): IEvent[]; + getStorage(): IEvent[]; + /** + * 上报丢失条数到日志系统 + */ + reportLostNum(): void; + /** + * 获取丢失条数map + * @returns 丢失条数map + */ + getLostMaps(): Record; + protected init(): void; + protected addItem(eventData: IEvent): void; + protected removeItems(actionIds: string[]): void; + protected updateForReportFail(actionIds: string[]): void; + protected updateForReporting(actionIds: string[]): void; + protected updateAllStack(stack: IEvent[]): void; + protected updateToStorage(): void; + /** + * 更新丢失条数 + * @param sessionId 当前被丢弃行为的会话id + */ + protected updateLostAction(sessionId: string): void; + /** + * 设置时间戳 + */ + protected setTimeStamp(): void; +} + +declare class QueueManage extends Queue { + protected ogEvents: string[]; + constructor({ userActionSetId, maxLength, ogEvents }: QueueManagerProps); + /** + * 获取可上报的队列 + * @param reportMaxLength 需要上报的队列最大长度 + */ + getReportableActions(reportMaxLength?: number): IEvent[]; + /** + * 添加行为到队列 + * @param eventData 单条行为数据 + */ + addAction(eventData: IEvent): TrackResponse; + /** + * 根据acition_id删除行为 + * @param actionIds 行为id列表 + */ + removeActions(actionIds: string[]): void; + /** + * 上报失败时更新队列状态 + * @param actionIds + */ + updateActionsForReportFail(actionIds: string[]): void; + /** + * 上报时更新队列状态为reporting + * @param actionIds 需要更新的行为id数组 + */ + updateActionsForReporting(actionIds: string[]): void; + /** + * 获取可上报队列长度 + * @returns 可上报队列长度 + */ + getReportableActionsLength(): number; + /** + * 按照优先级从大到小给队列排序 + * @param currEvent 当前事件 + * @param stack 当前队列 + */ + sortQueue(currEvent: IEvent, stack: IEvent[]): IEvent[]; + /** + * 计算优先级 + * @param currTime 当前时间 + * @param event 行为事件 + * @returns 权重值 + */ + private caculateWeight; + /** + * + * @param currTime 当前时间 + * @param actionTime 队列行为时间 + * @returns 权重值 + */ + private formatWeight; +} + +interface ConfigManager { + getRealTimeActionList: () => Array; + getRequestTimeout: () => number; +} +interface ActionReporterProps { + getBaseInfo: () => TrackBaseInfo; + reportLog: (param: LogParams) => void; + queueManager: QueueManage; + configManager?: ConfigManager; + onReportComplete?: Function | undefined; + onReportFail?: Function | undefined; +} +/** + * 行为上报类 + */ +declare class ActionReporter { + private static currentRequestCount; + private static requestConcurrency; + static setRequestConcurrency(n: number): void; + private getBaseInfo; + private reportLog; + private queueManager; + private configManager; + private onReportComplete; + private onReportFail; + private cgiBatchSize; + private reportThreshold; + private reportDelay; + private triggerExecuteSend; + private inspectDelay; + private inspectTimer; + private isNeedContinueSend; + constructor(props: ActionReporterProps); + /** + * 批量上报行为,track的时候触发 + */ + batchSend(): void; + /** + * 全量上报, flush的时候触发 + */ + flushSend(): void; + /** + * 执行指定数量的行为上报逻辑,超过接口batch上限则并行发送请求 + */ + private executeSend; + /** + * 组装上报用的行为数据 + */ + private generateActionReportParams; + /** + * 上报接口请求成功逻辑处理 + * @param resData + * @param actionIdList + */ + private dealSuccessData; + /** + * 上报接口请求失败逻辑处理 + * @param errData + * @param actionIdList + */ + private dealFailData; + /** + * wx.request文档:https://developers.weixin.qq.com/minigame/dev/api/network/request/wx.request.html + * @param param.data:接口请求参数、param.actionIdList:行为id列表 + * @returns + */ + private report; + /** + * 启动上报定时器 + */ + private startInspectTimer; + /** + * 上报回调数据 + */ + private doTrackCallbackFn; +} + +declare abstract class SdkExtCommon { + protected special_method_symbol: symbol; + /** + * 付费 + */ + onPurchase(value: number): TrackResponse; + /** + * 进入前台 + */ + onEnterForeground(): TrackResponse; + /** + * 进入后台 + */ + onEnterBackground(): TrackResponse; + /** + * 启动 + */ + onAppStart(): TrackResponse; + /** + * 退出 + */ + onAppQuit(): TrackResponse; + /** + * 收藏 + */ + onAddToWishlist(): TrackResponse; + protected wrapTrack(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse; + abstract track(action_type: ActionInfo["action_type"], action_param?: ActionInfo["action_param"]): TrackResponse; +} + +declare abstract class sdkExt extends SdkExtCommon { + /** + * 注册 + */ + onRegister(): TrackResponse; + /** + * 创角 + */ + onCreateRole(name?: string): TrackResponse; + /** + * 完成新手教程 + */ + onTutorialFinish(): TrackResponse; +} + +declare const initializedInstanceSymbol: unique symbol; +declare class SDK extends sdkExt { + private static [initializedInstanceSymbol]; + static setRequestConcurrency(n: number): void; + static setDebug(debug: boolean): void; + protected env: string; + protected sdk_version: string; + protected sdk_name: string; + protected config?: SdkConfig; + protected deviceInfo: Partial; + protected gameInfo: Partial; + protected session_id: string; + protected log_id: number; + protected queueManage?: QueueManage; + protected actionReporter?: ActionReporter; + protected openid?: string; + protected unionid?: string; + protected user_unique_id?: string; + protected inited: boolean; + protected initErrMsg: string; + protected onReportComplete?: Function | undefined; + protected onReportFail?: Function | undefined; + constructor(sdkConfig: SdkConfig); + /** + * 返回初始化状态 + * @returns + */ + getInitResult(): { + inited: boolean; + initErrMsg: string; + }; + /** + * 数据上报方法 + * 0: 成功 + * 100: 未完成初始化或重复初始化导致初始化失败,请先完成初始化 + * 101: action_type 或 action_param 参数错误 + * 102: action_param 参数过大,不能超过 xxxx 字符 + * 103: 缓存队列已满,主动丢弃行为 + * + */ + track(action_type: ActionInfo['action_type'], action_param?: ActionInfo['action_param']): TrackResponse; + /** + * 立即上报数据 + */ + flush(): void; + /** + * 设置 openId + * 0: 成功 + * 101: openid 格式错误 + */ + setOpenId(openid: string): { + code: number; + message: string; + }; + /** + * 设置 unionid + * 0: 成功 + * 101: unionid 格式错误 + */ + setUnionId(unionid: string): { + code: number; + message: string; + }; + /** + * 设置 user_unique_id + * @param user_unique_id + */ + setUserUniqueId(user_unique_id: string): { + code: number; + message: string; + }; + /** + * strategyConfig 入参 + * callback 回调函数 + */ + getStrategy(strategyConfig: Record, callback: Function): void; + protected doReportOnEnterBackground(): void; + /** + * 获取数据上报时所需要的 info 参数 + */ + private getTrackBaseInfo; + /** + * 生成上报队列需要的行为数据 + * @param actionParams 行为参数 + * @param is_sdk_auto_track 是否自动采集 + * @returns + */ + private createAction; + /** + * 给指定行为的inner_param字段追加字段 + * @param action 待追加字段的行为 + * @param key 待添加到inner_param字段的key + * @param value key对应的value + */ + private addActionInnerParam; + /** + * 不同行为携带的渠道来源判断逻辑 + * @param actionType + * @returns + */ + private getChannelByActionType; + /** + * 上报日志 + * @param params 日志参数 + */ + private reportLog; + private useAutoTrack; + private getAutoProxyRemoteConfig; + /** + * 设置openid时,如果值合法缓存到Storage + */ + private saveValidOpenidToStorage; + /** + * 初始化直玩逻辑 + */ + private initDirectGameConfig; + private addDirectGameStatusListener; +} + +export { SDK }; diff --git a/assets/libs/index.d.ts.meta b/assets/libs/index.d.ts.meta new file mode 100644 index 0000000..cca549f --- /dev/null +++ b/assets/libs/index.d.ts.meta @@ -0,0 +1,6 @@ +{ + "ver": "2.0.2", + "uuid": "2f27dc51-5072-4b4b-bb2b-b5955d7014c1", + "importer": "text", + "subMetas": {} +} \ No newline at end of file diff --git a/settings/project.json b/settings/project.json index c90c490..cda32d7 100644 --- a/settings/project.json +++ b/settings/project.json @@ -14,6 +14,8 @@ ] ], "excluded-modules": [ + "AudioSource", + "DragonBones", "Label Effect", "NodePool", "Native Socket", @@ -22,6 +24,7 @@ "PageViewIndicator", "RichText", "StudioComponent", + "Toggle", "TiledMap", "VideoPlayer", "3D",