@polyv/bulletin-sdk 2.5.0-rc-20251113.1 → 2.5.0-rc-20251225.4

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/index.cjs.js CHANGED
@@ -22,4 +22,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
22
22
  *
23
23
  * @author Feross Aboukhadijeh <https://feross.org>
24
24
  * @license MIT
25
- */g.exports=function(t){return t!=null&&(e(t)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&e(r.slice(0,0))}(t)||!!t._isBuffer)}},function(g,C,e){e.r(C),e.d(C,"ELog",function(){return l}),e.d(C,"ELogType",function(){return t}),e.d(C,"LogLevel",function(){return r});var t,r,n=e(1);(function(d){d.Log="log",d.Debug="debug",d.Info="info",d.Error="error",d.Warn="warn"})(t||(t={})),function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.NONE=5]="NONE"}(r||(r={}));var c=e(2),p=e.n(c);function y(d,B){B===void 0&&(B="polyv_sdk_api_innor");for(var b="",f=0,s=Object.keys(d).filter(function(A){return A!=="sign"}).sort();f<s.length;f++){var E=s[f];b+=""+E+d[E]}return p()(B+b+B).toLocaleUpperCase()}function o(d){return typeof d=="object"&&!Array.isArray(d)&&d!=null}var a=function(){function d(B){this.elog=B,this.queue=[]}return d.prototype.destroy=function(){this.clearTimer()},d.prototype.startTimer=function(){var B=this;this.timer||(this.timer=window.setInterval(function(){B.sendLogData()},this.elog.intervalTime))},d.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=void 0},d.prototype.joinQueue=function(B){this.queue.push(B),this.queue.length>=this.elog.maxQueueNumber?this.sendLogData():this.startTimer()},d.prototype.getLogDataByLive=function(B,b){if(this.elog.channelId){var f=this.elog.channelId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({channelId:f,ltype:b,timestamp:s}),log:B,channelId:f};return{url:this.elog.customLiveApiUrl?this.elog.customLiveApiUrl:this.elog.elogDomain+"/v4/live/save-elog",data:E}}},d.prototype.getLogDataByVod=function(B,b){if(this.elog.userId){var f=this.elog.userId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({userId:f,ltype:b,timestamp:s}),log:B,userId:f};return{url:this.elog.customVodApiUrl?this.elog.customVodApiUrl:this.elog.elogDomain+"/v4/vod/save-elog",data:E}}},d.prototype.sendLogData=function(){if(this.queue.length!==0){if(this.elog.logEnabled)if(this.elog.ltype){var B=this.elog,b=B.ltype,f=B.sendLog,s=B.useType;try{var E=JSON.stringify(this.queue),A=void 0;switch(s){case"live":A=this.getLogDataByLive(E,b);break;case"vod":A=this.getLogDataByVod(E,b)}if(!A)return;var w=A.url,T=A.data;typeof f=="function"?f(w,T):function(I,_){var R=new FormData;for(var M in _)R.append(M,_[M]);var q=new XMLHttpRequest;q.open("post",I),q.send(R)}(w,T),this.queue=[],this.clearTimer()}catch(I){console.error(I)}}else console.error("sendLogData error, ltype is undefined")}else this.clearTimer()},d}(),F=function(){return(F=Object.assign||function(d){for(var B,b=1,f=arguments.length;b<f;b++)for(var s in B=arguments[b])Object.prototype.hasOwnProperty.call(B,s)&&(d[s]=B[s]);return d}).apply(this,arguments)},x=function(d,B){for(var b=0,f=B.length,s=d.length;b<f;b++,s++)d[s]=B[b];return d},u=Object(n.uuidV4)(),h=navigator.userAgent,l=function(){function d(B){var b,f,s,E,A,w,T,I;B===void 0&&(B={}),this.version="2.2.1",this.elogDomain=this.__getElogDomain(B.elogDomain),this.customLiveApiUrl=B.liveApiUrl,this.customVodApiUrl=B.vodApiUrl,this.useType=B.useType||"live",this.channelId=B.channelId,this.userId=B.userId,this.viewerInfo=B.viewerInfo,this.ltype=B.ltype,this.intervalTime=(b=B.intervalTime)!==null&&b!==void 0?b:5e3,this.maxQueueNumber=(f=B.maxQueueNumber)!==null&&f!==void 0?f:30,this.logEnabled=(s=B.logEnabled)===null||s===void 0||s,this.logLevel=(E=B.logLevel)!==null&&E!==void 0?E:r.TRACE,this.consoleEnabled=(A=B.consoleEnabled)===null||A===void 0||A,this.consoleLevel=(w=B.consoleLevel)!==null&&w!==void 0?w:r.TRACE,this.consolePrefix=(T=B.consolePrefix)!==null&&T!==void 0?T:[],this.globalLog=(I=B.globalLog)!==null&&I!==void 0?I:{},this.sendLog=B.sendLog,this.logQueue=new a(this),this.joinLogQueue(t.Info,["user-agent"],{userAgent:h})}return d.prototype.__getElogDomain=function(B){return B||window.PLV_GLOBAL_URL_ORIGIN&&window.PLV_GLOBAL_URL_ORIGIN.elogOrigin||"https://elog.polyv.net"},d.prototype.setChannelId=function(B){return this.channelId=B,this},d.prototype.setUserId=function(B){return this.userId=B,this},d.prototype.setViewerInfo=function(B){return this.viewerInfo=B,this},d.prototype.setLogEnabled=function(B){return B===void 0&&(B=!0),this.logEnabled=B,this},d.prototype.getMessages=function(){return this.logQueue.queue},d.prototype.getConsoleContent=function(B){return x(x([],this.consolePrefix),B)},d.prototype.compareConsoleLevel=function(B){return this.consoleEnabled&&B>=this.consoleLevel},d.prototype.compareLogLevel=function(B){return B>=this.logLevel},d.prototype.log=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.TRACE;return this.compareConsoleLevel(f)&&console.log.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Log,B),this},d.prototype.debug=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.DEBUG;return this.compareConsoleLevel(f)&&console.debug.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Debug,B),this},d.prototype.info=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.INFO;return this.compareConsoleLevel(f)&&console.info.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Info,B),this},d.prototype.warn=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.WARN;return this.compareConsoleLevel(f)&&console.warn.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Warn,B),this},d.prototype.error=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.ERROR;return this.compareConsoleLevel(f)&&console.error.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Error,B),this},d.prototype.joinLogQueue=function(B,b,f){f===void 0&&(f={});var s=b.length>1?b:b[0],E=this.buildLogData(B,s,f);E&&this.logQueue.joinQueue(E)},d.prototype.buildLogData=function(B,b,f){var s,E;if(f===void 0&&(f={}),this.ltype){var A=F({type:B,uauuid:u,time:Date.now(),ltype:this.ltype,logVersion:this.version,str:"",arr:[],obj:{}},f);!((s=this.viewerInfo)===null||s===void 0)&&s.viewerId&&(A.viewerId=this.viewerInfo.viewerId),!((E=this.viewerInfo)===null||E===void 0)&&E.viewerName&&(A.viewerName=this.viewerInfo.viewerName),["string","number","boolean","undefined"].includes(typeof b)?A.str=""+b:function(T){return Array.isArray(T)}(b)?A.arr=b:typeof b=="object"&&(A.obj=b);var w=this.getGlobalLog(A);return o(w)&&(A=F(F({},A),w)),A}},d.prototype.getGlobalLog=function(B){if(o(this.globalLog))return this.globalLog;if(typeof this.globalLog=="function"){var b=this.globalLog(B);if(o(b))return b}},d.prototype.destroy=function(){this.logQueue.destroy()},d.version="2.2.1",d}()}]);class pi{constructor(C){se(this,"__iarCore");se(this,"iarCore");this.interactionCore=C,this.__iarCore=C,this.iarCore=C}}const gr="plvIarReadedBulletin--";class vi extends pi{constructor(e){super(e);se(this,"BulletinEvent",me);se(this,"eventEmitter",new nn);se(this,"__currentBulletin");se(this,"__onBulletin",e=>{const t=this.__formatBulletinInfo(e);this.__currentBulletin=t,this.eventEmitter.emit(me.PublishBulletin,{bulletinInfo:t})});se(this,"__onRemoveBulletin",e=>{this.eventEmitter.emit(me.RemoveBulletin,{id:e.id})});e.addSocketHandles("bulletin",{BULLETIN:this.__onBulletin,REMOVE_BULLETIN:this.__onRemoveBulletin})}__formatBulletinInfo(e){return{id:e.id,content:e.content,isPoppper:e.isPop===1,isTop:e.isTop===1,isReaded:this.__isReaded(e.id),createTime:e.createTime,nick:e.nick,pic:e.pic,actor:e.actor,userId:e.userId}}__isReaded(e){try{return localStorage.getItem(`${gr}${e}`)==="Y"}catch(t){return!1}}getCurrentBulletin(){return this.__currentBulletin}recordReaded(e){localStorage.setItem(`${gr}${e}`,"Y")}getBulletinList(){return Ft(this,arguments,function*(e={}){const{size:t=10}=e,r=yield this.interactionCore.getChannelInfo(),n=yield this.interactionCore.getUserInfo(),c=yield this.interactionCore.getChatToken(),p={channelId:r.channelId,roomId:r.channelId,userId:n.userId,token:c,size:t};e.time&&(p.score=e.time);const y=yield this.interactionCore.chatApi.get("/front/v2/channel/bullentin-list/get",p),o=[];return y.list.forEach(a=>{try{const F=JSON.parse(a);o.push(this.__formatBulletinInfo(F))}catch(F){}}),o})}}exports.Bulletin=vi;exports.BulletinEvent=me;console.log("%c@polyv/bulletin-sdk","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.5.0-rc-20251113.1]","[buildTime: 2025-11-13 05:47:46]");
25
+ */g.exports=function(t){return t!=null&&(e(t)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&e(r.slice(0,0))}(t)||!!t._isBuffer)}},function(g,C,e){e.r(C),e.d(C,"ELog",function(){return l}),e.d(C,"ELogType",function(){return t}),e.d(C,"LogLevel",function(){return r});var t,r,n=e(1);(function(d){d.Log="log",d.Debug="debug",d.Info="info",d.Error="error",d.Warn="warn"})(t||(t={})),function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.NONE=5]="NONE"}(r||(r={}));var c=e(2),p=e.n(c);function y(d,B){B===void 0&&(B="polyv_sdk_api_innor");for(var b="",f=0,s=Object.keys(d).filter(function(A){return A!=="sign"}).sort();f<s.length;f++){var E=s[f];b+=""+E+d[E]}return p()(B+b+B).toLocaleUpperCase()}function o(d){return typeof d=="object"&&!Array.isArray(d)&&d!=null}var a=function(){function d(B){this.elog=B,this.queue=[]}return d.prototype.destroy=function(){this.clearTimer()},d.prototype.startTimer=function(){var B=this;this.timer||(this.timer=window.setInterval(function(){B.sendLogData()},this.elog.intervalTime))},d.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=void 0},d.prototype.joinQueue=function(B){this.queue.push(B),this.queue.length>=this.elog.maxQueueNumber?this.sendLogData():this.startTimer()},d.prototype.getLogDataByLive=function(B,b){if(this.elog.channelId){var f=this.elog.channelId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({channelId:f,ltype:b,timestamp:s}),log:B,channelId:f};return{url:this.elog.customLiveApiUrl?this.elog.customLiveApiUrl:this.elog.elogDomain+"/v4/live/save-elog",data:E}}},d.prototype.getLogDataByVod=function(B,b){if(this.elog.userId){var f=this.elog.userId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({userId:f,ltype:b,timestamp:s}),log:B,userId:f};return{url:this.elog.customVodApiUrl?this.elog.customVodApiUrl:this.elog.elogDomain+"/v4/vod/save-elog",data:E}}},d.prototype.sendLogData=function(){if(this.queue.length!==0){if(this.elog.logEnabled)if(this.elog.ltype){var B=this.elog,b=B.ltype,f=B.sendLog,s=B.useType;try{var E=JSON.stringify(this.queue),A=void 0;switch(s){case"live":A=this.getLogDataByLive(E,b);break;case"vod":A=this.getLogDataByVod(E,b)}if(!A)return;var w=A.url,T=A.data;typeof f=="function"?f(w,T):function(I,_){var R=new FormData;for(var M in _)R.append(M,_[M]);var q=new XMLHttpRequest;q.open("post",I),q.send(R)}(w,T),this.queue=[],this.clearTimer()}catch(I){console.error(I)}}else console.error("sendLogData error, ltype is undefined")}else this.clearTimer()},d}(),F=function(){return(F=Object.assign||function(d){for(var B,b=1,f=arguments.length;b<f;b++)for(var s in B=arguments[b])Object.prototype.hasOwnProperty.call(B,s)&&(d[s]=B[s]);return d}).apply(this,arguments)},x=function(d,B){for(var b=0,f=B.length,s=d.length;b<f;b++,s++)d[s]=B[b];return d},u=Object(n.uuidV4)(),h=navigator.userAgent,l=function(){function d(B){var b,f,s,E,A,w,T,I;B===void 0&&(B={}),this.version="2.2.1",this.elogDomain=this.__getElogDomain(B.elogDomain),this.customLiveApiUrl=B.liveApiUrl,this.customVodApiUrl=B.vodApiUrl,this.useType=B.useType||"live",this.channelId=B.channelId,this.userId=B.userId,this.viewerInfo=B.viewerInfo,this.ltype=B.ltype,this.intervalTime=(b=B.intervalTime)!==null&&b!==void 0?b:5e3,this.maxQueueNumber=(f=B.maxQueueNumber)!==null&&f!==void 0?f:30,this.logEnabled=(s=B.logEnabled)===null||s===void 0||s,this.logLevel=(E=B.logLevel)!==null&&E!==void 0?E:r.TRACE,this.consoleEnabled=(A=B.consoleEnabled)===null||A===void 0||A,this.consoleLevel=(w=B.consoleLevel)!==null&&w!==void 0?w:r.TRACE,this.consolePrefix=(T=B.consolePrefix)!==null&&T!==void 0?T:[],this.globalLog=(I=B.globalLog)!==null&&I!==void 0?I:{},this.sendLog=B.sendLog,this.logQueue=new a(this),this.joinLogQueue(t.Info,["user-agent"],{userAgent:h})}return d.prototype.__getElogDomain=function(B){return B||window.PLV_GLOBAL_URL_ORIGIN&&window.PLV_GLOBAL_URL_ORIGIN.elogOrigin||"https://elog.polyv.net"},d.prototype.setChannelId=function(B){return this.channelId=B,this},d.prototype.setUserId=function(B){return this.userId=B,this},d.prototype.setViewerInfo=function(B){return this.viewerInfo=B,this},d.prototype.setLogEnabled=function(B){return B===void 0&&(B=!0),this.logEnabled=B,this},d.prototype.getMessages=function(){return this.logQueue.queue},d.prototype.getConsoleContent=function(B){return x(x([],this.consolePrefix),B)},d.prototype.compareConsoleLevel=function(B){return this.consoleEnabled&&B>=this.consoleLevel},d.prototype.compareLogLevel=function(B){return B>=this.logLevel},d.prototype.log=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.TRACE;return this.compareConsoleLevel(f)&&console.log.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Log,B),this},d.prototype.debug=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.DEBUG;return this.compareConsoleLevel(f)&&console.debug.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Debug,B),this},d.prototype.info=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.INFO;return this.compareConsoleLevel(f)&&console.info.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Info,B),this},d.prototype.warn=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.WARN;return this.compareConsoleLevel(f)&&console.warn.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Warn,B),this},d.prototype.error=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.ERROR;return this.compareConsoleLevel(f)&&console.error.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Error,B),this},d.prototype.joinLogQueue=function(B,b,f){f===void 0&&(f={});var s=b.length>1?b:b[0],E=this.buildLogData(B,s,f);E&&this.logQueue.joinQueue(E)},d.prototype.buildLogData=function(B,b,f){var s,E;if(f===void 0&&(f={}),this.ltype){var A=F({type:B,uauuid:u,time:Date.now(),ltype:this.ltype,logVersion:this.version,str:"",arr:[],obj:{}},f);!((s=this.viewerInfo)===null||s===void 0)&&s.viewerId&&(A.viewerId=this.viewerInfo.viewerId),!((E=this.viewerInfo)===null||E===void 0)&&E.viewerName&&(A.viewerName=this.viewerInfo.viewerName),["string","number","boolean","undefined"].includes(typeof b)?A.str=""+b:function(T){return Array.isArray(T)}(b)?A.arr=b:typeof b=="object"&&(A.obj=b);var w=this.getGlobalLog(A);return o(w)&&(A=F(F({},A),w)),A}},d.prototype.getGlobalLog=function(B){if(o(this.globalLog))return this.globalLog;if(typeof this.globalLog=="function"){var b=this.globalLog(B);if(o(b))return b}},d.prototype.destroy=function(){this.logQueue.destroy()},d.version="2.2.1",d}()}]);class pi{constructor(C){se(this,"__iarCore");se(this,"iarCore");this.interactionCore=C,this.__iarCore=C,this.iarCore=C}}const gr="plvIarReadedBulletin--";class vi extends pi{constructor(e){super(e);se(this,"BulletinEvent",me);se(this,"eventEmitter",new nn);se(this,"__currentBulletin");se(this,"__onBulletin",e=>{const t=this.__formatBulletinInfo(e);this.__currentBulletin=t,this.eventEmitter.emit(me.PublishBulletin,{bulletinInfo:t})});se(this,"__onRemoveBulletin",e=>{this.eventEmitter.emit(me.RemoveBulletin,{id:e.id})});e.addSocketHandles("bulletin",{BULLETIN:this.__onBulletin,REMOVE_BULLETIN:this.__onRemoveBulletin})}__formatBulletinInfo(e){return{id:e.id,content:e.content,isPoppper:e.isPop===1,isTop:e.isTop===1,isReaded:this.__isReaded(e.id),createTime:e.createTime,nick:e.nick,pic:e.pic,actor:e.actor,userId:e.userId}}__isReaded(e){try{return localStorage.getItem(`${gr}${e}`)==="Y"}catch(t){return!1}}getCurrentBulletin(){return this.__currentBulletin}recordReaded(e){localStorage.setItem(`${gr}${e}`,"Y")}getBulletinList(){return Ft(this,arguments,function*(e={}){const{size:t=10}=e,r=yield this.interactionCore.getChannelInfo(),n=yield this.interactionCore.getUserInfo(),c=yield this.interactionCore.getChatToken(),p={channelId:r.channelId,roomId:r.channelId,userId:n.userId,token:c,size:t};e.time&&(p.score=e.time);const y=yield this.interactionCore.chatApi.get("/front/v2/channel/bullentin-list/get",p),o=[];return y.list.forEach(a=>{try{const F=JSON.parse(a);o.push(this.__formatBulletinInfo(F))}catch(F){}}),o})}}exports.Bulletin=vi;exports.BulletinEvent=me;console.log("%c@polyv/bulletin-sdk","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.5.0-rc-20251225.4]","[buildTime: 2025-12-25 08:17:50]");
package/index.es.js CHANGED
@@ -11497,8 +11497,8 @@ class mi extends pi {
11497
11497
  console.log(
11498
11498
  "%c@polyv/bulletin-sdk",
11499
11499
  "background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff",
11500
- "[version: 2.5.0-rc-20251113.1]",
11501
- "[buildTime: 2025-11-13 05:47:46]"
11500
+ "[version: 2.5.0-rc-20251225.4]",
11501
+ "[buildTime: 2025-12-25 08:17:50]"
11502
11502
  );
11503
11503
  export {
11504
11504
  mi as Bulletin,
package/index.umd.js CHANGED
@@ -22,4 +22,4 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
22
22
  *
23
23
  * @author Feross Aboukhadijeh <https://feross.org>
24
24
  * @license MIT
25
- */g.exports=function(t){return t!=null&&(e(t)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&e(r.slice(0,0))}(t)||!!t._isBuffer)}},function(g,C,e){e.r(C),e.d(C,"ELog",function(){return l}),e.d(C,"ELogType",function(){return t}),e.d(C,"LogLevel",function(){return r});var t,r,n=e(1);(function(d){d.Log="log",d.Debug="debug",d.Info="info",d.Error="error",d.Warn="warn"})(t||(t={})),function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.NONE=5]="NONE"}(r||(r={}));var c=e(2),p=e.n(c);function y(d,B){B===void 0&&(B="polyv_sdk_api_innor");for(var b="",f=0,s=Object.keys(d).filter(function(A){return A!=="sign"}).sort();f<s.length;f++){var E=s[f];b+=""+E+d[E]}return p()(B+b+B).toLocaleUpperCase()}function a(d){return typeof d=="object"&&!Array.isArray(d)&&d!=null}var o=function(){function d(B){this.elog=B,this.queue=[]}return d.prototype.destroy=function(){this.clearTimer()},d.prototype.startTimer=function(){var B=this;this.timer||(this.timer=window.setInterval(function(){B.sendLogData()},this.elog.intervalTime))},d.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=void 0},d.prototype.joinQueue=function(B){this.queue.push(B),this.queue.length>=this.elog.maxQueueNumber?this.sendLogData():this.startTimer()},d.prototype.getLogDataByLive=function(B,b){if(this.elog.channelId){var f=this.elog.channelId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({channelId:f,ltype:b,timestamp:s}),log:B,channelId:f};return{url:this.elog.customLiveApiUrl?this.elog.customLiveApiUrl:this.elog.elogDomain+"/v4/live/save-elog",data:E}}},d.prototype.getLogDataByVod=function(B,b){if(this.elog.userId){var f=this.elog.userId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({userId:f,ltype:b,timestamp:s}),log:B,userId:f};return{url:this.elog.customVodApiUrl?this.elog.customVodApiUrl:this.elog.elogDomain+"/v4/vod/save-elog",data:E}}},d.prototype.sendLogData=function(){if(this.queue.length!==0){if(this.elog.logEnabled)if(this.elog.ltype){var B=this.elog,b=B.ltype,f=B.sendLog,s=B.useType;try{var E=JSON.stringify(this.queue),A=void 0;switch(s){case"live":A=this.getLogDataByLive(E,b);break;case"vod":A=this.getLogDataByVod(E,b)}if(!A)return;var w=A.url,T=A.data;typeof f=="function"?f(w,T):function(I,_){var R=new FormData;for(var M in _)R.append(M,_[M]);var q=new XMLHttpRequest;q.open("post",I),q.send(R)}(w,T),this.queue=[],this.clearTimer()}catch(I){console.error(I)}}else console.error("sendLogData error, ltype is undefined")}else this.clearTimer()},d}(),F=function(){return(F=Object.assign||function(d){for(var B,b=1,f=arguments.length;b<f;b++)for(var s in B=arguments[b])Object.prototype.hasOwnProperty.call(B,s)&&(d[s]=B[s]);return d}).apply(this,arguments)},x=function(d,B){for(var b=0,f=B.length,s=d.length;b<f;b++,s++)d[s]=B[b];return d},u=Object(n.uuidV4)(),h=navigator.userAgent,l=function(){function d(B){var b,f,s,E,A,w,T,I;B===void 0&&(B={}),this.version="2.2.1",this.elogDomain=this.__getElogDomain(B.elogDomain),this.customLiveApiUrl=B.liveApiUrl,this.customVodApiUrl=B.vodApiUrl,this.useType=B.useType||"live",this.channelId=B.channelId,this.userId=B.userId,this.viewerInfo=B.viewerInfo,this.ltype=B.ltype,this.intervalTime=(b=B.intervalTime)!==null&&b!==void 0?b:5e3,this.maxQueueNumber=(f=B.maxQueueNumber)!==null&&f!==void 0?f:30,this.logEnabled=(s=B.logEnabled)===null||s===void 0||s,this.logLevel=(E=B.logLevel)!==null&&E!==void 0?E:r.TRACE,this.consoleEnabled=(A=B.consoleEnabled)===null||A===void 0||A,this.consoleLevel=(w=B.consoleLevel)!==null&&w!==void 0?w:r.TRACE,this.consolePrefix=(T=B.consolePrefix)!==null&&T!==void 0?T:[],this.globalLog=(I=B.globalLog)!==null&&I!==void 0?I:{},this.sendLog=B.sendLog,this.logQueue=new o(this),this.joinLogQueue(t.Info,["user-agent"],{userAgent:h})}return d.prototype.__getElogDomain=function(B){return B||window.PLV_GLOBAL_URL_ORIGIN&&window.PLV_GLOBAL_URL_ORIGIN.elogOrigin||"https://elog.polyv.net"},d.prototype.setChannelId=function(B){return this.channelId=B,this},d.prototype.setUserId=function(B){return this.userId=B,this},d.prototype.setViewerInfo=function(B){return this.viewerInfo=B,this},d.prototype.setLogEnabled=function(B){return B===void 0&&(B=!0),this.logEnabled=B,this},d.prototype.getMessages=function(){return this.logQueue.queue},d.prototype.getConsoleContent=function(B){return x(x([],this.consolePrefix),B)},d.prototype.compareConsoleLevel=function(B){return this.consoleEnabled&&B>=this.consoleLevel},d.prototype.compareLogLevel=function(B){return B>=this.logLevel},d.prototype.log=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.TRACE;return this.compareConsoleLevel(f)&&console.log.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Log,B),this},d.prototype.debug=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.DEBUG;return this.compareConsoleLevel(f)&&console.debug.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Debug,B),this},d.prototype.info=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.INFO;return this.compareConsoleLevel(f)&&console.info.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Info,B),this},d.prototype.warn=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.WARN;return this.compareConsoleLevel(f)&&console.warn.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Warn,B),this},d.prototype.error=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.ERROR;return this.compareConsoleLevel(f)&&console.error.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Error,B),this},d.prototype.joinLogQueue=function(B,b,f){f===void 0&&(f={});var s=b.length>1?b:b[0],E=this.buildLogData(B,s,f);E&&this.logQueue.joinQueue(E)},d.prototype.buildLogData=function(B,b,f){var s,E;if(f===void 0&&(f={}),this.ltype){var A=F({type:B,uauuid:u,time:Date.now(),ltype:this.ltype,logVersion:this.version,str:"",arr:[],obj:{}},f);!((s=this.viewerInfo)===null||s===void 0)&&s.viewerId&&(A.viewerId=this.viewerInfo.viewerId),!((E=this.viewerInfo)===null||E===void 0)&&E.viewerName&&(A.viewerName=this.viewerInfo.viewerName),["string","number","boolean","undefined"].includes(typeof b)?A.str=""+b:function(T){return Array.isArray(T)}(b)?A.arr=b:typeof b=="object"&&(A.obj=b);var w=this.getGlobalLog(A);return a(w)&&(A=F(F({},A),w)),A}},d.prototype.getGlobalLog=function(B){if(a(this.globalLog))return this.globalLog;if(typeof this.globalLog=="function"){var b=this.globalLog(B);if(a(b))return b}},d.prototype.destroy=function(){this.logQueue.destroy()},d.version="2.2.1",d}()}]);class kn{constructor(C){be(this,"__iarCore");be(this,"iarCore");this.interactionCore=C,this.__iarCore=C,this.iarCore=C}}const Fr="plvIarReadedBulletin--";class Pn extends kn{constructor(e){super(e);be(this,"BulletinEvent",J0);be(this,"eventEmitter",new Q0);be(this,"__currentBulletin");be(this,"__onBulletin",e=>{const t=this.__formatBulletinInfo(e);this.__currentBulletin=t,this.eventEmitter.emit(J0.PublishBulletin,{bulletinInfo:t})});be(this,"__onRemoveBulletin",e=>{this.eventEmitter.emit(J0.RemoveBulletin,{id:e.id})});e.addSocketHandles("bulletin",{BULLETIN:this.__onBulletin,REMOVE_BULLETIN:this.__onRemoveBulletin})}__formatBulletinInfo(e){return{id:e.id,content:e.content,isPoppper:e.isPop===1,isTop:e.isTop===1,isReaded:this.__isReaded(e.id),createTime:e.createTime,nick:e.nick,pic:e.pic,actor:e.actor,userId:e.userId}}__isReaded(e){try{return localStorage.getItem(`${Fr}${e}`)==="Y"}catch(t){return!1}}getCurrentBulletin(){return this.__currentBulletin}recordReaded(e){localStorage.setItem(`${Fr}${e}`,"Y")}getBulletinList(){return Sr(this,arguments,function*(e={}){const{size:t=10}=e,r=yield this.interactionCore.getChannelInfo(),n=yield this.interactionCore.getUserInfo(),c=yield this.interactionCore.getChatToken(),p={channelId:r.channelId,roomId:r.channelId,userId:n.userId,token:c,size:t};e.time&&(p.score=e.time);const y=yield this.interactionCore.chatApi.get("/front/v2/channel/bullentin-list/get",p),a=[];return y.list.forEach(o=>{try{const F=JSON.parse(o);a.push(this.__formatBulletinInfo(F))}catch(F){}}),a})}}Y0.Bulletin=Pn,Y0.BulletinEvent=J0,Object.defineProperty(Y0,Symbol.toStringTag,{value:"Module"})});console.log("%c@polyv/bulletin-sdk","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.5.0-rc-20251113.1]","[buildTime: 2025-11-13 05:47:42]");
25
+ */g.exports=function(t){return t!=null&&(e(t)||function(r){return typeof r.readFloatLE=="function"&&typeof r.slice=="function"&&e(r.slice(0,0))}(t)||!!t._isBuffer)}},function(g,C,e){e.r(C),e.d(C,"ELog",function(){return l}),e.d(C,"ELogType",function(){return t}),e.d(C,"LogLevel",function(){return r});var t,r,n=e(1);(function(d){d.Log="log",d.Debug="debug",d.Info="info",d.Error="error",d.Warn="warn"})(t||(t={})),function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.NONE=5]="NONE"}(r||(r={}));var c=e(2),p=e.n(c);function y(d,B){B===void 0&&(B="polyv_sdk_api_innor");for(var b="",f=0,s=Object.keys(d).filter(function(A){return A!=="sign"}).sort();f<s.length;f++){var E=s[f];b+=""+E+d[E]}return p()(B+b+B).toLocaleUpperCase()}function a(d){return typeof d=="object"&&!Array.isArray(d)&&d!=null}var o=function(){function d(B){this.elog=B,this.queue=[]}return d.prototype.destroy=function(){this.clearTimer()},d.prototype.startTimer=function(){var B=this;this.timer||(this.timer=window.setInterval(function(){B.sendLogData()},this.elog.intervalTime))},d.prototype.clearTimer=function(){clearInterval(this.timer),this.timer=void 0},d.prototype.joinQueue=function(B){this.queue.push(B),this.queue.length>=this.elog.maxQueueNumber?this.sendLogData():this.startTimer()},d.prototype.getLogDataByLive=function(B,b){if(this.elog.channelId){var f=this.elog.channelId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({channelId:f,ltype:b,timestamp:s}),log:B,channelId:f};return{url:this.elog.customLiveApiUrl?this.elog.customLiveApiUrl:this.elog.elogDomain+"/v4/live/save-elog",data:E}}},d.prototype.getLogDataByVod=function(B,b){if(this.elog.userId){var f=this.elog.userId,s=Date.now(),E={timestamp:s,ltype:b,sign:y({userId:f,ltype:b,timestamp:s}),log:B,userId:f};return{url:this.elog.customVodApiUrl?this.elog.customVodApiUrl:this.elog.elogDomain+"/v4/vod/save-elog",data:E}}},d.prototype.sendLogData=function(){if(this.queue.length!==0){if(this.elog.logEnabled)if(this.elog.ltype){var B=this.elog,b=B.ltype,f=B.sendLog,s=B.useType;try{var E=JSON.stringify(this.queue),A=void 0;switch(s){case"live":A=this.getLogDataByLive(E,b);break;case"vod":A=this.getLogDataByVod(E,b)}if(!A)return;var w=A.url,T=A.data;typeof f=="function"?f(w,T):function(I,_){var R=new FormData;for(var M in _)R.append(M,_[M]);var q=new XMLHttpRequest;q.open("post",I),q.send(R)}(w,T),this.queue=[],this.clearTimer()}catch(I){console.error(I)}}else console.error("sendLogData error, ltype is undefined")}else this.clearTimer()},d}(),F=function(){return(F=Object.assign||function(d){for(var B,b=1,f=arguments.length;b<f;b++)for(var s in B=arguments[b])Object.prototype.hasOwnProperty.call(B,s)&&(d[s]=B[s]);return d}).apply(this,arguments)},x=function(d,B){for(var b=0,f=B.length,s=d.length;b<f;b++,s++)d[s]=B[b];return d},u=Object(n.uuidV4)(),h=navigator.userAgent,l=function(){function d(B){var b,f,s,E,A,w,T,I;B===void 0&&(B={}),this.version="2.2.1",this.elogDomain=this.__getElogDomain(B.elogDomain),this.customLiveApiUrl=B.liveApiUrl,this.customVodApiUrl=B.vodApiUrl,this.useType=B.useType||"live",this.channelId=B.channelId,this.userId=B.userId,this.viewerInfo=B.viewerInfo,this.ltype=B.ltype,this.intervalTime=(b=B.intervalTime)!==null&&b!==void 0?b:5e3,this.maxQueueNumber=(f=B.maxQueueNumber)!==null&&f!==void 0?f:30,this.logEnabled=(s=B.logEnabled)===null||s===void 0||s,this.logLevel=(E=B.logLevel)!==null&&E!==void 0?E:r.TRACE,this.consoleEnabled=(A=B.consoleEnabled)===null||A===void 0||A,this.consoleLevel=(w=B.consoleLevel)!==null&&w!==void 0?w:r.TRACE,this.consolePrefix=(T=B.consolePrefix)!==null&&T!==void 0?T:[],this.globalLog=(I=B.globalLog)!==null&&I!==void 0?I:{},this.sendLog=B.sendLog,this.logQueue=new o(this),this.joinLogQueue(t.Info,["user-agent"],{userAgent:h})}return d.prototype.__getElogDomain=function(B){return B||window.PLV_GLOBAL_URL_ORIGIN&&window.PLV_GLOBAL_URL_ORIGIN.elogOrigin||"https://elog.polyv.net"},d.prototype.setChannelId=function(B){return this.channelId=B,this},d.prototype.setUserId=function(B){return this.userId=B,this},d.prototype.setViewerInfo=function(B){return this.viewerInfo=B,this},d.prototype.setLogEnabled=function(B){return B===void 0&&(B=!0),this.logEnabled=B,this},d.prototype.getMessages=function(){return this.logQueue.queue},d.prototype.getConsoleContent=function(B){return x(x([],this.consolePrefix),B)},d.prototype.compareConsoleLevel=function(B){return this.consoleEnabled&&B>=this.consoleLevel},d.prototype.compareLogLevel=function(B){return B>=this.logLevel},d.prototype.log=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.TRACE;return this.compareConsoleLevel(f)&&console.log.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Log,B),this},d.prototype.debug=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.DEBUG;return this.compareConsoleLevel(f)&&console.debug.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Debug,B),this},d.prototype.info=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.INFO;return this.compareConsoleLevel(f)&&console.info.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Info,B),this},d.prototype.warn=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.WARN;return this.compareConsoleLevel(f)&&console.warn.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Warn,B),this},d.prototype.error=function(){for(var B=[],b=0;b<arguments.length;b++)B[b]=arguments[b];var f=r.ERROR;return this.compareConsoleLevel(f)&&console.error.apply(console,this.getConsoleContent(B)),this.compareLogLevel(f)&&this.joinLogQueue(t.Error,B),this},d.prototype.joinLogQueue=function(B,b,f){f===void 0&&(f={});var s=b.length>1?b:b[0],E=this.buildLogData(B,s,f);E&&this.logQueue.joinQueue(E)},d.prototype.buildLogData=function(B,b,f){var s,E;if(f===void 0&&(f={}),this.ltype){var A=F({type:B,uauuid:u,time:Date.now(),ltype:this.ltype,logVersion:this.version,str:"",arr:[],obj:{}},f);!((s=this.viewerInfo)===null||s===void 0)&&s.viewerId&&(A.viewerId=this.viewerInfo.viewerId),!((E=this.viewerInfo)===null||E===void 0)&&E.viewerName&&(A.viewerName=this.viewerInfo.viewerName),["string","number","boolean","undefined"].includes(typeof b)?A.str=""+b:function(T){return Array.isArray(T)}(b)?A.arr=b:typeof b=="object"&&(A.obj=b);var w=this.getGlobalLog(A);return a(w)&&(A=F(F({},A),w)),A}},d.prototype.getGlobalLog=function(B){if(a(this.globalLog))return this.globalLog;if(typeof this.globalLog=="function"){var b=this.globalLog(B);if(a(b))return b}},d.prototype.destroy=function(){this.logQueue.destroy()},d.version="2.2.1",d}()}]);class kn{constructor(C){be(this,"__iarCore");be(this,"iarCore");this.interactionCore=C,this.__iarCore=C,this.iarCore=C}}const Fr="plvIarReadedBulletin--";class Pn extends kn{constructor(e){super(e);be(this,"BulletinEvent",J0);be(this,"eventEmitter",new Q0);be(this,"__currentBulletin");be(this,"__onBulletin",e=>{const t=this.__formatBulletinInfo(e);this.__currentBulletin=t,this.eventEmitter.emit(J0.PublishBulletin,{bulletinInfo:t})});be(this,"__onRemoveBulletin",e=>{this.eventEmitter.emit(J0.RemoveBulletin,{id:e.id})});e.addSocketHandles("bulletin",{BULLETIN:this.__onBulletin,REMOVE_BULLETIN:this.__onRemoveBulletin})}__formatBulletinInfo(e){return{id:e.id,content:e.content,isPoppper:e.isPop===1,isTop:e.isTop===1,isReaded:this.__isReaded(e.id),createTime:e.createTime,nick:e.nick,pic:e.pic,actor:e.actor,userId:e.userId}}__isReaded(e){try{return localStorage.getItem(`${Fr}${e}`)==="Y"}catch(t){return!1}}getCurrentBulletin(){return this.__currentBulletin}recordReaded(e){localStorage.setItem(`${Fr}${e}`,"Y")}getBulletinList(){return Sr(this,arguments,function*(e={}){const{size:t=10}=e,r=yield this.interactionCore.getChannelInfo(),n=yield this.interactionCore.getUserInfo(),c=yield this.interactionCore.getChatToken(),p={channelId:r.channelId,roomId:r.channelId,userId:n.userId,token:c,size:t};e.time&&(p.score=e.time);const y=yield this.interactionCore.chatApi.get("/front/v2/channel/bullentin-list/get",p),a=[];return y.list.forEach(o=>{try{const F=JSON.parse(o);a.push(this.__formatBulletinInfo(F))}catch(F){}}),a})}}Y0.Bulletin=Pn,Y0.BulletinEvent=J0,Object.defineProperty(Y0,Symbol.toStringTag,{value:"Module"})});console.log("%c@polyv/bulletin-sdk","background:#67C23A;padding: 2px 6px;border-radius: 3px;color: #fff","[version: 2.5.0-rc-20251225.4]","[buildTime: 2025-12-25 08:17:47]");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polyv/bulletin-sdk",
3
- "version": "2.5.0-rc-20251113.1",
3
+ "version": "2.5.0-rc-20251225.4",
4
4
  "main": "./index.es.js",
5
5
  "dependencies": {
6
6
  "@polyv/interaction-core": "*"