vhall-mini-sdk 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -10
- package/lib/components/chat/chat-edit/chat-edit.js +7 -4
- package/lib/components/chat/chat-list/chat-list.js +1 -1
- package/lib/components/live-landscape/live-landscape.js +11 -7
- package/lib/components/live-landscape/live-landscape.wxml +2 -2
- package/lib/components/live-portrait/live-portrait.js +15 -7
- package/lib/components/live-portrait/live-portrait.wxml +3 -3
- package/lib/components/live-portrait/live-portrait.wxss +1 -1
- package/lib/components/lottery/lottery.wxml +2 -2
- package/lib/components/mall-reward/index.js +1 -0
- package/lib/components/player/extensions/observers.js +5 -5
- package/lib/components/player/player.js +5 -0
- package/lib/components/player/player.wxml +3 -3
- package/lib/components/product/product-card/product-card.js +1 -0
- package/lib/components/product/product-card/product-card.wxss +1 -1
- package/lib/components/product/product-list/product-list.js +1 -0
- package/lib/components/product/product-list/product-list.wxml +3 -11
- package/lib/components/signin/signin-dialog.js +1 -0
- package/lib/pubComponents/error-page/index.js +2 -20
- package/lib/sdk/config/index.js +1 -1
- package/lib/sdk/main/index.js +2 -2
- package/lib/sdk/player/index.js +1 -1
- package/lib/sdk/plugins/ChatServer.js +1 -1
- package/lib/sdk/plugins/CustomMenuServer.js +1 -1
- package/lib/sdk/plugins/InteractServer.js +1 -1
- package/lib/sdk/plugins/InviteCardServer.js +1 -1
- package/lib/sdk/plugins/LotteryServer.js +1 -1
- package/lib/sdk/plugins/MallRewardServer.js +1 -1
- package/lib/sdk/plugins/ProductServer.js +1 -1
- package/lib/shared/RequestUtil.js +1 -1
- package/lib/shared/logger.js +1 -1
- package/lib/shared/mpUtils.js +1 -1
- package/package.json +16 -6
package/lib/sdk/player/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){var e={338:function(e,t){var r;r=function(e){e.version="1.2.2";var t=function signed_crc_table(){for(var e=0,t=new Array(256),r=0;256!=r;++r)e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=1&(e=r)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1)?-306674912^e>>>1:e>>>1,t[r]=e;return"undefined"!=typeof Int32Array?new Int32Array(t):t}(),r=function slice_by_16_tables(e){var t=0,r=0,i=0,n="undefined"!=typeof Int32Array?new Int32Array(4096):new Array(4096);for(i=0;256!=i;++i)n[i]=e[i];for(i=0;256!=i;++i)for(r=e[i],t=256+i;t<4096;t+=256)r=n[t]=r>>>8^e[255&r];var o=[];for(i=1;16!=i;++i)o[i-1]="undefined"!=typeof Int32Array?n.subarray(256*i,256*i+256):n.slice(256*i,256*i+256);return o}(t),i=r[0],n=r[1],o=r[2],a=r[3],s=r[4],l=r[5],u=r[6],c=r[7],p=r[8],d=r[9],h=r[10],f=r[11],_=r[12],g=r[13],y=r[14];e.table=t,e.bstr=function crc32_bstr(e,r){for(var i=~r,n=0,o=e.length;n<o;)i=i>>>8^t[255&(i^e.charCodeAt(n++))];return~i},e.buf=function crc32_buf(e,r){for(var v=~r,b=e.length-15,m=0;m<b;)v=y[e[m++]^255&v]^g[e[m++]^v>>8&255]^_[e[m++]^v>>16&255]^f[e[m++]^v>>>24]^h[e[m++]]^d[e[m++]]^p[e[m++]]^c[e[m++]]^u[e[m++]]^l[e[m++]]^s[e[m++]]^a[e[m++]]^o[e[m++]]^n[e[m++]]^i[e[m++]]^t[e[m++]];for(b+=15;m<b;)v=v>>>8^t[255&(v^e[m++])];return~v},e.str=function crc32_str(e,r){for(var i=~r,n=0,o=e.length,a=0,s=0;n<o;)(a=e.charCodeAt(n++))<128?i=i>>>8^t[255&(i^a)]:a<2048?i=(i=i>>>8^t[255&(i^(192|a>>6&31))])>>>8^t[255&(i^(128|63&a))]:a>=55296&&a<57344?(a=64+(1023&a),s=1023&e.charCodeAt(n++),i=(i=(i=(i=i>>>8^t[255&(i^(240|a>>8&7))])>>>8^t[255&(i^(128|a>>2&63))])>>>8^t[255&(i^(128|s>>6&15|(3&a)<<4))])>>>8^t[255&(i^(128|63&s))]):i=(i=(i=i>>>8^t[255&(i^(224|a>>12&15))])>>>8^t[255&(i^(128|a>>6&63))])>>>8^t[255&(i^(128|63&a))];return~i}},"undefined"==typeof DO_NOT_EXPORT_CRC?r(t):r({})},547:function(e,t,r){"use strict";r.d(t,{envConfig:function(){return i}});const i={production:{BASE_URL:"https://open-api.vhall.com",VHALLYUN_API_BASE:"https://api.vhallyun.com",LOG_REPORT_BASE_URL:"https://dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0eUJFtW3vryA2NXx4M4f\n1w7dg3PHwOCA6Kx7JVfD/9eBGfqLhqsp+pg4AXG4PhuQx8EsV+sncQIiQO5J2//T\n3pO8LftDtCQztLnxnhq+BjhbFeswgfez2CwV2YKLTX2zyZ69T1Vu/M4H4gWSLeiV\n1FcH6xycA2+jG+EvOxSSItCKYT9EkB9BZSKf5RU7gM+qPtzdPtJP5vlsMCa0WnpY\nI6Qrmu/w9CZkL0397gUek9nBpPHkyPYg7ZijF3Gj8EqCMCVVTYpX96k4dd/Rz1em\ns4OSPF5jDsYZi58p+LmTcc3g7W9bD3QWWxzn47ie/Dh9LbnWfCqpGjUaHd3d42vR\ncQIDAQAB\n-----END PUBLIC KEY-----"},test:{BASE_URL:"https://test01-open-api.vhou.tv",VHALLYUN_API_BASE:"https://test01-api.vhallyun.com",LOG_REPORT_BASE_URL:"https://t-dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxWGCgHz2NLdVNa91CsNX\nFfCsxfgkTx738t3yMpuPYLL/5wwuWRrX7hBfNsfC+R5BW5b13ISzD001NNt+BWGK\np3V5fdWO18j9M/AhaTV2Ao/IpdP5huvVoNFVWPUQvX70FHu0sPVTev8ycAZHUpKx\n+mm83wxOpWBN5vAMJYx75pRCQfidb73XbOm6JXLJlxN91TUTrTiblxBhRwH0AQyr\ns9dUr+IJUZ1ea2uU3fkB4uYh7V/cHuNDMsJowfLtEU2+9IqEuJY4OwqX0qdfPF72\nsGMjCgghgL0z/7kv7Qe1+tOkJTBQTzODXBheGTVbF7hH2+5XuZsK2TfgBIew0I4k\n1wIDAQAB\n-----END PUBLIC KEY-----"}}}},t={};function __webpack_require__(r){var i=t[r];if(void 0!==i)return i.exports;var n=t[r]={exports:{}};return e[r](n,n.exports,__webpack_require__),n.exports}__webpack_require__.d=function(e,t){for(var r in t)__webpack_require__.o(t,r)&&!__webpack_require__.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},__webpack_require__.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},__webpack_require__.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};!function(){"use strict";__webpack_require__.r(r),__webpack_require__.d(r,{default:function(){return VhallPlayerCore}});class WxHttp{constructor(e){this.store=e}request(e,t={},r="POST"){return new Promise(((i,n)=>{const o={url:e,method:r,data:t,header:{"Content-Type":"application/x-www-form-urlencoded"},success:e=>this._handleSuccess(e,i,n),fail:e=>this._handleFail(e,n)};wx.request(o)}))}_handleSuccess(e,t,r){if(200!==e.statusCode)return r({code:e.statusCode,msg:"网络请求失败"});const i=e.data||{};200==+i.code?t(i.data):r(i)}_handleFail(e,t){t({code:-1,msg:"网络连接失败",errMsg:e.errMsg})}}const e="/v3/interacts/union/player-config",t="/sdk/v2/init/start",i="/sdk/v2/room/get-watch-info",n="/sdk/v2/demand/get-record-watch-info",o="/api/dispatch_play",a="/api/dispatch_replay";function safeUrlJoin(e,t){return`${e.replace(/\/$/,"")}/${t.replace(/^\//,"")}`}var s=__webpack_require__(547);class WxApi{constructor(e){this.currentEnvConfig=e?.env&&s.envConfig[e.env]?s.envConfig[e.env]:s.envConfig.production,this.http=new WxHttp(e)}initVhallPlayerConfig(t){const r=safeUrlJoin(this.currentEnvConfig.BASE_URL,e),i={webinar_id:t,tags:["basic-config","definition","screen-config","water-mark"]};return this.http.request(r,i)}initVhallyun(){const e=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,t);return this.http.request(e)}requestVhallyunLive(e){const t=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,i);return this.http.request(t,{...e,client:"pc_browser",package_check:"peter"})}requestGslbLive(e,t){const r=safeUrlJoin(e,o);return this.http.request(r,{...t,bu:1})}requestVhallyunVod(e){const t=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,n);return this.http.request(t,{...e,client:"pc_browser",package_check:"peter"})}requestGslbVod(e,t){const r=safeUrlJoin(e,a);return this.http.request(r,{...t,bu:1})}}const l={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let u=l.info;function createLogger(e=""){const t=e?`[${e}]`:"",r="[vhall-mp]",enabled=e=>e>=u;return{trace:function trace(...e){enabled(l.trace)&&console.trace(`${r}${t}`,...e)},debug:function debug(...e){enabled(l.debug)&&console.debug(`${r}${t}`,...e)},info:function info(...e){enabled(l.info)&&console.info(`${r}${t}`,...e)},log:function log(...e){enabled(l.log)&&console.log(`${r}${t}`,...e)},warn:function warn(...e){enabled(l.warn)&&console.warn(`${r}${t}`,...e)},error:function error(...e){enabled(l.error)&&console.error(`${r}${t}`,...e)}}}var c=createLogger;const p=__webpack_require__(338),d=c("playerCore_scheduler"),h=["same","origin","720p","720sp","480p","480sp","360p","360sp","a"];class Scheduler{constructor(e){this.option=e,this.audioMode=!1,this.hideSameQuality=!1,this.api=new WxApi(e)}static _getRandom(){return 1e8+(899999999*Math.random()|0)}static _createPlayToken(e){const t=e.split("_")[0],r=e.split("_")[1],i=t.split("").reverse().join("");return`${(p.str(i)>>>0).toString(16).toUpperCase()}_${r}`}static _decideCurrentQuality=function(e,t){let r=null;if(0==t.length)log.error("调度无法获取点播播放地址!");else if(1==t.length)r=t[0];else if(t.indexOf(e)>=0)r=e;else{let e=t.filter((e=>"same"!==e&&"a"!==e));r=e.length>0?e[0]:t[0]}return r};async initVhallPlayerConfig(e){return this.api.initVhallPlayerConfig(e)}initForLive(){return new Promise(((e,t)=>{this.api.requestVhallyunLive({app_id:this.option.paasAppId,room_id:this.option.paasRoomId,third_party_user_id:this.option.uid,access_token:this.option.paasAccessToken}).then((t=>{d.debug("vhallyun直播接口成功: ",t);var r=(e=>{const{dispatch_server:t,live_delay:r,live_subtitle_mps:i,log_info:n}=e;return{log_info:n,uid:n.uid,dispatch_server:t,subtitles:(i||"").split(",").map((e=>e.trim())).filter((e=>e.length>0)),live_delay:r}})(t);this.vhallyunLiveData=r,e(r)})).catch((e=>{d.error("初始化失败",e),t(e)}))}))}initGslbLive(){const _parseGslbLive=e=>{const{dispatch_urls_v2:t,token:r}=e,{stream_id:i,quality:n,multi_lang_subtitle:o,rtmp_urls:a}=t;let s,l=t.httpflv_urls;if(this.audioMode)s=["same"];else if(s=n.sort(((e,t)=>{const r=h.indexOf(e),i=h.indexOf(t);return-1===r&&-1===i?0:-1===r?1:-1===i?-1:r-i})),this.hideSameQuality){s.some((e=>"same"!==e&&"a"!==e))&&(s=s.filter((e=>"same"!==e)))}const u=this.vhallyunLiveData.subtitles;u.length>0&&(l=l.filter((e=>"tx"===e.cdn_name)));const c=[];l.forEach((e=>{c.push(e.cdn_name)})),d.debug("优先清晰度: ",this.option.defaultDefinition),d.debug("全部清晰度: ",s),d.debug("全部字幕: ",u),d.debug("全部线路: ",c);const p=this.option.defaultDefinition;let f=u.length>0?u[0]:"",_=Scheduler._decideCurrentQuality(p,s);if(!_)return log.error("无法获取有效的直播播放地址!"),null;d.debug("选择清晰度: ",_),d.debug("选择字幕: ",f),d.debug("选择线路: ",0);const g=Scheduler._createPlayToken(r),y=l[0].url,v=l[0].app;return{httpflv_urls:l,stream_id:i,newToken:g,lines:c,currentLines:0,videoSrc:`${y}/${v}/${i}${""==f?"":`_${f}`}${"same"==_?"":`_${_}`}.flv?token=${g}`,qualitys:s,currentQuality:_,subtitles:u,currentSubtitle:f}};return new Promise(((e,t)=>{this.api.requestGslbLive(this.vhallyunLiveData.dispatch_server,{app_id:this.option.paasAppId,webinar_id:this.option.paasRoomId,uid:this.option.uid,rand:Scheduler._getRandom()}).then((t=>{d.debug("GSLB直播接口成功: ",t);const r=_parseGslbLive(t);this.livePlayInfo=r,e(r)})).catch((e=>{d.error("初始化失败",e),t(e)}))}))}initForVod(){return new Promise(((e,t)=>{this.api.requestVhallyunVod({app_id:this.option.paasAppId,record_id:this.option.paasVodId,third_party_user_id:this.option.uid,access_token:this.option.paasAccessToken}).then((t=>{d.debug("vhallyun点播接口成功: ",t);var r=(e=>{const{cue_point:t,default_server:r,definition:i,dispatch_server:n,log_info:o,safe_server:a,subtitle_info:s,watermark:l}=e,u=a.hasOwnProperty("cipher_key"),c=r.uri,p=r.rand,d=o.uid;return i.sort(((e,t)=>{const r=h.indexOf(e),i=h.indexOf(t);return-1===r&&-1===i?0:-1===r?1:-1===i?-1:r-i})),{log_info:o,uid:d,rand:p,vodEncrypted:u,cue_point:t,videoUri:c,definition:i,dispatch_server:n,subtitle_info:s,watermark:l}})(t);this.vhallyunVodData=r,e(r)})).catch((e=>{d.error("初始化失败",e),t(e)}))}))}initGslbVod(){const _parseGslbVod=e=>{const{hls_domainnames:t,token:r}=e;let i;i=this.audioMode?["same"]:this.vhallyunVodData.definition;const n=i.indexOf("same")>=0?"same":i[0],o=[];t[n].forEach((e=>{o.push(e.cdn_name)})),d.debug("优先清晰度: ",this.option.defaultDefinition),d.debug("全部清晰度: ",i),d.debug("全部线路: ",o);const a=this.option.defaultDefinition;let s=Scheduler._decideCurrentQuality(a,i);if(!s)return log.error("无法获取有效的点播播放地址!"),null;d.debug("选择清晰度: ",s),d.debug("选择线路: ",0);const l=Scheduler._createPlayToken(r),u=t[s][0].hls_domainname;return{hls_domainnames:t,newToken:l,lines:o,currentLines:0,videoSrc:`${u}?token=${l}`,qualitys:i,currentQuality:s}};return new Promise(((e,t)=>{this.api.requestGslbVod(this.vhallyunVodData.dispatch_server,{app_id:this.option.paasAppId,webinar_id:this.option.paasVodId,uid:this.vhallyunVodData.uid,rand:this.vhallyunVodData.rand,uri:this.vhallyunVodData.videoUri,quality:`["${this.vhallyunVodData.definition.join('","')}"]`}).then((t=>{d.debug("GSLB点播接口成功: ",t);const r=_parseGslbVod(t);this.vodPlayInfo=r,e(r)})).catch((e=>{d.error("初始化失败",e),t(e)}))}))}getVideoSrc(e,t){if("vod"==this.option.type){const t=this.vodPlayInfo.newToken;return`${this.vodPlayInfo.hls_domainnames[e][this.vodPlayInfo.currentLines].hls_domainname}?token=${t}`}{const r=this.livePlayInfo.newToken,i="same"==e?"":`_${e}`,n=""==t?"":`_${t}`;return`${this.livePlayInfo.httpflv_urls[this.livePlayInfo.currentLines].url}/${this.livePlayInfo.httpflv_urls[this.livePlayInfo.currentLines].app}/${this.livePlayInfo.stream_id}${n}${i}.flv?token=${r}`}}}const f="function"==typeof Buffer,_=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder?new TextEncoder:void 0),g=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),y=(e=>{let t={};return e.forEach(((e,r)=>t[e]=r)),t})(g),v=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,b=String.fromCharCode.bind(String),m=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),e=>e.replace(/=/g,"").replace(/[+\/]/g,(e=>"+"==e?"-":"_"))),_tidyB64=e=>e.replace(/[^A-Za-z0-9\+\/]/g,""),btoaPolyfill=e=>{let t,r,i,n,o="";const a=e.length%3;for(let a=0;a<e.length;){if((r=e.charCodeAt(a++))>255||(i=e.charCodeAt(a++))>255||(n=e.charCodeAt(a++))>255)throw new TypeError("invalid character found");t=r<<16|i<<8|n,o+=g[t>>18&63]+g[t>>12&63]+g[t>>6&63]+g[63&t]}return a?o.slice(0,a-3)+"===".substring(a):o},w="function"==typeof btoa?e=>btoa(e):f?e=>Buffer.from(e,"binary").toString("base64"):btoaPolyfill,A=f?e=>Buffer.from(e).toString("base64"):e=>{let t=[];for(let r=0,i=e.length;r<i;r+=4096)t.push(b.apply(null,e.subarray(r,r+4096)));return w(t.join(""))},cb_utob=e=>{if(e.length<2)return(t=e.charCodeAt(0))<128?e:t<2048?b(192|t>>>6)+b(128|63&t):b(224|t>>>12&15)+b(128|t>>>6&63)+b(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return b(240|t>>>18&7)+b(128|t>>>12&63)+b(128|t>>>6&63)+b(128|63&t)},C=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=e=>e.replace(C,cb_utob),I=f?e=>Buffer.from(e,"utf8").toString("base64"):_?e=>A(_.encode(e)):e=>w(utob(e)),encode=(e,t=!1)=>t?m(I(e)):I(e),atobPolyfill=e=>{if(e=e.replace(/\s+/g,""),!v.test(e))throw new TypeError("malformed base64.");e+="==".slice(2-(3&e.length));let t,r,i,n="";for(let o=0;o<e.length;)t=y[e.charAt(o++)]<<18|y[e.charAt(o++)]<<12|(r=y[e.charAt(o++)])<<6|(i=y[e.charAt(o++)]),n+=64===r?b(t>>16&255):64===i?b(t>>16&255,t>>8&255):b(t>>16&255,t>>8&255,255&t);return n},P=encode;function guid(){return"xxxxxxxx-xxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function formatTimestamp(e,t="YYYY-MM-DD HH:mm:ss"){const r=10===e.toString().length?1e3*e:e,i=new Date(r),n=i.getFullYear(),o=String(i.getMonth()+1).padStart(2,"0"),a=String(i.getDate()).padStart(2,"0"),s=String(i.getHours()).padStart(2,"0"),l=String(i.getMinutes()).padStart(2,"0"),u=String(i.getSeconds()).padStart(2,"0");return t?t.replaceAll("YYYY",n).replaceAll("MM",o).replaceAll("DD",a).replaceAll("HH",s).replaceAll("mm",l).replaceAll("ss",u):`${n}-${o}-${a} ${s}:${l}:${u}`}const k=c("playerCore_logReport"),R=getApp(),x="wxminiprogram",S=102001,T=102002,D=92001,L=92005;class LogReport{constructor(e){const t=e?.env&&s.envConfig[e.env]?s.envConfig[e.env]:s.envConfig.production;this.logReportBaseUrl=t.LOG_REPORT_BASE_URL,this.option=e,this._infoPackInterval=void 0,this.infoPackIntervalMs=3e4,this.body={},this.uuid=void 0}justUpdateData(e){this.option=e,this.initReportConfig()}init(){k.debug("init() exec!"),!1!==this.option.enable&&(this.uuid=guid(),this.initReportConfig())}initReportConfig(){const e=this.uuid?this.uuid:guid();this.body={ver:this.option.componetVersion,bu:1,flow_type:2,vtype:"",topic:"",webUrl:"",pf:9,df:x,ua:x,browser_name:x,osv:x,ndi:x,uid:this.option.uid||"",_uuid:e,s:e,app_id:"",p:"",aid:"",biz_id:"",guid:"",vid:"",vfid:"",videoWidth:0,videoHeight:0,protocol:"live"===this.option.type?"flv":"hls",picture_quality:"",sd:"",fd:"",tt:this.infoPackIntervalMs,bc:0,bt:0,tf:0,errcode:0,pushTime:Date.now(),reportTime:Date.now()},Object.assign(this.body,this.option.otherOption)}updateReportConfig(e){Object.assign(this.body,e)}start(){k.debug("start() exec"),this.startPack(),this.resume()}resume(){k.debug("resume() call"),this._clearTimer(),this._infoPackInterval=setInterval(this.infoPack.bind(this),this.infoPackIntervalMs),R.globalData?.playerReportTimer||(R.globalData.playerReportTimer=[]),R.globalData.playerReportTimer.push(this._infoPackInterval)}startPack(){if(Date.now()-R.globalData.playerReportStartTs<1e3)return void(R.globalData.playerReportStartTs=Date.now());R.globalData.playerReportStartTs=Date.now();const e="live"===this.option.type?S:D;this._report(e),k.debug(`startPack() call:, ${formatTimestamp(Date.now())}, ${e}: `,this.body)}infoPack(){const e="live"===this.option.type?T:L;this._report(e),k.debug(`infoPack() call: timerId=${this._infoPackInterval}, ${formatTimestamp(Date.now())}, ${e}: `,this.body)}_stringToBase64(e){let t=function stringToUtf8ArrayBuffer(e){let t=[];for(let r=0;r<e.length;r++){let i=e.charCodeAt(r);i<128?t.push(i):i<2048?t.push(192|i>>6,128|63&i):i<55296||i>=57344?t.push(224|i>>12,128|i>>6&63,128|63&i):(r++,i=65536+((1023&i)<<10|1023&e.charCodeAt(r)),t.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|63&i))}return new Uint8Array(t)}(e);return wx.arrayBufferToBase64(t)}_report(e){this.body.reportTime=Date.now();const t={k:e,id:Date.now(),token:P(JSON.stringify(this.body))};wx.request({url:this.logReportBaseUrl,method:"GET",data:t,success(e){}})}_clearTimer(){if(this._infoPackInterval&&(clearInterval(this._infoPackInterval),this._infoPackInterval=void 0),R.globalData?.playerReportTimer){for(const e of R.globalData.playerReportTimer)clearInterval(e);R.globalData.playerReportTimer=[]}}destroy(){k.debug("destroy() call"),this._clearTimer()}}const B=c("playerCore");class VhallPlayerCore{constructor(){}init(e){this.option=e,this.scheduler=new Scheduler(e),this.logReporter&&this.logReporter._infoPackInterval>0?(B.debug("LogReport justUpdateData"),this.logReporter.justUpdateData(e)):(this.logReporter=new LogReport(e),this.logReporter.init())}async initVhallPlayer(){try{const e=this.option.watchInitData,t=e.webinar.id,r=e.join_info.third_party_user_id,i=e.join_info.nickname,n=await this.scheduler.initVhallPlayerConfig(t),o=e.webinar.type;let a="";1==o?a="live":2==o&&e.warmup&&e.warmup.warmup_paas_record_id||4!=o&&5!=o||(a="vod");const s=e.interact.paas_app_id,l=e.interact.room_id,u=e.paas_record_id,c=e.interact.paas_access_token,p=Boolean(1==parseInt(e.webinar.mode));this.scheduler.audioMode=p;const d=Boolean(0==e.webinar.webinar_show_type),h=1==e.webinar.no_delay_webinar?"RTC":"live",f=1==n["basic-config"].data.autoplay,_=1==n["basic-config"].data.progress_bar,g=n.definition.data.default_definition,y=this.option.permissionValue,v=Boolean("1"==y?.live_hidden_same);this.scheduler.hideSameQuality=v;let b=e.webinar.img_url;d&&e.webinar.vertical_img_url&&(b=e.webinar.vertical_img_url);let m={};b.length>0&&(m={enable:!0,url:b});const w=n["water-mark"].data;let A={};if(1==w.watermark_open&&w.img_url.length>0){const e=["tl","tr","bl","br"][w.img_position-1],t=[["12%","12%"],["10%","10%"],["8%","8%"]][w.img_size-1];A={enable:!0,url:w.img_url,align:e,position:["20px","20px"],size:t,alpha:w.img_alpha}}const C=n["screen-config"].data;let I={};if(1==C.scrolling_open){const e=C.scroll_type-1,t=C.alpha,n=C.size,o=C.color,a=C.speed,s=C.interval,l=C.position;I={enable:!0,displayType:e,text:1==C.text_type?C.text:`${r}-${i}`,alpha:t,size:n,color:o,interval:s,speed:a,position:l}}return Object.assign(this.scheduler.option,{uid:r,type:a,paasAppId:s,paasRoomId:l,paasVodId:u,paasAccessToken:c,defaultDefinition:g}),this.logReporter.updateReportConfig(e.report_data),this.logReporter.option.type=a,this.logReporter.updateReportConfig({app_id:s,aid:"live"==a?l:u,p:"live"==a?l:u,uid:r}),{type:a,paasAppId:s,paasRoomId:l,paasVodId:u,paasAccessToken:c,audioMode:p,liveDelayMode:h,verticalMode:d,autoplay:f,showProgress:_,defaultDefinition:g,posterOption:m,watermarkOption:A,marqueeOption:I}}catch(e){throw B.error("初始化失败",e),e}}initVhallyunLive(){return new Promise(((e,t)=>{this.scheduler.initForLive().then((r=>{this.logReporter.updateReportConfig({s:r.log_info.session_id}),this.scheduler.initGslbLive(r).then((t=>{this.logReporter.updateReportConfig({picture_quality:t.currentQuality,s:r.log_info.session_id}),this.logReporter.start(),e(t)})).catch((e=>{t(e)}))})).catch((e=>{t(e)}))}))}async initVhallyunVod(){return new Promise(((e,t)=>{this.scheduler.initForVod().then((r=>{this.logReporter.updateReportConfig({s:r.log_info.session_id}),this.scheduler.initGslbVod(r).then((t=>{this.logReporter.updateReportConfig({picture_quality:t.currentQuality,s:r.log_info.session_id}),this.logReporter.start(),e(t)})).catch((e=>{t(e)}))})).catch((e=>{t(e)}))}))}getVideoSrc(e,t){return this.logReporter.updateReportConfig({picture_quality:e}),this.scheduler.getVideoSrc(e,t)}resume(){this.logReporter?.resume()}destroy(){this.logReporter?.destroy()}}}(),module.exports=r}();
|
|
1
|
+
"use strict";function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _createClass(e,r,t){return r&&_defineProperties(e.prototype,r),t&&_defineProperties(e,t),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}var hasRequiredCrc32,crc32$1={};let WxHttp=function(){return _createClass(function WxHttp(store){_classCallCheck(this,WxHttp),this.store=store},[{key:"request",value:function request(url,data={},method="POST"){return new Promise((resolve,reject)=>{const config={url:url,method:method,data:data,header:{"Content-Type":"application/x-www-form-urlencoded"},success:res=>this._handleSuccess(res,resolve,reject),fail:err=>this._handleFail(err,reject)};wx.request(config)})}},{key:"_handleSuccess",value:function _handleSuccess(res,resolve,reject){if(200!==res.statusCode)return reject({code:res.statusCode,msg:"网络请求失败"});const response=res.data||{};200===+response.code?resolve(response.data):reject(response)}},{key:"_handleFail",value:function _handleFail(err,reject){reject({code:-1,msg:"网络连接失败",errMsg:err.errMsg})}}])}();const VHALL_API_LIST_PLAYER_CONFIG="/v3/interacts/union/player-config",VHALLYUN_API_LIST_INIT="/sdk/v2/init/start",VHALLYUN_API_LIST_INIT_LIVE="/sdk/v2/room/get-watch-info",VHALLYUN_API_LIST_INIT_VOD="/sdk/v2/demand/get-record-watch-info",VHALLYUN_API_LIST_DISPATCH_LIVE="/api/dispatch_play",VHALLYUN_API_LIST_DISPATCH_VOD="/api/dispatch_replay";function safeUrlJoin(baseUrl,path){return`${baseUrl.replace(/\/$/,"")}/${path.replace(/^\//,"")}`}const envConfig={production:{BASE_URL:"https://open-api.vhall.com",VHALLYUN_API_BASE:"https://api.vhallyun.com",LOG_REPORT_BASE_URL:"https://dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0eUJFtW3vryA2NXx4M4f\n1w7dg3PHwOCA6Kx7JVfD/9eBGfqLhqsp+pg4AXG4PhuQx8EsV+sncQIiQO5J2//T\n3pO8LftDtCQztLnxnhq+BjhbFeswgfez2CwV2YKLTX2zyZ69T1Vu/M4H4gWSLeiV\n1FcH6xycA2+jG+EvOxSSItCKYT9EkB9BZSKf5RU7gM+qPtzdPtJP5vlsMCa0WnpY\nI6Qrmu/w9CZkL0397gUek9nBpPHkyPYg7ZijF3Gj8EqCMCVVTYpX96k4dd/Rz1em\ns4OSPF5jDsYZi58p+LmTcc3g7W9bD3QWWxzn47ie/Dh9LbnWfCqpGjUaHd3d42vR\ncQIDAQAB\n-----END PUBLIC KEY-----"},test:{BASE_URL:"https://test01-open-api.vhou.tv",VHALLYUN_API_BASE:"https://test01-api.vhallyun.com",LOG_REPORT_BASE_URL:"https://t-dc.e.vhall.com/login",PUBLIC_KEY:"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAxWGCgHz2NLdVNa91CsNX\nFfCsxfgkTx738t3yMpuPYLL/5wwuWRrX7hBfNsfC+R5BW5b13ISzD001NNt+BWGK\np3V5fdWO18j9M/AhaTV2Ao/IpdP5huvVoNFVWPUQvX70FHu0sPVTev8ycAZHUpKx\n+mm83wxOpWBN5vAMJYx75pRCQfidb73XbOm6JXLJlxN91TUTrTiblxBhRwH0AQyr\ns9dUr+IJUZ1ea2uU3fkB4uYh7V/cHuNDMsJowfLtEU2+9IqEuJY4OwqX0qdfPF72\nsGMjCgghgL0z/7kv7Qe1+tOkJTBQTzODXBheGTVbF7hH2+5XuZsK2TfgBIew0I4k\n1wIDAQAB\n-----END PUBLIC KEY-----"}};let WxApi=function(){return _createClass(function WxApi(store){_classCallCheck(this,WxApi),this.currentEnvConfig=store?.env&&envConfig[store.env]?envConfig[store.env]:envConfig.production,this.http=new WxHttp(store)},[{key:"initVhallPlayerConfig",value:function initVhallPlayerConfig(webinarId){const url=safeUrlJoin(this.currentEnvConfig.BASE_URL,VHALL_API_LIST_PLAYER_CONFIG),data={webinar_id:webinarId,tags:["basic-config","definition","screen-config","water-mark"]};return this.http.request(url,data)}},{key:"initVhallyun",value:function initVhallyun(){const url=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,VHALLYUN_API_LIST_INIT);return this.http.request(url)}},{key:"requestVhallyunLive",value:function requestVhallyunLive(data){const url=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,VHALLYUN_API_LIST_INIT_LIVE);return this.http.request(url,{...data,client:"pc_browser",package_check:"peter"})}},{key:"requestGslbLive",value:function requestGslbLive(domain,data){const url=safeUrlJoin(domain,VHALLYUN_API_LIST_DISPATCH_LIVE);return this.http.request(url,{...data,bu:1})}},{key:"requestVhallyunVod",value:function requestVhallyunVod(data){const url=safeUrlJoin(this.currentEnvConfig.VHALLYUN_API_BASE,VHALLYUN_API_LIST_INIT_VOD);return this.http.request(url,{...data,client:"pc_browser",package_check:"peter"})}},{key:"requestGslbVod",value:function requestGslbVod(domain,data){const url=safeUrlJoin(domain,VHALLYUN_API_LIST_DISPATCH_VOD);return this.http.request(url,{...data,bu:1})}}])}();const LOG_LEVEL_trace=0,LOG_LEVEL_debug=1,LOG_LEVEL_info=2,LOG_LEVEL_log=2,LOG_LEVEL_warn=3,LOG_LEVEL_error=4;let _logLevel=LOG_LEVEL_info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL_trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL_debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL_info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL_log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL_warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL_error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}const crc32=function requireCrc32(){return hasRequiredCrc32||(hasRequiredCrc32=1,factory=function(CRC32){CRC32.version="1.2.2";var T0=function signed_crc_table(){for(var c=0,table=new Array(256),n=0;256!=n;++n)c=1&(c=1&(c=1&(c=1&(c=1&(c=1&(c=1&(c=1&(c=n)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1)?-306674912^c>>>1:c>>>1,table[n]=c;return"undefined"!=typeof Int32Array?new Int32Array(table):table}(),TT=function slice_by_16_tables(T){var c=0,v=0,n=0,table="undefined"!=typeof Int32Array?new Int32Array(4096):new Array(4096);for(n=0;256!=n;++n)table[n]=T[n];for(n=0;256!=n;++n)for(v=T[n],c=256+n;c<4096;c+=256)v=table[c]=v>>>8^T[255&v];var out=[];for(n=1;16!=n;++n)out[n-1]="undefined"!=typeof Int32Array?table.subarray(256*n,256*n+256):table.slice(256*n,256*n+256);return out}(T0),T1=TT[0],T2=TT[1],T3=TT[2],T4=TT[3],T5=TT[4],T6=TT[5],T7=TT[6],T8=TT[7],T9=TT[8],Ta=TT[9],Tb=TT[10],Tc=TT[11],Td=TT[12],Te=TT[13],Tf=TT[14];CRC32.table=T0,CRC32.bstr=function crc32_bstr(bstr,seed){for(var C=-1^seed,i=0,L=bstr.length;i<L;)C=C>>>8^T0[255&(C^bstr.charCodeAt(i++))];return~C},CRC32.buf=function crc32_buf(B,seed){for(var C=-1^seed,L=B.length-15,i=0;i<L;)C=Tf[B[i++]^255&C]^Te[B[i++]^C>>8&255]^Td[B[i++]^C>>16&255]^Tc[B[i++]^C>>>24]^Tb[B[i++]]^Ta[B[i++]]^T9[B[i++]]^T8[B[i++]]^T7[B[i++]]^T6[B[i++]]^T5[B[i++]]^T4[B[i++]]^T3[B[i++]]^T2[B[i++]]^T1[B[i++]]^T0[B[i++]];for(L+=15;i<L;)C=C>>>8^T0[255&(C^B[i++])];return~C},CRC32.str=function crc32_str(str,seed){for(var C=-1^seed,i=0,L=str.length,c=0,d=0;i<L;)(c=str.charCodeAt(i++))<128?C=C>>>8^T0[255&(C^c)]:c<2048?C=(C=C>>>8^T0[255&(C^(192|c>>6&31))])>>>8^T0[255&(C^(128|63&c))]:c>=55296&&c<57344?(c=64+(1023&c),d=1023&str.charCodeAt(i++),C=(C=(C=(C=C>>>8^T0[255&(C^(240|c>>8&7))])>>>8^T0[255&(C^(128|c>>2&63))])>>>8^T0[255&(C^(128|d>>6&15|(3&c)<<4))])>>>8^T0[255&(C^(128|63&d))]):C=(C=(C=C>>>8^T0[255&(C^(224|c>>12&15))])>>>8^T0[255&(C^(128|c>>6&63))])>>>8^T0[255&(C^(128|63&c))];return~C}},"undefined"==typeof DO_NOT_EXPORT_CRC?factory(crc32$1):factory({})),crc32$1;var factory}(),logger$2=createLogger("playerCore_scheduler"),QUALITY_SORTED_LIST=["same","origin","720p","720sp","480p","480sp","360p","360sp","a"];let Scheduler=function(){function Scheduler(option){_classCallCheck(this,Scheduler),this.option=option,this.audioMode=!1,this.hideSameQuality=!1,this.api=new WxApi(option)}return _createClass(Scheduler,[{key:"initVhallPlayerConfig",value:async function initVhallPlayerConfig(webinarId){return this.api.initVhallPlayerConfig(webinarId)}},{key:"initForLive",value:function initForLive(){return new Promise((resolve,reject)=>{this.api.requestVhallyunLive({app_id:this.option.paasAppId,room_id:this.option.paasRoomId,third_party_user_id:this.option.uid,access_token:this.option.paasAccessToken}).then(data=>{logger$2.debug("vhallyun直播接口成功: ",data);var vhallyunLiveData=(data=>{const{dispatch_server:dispatch_server,live_delay:live_delay,live_subtitle_mps:live_subtitle_mps,log_info:log_info}=data;return{log_info:log_info,uid:log_info.uid,dispatch_server:dispatch_server,subtitles:(live_subtitle_mps||"").split(",").map(s=>s.trim()).filter(s=>s.length>0),live_delay:live_delay}})(data);this.vhallyunLiveData=vhallyunLiveData,resolve(vhallyunLiveData)}).catch(err=>{logger$2.error("初始化失败",err),reject(err)})})}},{key:"initGslbLive",value:function initGslbLive(){const _parseGslbLive=data=>{const{dispatch_urls_v2:dispatch_urls_v2,token:token}=data,{stream_id:stream_id,quality:quality,multi_lang_subtitle:multi_lang_subtitle,rtmp_urls:rtmp_urls}=dispatch_urls_v2;let qualitys,httpflv_urls=dispatch_urls_v2.httpflv_urls;if(this.audioMode)qualitys=["same"];else if(qualitys=quality.sort((a,b)=>{const indexA=QUALITY_SORTED_LIST.indexOf(a),indexB=QUALITY_SORTED_LIST.indexOf(b);return-1===indexA&&-1===indexB?0:-1===indexA?1:-1===indexB?-1:indexA-indexB}),this.hideSameQuality){qualitys.some(item=>"same"!==item&&"a"!==item)&&(qualitys=qualitys.filter(item=>"same"!==item))}const subtitles=this.vhallyunLiveData.subtitles;subtitles.length>0&&(httpflv_urls=httpflv_urls.filter(item=>"tx"===item.cdn_name));const lines=[];httpflv_urls.forEach(item=>{lines.push(item.cdn_name)}),logger$2.debug("优先清晰度: ",this.option.defaultDefinition),logger$2.debug("全部清晰度: ",qualitys),logger$2.debug("全部字幕: ",subtitles),logger$2.debug("全部线路: ",lines);const defaultDefinition=this.option.defaultDefinition;let currentSubtitle=subtitles.length>0?subtitles[0]:"",currentQuality=Scheduler._decideCurrentQuality(defaultDefinition,qualitys);if(!currentQuality)return log.error("无法获取有效的直播播放地址!"),null;logger$2.debug("选择清晰度: ",currentQuality),logger$2.debug("选择字幕: ",currentSubtitle),logger$2.debug("选择线路: ",0);const newToken=Scheduler._createPlayToken(token),http_flv_domain=httpflv_urls[0].url,http_flv_app=httpflv_urls[0].app;return{httpflv_urls:httpflv_urls,stream_id:stream_id,newToken:newToken,lines:lines,currentLines:0,videoSrc:`${http_flv_domain}/${http_flv_app}/${stream_id}${""==currentSubtitle?"":`_${currentSubtitle}`}${"same"==currentQuality?"":`_${currentQuality}`}.flv?token=${newToken}`,qualitys:qualitys,currentQuality:currentQuality,subtitles:subtitles,currentSubtitle:currentSubtitle}};return new Promise((resolve,reject)=>{this.api.requestGslbLive(this.vhallyunLiveData.dispatch_server,{app_id:this.option.paasAppId,webinar_id:this.option.paasRoomId,uid:this.option.uid,rand:Scheduler._getRandom()}).then(data=>{logger$2.debug("GSLB直播接口成功: ",data);const livePlayInfo=_parseGslbLive(data);this.livePlayInfo=livePlayInfo,resolve(livePlayInfo)}).catch(err=>{logger$2.error("初始化失败",err),reject(err)})})}},{key:"initForVod",value:function initForVod(){return new Promise((resolve,reject)=>{this.api.requestVhallyunVod({app_id:this.option.paasAppId,record_id:this.option.paasVodId,third_party_user_id:this.option.uid,access_token:this.option.paasAccessToken}).then(data=>{logger$2.debug("vhallyun点播接口成功: ",data);var vhallyunVodData=(data=>{const{cue_point:cue_point,default_server:default_server,definition:definition,dispatch_server:dispatch_server,log_info:log_info,safe_server:safe_server,subtitle_info:subtitle_info,watermark:watermark}=data,vodEncrypted=safe_server.hasOwnProperty("cipher_key"),videoUri=default_server.uri,rand=default_server.rand,uid=log_info.uid;return definition.sort((a,b)=>{const indexA=QUALITY_SORTED_LIST.indexOf(a),indexB=QUALITY_SORTED_LIST.indexOf(b);return-1===indexA&&-1===indexB?0:-1===indexA?1:-1===indexB?-1:indexA-indexB}),{log_info:log_info,uid:uid,rand:rand,vodEncrypted:vodEncrypted,cue_point:cue_point,videoUri:videoUri,definition:definition,dispatch_server:dispatch_server,subtitle_info:subtitle_info,watermark:watermark}})(data);this.vhallyunVodData=vhallyunVodData,resolve(vhallyunVodData)}).catch(err=>{logger$2.error("初始化失败",err),reject(err)})})}},{key:"initGslbVod",value:function initGslbVod(){const _parseGslbVod=data=>{const{hls_domainnames:hls_domainnames,token:token}=data;let qualitys;qualitys=this.audioMode?["same"]:this.vhallyunVodData.definition;const qualitySample=qualitys.indexOf("same")>=0?"same":qualitys[0],lines=[];hls_domainnames[qualitySample].forEach(item=>{lines.push(item.cdn_name)}),logger$2.debug("优先清晰度: ",this.option.defaultDefinition),logger$2.debug("全部清晰度: ",qualitys),logger$2.debug("全部线路: ",lines);const defaultDefinition=this.option.defaultDefinition;let currentQuality=Scheduler._decideCurrentQuality(defaultDefinition,qualitys);if(!currentQuality)return log.error("无法获取有效的点播播放地址!"),null;logger$2.debug("选择清晰度: ",currentQuality),logger$2.debug("选择线路: ",0);const newToken=Scheduler._createPlayToken(token),hls_url_tmp=hls_domainnames[currentQuality][0].hls_domainname;return{hls_domainnames:hls_domainnames,newToken:newToken,lines:lines,currentLines:0,videoSrc:`${hls_url_tmp}?token=${newToken}`,qualitys:qualitys,currentQuality:currentQuality}};return new Promise((resolve,reject)=>{this.api.requestGslbVod(this.vhallyunVodData.dispatch_server,{app_id:this.option.paasAppId,webinar_id:this.option.paasVodId,uid:this.vhallyunVodData.uid,rand:this.vhallyunVodData.rand,uri:this.vhallyunVodData.videoUri,quality:`["${this.vhallyunVodData.definition.join('","')}"]`}).then(data=>{logger$2.debug("GSLB点播接口成功: ",data);const vodPlayInfo=_parseGslbVod(data);this.vodPlayInfo=vodPlayInfo,resolve(vodPlayInfo)}).catch(err=>{logger$2.error("初始化失败",err),reject(err)})})}},{key:"getVideoSrc",value:function getVideoSrc(quality,subtitle){if("vod"==this.option.type){const newToken=this.vodPlayInfo.newToken;return`${this.vodPlayInfo.hls_domainnames[quality][this.vodPlayInfo.currentLines].hls_domainname}?token=${newToken}`}{const newToken=this.livePlayInfo.newToken,http_flv_quality="same"==quality?"":`_${quality}`,http_flv_subtitle=""==subtitle?"":`_${subtitle}`;return`${this.livePlayInfo.httpflv_urls[this.livePlayInfo.currentLines].url}/${this.livePlayInfo.httpflv_urls[this.livePlayInfo.currentLines].app}/${this.livePlayInfo.stream_id}${http_flv_subtitle}${http_flv_quality}.flv?token=${newToken}`}}}],[{key:"_getRandom",value:function _getRandom(){return 1e8+(899999999*Math.random()|0)}},{key:"_createPlayToken",value:function _createPlayToken(originToken){const pre=originToken.split("_")[0],last=originToken.split("_")[1],reverseToken=pre.split("").reverse().join("");return`${(crc32.str(reverseToken)>>>0).toString(16).toUpperCase()}_${last}`}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(Scheduler,"_decideCurrentQuality",function(defaultDefinition,qualitys){let currentQuality=null;if(0==qualitys.length)log.error("调度无法获取点播播放地址!");else if(1==qualitys.length)currentQuality=qualitys[0];else if(qualitys.indexOf(defaultDefinition)>=0)currentQuality=defaultDefinition;else{let alternatives=qualitys.filter(item=>"same"!==item&&"a"!==item);currentQuality=alternatives.length>0?alternatives[0]:qualitys[0]}return currentQuality});const _hasBuffer="function"==typeof Buffer,_TE=("function"==typeof TextDecoder&&new TextDecoder,"function"==typeof TextEncoder?new TextEncoder:void 0),b64chs=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),b64tab=(()=>{let tab={};return b64chs.forEach((c,i)=>tab[c]=i),tab})(),b64re=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,_fromCC=String.fromCharCode.bind(String),_mkUriSafe=("function"==typeof Uint8Array.from&&Uint8Array.from.bind(Uint8Array),src=>src.replace(/=/g,"").replace(/[+\/]/g,m0=>"+"==m0?"-":"_")),_tidyB64=s=>s.replace(/[^A-Za-z0-9\+\/]/g,""),btoaPolyfill=bin=>{let u32,c0,c1,c2,asc="";const pad=bin.length%3;for(let i=0;i<bin.length;){if((c0=bin.charCodeAt(i++))>255||(c1=bin.charCodeAt(i++))>255||(c2=bin.charCodeAt(i++))>255)throw new TypeError("invalid character found");u32=c0<<16|c1<<8|c2,asc+=b64chs[u32>>18&63]+b64chs[u32>>12&63]+b64chs[u32>>6&63]+b64chs[63&u32]}return pad?asc.slice(0,pad-3)+"===".substring(pad):asc},_btoa="function"==typeof btoa?bin=>btoa(bin):_hasBuffer?bin=>Buffer.from(bin,"binary").toString("base64"):btoaPolyfill,_fromUint8Array=_hasBuffer?u8a=>Buffer.from(u8a).toString("base64"):u8a=>{let strs=[];for(let i=0,l=u8a.length;i<l;i+=4096)strs.push(_fromCC.apply(null,u8a.subarray(i,i+4096)));return _btoa(strs.join(""))},cb_utob=c=>{if(c.length<2)return(cc=c.charCodeAt(0))<128?c:cc<2048?_fromCC(192|cc>>>6)+_fromCC(128|63&cc):_fromCC(224|cc>>>12&15)+_fromCC(128|cc>>>6&63)+_fromCC(128|63&cc);var cc=65536+1024*(c.charCodeAt(0)-55296)+(c.charCodeAt(1)-56320);return _fromCC(240|cc>>>18&7)+_fromCC(128|cc>>>12&63)+_fromCC(128|cc>>>6&63)+_fromCC(128|63&cc)},re_utob=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,utob=u=>u.replace(re_utob,cb_utob),_encode=_hasBuffer?s=>Buffer.from(s,"utf8").toString("base64"):_TE?s=>_fromUint8Array(_TE.encode(s)):s=>_btoa(utob(s)),encode=(src,urlsafe=!1)=>urlsafe?_mkUriSafe(_encode(src)):_encode(src),atobPolyfill=asc=>{if(asc=asc.replace(/\s+/g,""),!b64re.test(asc))throw new TypeError("malformed base64.");asc+="==".slice(2-(3&asc.length));let u24,r1,r2,bin="";for(let i=0;i<asc.length;)u24=b64tab[asc.charAt(i++)]<<18|b64tab[asc.charAt(i++)]<<12|(r1=b64tab[asc.charAt(i++)])<<6|(r2=b64tab[asc.charAt(i++)]),bin+=64===r1?_fromCC(u24>>16&255):64===r2?_fromCC(u24>>16&255,u24>>8&255):_fromCC(u24>>16&255,u24>>8&255,255&u24);return bin},gBase64_encode=encode;function guid(){return"xxxxxxxx-xxxxxxxx".replace(/[xy]/g,function(c){var r=16*Math.random()|0;return("x"===c?r:3&r|8).toString(16)})}function formatTimestamp(timestamp,format="YYYY-MM-DD HH:mm:ss"){const ms=10===timestamp.toString().length?1e3*timestamp:timestamp,date=new Date(ms),year=date.getFullYear(),month=String(date.getMonth()+1).padStart(2,"0"),day=String(date.getDate()).padStart(2,"0"),hours=String(date.getHours()).padStart(2,"0"),minutes=String(date.getMinutes()).padStart(2,"0"),seconds=String(date.getSeconds()).padStart(2,"0");return format?format.replaceAll("YYYY",year).replaceAll("MM",month).replaceAll("DD",day).replaceAll("HH",hours).replaceAll("mm",minutes).replaceAll("ss",seconds):`${year}-${month}-${day} ${hours}:${minutes}:${seconds}`}const logger$1=createLogger("playerCore_logReport"),app=getApp(),DF="wxminiprogram",LIVE_CODE_Start=102001,LIVE_CODE_Info=102002,VOD_CODE_Start=92001,VOD_CODE_Info=92005;let LogReport=function(){return _createClass(function LogReport(option){_classCallCheck(this,LogReport);const currentEnvConfig=option?.env&&envConfig[option.env]?envConfig[option.env]:envConfig.production;this.logReportBaseUrl=currentEnvConfig.LOG_REPORT_BASE_URL,this.option=option,this._infoPackInterval=void 0,this.infoPackIntervalMs=3e4,this.body={},this.uuid=void 0},[{key:"justUpdateData",value:function justUpdateData(option){this.option=option,this.initReportConfig()}},{key:"init",value:function init(){logger$1.debug("init() exec!"),!1!==this.option.enable&&(this.uuid=guid(),this.initReportConfig())}},{key:"initReportConfig",value:function initReportConfig(){const uuid=this.uuid?this.uuid:guid();this.body={ver:this.option.componetVersion,bu:1,flow_type:2,vtype:"",topic:"",webUrl:"",pf:9,df:DF,ua:DF,browser_name:DF,osv:DF,ndi:DF,uid:this.option.uid||"",_uuid:uuid,s:uuid,app_id:"",p:"",aid:"",biz_id:"",guid:"",vid:"",vfid:"",videoWidth:0,videoHeight:0,protocol:"live"===this.option.type?"flv":"hls",picture_quality:"",sd:"",fd:"",tt:this.infoPackIntervalMs,bc:0,bt:0,tf:0,errcode:0,pushTime:Date.now(),reportTime:Date.now()},Object.assign(this.body,this.option.otherOption)}},{key:"updateReportConfig",value:function updateReportConfig(obj){Object.assign(this.body,obj)}},{key:"start",value:function start(){logger$1.debug("start() exec"),this.startPack(),this.resume()}},{key:"resume",value:function resume(){logger$1.debug("resume() call"),this._clearTimer(),this._infoPackInterval=setInterval(this.infoPack.bind(this),this.infoPackIntervalMs),app.globalData?.playerReportTimer||(app.globalData.playerReportTimer=[]),app.globalData.playerReportTimer.push(this._infoPackInterval)}},{key:"startPack",value:function startPack(){if(Date.now()-app.globalData.playerReportStartTs<1e3)return void(app.globalData.playerReportStartTs=Date.now());app.globalData.playerReportStartTs=Date.now();const code="live"===this.option.type?LIVE_CODE_Start:VOD_CODE_Start;this._report(code),logger$1.debug(`startPack() call:, ${formatTimestamp(Date.now())}, ${code}: `,this.body)}},{key:"infoPack",value:function infoPack(){const code="live"===this.option.type?LIVE_CODE_Info:VOD_CODE_Info;this._report(code),logger$1.debug(`infoPack() call: timerId=${this._infoPackInterval}, ${formatTimestamp(Date.now())}, ${code}: `,this.body)}},{key:"_stringToBase64",value:function _stringToBase64(str){let arrayBuffer=function stringToUtf8ArrayBuffer(input){let utf8=[];for(let i=0;i<input.length;i++){let code=input.charCodeAt(i);code<128?utf8.push(code):code<2048?utf8.push(192|code>>6,128|63&code):code<55296||code>=57344?utf8.push(224|code>>12,128|code>>6&63,128|63&code):(i++,code=65536+((1023&code)<<10|1023&input.charCodeAt(i)),utf8.push(240|code>>18,128|code>>12&63,128|code>>6&63,128|63&code))}return new Uint8Array(utf8)}(str);return wx.arrayBufferToBase64(arrayBuffer)}},{key:"_report",value:function _report(code){this.body.reportTime=Date.now();const data={k:code,id:Date.now(),token:gBase64_encode(JSON.stringify(this.body))};wx.request({url:this.logReportBaseUrl,method:"GET",data:data,success(res){}})}},{key:"_clearTimer",value:function _clearTimer(){if(this._infoPackInterval&&(clearInterval(this._infoPackInterval),this._infoPackInterval=void 0),app.globalData?.playerReportTimer){for(const timer of app.globalData.playerReportTimer)clearInterval(timer);app.globalData.playerReportTimer=[]}}},{key:"destroy",value:function destroy(){logger$1.debug("destroy() call"),this._clearTimer()}}])}();const logger=createLogger("playerCore");let VhallPlayerCore=function(){return _createClass(function VhallPlayerCore(){_classCallCheck(this,VhallPlayerCore)},[{key:"init",value:function init(option){this.option=option,this.scheduler=new Scheduler(option),this.logReporter&&this.logReporter._infoPackInterval>0?(logger.debug("LogReport justUpdateData"),this.logReporter.justUpdateData(option)):(this.logReporter=new LogReport(option),this.logReporter.init())}},{key:"initVhallPlayer",value:async function initVhallPlayer(){try{const vhallInitData=this.option.watchInitData,webinarId=vhallInitData.webinar.id,uid=vhallInitData.join_info.third_party_user_id,nickname=vhallInitData.join_info.nickname,vhallPlayerConfig=await this.scheduler.initVhallPlayerConfig(webinarId),webinar_type=vhallInitData.webinar.type;let type="";1==webinar_type?type="live":2==webinar_type&&vhallInitData.warmup&&vhallInitData.warmup.warmup_paas_record_id||4!=webinar_type&&5!=webinar_type||(type="vod");const paasAppId=vhallInitData.interact.paas_app_id,paasRoomId=vhallInitData.interact.room_id,paasVodId=vhallInitData.paas_record_id,paasAccessToken=vhallInitData.interact.paas_access_token,audioMode=Boolean(1==parseInt(vhallInitData.webinar.mode));this.scheduler.audioMode=audioMode;const verticalMode=Boolean(0==vhallInitData.webinar.webinar_show_type),liveDelayMode=1==vhallInitData.webinar.no_delay_webinar?"RTC":"live",autoplay=1==vhallPlayerConfig["basic-config"].data.autoplay,showProgress=1==vhallPlayerConfig["basic-config"].data.progress_bar,defaultDefinition=vhallPlayerConfig.definition.data.default_definition,permission_value_obj=this.option.permissionValue,hideSameQuality=Boolean("1"==permission_value_obj?.live_hidden_same);this.scheduler.hideSameQuality=hideSameQuality;let posterUrl=vhallInitData.webinar.img_url;verticalMode&&vhallInitData.webinar.vertical_img_url&&(posterUrl=vhallInitData.webinar.vertical_img_url);let posterOption={};posterUrl.length>0&&(posterOption={enable:!0,url:posterUrl});const watermarkConfig=vhallPlayerConfig["water-mark"].data;let watermarkOption={};if(1==watermarkConfig.watermark_open&&watermarkConfig.img_url.length>0){const align=["tl","tr","bl","br"][watermarkConfig.img_position-1],size=[["12%","12%"],["10%","10%"],["8%","8%"]][watermarkConfig.img_size-1];watermarkOption={enable:!0,url:watermarkConfig.img_url,align:align,position:["20px","20px"],size:size,alpha:watermarkConfig.img_alpha}}const marqueeConfig=vhallPlayerConfig["screen-config"].data;let marqueeOption={};if(1==marqueeConfig.scrolling_open){const displayType=marqueeConfig.scroll_type-1,alpha=marqueeConfig.alpha,size=marqueeConfig.size,color=marqueeConfig.color,speed=marqueeConfig.speed,interval=marqueeConfig.interval,position=marqueeConfig.position;marqueeOption={enable:!0,displayType:displayType,text:1==marqueeConfig.text_type?marqueeConfig.text:`${uid}-${nickname}`,alpha:alpha,size:size,color:color,interval:interval,speed:speed,position:position}}return Object.assign(this.scheduler.option,{uid:uid,type:type,paasAppId:paasAppId,paasRoomId:paasRoomId,paasVodId:paasVodId,paasAccessToken:paasAccessToken,defaultDefinition:defaultDefinition}),this.logReporter.updateReportConfig(vhallInitData.report_data),this.logReporter.option.type=type,this.logReporter.updateReportConfig({app_id:paasAppId,aid:"live"==type?paasRoomId:paasVodId,p:"live"==type?paasRoomId:paasVodId,uid:uid}),{type:type,paasAppId:paasAppId,paasRoomId:paasRoomId,paasVodId:paasVodId,paasAccessToken:paasAccessToken,audioMode:audioMode,liveDelayMode:liveDelayMode,verticalMode:verticalMode,autoplay:autoplay,showProgress:showProgress,defaultDefinition:defaultDefinition,posterOption:posterOption,watermarkOption:watermarkOption,marqueeOption:marqueeOption}}catch(err){throw logger.error("初始化失败",err),err}}},{key:"initVhallyunLive",value:function initVhallyunLive(){return new Promise((resolve,reject)=>{this.scheduler.initForLive().then(vhallyunLiveData=>{this.logReporter.updateReportConfig({s:vhallyunLiveData.log_info.session_id}),this.scheduler.initGslbLive(vhallyunLiveData).then(data=>{this.logReporter.updateReportConfig({picture_quality:data.currentQuality,s:vhallyunLiveData.log_info.session_id}),this.logReporter.start(),resolve(data)}).catch(error=>{reject(error)})}).catch(error=>{reject(error)})})}},{key:"initVhallyunVod",value:async function initVhallyunVod(){return new Promise((resolve,reject)=>{this.scheduler.initForVod().then(vhallyunVodData=>{this.logReporter.updateReportConfig({s:vhallyunVodData.log_info.session_id}),this.scheduler.initGslbVod(vhallyunVodData).then(data=>{this.logReporter.updateReportConfig({picture_quality:data.currentQuality,s:vhallyunVodData.log_info.session_id}),this.logReporter.start(),resolve(data)}).catch(error=>{reject(error)})}).catch(error=>{reject(error)})})}},{key:"getVideoSrc",value:function getVideoSrc(quality,subtitle){return this.logReporter.updateReportConfig({picture_quality:quality}),this.scheduler.getVideoSrc(quality,subtitle)}},{key:"resume",value:function resume(){this.logReporter?.resume()}},{key:"destroy",value:function destroy(){this.logReporter?.destroy()}}])}();module.exports=VhallPlayerCore;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}let ChatServer=function(){function ChatServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,ChatServer),(_this=_callSuper(this,ChatServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this.listenerEvent(),_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(ChatServer,BaseServer),_createClass(ChatServer,[{key:"getHistoryList",value:async function getHistoryList(params){const url="/v3/interacts/chat/"+("down"==params?.anchor_path?"get-list":"latest-list"),{webinarId:webinarId,interact:interact}=this.sdkInstance.store.get("")||{};return await this.wxApi.sendGet(url,{room_id:interact.room_id,webinar_id:webinarId,...params})}},{key:"listenerEvent",value:function listenerEvent(){this.sdkInstance.on(this.sdkInstance.EVENT.ROOM_MSG,msg=>{msg.data.event_type===this.sdkInstance.EVENT.DELETE_MSG&&this.sdkInstance.emit(this.sdkInstance.EVENT.DELETE_MSG,msg.data)})}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(ChatServer,"name","ChatServer"),module.exports=ChatServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}let CustomMenuServer=function(){return _createClass(function CustomMenuServer(sdkInstance){!function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,CustomMenuServer),this.sdkInstance=sdkInstance,this.wxApi=this.sdkInstance.wxApi},[{key:"getCustomMenuDetail",value:async function getCustomMenuDetail(menu_id){const customMenuDetail=this.sdkInstance.store.get("customMenuDetail")||{};if(customMenuDetail[`${menu_id}`])return customMenuDetail[`${menu_id}`];const res=await this.wxApi.sendPost("/v3/interacts/menu/menu-get-info",{menu_id:menu_id});return 200===res?.code&&this.sdkInstance.store.set(`customMenuDetail.${menu_id}`,res.data),res?.data}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(CustomMenuServer,"name","CustomMenuServer"),module.exports=CustomMenuServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}let InteractServer=function(){function InteractServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,InteractServer),(_this=_callSuper(this,InteractServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this.likeCount=0,_this.likeTimer=null,_this.isClicking=!1,_this.listenerEvent(),_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(InteractServer,BaseServer),_createClass(InteractServer,[{key:"like",value:function like(){const curLike=this.sdkInstance.store.get("likeCount")||0;this.sdkInstance.store.set("likeCount",curLike+1),this.likeCount++,this.likeTimer&&clearTimeout(this.likeTimer),this.likeTimer=setTimeout(()=>{this.isClicking=!1,this.sendLikeRequest()},2e3)}},{key:"sendLikeRequest",value:async function sendLikeRequest(){const{interact:interact}=this.sdkInstance.store.get("")||{};try{const url="/v3/interacts/like/create-user-like",params={room_id:interact.room_id,num:this.likeCount};200==(await this.wxApi.sendPost(url,params)).code&&(this.likeCount=0)}catch(error){console.error("点赞失败:",error)}finally{this.likeTimer=null}}},{key:"getGiftList",value:async function getGiftList(){const{interact:interact}=this.sdkInstance.store.get("")||{};try{const url="/v3/interacts/gift/get-webinar-using-gift-list",params={room_id:interact?.room_id},res=await this.wxApi.sendGet(url,params);return res&&res.data&&Array.isArray(res.data.list)?res.data.list.map(item=>({id:item.id,name:item.name,price:item.price,icon:item.image_url})):[]}catch(error){return console.error("获取礼物列表失败:",error),[]}}},{key:"sendGift",value:async function sendGift(gift){const{interact:interact}=this.sdkInstance.store.get("")||{},user=this.sdkInstance.store?.get("user"),params={room_id:interact?.room_id,gift_id:gift.id,channel:"WEIXIN",service_code:"H5_PAY",nickname:user?.nickname||""};return await this.wxApi.sendPost("/v3/interacts/gift/send-gift",params)}},{key:"listenerEvent",value:function listenerEvent(){this.sdkInstance.on(this.sdkInstance.EVENT.LIKE_MSG,function throttle(func,delay){let timer=null,lastExecTime=0;return function(...args){const currentTime=Date.now(),elapsedTime=currentTime-lastExecTime;elapsedTime>=delay?(func.apply(this,args),lastExecTime=currentTime):timer||(timer=setTimeout(()=>{func.apply(this,args),lastExecTime=Date.now(),timer=null},delay-elapsedTime))}}(msg=>{if(!this.isClicking){const num=msg.data.num;num>this.sdkInstance.store.get("likeCount")&&this.sdkInstance.store.set("likeCount",num)}},2e3)),this.sdkInstance.on(this.sdkInstance.EVENT.ROOM_MSG,msg=>{"gift_send_success"===msg.data.type&&this.sdkInstance.emit(this.sdkInstance.EVENT.GIFT_MSG,msg.data)})}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(InteractServer,"name","InteractServer"),module.exports=InteractServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}const EVENT_SDK_READY="sdkStateReady",LOG_LEVEL_trace=(wx.getAccountInfoSync(),0),LOG_LEVEL_debug=1,LOG_LEVEL_info=2,LOG_LEVEL_log=2,LOG_LEVEL_warn=3,LOG_LEVEL_error=4;let _logLevel=LOG_LEVEL_info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}const logger=function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL_trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL_debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL_info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL_log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL_warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL_error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}("InviteCardServer");let InviteCardServer=function(){return _createClass(function InviteCardServer(sdkInstance){!function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,InviteCardServer),this.sdkInstance=sdkInstance,this.wxApi=this.sdkInstance.wxApi,this.initEvents()},[{key:"initEvents",value:function initEvents(){this.sdkInstance.on(EVENT_SDK_READY,()=>{1==this.sdkInstance.store.get("inviteCardStatus").status&&this.getInviteCode()})}},{key:"_parseReqParams",value:function _parseReqParams(extendParmas,sence){const watchInitData=this.sdkInstance.store.get("watchInitData");let inviteId=this.sdkInstance.store.get("user").user_id;const target={source_id:watchInitData?.webinar?.id,source_type:1};if("relationship"===sence?(target.be_invite_id=inviteId,target.be_invite_id_type=1):(target.invite_id=inviteId,target.invite_id_type=1),Array.isArray(extendParmas))for(const key of extendParmas)switch(key){case"language_type":target[key]=0;break;case"channel":target[key]="main";break;case"visitor_id":target[key]=watchInitData?.visitor_id||"";break;case"business_uid":target[key]=watchInitData?.webinar.userinfo.user_id;break;case"invite_type":target[key]=5}return target}},{key:"getInviteCode",value:async function getInviteCode(){const reqParam=this._parseReqParams(["language_type","channel","business_uid","visitor_id"]);try{const res=await this.wxApi.sendPost("/v1/marketing/app/invite/card/my-invite-card",reqParam);return res&&200===res.code&&res.data?.invite_code?(this.sdkInstance.store.set("invite_code",res.data.invite_code),res.data.invite_code):null}catch(error){return logger.error("获取邀请卡信息出现异常,error:",error),null}}},{key:"bindInviteRelation",value:async function bindInviteRelation(invite_code,open_id){if(!invite_code||!open_id)return;const reqParam={invite_code:invite_code,wechat_open_id:open_id,...this._parseReqParams(["business_uid","invite_type","channel","visitor_id"],"relationship")};logger.debug("bindInviteRelation reqParam:",JSON.stringify(reqParam));try{const res=await this.wxApi.sendPost("/v1/marketing/app/invite/card/create-invite-other-relation",reqParam);return res&&res.code,logger.debug("bindInviteRelation res:",res),res}catch(error){return logger.error("绑定邀约关系出现异常,error:",error),null}}},{key:"getInviteCardInfo",value:async function getInviteCardInfo(){const reqParam=this._parseReqParams(["language_type","channel","business_uid"]),res=await this.wxApi.sendPost("/v1/marketing/app/invite/card/init-invite-card",reqParam);return res&&200===res.code&&res.data&&(this.sdkInstance.store.set("inviteCardInfo",res.data),res.data.invite_code&&this.sdkInstance.store.set("invite_code",res.data.invite_code)),res?.data||null}},{key:"getInviteRankList",value:async function getInviteRankList(){const reqParam={pos:0,limit:200,...this._parseReqParams()},res=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/get-top-list",reqParam);return res&&200===res.code&&res.data?res.data:null}},{key:"getMyInviteDetails",value:async function getMyInviteDetails(){const reqParam=this._parseReqParams(["business_uid"]),res=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/my-invite-details",reqParam);return res&&200===res.code&&res.data?res.data:null}},{key:"getMyInviteDetailsUrl",value:async function getMyInviteDetailsUrl(){const reqParam=this._parseReqParams(["business_uid"]),res=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/my-invite-details-url",reqParam);return res&&200===res.code&&res.data?res.data:null}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(InviteCardServer,"name","InviteCardServer"),module.exports=InviteCardServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}let LotteryServer=function(){function LotteryServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,LotteryServer),(_this=_callSuper(this,LotteryServer)).sdkInstance=sdkInstance,_this.sdkInstance.EVENT=Object.assign({LOTTERY_START:"lottery_push",LOTTERY_END:"lottery_result_notice",LOTTERY_WIN:"lottery_win",LOTTERY_MISS:"lottery_miss"},_this.sdkInstance.EVENT),_this.wxApi=sdkInstance.wxApi,_this.lotteryList=[],_this.lastMsgTime="",_this.listenerEvent(),_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(LotteryServer,BaseServer),_createClass(LotteryServer,[{key:"getLotteryList",value:async function getLotteryList(params){return this.wxApi.sendGet("/v3/vss/lottery/check-list",{show_all:1,...params}).then(res=>(200==res.code&&(this.lotteryList=res.data||[],this.sdkInstance.store.set("lotteryList",res.data)),res))}},{key:"getLotteryDetail",value:async function getLotteryDetail(params){return this.wxApi.sendGet("/v3/lottery/webinar/get-lottery-info",{...params}).then(res=>(200==res.code&&this.sdkInstance.store.set("currentLottery",res.data),res))}},{key:"listenerEvent",value:function listenerEvent(){const{LOTTERY_START:LOTTERY_START,LOTTERY_END:LOTTERY_END}=this.sdkInstance.EVENT;this.sdkInstance.on(this.sdkInstance.EVENT.ROOM_MSG,msg=>{[LOTTERY_START,LOTTERY_END].includes(msg.data.type)&&msg.date_time>this.lastMsgTime&&(this._handleLotteryMsg(msg.data),this.lastMsgTime=msg.date_time)})}},{key:"_handleLotteryMsg",value:async function _handleLotteryMsg(data){const{LOTTERY_START:LOTTERY_START,LOTTERY_END:LOTTERY_END}=this.sdkInstance.EVENT,userInfo=this.sdkInstance.store.get("user");switch(data.type){case LOTTERY_START:this.sdkInstance.emit(LOTTERY_START,data),this.updateLotteryList({id:data.lottery_id,lottery_status:0,can_look_award_pool:data.can_look_award_pool,win:0});break;case LOTTERY_END:const{lottery_winners_award:lottery_winners_award,receive_award_way:receive_award_way}=data,result=lottery_winners_award.find(el=>userInfo.user_id==el.uid);result&&(result.receive_award_way=receive_award_way),this.sdkInstance.emit(LOTTERY_END,result,data),this.updateLotteryList({id:data.lottery_id,lottery_status:1,receive_award_way:receive_award_way,win:result?1:0,title:data.title,publish_winner:data.publish_winner})}}},{key:"updateLotteryList",value:function updateLotteryList(newLottery){const currentList=this.sdkInstance.store.get("lotteryList")||[],index=currentList.findIndex(item=>item.lottery_id===newLottery.lottery_id);index>=0?currentList[index]={...currentList[index],...newLottery}:currentList.unshift(newLottery),this.sdkInstance.store.set("lotteryList",[...currentList]),this.lotteryList=currentList}},{key:"joinLottery",value:async function joinLottery(params){return this.wxApi.sendPost("/v3/lottery/webinar/join-lottery",{...params})}},{key:"getLotteryWinners",value:async function getLotteryWinners(params){return this.wxApi.sendGet("/v3/lottery/webinar/get-lottery-winners",{...params})}},{key:"getReceiveAwardSetting",value:async function getReceiveAwardSetting(params){return this.wxApi.sendPost("/v3/vss/lottery/get-receive-award-setting",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(res=>res)}},{key:"submitLotteryAward",value:async function submitLotteryAward(params){return this.wxApi.sendPost("/v3/vss/lottery/award",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(res=>res)}},{key:"getLotteryUserInfo",value:async function getLotteryUserInfo(params){const{interact:interact}=this.sdkInstance.store.get("");return this.wxApi.sendPost("/v3/vss/lottery/user-info",Object.assign({room_id:interact.room_id},params),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(res=>res)}},{key:"getAwardList",value:async function getAwardList(params){return this.wxApi.sendPost("/v3/vss/lottery/award/list",Object.assign({pos:0,limit:20},params),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(res=>res)}},{key:"getWinnerList",value:async function getWinnerList(params){const{interact:interact}=this.sdkInstance.store.get("");return this.wxApi.sendPost("/v3/vss/lottery/users-get",Object.assign({room_id:interact.room_id},params),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(res=>res)}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(LotteryServer,"name","LotteryServer"),module.exports=LotteryServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}const LOG_LEVEL_trace=0,LOG_LEVEL_debug=1,LOG_LEVEL_info=2,LOG_LEVEL_log=2,LOG_LEVEL_warn=3,LOG_LEVEL_error=4;let _logLevel=LOG_LEVEL_info;function formatTime(){const date=new Date,pad=(n,len=2)=>String(n).padStart(len,"0");return`${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}:${pad(date.getMilliseconds(),3)}`}const logger=function createLogger(module=""){const prefix=module?`[${module}]`:"",appPrefix="VhallMiniSDK",enabled=level=>level>=_logLevel;return{trace:function trace(...args){enabled(LOG_LEVEL_trace)&&console.trace(`${appPrefix} [${formatTime()}] <TRACE> ${prefix} `,...args)},debug:function debug(...args){enabled(LOG_LEVEL_debug)&&console.debug(`${appPrefix} [${formatTime()}] <DEBUG> ${prefix} `,...args)},info:function info(...args){enabled(LOG_LEVEL_info)&&console.info(`${appPrefix} [${formatTime()}] <INFO> ${prefix}`,...args)},log:function log(...args){enabled(LOG_LEVEL_log)&&console.log(`${appPrefix} [${formatTime()}] <LOG> ${prefix}`,...args)},warn:function warn(...args){enabled(LOG_LEVEL_warn)&&console.warn(`${appPrefix} [${formatTime()}] <WARN> ${prefix}`,...args)},error:function error(...args){enabled(LOG_LEVEL_error)&&console.error(`${appPrefix} [${formatTime()}] <ERROR> ${prefix}`,...args)}}}("MallRewardServer");let MallRewardServer=function(){function MallRewardServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,MallRewardServer),(_this=_callSuper(this,MallRewardServer)).sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(MallRewardServer,BaseServer),_createClass(MallRewardServer,[{key:"getValidList",value:async function getValidList(){console.log("mall-reward 获取商城奖励列表");const watchInitData=this.sdkInstance.store.get("watchInitData"),params={webinar_id:this.sdkInstance.webinarId,sence_type:5==watchInitData?.webinar?.type?1:0,switch_id:watchInitData?.switch?.switch_id};try{const res=await this.wxApi.sendPost("/v3/vss/mall-reward/get-valid-list",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});return res&&200===res.code&&res.data&&(Array.isArray(res.data.list)&&res.data.list.forEach(item=>{item.tip_setting=function(val){const type=Object.prototype.toString.call(val);if(["[object Array]","[object Object]","[object Null]"].includes(type))return val;try{return JSON.parse(val)}catch(ex){return null}}(item.tip_setting)}),this.sdkInstance.store.set("mallRewardInfo",res?.data||null),this.updateActiveMallReward()),res?.data||null}catch(error){return logger.error("获取商城奖励列表出现异常,error:",error),null}}},{key:"updateActiveMallReward",value:function updateActiveMallReward(){const mallRewardInfo=this.sdkInstance.store.get("mallRewardInfo");if(!mallRewardInfo||!mallRewardInfo.list||0===mallRewardInfo.list.length)return null;let minViewingMinutes,idx=-1;for(let i=0;i<mallRewardInfo.list.length;i++){let item=mallRewardInfo.list[i];if(0===item.claim_status&&0===item.viewing_minutes&&1===item.status&&item.remaining_quota>0){idx=i;break}0===item.claim_status&&item.viewing_minutes>0&&0===item.status&&item.remaining_quota>0&&(void 0===minViewingMinutes||item.watch_minute<minViewingMinutes)&&(minViewingMinutes=item.viewing_minutes,idx=i)}return idx>-1?mallRewardInfo.list[idx]:null}},{key:"claimMallReward",value:async function claimMallReward(rewardId){const watchInitData=this.sdkInstance.store.get("watchInitData"),params={reward_id:rewardId,webinar_id:this.sdkInstance.webinarId,sence_type:5==watchInitData?.webinar?.type?1:0,switch_id:watchInitData?.switch?.switch_id};try{return await this.wxApi.sendPost("/v3/vss/mall-reward/receive",params,{headers:{"Content-Type":"application/x-www-form-urlencoded"}})}catch(error){return logger.error("领取商城奖励出现异常,error:",error),error}}}])}();!function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}(MallRewardServer,"name","MallRewardServer"),module.exports=MallRewardServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";function _callSuper(t,o,e){return o=_getPrototypeOf(o),function _possibleConstructorReturn(t,e){if(e&&("object"==typeof e||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function _assertThisInitialized(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(t)}(t,_isNativeReflectConstruct()?Reflect.construct(o,[],_getPrototypeOf(t).constructor):o.apply(t,e))}function _createClass(e,r,t){return r&&function _defineProperties(e,r){for(var t=0;t<r.length;t++){var o=r[t];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function _defineProperty(e,r,t){return(r=_toPropertyKey(r))in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _isNativeReflectConstruct(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(_isNativeReflectConstruct=function(){return!!t})()}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _toPropertyKey(t){var i=function _toPrimitive(t,r){if("object"!=typeof t||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var i=e.call(t,r);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===r?String:Number)(t)}(t,"string");return"symbol"==typeof i?i:i+""}class BaseServer{constructor(){this.handlers=Object.create(null)}on=(type,handler)=>{const bindings=[];if("object"==typeof type&&null!==type)Object.entries(type).forEach(([eventName,eventHandler])=>{this._validateParams(eventName,eventHandler),this._addHandler(eventName,eventHandler),bindings.push({type:eventName,handler:eventHandler})});else{if("string"!=typeof type||"function"!=typeof handler)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(type,handler),this._addHandler(type,handler),bindings.push({type:type,handler:handler})}return()=>{bindings.forEach(({type:eventName,handler:eventHandler})=>{if(!this.handlers[eventName])return;const index=this.handlers[eventName].findIndex(handler=>handler===eventHandler);-1!==index&&(this.handlers[eventName].splice(index,1),0===this.handlers[eventName].length&&delete this.handlers[eventName])})}};emit=(type,...params)=>{this.handlers[type]&&[...this.handlers[type]].forEach(handler=>{handler(...params)})};off=(type,handler)=>{if(!this.handlers[type])throw new Error(`不存在事件: ${type}`);if(handler){const index=this.handlers[type].findIndex(ele=>ele===handler);this.handlers[type].splice(index,1),0===this.handlers[type].length&&delete this.handlers[type]}else delete this.handlers[type]};_validateParams(type,handler){if("string"!=typeof type)throw new Error("事件名必须为字符串");if("function"!=typeof handler)throw new Error("事件处理函数必须为函数")}_addHandler(type,handler){this.handlers[type]||(this.handlers[type]=[]),this.handlers[type].includes(handler)||this.handlers[type].push(handler)}}let ProductServer=function(){function ProductServer(sdkInstance){var _this;return function _classCallCheck(a,n){if(!(a instanceof n))throw new TypeError("Cannot call a class as a function")}(this,ProductServer),_defineProperty(_this=_callSuper(this,ProductServer),"onForeground",({gap:gap})=>{_this.getProductList({}).catch(e=>console.error("ProductServer.onForeground refresh failed:",e))}),_this.sdkInstance=sdkInstance,_this.wxApi=sdkInstance.wxApi,_this.productList=[],_this.lastMsgTime="",_this.listenerEvent(),_this.sdkInstance.on(_this.sdkInstance.EVENT.FOREGROUND_REFRESH,(...args)=>_this.onForeground(...args)),_this}return function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&_setPrototypeOf(t,e)}(ProductServer,BaseServer),_createClass(ProductServer,[{key:"getProductList",value:async function getProductList(params){return this.wxApi.sendGet("/v3/goods/webinar/get-online-goods",{...params}).then(res=>(200==res.code&&(res.data=res.data.filter(el=>1==el.status).map(item=>this._getCurClientBuyTypeInfo(item)),this.productList=res.data,this.sdkInstance.store.set("productList",res.data)),res))}},{key:"listenerEvent",value:function listenerEvent(){this.sdkInstance.on(this.sdkInstance.EVENT.CUSTOM_MSG,msg=>{["goods_update_info","push_goods_change"].includes(msg.data.type)&&(this.sdkInstance.get("logReportServer")?.report("116999",{stage:msg.data.type,logData:msg}),msg.date_time>this.lastMsgTime&&(this._getProductListByCdn(msg.data),this.sdkInstance.BRSAgent?.customLog("product:update"),this.lastMsgTime=msg.date_time))})}},{key:"_getProductListByCdn",value:async function _getProductListByCdn(params){try{const res=await this.wxApi.sendGet(params.cdn_url,{},{timeout:5e3});return this.sdkInstance.get("logReportServer")?.report("116999",{stage:"getProductListByCdn",logData:res}),this.productList=res.filter(el=>1==el.status).map(item=>this._getCurClientBuyTypeInfo(item)),this.sdkInstance.store.set("productList",this.productList),res}catch(error){if(console.error("请求 cdn_url 失败:",error),!params.access_url)throw error;try{const res=await this.wxApi.sendGet(params.access_url);return this.sdkInstance.get("logReportServer")?.report("116999",{stage:"getProductListByCdn2",logData:res}),this.productList=res.filter(el=>1==el.status).map(item=>this._getCurClientBuyTypeInfo(item)),this.sdkInstance.store.set("productList",this.productList),res}catch(accessError){throw console.error("请求 access_url 也失败:",accessError),accessError}}}},{key:"_getCurClientBuyTypeInfo",value:function _getCurClientBuyTypeInfo(info){if(0==info.enable_multi_config)return info;{let platform,extLink,appEmbed,miniProgram;info.sku.forEach(el=>{const item=Object(el,el.sku_conf);1==item.buy_type?platform=item:2==item.buy_type?extLink=item:3==item.buy_type?appEmbed=item:4==item.buy_type&&(miniProgram=item)});const data=platform||miniProgram||extLink||appEmbed;return Object.assign(info,data,{mini_program_config:miniProgram})}}}])}();_defineProperty(ProductServer,"name","ProductServer"),module.exports=ProductServer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _utils=require("./utils");class RequestUtil{constructor(e={}){this.baseUrl=e?.baseUrl,this.headers=Object.assign({Accept:"*/*","Content-Type":"application/json","Accept-Language":"zh-CN,zh;q=0.8",platform:e?.platform},e?.headers),this._intercept={config:(e={})=>(e.url=(0,_utils.safeUrlJoin)(this.baseUrl,e.url),e),success:e=>e,fail:e=>e,complete:e=>{}}}setCommonHeaders=function(e,t){this.headers[e]=t};request=function(e){const t=this,s=t._intercept.config(e),r=Object.assign({},t.headers,s.headers);return new Promise((function(e,i){wx.request({url:s.url,data:s.data,header:r,method:s.method||"GET",success:s=>{const r=t._intercept.success(s);e(r.data)},fail:e=>{const s=t._intercept.fail(e);i(s)},complete:e=>{t._intercept.complete(e)}})}))};sendGet=function(e,t,s){return this.request({url:e,method:"GET",data:t,...s})};sendPost=function(e,t,s){return this.request({url:e,method:"POST",data:t,...s})}}exports.default=RequestUtil;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=void 0;var _utils=require("./utils");class RequestUtil{constructor(e={}){this.baseUrl=e?.baseUrl,this.headers=Object.assign({Accept:"*/*","Content-Type":"application/json","Accept-Language":"zh-CN,zh;q=0.8",platform:e?.platform},e?.headers),this._intercept={config:(e={})=>(e.url=(0,_utils.safeUrlJoin)(this.baseUrl,e.url),e),success:e=>e,fail:e=>e,complete:e=>{}}}setCommonHeaders=function(e,t){this.headers[e]=t};request=function(e){const t=this,s=t._intercept.config(e),r=Object.assign({},t.headers,s.headers);return new Promise((function(e,i){wx.request({url:s.url,data:s.data,header:r,method:s.method||"GET",timeout:s.timeout,success:s=>{const r=t._intercept.success(s);e(r.data)},fail:e=>{const s=t._intercept.fail(e);i(s)},complete:e=>{t._intercept.complete(e)}})}))};sendGet=function(e,t,s){return this.request({url:e,method:"GET",data:t,...s})};sendPost=function(e,t,s){return this.request({url:e,method:"POST",data:t,...s})}}exports.default=RequestUtil;
|
package/lib/shared/logger.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.LOG_LEVEL=void 0,exports.getLogLevel=getLogLevel,exports.log=void 0,exports.setLogLevel=setLogLevel;const LOG_LEVEL=exports.LOG_LEVEL={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let _logLevel=LOG_LEVEL.info;function setLogLevel(e){"number"!=typeof e
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.default=exports.LOG_LEVEL=void 0,exports.formatTime=formatTime,exports.getLogLevel=getLogLevel,exports.log=void 0,exports.setLogLevel=setLogLevel;const LOG_LEVEL=exports.LOG_LEVEL={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let _logLevel=LOG_LEVEL.info;function setLogLevel(e){if("number"!=typeof e){if("string"==typeof e){const o=e.toLowerCase();if(void 0!==LOG_LEVEL[o])return void(_logLevel=LOG_LEVEL[o]);const t=Number(e);if(Number.isFinite(t))return void(_logLevel=t)}}else _logLevel=e}function getLogLevel(){return _logLevel}function formatTime(){const e=new Date,pad=(e,o=2)=>String(e).padStart(o,"0");return`${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}:${pad(e.getMilliseconds(),3)}`}function createLogger(e=""){const o=e?`[${e}]`:"",t="VhallMiniSDK",enabled=e=>e>=_logLevel;return{trace:function trace(...e){enabled(LOG_LEVEL.trace)&&console.trace(`${t} [${formatTime()}] <TRACE> ${o} `,...e)},debug:function debug(...e){enabled(LOG_LEVEL.debug)&&console.debug(`${t} [${formatTime()}] <DEBUG> ${o} `,...e)},info:function info(...e){enabled(LOG_LEVEL.info)&&console.info(`${t} [${formatTime()}] <INFO> ${o}`,...e)},log:function log(...e){enabled(LOG_LEVEL.log)&&console.log(`${t} [${formatTime()}] <LOG> ${o}`,...e)},warn:function warn(...e){enabled(LOG_LEVEL.warn)&&console.warn(`${t} [${formatTime()}] <WARN> ${o}`,...e)},error:function error(...e){enabled(LOG_LEVEL.error)&&console.error(`${t} [${formatTime()}] <ERROR> ${o}`,...e)}}}const log=exports.log={createLogger:createLogger,setLogLevel:setLogLevel,getLogLevel:getLogLevel};var _default=exports.default=createLogger;
|
package/lib/shared/mpUtils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";let deviceInfo_platform;function getDevicePlatform(){try{if(!deviceInfo_platform){const e=wx.getDeviceInfo();deviceInfo_platform=e.platform}return deviceInfo_platform}catch(e){return"unkown"}}function isInPc(){try{return deviceInfo_platform||this.getDevicePlatform(),"windows"===deviceInfo_platform||"mac"===deviceInfo_platform}catch(e){return!1}}function showToast(e,
|
|
1
|
+
"use strict";let deviceInfo_platform;function getDevicePlatform(){try{if(!deviceInfo_platform){const e=wx.getDeviceInfo();deviceInfo_platform=e.platform}return deviceInfo_platform}catch(e){return"unkown"}}function isInPc(){try{return deviceInfo_platform||this.getDevicePlatform(),"windows"===deviceInfo_platform||"mac"===deviceInfo_platform}catch(e){return!1}}function showToast(e,o="none",t=1500){return wx.showToast({title:e,icon:o,duration:t})}function reloadCurrentPage(){const e=getCurrentPages();if(!e||0===e.length)return void console.error("[SDK] reloadCurrentPage failed: page stack is empty");const o=e[e.length-1],{route:t,options:r}=o,n=Object.keys(r).map((e=>`${e}=${encodeURIComponent(r[e])}`)).join("&"),a=`/${t}`+(n?`?${n}`:"");wx.redirectTo({url:a,success:()=>{console.log("[SDK] Page reloaded via redirectTo:",a)},fail:e=>{console.warn("[SDK] redirectTo failed, fallback to reLaunch:",e.errMsg),wx.reLaunch({url:a})}})}Object.defineProperty(exports,"__esModule",{value:!0}),exports.getDevicePlatform=getDevicePlatform,exports.isInPc=isInPc,exports.reloadCurrentPage=reloadCurrentPage,exports.showToast=showToast;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vhall-mini-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"author": "vhall",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"miniprogram": "lib",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"lint": "eslint ./packages --ext .js,.ts --fix && stylelint \"packages/**/*.less\" --fix",
|
|
13
13
|
"prepare": "husky",
|
|
14
14
|
"release": "sh build/release.sh",
|
|
15
|
-
"build:lib": "SKIP_MP_COMPONENTS_SYNC=true yarn && npx gulp -f build/compiler.js --series buildLib"
|
|
15
|
+
"build:lib": "SKIP_MP_COMPONENTS_SYNC=true yarn && npx gulp -f build/compiler.js --series buildLib",
|
|
16
|
+
"dev:lib": "SKIP_MP_COMPONENTS_SYNC=true npx gulp -f build/compiler.js buildLibWatch"
|
|
16
17
|
},
|
|
17
18
|
"files": [
|
|
18
19
|
"dist",
|
|
@@ -37,11 +38,16 @@
|
|
|
37
38
|
"devDependencies": {
|
|
38
39
|
"@babel/core": "^7.16.0",
|
|
39
40
|
"@babel/plugin-transform-modules-commonjs": "^7.16.0",
|
|
41
|
+
"@babel/preset-env": "^7.21.4",
|
|
40
42
|
"@babel/preset-typescript": "^7.16.0",
|
|
41
|
-
"
|
|
43
|
+
"@rollup/plugin-babel": "^7.1.0",
|
|
44
|
+
"@rollup/plugin-commonjs": "^29.0.3",
|
|
45
|
+
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
46
|
+
"@rollup/plugin-terser": "^1.0.0",
|
|
42
47
|
"@types/jest": "^27.0.2",
|
|
43
48
|
"@types/wechat-miniprogram": "^3.4.8",
|
|
44
49
|
"gulp": "^4.0.2",
|
|
50
|
+
"gulp-babel": "^8.0.0",
|
|
45
51
|
"gulp-concat": "^2.6.1",
|
|
46
52
|
"gulp-insert": "^0.5.0",
|
|
47
53
|
"gulp-less": "^5.0.0",
|
|
@@ -51,18 +57,22 @@
|
|
|
51
57
|
"gulp-typescript": "^6.0.0-alpha.1",
|
|
52
58
|
"husky": "^9.1.7",
|
|
53
59
|
"jest": "^27.3.1",
|
|
60
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
61
|
+
"@rollup/plugin-commonjs": "^28.0.0",
|
|
62
|
+
"@rollup/plugin-node-resolve": "^16.0.0",
|
|
63
|
+
"@rollup/plugin-terser": "^0.4.4",
|
|
54
64
|
"lint-staged": "^13.0.3",
|
|
65
|
+
"rollup": "^4.24.0",
|
|
55
66
|
"merge2": "^1.4.1",
|
|
56
67
|
"miniprogram-api-typings": "^3.1.6",
|
|
57
68
|
"miniprogram-ci": "^1.6.1",
|
|
58
69
|
"miniprogram-simulate": "^1.4.2",
|
|
59
70
|
"prettier": "^3.8.4",
|
|
71
|
+
"rollup": "^4",
|
|
60
72
|
"stylelint": "13.13.1",
|
|
61
73
|
"ts-jest": "^27.0.7",
|
|
62
74
|
"tscpaths": "^0.0.9",
|
|
63
|
-
"typescript": "^4.4.4"
|
|
64
|
-
"webpack": "5",
|
|
65
|
-
"webpack-stream": "^7.0.0"
|
|
75
|
+
"typescript": "^4.4.4"
|
|
66
76
|
},
|
|
67
77
|
"browserslist": [
|
|
68
78
|
"Chrome >= 53",
|