vhall-mini-sdk 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/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 +11 -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/player/components/online-hot/index.js +2 -2
- 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-list/product-list.wxml +3 -11
- package/lib/components/signin/signin-dialog.js +1 -0
- package/lib/sdk/main/index.js +2 -1
- package/lib/sdk/player/index.js +1 -1
- package/lib/sdk/plugins/InviteCardServer.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/package.json +2 -4
- package/postinstall.js +21 -51
- package/dist/components/chat/chat-edit/chat-edit.js +0 -127
- package/dist/components/chat/chat-edit/chat-edit.json +0 -4
- package/dist/components/chat/chat-edit/chat-edit.wxml +0 -7
- package/dist/components/chat/chat-edit/chat-edit.wxss +0 -1
- package/dist/components/chat/chat-item/chat-item.js +0 -253
- package/dist/components/chat/chat-item/chat-item.json +0 -3
- package/dist/components/chat/chat-item/chat-item.wxml +0 -96
- package/dist/components/chat/chat-item/chat-item.wxss +0 -1
- package/dist/components/chat/chat-list/chat-list.js +0 -216
- package/dist/components/chat/chat-list/chat-list.json +0 -6
- package/dist/components/chat/chat-list/chat-list.wxml +0 -9
- package/dist/components/chat/chat-list/chat-list.wxss +0 -1
- package/dist/components/chat/chat.js +0 -98
- package/dist/components/chat/chat.json +0 -7
- package/dist/components/chat/chat.wxml +0 -7
- package/dist/components/chat/chat.wxss +0 -1
- package/dist/components/gift/gift-display/gift-display.js +0 -118
- package/dist/components/gift/gift-display/gift-display.json +0 -3
- package/dist/components/gift/gift-display/gift-display.wxml +0 -16
- package/dist/components/gift/gift-display/gift-display.wxss +0 -1
- package/dist/components/gift/gift-sender/gift-sender.js +0 -63
- package/dist/components/gift/gift-sender/gift-sender.json +0 -6
- package/dist/components/gift/gift-sender/gift-sender.wxml +0 -19
- package/dist/components/gift/gift-sender/gift-sender.wxss +0 -1
- package/dist/components/introduction/introduction.js +0 -43
- package/dist/components/introduction/introduction.json +0 -3
- package/dist/components/introduction/introduction.wxml +0 -8
- package/dist/components/introduction/introduction.wxss +0 -1
- package/dist/components/invite-rank/img/bronze.png +0 -0
- package/dist/components/invite-rank/img/gold.png +0 -0
- package/dist/components/invite-rank/img/silver.png +0 -0
- package/dist/components/invite-rank/index.js +0 -135
- package/dist/components/invite-rank/index.json +0 -8
- package/dist/components/invite-rank/index.wxml +0 -42
- package/dist/components/invite-rank/index.wxss +0 -1
- package/dist/components/invite-rank/invite-rank-item.js +0 -12
- package/dist/components/invite-rank/invite-rank-item.json +0 -4
- package/dist/components/invite-rank/invite-rank-item.wxml +0 -21
- package/dist/components/invite-rank/invite-rank-item.wxss +0 -1
- package/dist/components/invite-rank/my-invite-detail.js +0 -82
- package/dist/components/invite-rank/my-invite-detail.json +0 -7
- package/dist/components/invite-rank/my-invite-detail.wxml +0 -27
- package/dist/components/invite-rank/my-invite-detail.wxss +0 -1
- package/dist/components/invite-rank/util.wxs +0 -21
- package/dist/components/live-landscape/live-landscape.js +0 -216
- package/dist/components/live-landscape/live-landscape.json +0 -39
- package/dist/components/live-landscape/live-landscape.wxml +0 -73
- package/dist/components/live-landscape/live-landscape.wxss +0 -1
- package/dist/components/live-portrait/live-portrait.js +0 -274
- package/dist/components/live-portrait/live-portrait.json +0 -38
- package/dist/components/live-portrait/live-portrait.wxml +0 -106
- package/dist/components/live-portrait/live-portrait.wxss +0 -1
- package/dist/components/lottery/lottery-accept/index.js +0 -249
- package/dist/components/lottery/lottery-accept/index.json +0 -4
- package/dist/components/lottery/lottery-accept/index.wxml +0 -49
- package/dist/components/lottery/lottery-accept/index.wxss +0 -1
- package/dist/components/lottery/lottery-history/index.js +0 -36
- package/dist/components/lottery/lottery-history/index.json +0 -3
- package/dist/components/lottery/lottery-history/index.wxml +0 -28
- package/dist/components/lottery/lottery-history/index.wxss +0 -1
- package/dist/components/lottery/lottery-shake/lottery-shake.js +0 -328
- package/dist/components/lottery/lottery-shake/lottery-shake.json +0 -1
- package/dist/components/lottery/lottery-shake/lottery-shake.wxml +0 -52
- package/dist/components/lottery/lottery-shake/lottery-shake.wxss +0 -1
- package/dist/components/lottery/lottery-slot/lottery-slot.js +0 -230
- package/dist/components/lottery/lottery-slot/lottery-slot.json +0 -1
- package/dist/components/lottery/lottery-slot/lottery-slot.wxml +0 -62
- package/dist/components/lottery/lottery-slot/lottery-slot.wxss +0 -1
- package/dist/components/lottery/lottery-wheel/lottery-wheel.js +0 -153
- package/dist/components/lottery/lottery-wheel/lottery-wheel.json +0 -4
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxml +0 -91
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxss +0 -1
- package/dist/components/lottery/lottery-winners/index.js +0 -101
- package/dist/components/lottery/lottery-winners/index.json +0 -4
- package/dist/components/lottery/lottery-winners/index.wxml +0 -39
- package/dist/components/lottery/lottery-winners/index.wxss +0 -1
- package/dist/components/lottery/lottery.js +0 -388
- package/dist/components/lottery/lottery.json +0 -11
- package/dist/components/lottery/lottery.wxml +0 -78
- package/dist/components/lottery/lottery.wxss +0 -1
- package/dist/components/lottery/wheel.json +0 -49
- package/dist/components/mall-reward/common/reward-card.wxss +0 -0
- package/dist/components/mall-reward/duration-icon/index.js +0 -101
- package/dist/components/mall-reward/duration-icon/index.json +0 -3
- package/dist/components/mall-reward/duration-icon/index.wxml +0 -7
- package/dist/components/mall-reward/duration-icon/index.wxss +0 -1
- package/dist/components/mall-reward/f-count-down/index.js +0 -61
- package/dist/components/mall-reward/f-count-down/index.json +0 -3
- package/dist/components/mall-reward/f-count-down/index.wxml +0 -9
- package/dist/components/mall-reward/f-count-down/index.wxss +0 -1
- package/dist/components/mall-reward/f-empty/index.js +0 -11
- package/dist/components/mall-reward/f-empty/index.json +0 -3
- package/dist/components/mall-reward/f-empty/index.wxml +0 -8
- package/dist/components/mall-reward/f-empty/index.wxss +0 -1
- package/dist/components/mall-reward/f-history/index.js +0 -84
- package/dist/components/mall-reward/f-history/index.json +0 -4
- package/dist/components/mall-reward/f-history/index.wxml +0 -38
- package/dist/components/mall-reward/f-history/index.wxss +0 -1
- package/dist/components/mall-reward/f-open/index.js +0 -36
- package/dist/components/mall-reward/f-open/index.json +0 -3
- package/dist/components/mall-reward/f-open/index.wxml +0 -10
- package/dist/components/mall-reward/f-open/index.wxss +0 -1
- package/dist/components/mall-reward/f-receive/index.js +0 -36
- package/dist/components/mall-reward/f-receive/index.json +0 -3
- package/dist/components/mall-reward/f-receive/index.wxml +0 -9
- package/dist/components/mall-reward/f-receive/index.wxss +0 -1
- package/dist/components/mall-reward/index.js +0 -374
- package/dist/components/mall-reward/index.json +0 -8
- package/dist/components/mall-reward/index.wxml +0 -4
- package/dist/components/mall-reward/index.wxss +0 -0
- package/dist/components/mall-reward/main-popup/index.js +0 -46
- package/dist/components/mall-reward/main-popup/index.json +0 -12
- package/dist/components/mall-reward/main-popup/index.wxml +0 -16
- package/dist/components/mall-reward/main-popup/index.wxss +0 -1
- package/dist/components/player/assets/image/arrow-left.png +0 -0
- package/dist/components/player/assets/image/arrow-right.png +0 -0
- package/dist/components/player/assets/image/enterFullScreen.png +0 -0
- package/dist/components/player/assets/image/exitFullScreen.png +0 -0
- package/dist/components/player/assets/image/fullscreen_1.png +0 -0
- package/dist/components/player/assets/image/fullscreen_2.png +0 -0
- package/dist/components/player/assets/image/pause.png +0 -0
- package/dist/components/player/assets/image/pause_1.png +0 -0
- package/dist/components/player/assets/image/play.png +0 -0
- package/dist/components/player/assets/image/play_1.png +0 -0
- package/dist/components/player/assets/image/refresh.png +0 -0
- package/dist/components/player/assets/image/refresh_1.png +0 -0
- package/dist/components/player/assets/image/subtitle_close.png +0 -0
- package/dist/components/player/assets/image/subtitle_default.png +0 -0
- package/dist/components/player/assets/image/volume-off.png +0 -0
- package/dist/components/player/assets/image/volume-on.png +0 -0
- package/dist/components/player/common/config.js +0 -7
- package/dist/components/player/common/veComponent.js +0 -4
- package/dist/components/player/components/barrage/barrage-canvas.js +0 -488
- package/dist/components/player/components/barrage/barrage-dom.js +0 -471
- package/dist/components/player/components/barrage/index.js +0 -62
- package/dist/components/player/components/barrage/index.json +0 -4
- package/dist/components/player/components/barrage/index.wxml +0 -39
- package/dist/components/player/components/barrage/index.wxss +0 -1
- package/dist/components/player/components/barrage/utils.js +0 -71
- package/dist/components/player/components/controls/controls.js +0 -93
- package/dist/components/player/components/controls/controls.json +0 -6
- package/dist/components/player/components/controls/controls.wxml +0 -60
- package/dist/components/player/components/controls/controls.wxss +0 -1
- package/dist/components/player/components/danmaku/danmaku.js +0 -23
- package/dist/components/player/components/danmaku/danmaku.json +0 -4
- package/dist/components/player/components/danmaku/danmaku.wxml +0 -1
- package/dist/components/player/components/danmaku/danmaku.wxss +0 -0
- package/dist/components/player/components/error/error.js +0 -15
- package/dist/components/player/components/error/error.json +0 -3
- package/dist/components/player/components/error/error.wxml +0 -6
- package/dist/components/player/components/error/error.wxss +0 -1
- package/dist/components/player/components/loading/loading.js +0 -9
- package/dist/components/player/components/loading/loading.json +0 -3
- package/dist/components/player/components/loading/loading.wxml +0 -4
- package/dist/components/player/components/loading/loading.wxss +0 -1
- package/dist/components/player/components/main/extensions/data.js +0 -8
- package/dist/components/player/components/main/extensions/export.js +0 -83
- package/dist/components/player/components/main/extensions/methods.js +0 -110
- package/dist/components/player/components/main/extensions/observers.js +0 -41
- package/dist/components/player/components/main/extensions/props.js +0 -177
- package/dist/components/player/components/main/index.js +0 -44
- package/dist/components/player/components/main/index.json +0 -4
- package/dist/components/player/components/main/index.wxml +0 -7
- package/dist/components/player/components/main/index.wxss +0 -1
- package/dist/components/player/components/marquee/marquee.js +0 -304
- package/dist/components/player/components/marquee/marquee.json +0 -4
- package/dist/components/player/components/marquee/marquee.wxml +0 -14
- package/dist/components/player/components/marquee/marquee.wxss +0 -1
- package/dist/components/player/components/online-hot/assets/line-hot.png +0 -0
- package/dist/components/player/components/online-hot/assets/line-user.png +0 -0
- package/dist/components/player/components/online-hot/index.js +0 -66
- package/dist/components/player/components/online-hot/index.json +0 -3
- package/dist/components/player/components/online-hot/index.wxml +0 -15
- package/dist/components/player/components/online-hot/index.wxss +0 -1
- package/dist/components/player/components/poster/poster.js +0 -12
- package/dist/components/player/components/poster/poster.json +0 -3
- package/dist/components/player/components/poster/poster.wxml +0 -5
- package/dist/components/player/components/poster/poster.wxss +0 -1
- package/dist/components/player/components/watermark/watermark.js +0 -52
- package/dist/components/player/components/watermark/watermark.json +0 -4
- package/dist/components/player/components/watermark/watermark.wxml +0 -8
- package/dist/components/player/components/watermark/watermark.wxss +0 -1
- package/dist/components/player/extensions/data.js +0 -63
- package/dist/components/player/extensions/export.js +0 -325
- package/dist/components/player/extensions/methods.js +0 -406
- package/dist/components/player/extensions/observers.js +0 -114
- package/dist/components/player/extensions/props.js +0 -162
- package/dist/components/player/player.js +0 -83
- package/dist/components/player/player.json +0 -33
- package/dist/components/player/player.wxml +0 -48
- package/dist/components/player/player.wxss +0 -1
- package/dist/components/praise/praise.js +0 -150
- package/dist/components/praise/praise.json +0 -5
- package/dist/components/praise/praise.wxml +0 -17
- package/dist/components/praise/praise.wxss +0 -1
- package/dist/components/product/product-card/product-card.js +0 -109
- package/dist/components/product/product-card/product-card.json +0 -3
- package/dist/components/product/product-card/product-card.wxml +0 -47
- package/dist/components/product/product-card/product-card.wxss +0 -1
- package/dist/components/product/product-detail/product-detail.js +0 -127
- package/dist/components/product/product-detail/product-detail.json +0 -3
- package/dist/components/product/product-detail/product-detail.wxml +0 -57
- package/dist/components/product/product-detail/product-detail.wxss +0 -1
- package/dist/components/product/product-item/product-item.js +0 -56
- package/dist/components/product/product-item/product-item.json +0 -3
- package/dist/components/product/product-item/product-item.wxml +0 -35
- package/dist/components/product/product-item/product-item.wxss +0 -1
- package/dist/components/product/product-list/product-list.js +0 -67
- package/dist/components/product/product-list/product-list.json +0 -6
- package/dist/components/product/product-list/product-list.wxml +0 -16
- package/dist/components/product/product-list/product-list.wxss +0 -1
- package/dist/components/product/product-order/product-order.js +0 -394
- package/dist/components/product/product-order/product-order.json +0 -3
- package/dist/components/product/product-order/product-order.wxml +0 -75
- package/dist/components/product/product-order/product-order.wxss +0 -1
- package/dist/components/signin/signin-dialog.js +0 -305
- package/dist/components/signin/signin-dialog.json +0 -7
- package/dist/components/signin/signin-dialog.wxml +0 -19
- package/dist/components/signin/signin-dialog.wxss +0 -1
- package/dist/components/top-notify/index.js +0 -14
- package/dist/components/top-notify/index.json +0 -3
- package/dist/components/top-notify/index.wxml +0 -2
- package/dist/components/top-notify/index.wxss +0 -1
- package/dist/pubComponents/countdown/countdown.js +0 -97
- package/dist/pubComponents/countdown/countdown.json +0 -5
- package/dist/pubComponents/countdown/countdown.wxml +0 -19
- package/dist/pubComponents/countdown/countdown.wxss +0 -1
- package/dist/pubComponents/error-page/index.js +0 -146
- package/dist/pubComponents/error-page/index.json +0 -5
- package/dist/pubComponents/error-page/index.wxml +0 -37
- package/dist/pubComponents/error-page/index.wxss +0 -1
- package/dist/pubComponents/popup/popup.js +0 -161
- package/dist/pubComponents/popup/popup.json +0 -5
- package/dist/pubComponents/popup/popup.wxml +0 -17
- package/dist/pubComponents/popup/popup.wxss +0 -1
- package/dist/pubComponents/tabs/index.js +0 -95
- package/dist/pubComponents/tabs/index.json +0 -4
- package/dist/pubComponents/tabs/index.wxml +0 -22
- package/dist/pubComponents/tabs/index.wxss +0 -1
- package/dist/sdk/config/index.js +0 -1
- package/dist/sdk/main/index.js +0 -1
- package/dist/sdk/player/index.js +0 -1
- package/dist/sdk/plugins/ChatServer.js +0 -1
- package/dist/sdk/plugins/CustomMenuServer.js +0 -1
- package/dist/sdk/plugins/InteractServer.js +0 -1
- package/dist/sdk/plugins/InviteCardServer.js +0 -1
- package/dist/sdk/plugins/LotteryServer.js +0 -1
- package/dist/sdk/plugins/MallRewardServer.js +0 -1
- package/dist/sdk/plugins/ProductServer.js +0 -1
- package/dist/shared/RequestUtil.js +0 -1
- package/dist/shared/SerializableMap.js +0 -1
- package/dist/shared/base.server.js +0 -1
- package/dist/shared/cacheUtil.js +0 -1
- package/dist/shared/dateUtil.js +0 -1
- package/dist/shared/logger.js +0 -1
- package/dist/shared/mpUtils.js +0 -1
- package/dist/shared/utils.js +0 -1
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
|
+
!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,m=e.length-15,b=0;b<m;)v=y[e[b++]^255&v]^g[e[b++]^v>>8&255]^_[e[b++]^v>>16&255]^f[e[b++]^v>>>24]^h[e[b++]]^d[e[b++]]^p[e[b++]]^c[e[b++]]^u[e[b++]]^l[e[b++]]^s[e[b++]]^a[e[b++]]^o[e[b++]]^n[e[b++]]^i[e[b++]]^t[e[b++]];for(m+=15;b<m;)v=v>>>8^t[255&(v^e[b++])];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 formatTime(){const e=new Date,pad=(e,t=2)=>String(e).padStart(t,"0");return`${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}:${pad(e.getMilliseconds(),3)}`}function createLogger(e=""){const t=e?`[${e}]`:"",r="VhallMiniSDK",enabled=e=>e>=u;return{trace:function trace(...e){enabled(l.trace)&&console.trace(`${r} [${formatTime()}] <TRACE> ${t} `,...e)},debug:function debug(...e){enabled(l.debug)&&console.debug(`${r} [${formatTime()}] <DEBUG> ${t} `,...e)},info:function info(...e){enabled(l.info)&&console.info(`${r} [${formatTime()}] <INFO> ${t}`,...e)},log:function log(...e){enabled(l.log)&&console.log(`${r} [${formatTime()}] <LOG> ${t}`,...e)},warn:function warn(...e){enabled(l.warn)&&console.warn(`${r} [${formatTime()}] <WARN> ${t}`,...e)},error:function error(...e){enabled(l.error)&&console.error(`${r} [${formatTime()}] <ERROR> ${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}=?)?$/,m=String.fromCharCode.bind(String),b=("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(m.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?m(192|t>>>6)+m(128|63&t):m(224|t>>>12&15)+m(128|t>>>6&63)+m(128|63&t);var t=65536+1024*(e.charCodeAt(0)-55296)+(e.charCodeAt(1)-56320);return m(240|t>>>18&7)+m(128|t>>>12&63)+m(128|t>>>6&63)+m(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?b(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?m(t>>16&255):64===i?m(t>>16&255,t>>8&255):m(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(),T="wxminiprogram",S=102001,x=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:T,ua:T,browser_name:T,osv:T,ndi:T,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?x: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 $=c("playerCore");class VhallPlayerCore{constructor(){}init(e){this.option=e,this.scheduler=new Scheduler(e),this.logReporter&&this.logReporter._infoPackInterval>0?($.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 m=e.webinar.img_url;d&&e.webinar.vertical_img_url&&(m=e.webinar.vertical_img_url);let b={};m.length>0&&(b={enable:!0,url:m});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:b,watermarkOption:A,marqueeOption:I}}catch(e){throw $.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 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e={d:function(t,
|
|
1
|
+
!function(){"use strict";var e={d:function(t,i){for(var n in i)e.o(i,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:i[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{InviteCardServer:function(){return InviteCardServer},default:function(){return s}});const i="sdkStateReady";wx.getAccountInfoSync();const n={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let a=n.info;function formatTime(){const e=new Date,pad=(e,t=2)=>String(e).padStart(t,"0");return`${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}:${pad(e.getMilliseconds(),3)}`}function createLogger(e=""){const t=e?`[${e}]`:"",i="VhallMiniSDK",enabled=e=>e>=a;return{trace:function trace(...e){enabled(n.trace)&&console.trace(`${i} [${formatTime()}] <TRACE> ${t} `,...e)},debug:function debug(...e){enabled(n.debug)&&console.debug(`${i} [${formatTime()}] <DEBUG> ${t} `,...e)},info:function info(...e){enabled(n.info)&&console.info(`${i} [${formatTime()}] <INFO> ${t}`,...e)},log:function log(...e){enabled(n.log)&&console.log(`${i} [${formatTime()}] <LOG> ${t}`,...e)},warn:function warn(...e){enabled(n.warn)&&console.warn(`${i} [${formatTime()}] <WARN> ${t}`,...e)},error:function error(...e){enabled(n.error)&&console.error(`${i} [${formatTime()}] <ERROR> ${t}`,...e)}}}const r=createLogger("InviteCardServer");class InviteCardServer{static name="InviteCardServer";constructor(e){this.sdkInstance=e,this.wxApi=this.sdkInstance.wxApi,this.initEvents()}initEvents(){this.sdkInstance.on(i,(()=>{1==this.sdkInstance.store.get("inviteCardStatus").status&&this.getInviteCode()}))}_parseReqParams(e,t){const i=this.sdkInstance.store.get("watchInitData");let n=this.sdkInstance.store.get("user").user_id;const a={source_id:i?.webinar?.id,source_type:1};if("relationship"===t?(a.be_invite_id=n,a.be_invite_id_type=1):(a.invite_id=n,a.invite_id_type=1),Array.isArray(e))for(const t of e)switch(t){case"language_type":a[t]=0;break;case"channel":a[t]="main";break;case"visitor_id":a[t]=i?.visitor_id||"";break;case"business_uid":a[t]=i?.webinar.userinfo.user_id;break;case"invite_type":a[t]=5}return a}async getInviteCode(){const e=this._parseReqParams(["language_type","channel","business_uid","visitor_id"]);try{const t=await this.wxApi.sendPost("/v1/marketing/app/invite/card/my-invite-card",e);return t&&200===t.code&&t.data?.invite_code?(this.sdkInstance.store.set("invite_code",t.data.invite_code),t.data.invite_code):null}catch(e){return r.error("获取邀请卡信息出现异常,error:",e),null}}async bindInviteRelation(e,t){if(!e||!t)return;const i={invite_code:e,wechat_open_id:t,...this._parseReqParams(["business_uid","invite_type","channel","visitor_id"],"relationship")};r.debug("bindInviteRelation reqParam:",JSON.stringify(i));try{const e=await this.wxApi.sendPost("/v1/marketing/app/invite/card/create-invite-other-relation",i);return e&&e.code,r.debug("bindInviteRelation res:",e),e}catch(e){return r.error("绑定邀约关系出现异常,error:",e),null}}async getInviteCardInfo(){const e=this._parseReqParams(["language_type","channel","business_uid"]),t=await this.wxApi.sendPost("/v1/marketing/app/invite/card/init-invite-card",e);return t&&200===t.code&&t.data&&(this.sdkInstance.store.set("inviteCardInfo",t.data),t.data.invite_code&&this.sdkInstance.store.set("invite_code",t.data.invite_code)),t?.data||null}async getInviteRankList(){const e={pos:0,limit:200,...this._parseReqParams()},t=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/get-top-list",e);return t&&200===t.code&&t.data?t.data:null}async getMyInviteDetails(){const e=this._parseReqParams(["business_uid"]),t=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/my-invite-details",e);return t&&200===t.code&&t.data?t.data:null}async getMyInviteDetailsUrl(){const e=this._parseReqParams(["business_uid"]),t=await this.wxApi.sendPost("/v1/marketing/app/invite/stat/my-invite-details-url",e);return t&&200===t.code&&t.data?t.data:null}}var s=InviteCardServer;module.exports=t}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MallRewardServer:function(){return MallRewardServer},default:function(){return
|
|
1
|
+
!function(){"use strict";var e={d:function(t,r){for(var n in r)e.o(r,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:r[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{MallRewardServer:function(){return MallRewardServer},default:function(){return i}});class BaseServer{constructor(){this.handlers=Object.create(null)}on=(e,t)=>{const r=[];if("object"==typeof e&&null!==e)Object.entries(e).forEach((([e,t])=>{this._validateParams(e,t),this._addHandler(e,t),r.push({type:e,handler:t})}));else{if("string"!=typeof e||"function"!=typeof t)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(e,t),this._addHandler(e,t),r.push({type:e,handler:t})}return()=>{r.forEach((({type:e,handler:t})=>{if(!this.handlers[e])return;const r=this.handlers[e].findIndex((e=>e===t));-1!==r&&(this.handlers[e].splice(r,1),0===this.handlers[e].length&&delete this.handlers[e])}))}};emit=(e,...t)=>{this.handlers[e]&&[...this.handlers[e]].forEach((e=>{e(...t)}))};off=(e,t)=>{if(!this.handlers[e])throw new Error(`不存在事件: ${e}`);if(t){const r=this.handlers[e].findIndex((e=>e===t));this.handlers[e].splice(r,1),0===this.handlers[e].length&&delete this.handlers[e]}else delete this.handlers[e]};_validateParams(e,t){if("string"!=typeof e)throw new Error("事件名必须为字符串");if("function"!=typeof t)throw new Error("事件处理函数必须为函数")}_addHandler(e,t){this.handlers[e]||(this.handlers[e]=[]),this.handlers[e].includes(t)||this.handlers[e].push(t)}}const r={trace:0,debug:1,info:2,log:2,warn:3,error:4,silent:5};let n=r.info;function formatTime(){const e=new Date,pad=(e,t=2)=>String(e).padStart(t,"0");return`${pad(e.getHours())}:${pad(e.getMinutes())}:${pad(e.getSeconds())}:${pad(e.getMilliseconds(),3)}`}function createLogger(e=""){const t=e?`[${e}]`:"",a="VhallMiniSDK",enabled=e=>e>=n;return{trace:function trace(...e){enabled(r.trace)&&console.trace(`${a} [${formatTime()}] <TRACE> ${t} `,...e)},debug:function debug(...e){enabled(r.debug)&&console.debug(`${a} [${formatTime()}] <DEBUG> ${t} `,...e)},info:function info(...e){enabled(r.info)&&console.info(`${a} [${formatTime()}] <INFO> ${t}`,...e)},log:function log(...e){enabled(r.log)&&console.log(`${a} [${formatTime()}] <LOG> ${t}`,...e)},warn:function warn(...e){enabled(r.warn)&&console.warn(`${a} [${formatTime()}] <WARN> ${t}`,...e)},error:function error(...e){enabled(r.error)&&console.error(`${a} [${formatTime()}] <ERROR> ${t}`,...e)}}}const a=createLogger("MallRewardServer");class MallRewardServer extends BaseServer{static name="MallRewardServer";constructor(e){super(),this.sdkInstance=e,this.wxApi=e.wxApi}async getValidList(){console.log("mall-reward 获取商城奖励列表");const e=this.sdkInstance.store.get("watchInitData"),t={webinar_id:this.sdkInstance.webinarId,sence_type:5==e?.webinar?.type?1:0,switch_id:e?.switch?.switch_id};try{const e=await this.wxApi.sendPost("/v3/vss/mall-reward/get-valid-list",t,{headers:{"Content-Type":"application/x-www-form-urlencoded"}});return e&&200===e.code&&e.data&&(Array.isArray(e.data.list)&&e.data.list.forEach((e=>{e.tip_setting=function(e){const t=Object.prototype.toString.call(e);if(["[object Array]","[object Object]","[object Null]"].includes(t))return e;try{return JSON.parse(e)}catch(e){return null}}(e.tip_setting)})),this.sdkInstance.store.set("mallRewardInfo",e?.data||null),this.updateActiveMallReward()),e?.data||null}catch(e){return a.error("获取商城奖励列表出现异常,error:",e),null}}updateActiveMallReward(){const e=this.sdkInstance.store.get("mallRewardInfo");if(!e||!e.list||0===e.list.length)return null;let t,r=-1;for(let n=0;n<e.list.length;n++){let a=e.list[n];if(0===a.claim_status&&0===a.viewing_minutes&&1===a.status&&a.remaining_quota>0){r=n;break}0===a.claim_status&&a.viewing_minutes>0&&0===a.status&&a.remaining_quota>0&&(void 0===t||a.watch_minute<t)&&(t=a.viewing_minutes,r=n)}return r>-1?e.list[r]:null}async claimMallReward(e){const t=this.sdkInstance.store.get("watchInitData"),r={reward_id:e,webinar_id:this.sdkInstance.webinarId,sence_type:5==t?.webinar?.type?1:0,switch_id:t?.switch?.switch_id};try{return await this.wxApi.sendPost("/v3/vss/mall-reward/receive",r,{headers:{"Content-Type":"application/x-www-form-urlencoded"}})}catch(e){return a.error("领取商城奖励出现异常,error:",e),e}}}var i=MallRewardServer;module.exports=t}();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(){"use strict";var t={d:function(e,s){for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ProductServer:function(){return ProductServer},default:function(){return s}});class BaseServer{constructor(){this.handlers=Object.create(null)}on=(t,e)=>{const s=[];if("object"==typeof t&&null!==t)Object.entries(t).forEach((([t,e])=>{this._validateParams(t,e),this._addHandler(t,e),s.push({type:t,handler:e})}));else{if("string"!=typeof t||"function"!=typeof e)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(t,e),this._addHandler(t,e),s.push({type:t,handler:e})}return()=>{s.forEach((({type:t,handler:e})=>{if(!this.handlers[t])return;const s=this.handlers[t].findIndex((t=>t===e));-1!==s&&(this.handlers[t].splice(s,1),0===this.handlers[t].length&&delete this.handlers[t])}))}};emit=(t,...e)=>{this.handlers[t]&&[...this.handlers[t]].forEach((t=>{t(...e)}))};off=(t,e)=>{if(!this.handlers[t])throw new Error(`不存在事件: ${t}`);if(e){const s=this.handlers[t].findIndex((t=>t===e));this.handlers[t].splice(s,1),0===this.handlers[t].length&&delete this.handlers[t]}else delete this.handlers[t]};_validateParams(t,e){if("string"!=typeof t)throw new Error("事件名必须为字符串");if("function"!=typeof e)throw new Error("事件处理函数必须为函数")}_addHandler(t,e){this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].includes(e)||this.handlers[t].push(e)}}class ProductServer extends BaseServer{static name="ProductServer";constructor(t){super(),this.sdkInstance=t,this.wxApi=t.wxApi,this.productList=[],this.lastMsgTime="",this.listenerEvent(),this.sdkInstance.on(this.sdkInstance.EVENT.FOREGROUND_REFRESH,((...t)=>this.onForeground(...t)))}async getProductList(t){return this.wxApi.sendGet("/v3/goods/webinar/get-online-goods",{...t}).then((t=>(200==t.code&&(t.data=t.data.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.productList=t.data,this.sdkInstance.store.set("productList",t.data)),t)))}onForeground=({gap:t})=>{this.getProductList({}).catch((t=>console.error("ProductServer.onForeground refresh failed:",t)))};listenerEvent(){this.sdkInstance.on(this.sdkInstance.EVENT.CUSTOM_MSG,(t=>{["goods_update_info","push_goods_change"].includes(t.data.type)&&t.date_time>this.lastMsgTime&&(this._getProductListByCdn(t.data),this.sdkInstance.BRSAgent?.customLog("product:update"),this.lastMsgTime=t.date_time)}))}async _getProductListByCdn(t){try{const e=await this.wxApi.sendGet(t.cdn_url,{},{timeout:5e3});return this.productList=e.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.sdkInstance.store.set("productList",this.productList),e}catch(e){if(console.error("请求 cdn_url 失败:",e),!t.access_url)throw e;try{const e=await this.wxApi.sendGet(t.access_url);return this.productList=e.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.sdkInstance.store.set("productList",this.productList),e}catch(t){throw console.error("请求 access_url 也失败:",t),t}}}_getCurClientBuyTypeInfo(t){if(0==t.enable_multi_config)return t;{let e,s,r,n;t.sku.forEach((t=>{const
|
|
1
|
+
!function(){"use strict";var t={d:function(e,s){for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r:function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ProductServer:function(){return ProductServer},default:function(){return s}});class BaseServer{constructor(){this.handlers=Object.create(null)}on=(t,e)=>{const s=[];if("object"==typeof t&&null!==t)Object.entries(t).forEach((([t,e])=>{this._validateParams(t,e),this._addHandler(t,e),s.push({type:t,handler:e})}));else{if("string"!=typeof t||"function"!=typeof e)throw new Error("参数格式错误,支持:$on(事件名, 处理函数) 或 $on({事件名: 处理函数, ...})");this._validateParams(t,e),this._addHandler(t,e),s.push({type:t,handler:e})}return()=>{s.forEach((({type:t,handler:e})=>{if(!this.handlers[t])return;const s=this.handlers[t].findIndex((t=>t===e));-1!==s&&(this.handlers[t].splice(s,1),0===this.handlers[t].length&&delete this.handlers[t])}))}};emit=(t,...e)=>{this.handlers[t]&&[...this.handlers[t]].forEach((t=>{t(...e)}))};off=(t,e)=>{if(!this.handlers[t])throw new Error(`不存在事件: ${t}`);if(e){const s=this.handlers[t].findIndex((t=>t===e));this.handlers[t].splice(s,1),0===this.handlers[t].length&&delete this.handlers[t]}else delete this.handlers[t]};_validateParams(t,e){if("string"!=typeof t)throw new Error("事件名必须为字符串");if("function"!=typeof e)throw new Error("事件处理函数必须为函数")}_addHandler(t,e){this.handlers[t]||(this.handlers[t]=[]),this.handlers[t].includes(e)||this.handlers[t].push(e)}}class ProductServer extends BaseServer{static name="ProductServer";constructor(t){super(),this.sdkInstance=t,this.wxApi=t.wxApi,this.productList=[],this.lastMsgTime="",this.listenerEvent(),this.sdkInstance.on(this.sdkInstance.EVENT.FOREGROUND_REFRESH,((...t)=>this.onForeground(...t)))}async getProductList(t){return this.wxApi.sendGet("/v3/goods/webinar/get-online-goods",{...t}).then((t=>(200==t.code&&(t.data=t.data.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.productList=t.data,this.sdkInstance.store.set("productList",t.data)),t)))}onForeground=({gap:t})=>{this.getProductList({}).catch((t=>console.error("ProductServer.onForeground refresh failed:",t)))};listenerEvent(){this.sdkInstance.on(this.sdkInstance.EVENT.CUSTOM_MSG,(t=>{["goods_update_info","push_goods_change"].includes(t.data.type)&&(this.sdkInstance.get("logReportServer").report("116999",{stage:t.data.type,logData:t}),t.date_time>this.lastMsgTime&&(this._getProductListByCdn(t.data),this.sdkInstance.BRSAgent?.customLog("product:update"),this.lastMsgTime=t.date_time))}))}async _getProductListByCdn(t){try{const e=await this.wxApi.sendGet(t.cdn_url,{},{timeout:5e3});return this.sdkInstance.get("logReportServer").report("116999",{stage:"getProductListByCdn",logData:e}),this.productList=e.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.sdkInstance.store.set("productList",this.productList),e}catch(e){if(console.error("请求 cdn_url 失败:",e),!t.access_url)throw e;try{const e=await this.wxApi.sendGet(t.access_url);return this.sdkInstance.get("logReportServer").report("116999",{stage:"getProductListByCdn2",logData:e}),this.productList=e.filter((t=>1==t.status)).map((t=>this._getCurClientBuyTypeInfo(t))),this.sdkInstance.store.set("productList",this.productList),e}catch(t){throw console.error("请求 access_url 也失败:",t),t}}}_getCurClientBuyTypeInfo(t){if(0==t.enable_multi_config)return t;{let e,s,r,n;t.sku.forEach((t=>{const o=Object(t,t.sku_conf);1==o.buy_type?e=o:2==o.buy_type?s=o:3==o.buy_type?r=o:4==o.buy_type&&(n=o)}));const o=e||n||s||r;return Object.assign(t,o,{mini_program_config:n})}}}var s=ProductServer;module.exports=e}();
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vhall-mini-sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"author": "vhall",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"miniprogram": "lib",
|
|
@@ -12,7 +12,7 @@
|
|
|
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
|
|
15
|
+
"build:lib": "SKIP_MP_COMPONENTS_SYNC=true yarn && npx gulp -f build/compiler.js --series buildLib"
|
|
16
16
|
},
|
|
17
17
|
"files": [
|
|
18
18
|
"dist",
|
|
@@ -74,9 +74,7 @@
|
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
76
|
"await-to-js": "^3.0.0",
|
|
77
|
-
"chalk": "4",
|
|
78
77
|
"crc-32": "^1.2.0",
|
|
79
|
-
"fs-extra": "^11.3.6",
|
|
80
78
|
"js-base64": "^3.7.7",
|
|
81
79
|
"miniprogram-sm-crypto": "^0.3.13"
|
|
82
80
|
}
|
package/postinstall.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
const fs = require('fs
|
|
1
|
+
const fs = require('fs');
|
|
2
2
|
const path = require('path');
|
|
3
|
-
const chalk = require('chalk'); // 可选,让日志更好看,需要 npm i chalk -D 加到组件库依赖里
|
|
4
3
|
|
|
5
4
|
/**
|
|
6
5
|
* 1. 基础路径定义
|
|
@@ -29,9 +28,9 @@ const userPkgPath = path.resolve(projectRoot, 'package.json');
|
|
|
29
28
|
let userPkg = {};
|
|
30
29
|
if (fs.existsSync(userPkgPath)) {
|
|
31
30
|
try {
|
|
32
|
-
userPkg = fs.
|
|
31
|
+
userPkg = JSON.parse(fs.readFileSync(userPkgPath, 'utf-8'));
|
|
33
32
|
} catch (e) {
|
|
34
|
-
console.warn(
|
|
33
|
+
console.warn('[vhall-mini-sdk] 无法读取用户项目 package.json,使用默认配置');
|
|
35
34
|
}
|
|
36
35
|
}
|
|
37
36
|
// 如果用户自定义了 uni-app 根目录,就用自定义的
|
|
@@ -43,53 +42,24 @@ if (userPkg.mpComponents?.root) {
|
|
|
43
42
|
* 3. 核心:判断是否为 uni-app 环境
|
|
44
43
|
*/
|
|
45
44
|
function isUniAppProject(root) {
|
|
46
|
-
//
|
|
45
|
+
// 强制开关:如果用户设置了环境变量,优先遵循
|
|
47
46
|
if (process.env.SKIP_MP_COMPONENTS_SYNC === 'true') {
|
|
48
|
-
console.log(
|
|
47
|
+
console.log('[vhall-mini-sdk] SKIP_MP_COMPONENTS_SYNC=true,跳过 wxcomponents 同步');
|
|
49
48
|
return false;
|
|
50
49
|
}
|
|
51
50
|
if (process.env.FORCE_MP_COMPONENTS_SYNC === 'true') {
|
|
52
|
-
console.log(
|
|
51
|
+
console.log('[vhall-mini-sdk] FORCE_MP_COMPONENTS_SYNC=true,强制同步');
|
|
53
52
|
return true;
|
|
54
53
|
}
|
|
55
54
|
|
|
56
|
-
//
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (!fs.existsSync(pagesPath) || !fs.existsSync(manifestPath)) {
|
|
61
|
-
console.log(chalk.gray('ℹ️ 未检测到 uni-app 环境(缺少 pages.json/manifest.json),跳过 wxcomponents 同步'));
|
|
62
|
-
return false;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// 3.3 辅助校验:pages.json 是合法 JSON,且包含 uni-app 特有字段
|
|
66
|
-
try {
|
|
67
|
-
const pagesConfig = fs.readJsonSync(pagesPath);
|
|
68
|
-
// uni-app 的 pages.json 一定有 pages 数组或 globalStyle 字段
|
|
69
|
-
if (!pagesConfig.pages && !pagesConfig.globalStyle) {
|
|
70
|
-
console.log(chalk.gray('ℹ️ 检测到 pages.json 不符合 uni-app 规范,跳过同步'));
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
} catch (e) {
|
|
74
|
-
console.log(chalk.gray('ℹ️ pages.json 不是合法 JSON,跳过同步'));
|
|
75
|
-
return false;
|
|
55
|
+
// 同时存在 pages.json 和 manifest.json 即判定为 uni-app 项目
|
|
56
|
+
if (fs.existsSync(path.resolve(root, 'pages.json')) && fs.existsSync(path.resolve(root, 'manifest.json'))) {
|
|
57
|
+
return true;
|
|
76
58
|
}
|
|
77
59
|
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// Object.keys(userPkg.devDependencies || {}).some((dep) => dep.startsWith('@dcloudio'));
|
|
82
|
-
// if (!hasDCloudDep) {
|
|
83
|
-
// console.log(
|
|
84
|
-
// chalk.gray(
|
|
85
|
-
// 'ℹ️ 未检测到 @dcloudio 相关依赖,若确认是 uni-app 项目,请设置 FORCE_MP_COMPONENTS_SYNC=true',
|
|
86
|
-
// ),
|
|
87
|
-
// );
|
|
88
|
-
// // 这里可以根据团队要求决定是否返回 false,一般前两步过了就可以放行
|
|
89
|
-
// // return false
|
|
90
|
-
// }
|
|
91
|
-
|
|
92
|
-
return true;
|
|
60
|
+
// 兜底:如果是 CLI 项目,校验是否有 @dcloudio 依赖
|
|
61
|
+
const deps = { ...userPkg.dependencies, ...userPkg.devDependencies };
|
|
62
|
+
return !!(deps['@dcloudio/uni-app'] || deps['@dcloudio/vue-cli-plugin-uni']);
|
|
93
63
|
}
|
|
94
64
|
|
|
95
65
|
/**
|
|
@@ -98,7 +68,7 @@ function isUniAppProject(root) {
|
|
|
98
68
|
function syncWxComponents() {
|
|
99
69
|
let srcDir = path.resolve(PKG_ROOT, 'lib');
|
|
100
70
|
if (!fs.existsSync(srcDir)) {
|
|
101
|
-
console.error(
|
|
71
|
+
console.error('[vhall-mini-sdk] 组件库内未找到 lib 目录,同步失败');
|
|
102
72
|
return;
|
|
103
73
|
}
|
|
104
74
|
// 目标目录
|
|
@@ -106,19 +76,19 @@ function syncWxComponents() {
|
|
|
106
76
|
|
|
107
77
|
try {
|
|
108
78
|
// 清空旧目录
|
|
109
|
-
fs.
|
|
79
|
+
fs.rmSync(destDir, { recursive: true, force: true });
|
|
110
80
|
// 拷贝组件
|
|
111
|
-
fs.
|
|
81
|
+
fs.cpSync(srcDir, destDir, { recursive: true });
|
|
112
82
|
// 同步 package.json(提供组件元信息,便于 uni-app 识别该 npm 组件)
|
|
113
83
|
const srcPkg = path.resolve(PKG_ROOT, 'package.json');
|
|
114
84
|
if (fs.existsSync(srcPkg)) {
|
|
115
|
-
fs.
|
|
85
|
+
fs.copyFileSync(srcPkg, path.resolve(destDir, 'package.json'));
|
|
116
86
|
}
|
|
117
|
-
console.log(
|
|
118
|
-
console.log(
|
|
119
|
-
console.log(
|
|
87
|
+
console.log('[vhall-mini-sdk] wxcomponents 同步成功');
|
|
88
|
+
console.log(` 源目录:${srcDir}`);
|
|
89
|
+
console.log(` 目标目录:${destDir}`);
|
|
120
90
|
} catch (err) {
|
|
121
|
-
console.error(
|
|
91
|
+
console.error('[vhall-mini-sdk] wxcomponents 同步失败:', err.message);
|
|
122
92
|
// 不主动 exit(1),避免阻断用户 npm install
|
|
123
93
|
}
|
|
124
94
|
}
|
|
@@ -129,5 +99,5 @@ try {
|
|
|
129
99
|
syncWxComponents();
|
|
130
100
|
}
|
|
131
101
|
} catch (err) {
|
|
132
|
-
console.error(
|
|
102
|
+
console.error('[vhall-mini-sdk] postinstall 脚本执行异常:', err.message);
|
|
133
103
|
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
Component({
|
|
2
|
-
options: {
|
|
3
|
-
styleIsolation: 'apply-shared',
|
|
4
|
-
},
|
|
5
|
-
properties: {
|
|
6
|
-
sdkInstance: {
|
|
7
|
-
type: Object,
|
|
8
|
-
value: null,
|
|
9
|
-
},
|
|
10
|
-
},
|
|
11
|
-
|
|
12
|
-
data: {
|
|
13
|
-
userInfo: {},
|
|
14
|
-
isBanned: false, //是否禁言
|
|
15
|
-
isAllBanned: false, //是否禁言所有人,
|
|
16
|
-
bannedMode: 1,//1禁言无感知,0禁言有感知
|
|
17
|
-
placeholder: '参与聊天',
|
|
18
|
-
chatValue: '',
|
|
19
|
-
inputBottom: 0,
|
|
20
|
-
keyboardListener: null,
|
|
21
|
-
},
|
|
22
|
-
lifetimes: {
|
|
23
|
-
attached() {
|
|
24
|
-
this.ListenKeyboard();
|
|
25
|
-
},
|
|
26
|
-
detached: function detached() {
|
|
27
|
-
this.unsub && this.unsub();
|
|
28
|
-
this.keyboardListener && this.keyboardListener.disconnect();
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
observers: {
|
|
32
|
-
isBanned(newVal) {
|
|
33
|
-
this.setPlaceholder()
|
|
34
|
-
},
|
|
35
|
-
isAllBanned(newVal) {
|
|
36
|
-
this.setPlaceholder()
|
|
37
|
-
},
|
|
38
|
-
bannedMode(newVal) {
|
|
39
|
-
this.setPlaceholder()
|
|
40
|
-
},
|
|
41
|
-
sdkInstance: function sdkInstance(_sdkInstance) {
|
|
42
|
-
if (!_sdkInstance) return;
|
|
43
|
-
this.unsub = _sdkInstance.store.get({
|
|
44
|
-
user: (val) => {
|
|
45
|
-
this.setData({
|
|
46
|
-
userInfo: val,
|
|
47
|
-
});
|
|
48
|
-
},
|
|
49
|
-
'interactToolStatus.is_banned': (val) => {
|
|
50
|
-
this.setData({
|
|
51
|
-
isBanned: !!val,
|
|
52
|
-
});
|
|
53
|
-
},
|
|
54
|
-
'interactToolStatus.all_banned': (val) => {
|
|
55
|
-
this.setData({
|
|
56
|
-
isAllBanned: !!val,
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
'interactToolStatus.banned_mode': (val) => {
|
|
60
|
-
this.setData({
|
|
61
|
-
bannedMode: val,
|
|
62
|
-
})
|
|
63
|
-
},
|
|
64
|
-
'permissions': (val) => {
|
|
65
|
-
const status = _sdkInstance.store.get('liveInfo.status');
|
|
66
|
-
// 4 点播 5 回放 && 开启了回放禁言
|
|
67
|
-
if ((status == 4 || status == 5) && val['ui.watch_record_no_chatting'] == 1) {
|
|
68
|
-
this.setData({
|
|
69
|
-
isAllBanned: true,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
'liveInfo.status': (status) => {
|
|
74
|
-
if (status == 3) {
|
|
75
|
-
this.setData({
|
|
76
|
-
isAllBanned: true,
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
methods: {
|
|
84
|
-
ListenKeyboard() {
|
|
85
|
-
this.keyboardListener = wx.onKeyboardHeightChange((res) => {
|
|
86
|
-
this.setData({
|
|
87
|
-
inputBottom: res.height,
|
|
88
|
-
});
|
|
89
|
-
});
|
|
90
|
-
},
|
|
91
|
-
// 获得焦点
|
|
92
|
-
onInputFocus(e) {
|
|
93
|
-
this.setPlaceholder('focus')
|
|
94
|
-
},
|
|
95
|
-
onInputBlur() {
|
|
96
|
-
// 失去焦点时重置位置,并移除键盘监听
|
|
97
|
-
this.setData({ inputBottom: 0 });
|
|
98
|
-
this.setPlaceholder()
|
|
99
|
-
},
|
|
100
|
-
setPlaceholder(action) {
|
|
101
|
-
if (this.data.isBanned && this.data.bannedMode != 1 || this.data.isAllBanned) {
|
|
102
|
-
this.setData({
|
|
103
|
-
placeholder: '禁止发言'
|
|
104
|
-
})
|
|
105
|
-
} else {
|
|
106
|
-
this.setData({
|
|
107
|
-
placeholder: action === 'focus' ? '' : '参与聊天'
|
|
108
|
-
})
|
|
109
|
-
}
|
|
110
|
-
},
|
|
111
|
-
chatInputChange: function chatInputChange(e) {},
|
|
112
|
-
bindconfirm: function bindconfirm(e) {
|
|
113
|
-
if (!e.detail.value.trim()) {
|
|
114
|
-
return;
|
|
115
|
-
}
|
|
116
|
-
const sdkInstance = this.properties.sdkInstance;
|
|
117
|
-
if (sdkInstance) {
|
|
118
|
-
sdkInstance.sendChat({
|
|
119
|
-
data: e.detail.value,
|
|
120
|
-
});
|
|
121
|
-
this.setData({
|
|
122
|
-
chatValue: '',
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
});
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<view class="comment-wrapper safe-area-inset-bottom">
|
|
2
|
-
<image wx:if="{{userInfo.avatar}}" class="avatar" src="{{userInfo.avatar}}"></image>
|
|
3
|
-
<view class="chat-edit-input-box {{inputBottom !== 0 ? 'input-active' : ''}}" style="bottom: {{inputBottom}}px;">
|
|
4
|
-
<input bindinput="chatInputChange" adjust-position="{{false}}" value="{{ chatValue }}" class="chat-edit-input" id="chat-edit-input" placeholder-class="chat-edit-input-placeholder" placeholder="{{placeholder}}" disabled="{{isBanned&&bannedMode!=1 ||isAllBanned}}" maxlength="200" bindconfirm="bindconfirm" bindtap="bindtap" bindblur="onInputBlur" bindfocus="onInputFocus" confirm-type="send" type="text" />
|
|
5
|
-
</view>
|
|
6
|
-
<slot></slot>
|
|
7
|
-
</view>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
.comment-wrapper{align-items:center;display:flex;flex:1;height:100%;justify-content:flex-start;margin:0 28rpx 5px}.comment-wrapper .avatar{border-radius:50%;height:2rem;width:2rem}.comment-wrapper .chat-edit-input-box{box-sizing:border-box;flex:1;padding:0 10rpx}.comment-wrapper .chat-edit-input-box.input-active{align-items:center;background:#fff;display:flex;left:0;padding:16rpx 24rpx;position:fixed;right:0;width:100%}.comment-wrapper .chat-edit-input-box.input-active .chat-edit-input,.comment-wrapper .chat-edit-input-box.input-active .chat-edit-input-placeholder{color:#262626!important}.chat-edit-input{background-color:rgba(0,0,0,.25);border:none;border-radius:1rem;box-sizing:border-box;color:#262626;flex:1;font-size:1rem;height:2rem;padding:14rpx 30rpx;text-overflow:ellipsis;white-space:nowrap}.chat-edit-input-placeholder{color:#262626}.comment-wrapper-fixed{background-color:#fff;bottom:0;box-sizing:border-box;height:55px;margin:0;padding:0 10px;position:fixed;width:100vw}
|