quickvo-player 0.0.6 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -4,12 +4,12 @@ var X = (h) => {
4
4
  };
5
5
  var tt = (h, o, a) => o in h ? Z(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a;
6
6
  var m = (h, o, a) => tt(h, typeof o != "symbol" ? o + "" : o, a), Q = (h, o, a) => o.has(h) || X("Cannot " + a);
7
- var U = (h, o, a) => (Q(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), K = (h, o, a, u) => (Q(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
8
- const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(u,t)=>{const s=new Uint8Array(u),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=u=>{let t=0;const s=new DataView(u.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const i=s.getUint8(t)&255;t=t+1;const h=`avc1.${Array.from([n,a,i],b=>b.toString(16).padStart(2,"0")).join("")}`,c=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const l=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const f=s.getUint16(t,!1);t=t+2;const y=new Uint8Array(s.buffer.slice(t,t+f));return t=t+f,{version:e,codec:h,profile:n,compatibility:a,level:i,lengthSizeMinusOne:c,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:l,numOfPictureParameterSets:d,pictureParameterSetLength:f,pps:y}},M=u=>{const t=new Uint8Array(4+u.length);return new DataView(t.buffer).setUint32(0,u.length,!1),t.set(u,4),t},C=u=>{let t=0;for(const n of u)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of u){const a=n;s.set(a,e),e+=a.length}return s},x=u=>{let t="unknown";switch(u){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class D{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:i,payload_unit_start_indicator:o,adaptation_field_control:r}=n;if(a===1||i===void 0)return;let h=184;if(r===2||r===3){const c=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=c,h-=c}if(r===3&&(h-=1),r===1||r===3){const c=new Uint8Array(t.buffer.slice(e,e+h));if(i===0)return this.parsePAT(t,e);{const{programs:l=[]}=this.pat||{};if(l.find(f=>f.pmt_pid===i))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(l=>l.elementary_pid===i);if(p){if(o===1){const l=this.payloadMap.get(i);if(l){switch(p.kind){case"audio":break;case"video":{const d=await this.parseVideo(l);this.on.chunk&&this.on.chunk(d),await new Promise(f=>setTimeout(()=>f(!0),8))}break}this.payloadMap.delete(i)}}{this.payloadMap.has(i)||this.payloadMap.set(i,new Uint8Array);const l=this.payloadMap.get(i),d=new Uint8Array(l.byteLength+c.byteLength);d.set(l,0),d.set(c,l.byteLength),this.payloadMap.set(i,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),i=t.getUint8(e+2),o=t.getUint8(e+3),r=(a&128)>>7;if(r===1)return{sync_byte:n,transport_error_indicator:r};const h=(a&64)>>6,c=(a&32)>>5,g=(a&31)<<8|i,p=(o&192)>>6,l=o>>4&3,d=o&15;return{sync_byte:n,transport_error_indicator:r,payload_unit_start_indicator:h,transport_priority:c,pid:g,transport_scrambling_control:p,adaptation_field_control:l,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const o=t.getUint8(e);e+=1;const r=t.getUint8(e);if(e+=1,r!==0)throw new Error("Invalid PAT table_id");const h=t.getUint16(e)&4095;e+=2;const c=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const l=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:o,table_id:r,section_length:h,transport_stream_id:c,version_number:g,current_next_indicator:p,section_number:l,last_section_number:d}}const a=[];{const o=n.section_length-5-4,r=e+o;for(;e<r;){const h=t.getUint16(e),c=t.getUint16(e+2)&8191;e+=4,h!==0&&c>=32&&c<=8190&&a.push({program_number:h,pmt_pid:c})}}const i=t.getUint32(e);this.pat={header:n,programs:a,crc32:i},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const o=t.getUint8(e);e+=1;const r=t.getUint8(e);if(e+=1,r!==2)throw new Error("Invalid PMT table_id");const h=t.getUint16(e)&4095;e+=2;const c=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const l=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const f=t.getUint16(e)&8191;e+=2;const y=t.getUint16(e)&4095;e+=2,n={pointer_field:o,table_id:r,section_length:h,transport_stream_id:c,version_number:g,current_next_indicator:p,section_number:l,last_section_number:d,pcr_pid:f,program_info_length:y}}const a=[];{const o=n.section_length-9-4,r=e+o;for(;e<r;){const h=t.getUint8(e),c=x(h),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:c,stream_type:h,elementary_pid:g,es_info_length:p})}}const i=t.getUint32(e);this.pmt={header:n,streams:a,crc32:i},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,i,o;const r=t.getUint8(e),h=!!(r&128),c=!!(r&64),g=!!(r&32),p=!!(r&16),l=!!(r&8),d=!!(r&4),f=!!(r&2),y=!!(r&1);e+=1;const b=(U,m)=>{let _=BigInt(0);_|=BigInt(U.getUint16(m))<<25n,_|=BigInt(U.getUint16(m+1))<<17n,_|=BigInt(U.getUint16(m+2))<<9n,_|=BigInt(U.getUint16(m+3))<<1n,_|=BigInt(U.getUint16(m+4)>>7);const B=(U.getUint16(m+4)&1)<<8|U.getUint16(m+5);return _=_*300n+BigInt(B),_};if(p&&(n=b(t,e),e+=6),l&&(a=b(t,e),e+=6),d&&(i=t.getInt8(e),e+=1),f){const U=t.getUint8(e);e+=1,o=new Uint8Array(t.buffer,e,U),e+=U}return{discontinuity_indicator:h,random_access_indicator:c,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:l,splicing_point_flag:d,transport_private_data_flag:f,adaptation_field_extension_flag:y,pcr:n,opcr:a,splice_countdown:i,transport_private_data:o}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const i=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!i)throw new Error("invalid ts video payload.");const o=s.getUint8(e);e+=1;const r=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let h,c;const g=o!==188&&o!==190&&o!==191&&o!==240&&o!==241&&o!==255&&o!==242;if(g){e+=1;const p=s.getUint8(e);e+=1;const l=p>>6,d=s.getUint8(e);e+=1,(l&2)===2&&(h=this.parsePtsDts(s,e),e+=5),(l&1)===1?(c=this.parsePtsDts(s,e),e+=5):c=h,e+=d-(e-9)}n={stream_id:o,pes_packet_length:r,pts:h,dts:c,optional_header_exist:g}}a=t.slice(e);{const i=this.getNalus(a);if(!this.videoConfig){let l,d;if(l=i.find(y=>y.type===7)?.nalu.slice(4),d=i.find(y=>y.type===8)?.nalu.slice(4),l&&d){const f=I(l,d),{codec:y}=T(f);this.videoConfig={kind:"video",codec:y,description:f,sps:l,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const o=[];let r="delta";for(const l of i){const{type:d,nalu:f}=l;switch(d){case 6:case 9:o.push(f);break;case 1:r="delta",o.push(f);break;case 5:r="key",o.push(f);break}}const h=C(o),{dts:c=0,pts:g=0}=n,p=g-c;return{kind:"video",type:r,dts:c,pts:g,cts:p,data:h,nalus:o}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),i=t.getUint8(s+3),o=t.getUint8(s+4),r=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(i)&0b11111111n)<<7n|(BigInt(o)&0b11111110n)>>1n;return Number(r)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let i=e-n;if(t[e-1]===0&&(i-=1),i!==0){const o=t.slice(n,n+i),r=M(o);s.push({type:a,nalu:r})}}return s}}const k=(u,t)=>u.getUint8(t)<<16|u.getUint8(t+1)<<8|u.getUint8(t+2);class L{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:i,timestamp:o}=n;if(a){const r=this.parseTagBody(a,t,s+4+11,i);switch(a){case"script":this.on.info&&this.on.info(r);break;case"audio":{const{accPacketType:h}=r;if(h===0){const{codec:c,sampleRate:g,channelConfiguration:p}=r;this.audioConfig={kind:"audio",codec:c,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:c,data:g}=r,p="key",l=c===void 0?void 0:c+o;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:o,pts:l,cts:c,data:g})}}break;case"video":{const{avcPacketType:h}=r;if(h===0){const{codec:c,sps:g,pps:p,data:l}=r;this.videoConfig={kind:"video",codec:c,description:l,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:c,cts:g,data:p,nalus:l}=r,d=c===1?"key":"delta",f=g===void 0?void 0:g+o;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:o,pts:f,cts:g,data:p,nalus:l})}}break}s=s+4+11+i}await new Promise(r=>setTimeout(()=>r(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,i;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const r=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,h,,c]=r;a={audio:c==="1",video:h==="1"}}i=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:i}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,i,o;{const r=t.getUint8(s);let h;switch(r){case 18:h="script";break;case 8:h="audio";break;case 9:h="video";break}e=h}return n=k(t,s+1),a=k(t,s+4),i=t.getUint8(s+7),o=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:i,streamID:o}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const o=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(o)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),i=a>>4&15,o=a>>2&3,r=a>>1&1,h=a&1;n=n+1;const c=t.getUint8(n);n=n+1;const g=e-2,p=new Uint8Array(t.buffer.slice(n,n+g));if(i===10&&c===0){const l=t.getUint8(n),d=t.getUint8(n+1),f=(l&248)>>3,y=(l&7)<<1|d>>7,b=(d&120)>>3,U=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],m=`mp4a.40.${f}`,_=U[y];return{soundFormat:i,soundRate:o,soundSize:r,soundType:h,accPacketType:c,data:p,audioObjectType:f,samplingFrequencyIndex:y,channelConfiguration:b,codec:m,sampleRate:_}}return{soundFormat:i,soundRate:o,soundSize:r,soundType:h,accPacketType:c,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),i=a>>4&15,o=a&15;n=n+1;const r=t.getUint8(n);n=n+1;const h=k(t,n);n=n+3;const c=e-5,g=new Uint8Array(t.buffer.slice(n,n+c));switch(o){case 7:if(r===0){const p=T(g);return{frameType:i,codecID:o,avcPacketType:r,cts:h,data:g,...p}}else if(r===1){const p=[],l=n+e-5;for(;!(n+4>l);){const d=t.getUint32(n,!1),f=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(f)}return{frameType:i,codecID:o,avcPacketType:r,cts:h,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:i,codecID:o,avcPacketType:r,cts:h,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,i=0;switch(e){case 0:a=t.getFloat64(n,!1),i=8;break;case 1:a=!!t.getUint8(n),i=1;break;case 2:{a="";const r=t.getUint16(n,!1);n=n+2;const h=new Int8Array(t.buffer,n,r).filter(g=>g!==0);a=(this.textDecoder?.decode(h)||"").trim(),i=2+r}break;case 3:for(a={};n<t.byteLength;){const r=t.getUint16(n,!1);if(r===0)break;n=n+2;const h=this.getAMFName(t,n,r);n=n+r;const c=this.getAmfType(t,n);if(c===6)break;n=n+1;const g=this.getAMFValue(t,n,c);n=n+g.length,a[h]=g.value,i=2+r+1+g.length}break;case 8:{a={};const r=t.getUint32(n,!1);n=n+4;for(let h=0;h<r;h++){const c=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,c);n=n+c;const p=this.getAmfType(t,n);n=n+1;const l=this.getAMFValue(t,n,p);n=n+l.length,a[g]=l.value,i=2+c+1+l.length}}break;case 10:{a=[];const r=t.getUint32(n,!1);n=n+4;for(let h=0;h<r;h++){const c=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,c);n=n+g.length,a.push(g.value),i=1+g.length}}break}return{amfType:e,length:i,value:a}}}class S{pattern;cacher=new P;isParseing=!1;offset=0;on={};parser;constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new L;break;case"hls":this.parser=new D;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new S;A.on.debug=u=>postMessage({action:"onDebug",data:u}),A.on.info=u=>postMessage({action:"onInfo",data:u}),A.on.config=u=>postMessage({action:"onConfig",data:u}),A.on.chunk=u=>postMessage({action:"onChunk",data:u}),onmessage=u=>{const{action:t,data:s}=u.data,e=A[t];e&&e(s)}})();\n', T = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
9
- function L(h) {
7
+ var I = (h, o, a) => (Q(h, o, "read from private field"), a ? a.call(h) : o.get(h)), J = (h, o, a) => o.has(h) ? X("Cannot add the same private member more than once") : o instanceof WeakSet ? o.add(h) : o.set(h, a), K = (h, o, a, u) => (Q(h, o, "write to private field"), u ? u.call(h, a) : o.set(h, a), a);
8
+ const D = '(function(){"use strict";class P{pendingPayloads=[];payload=new Uint8Array(0);chunks=[];push=t=>{this.pendingPayloads.push(t)};next=(t=0)=>{this.payload=this.payload.slice(t);const s=this.pendingPayloads.shift();if(!s)return!1;const e=new Uint8Array(this.payload.byteLength+s.byteLength);return e.set(this.payload,0),e.set(s,this.payload.byteLength),this.payload=e,new DataView(this.payload.buffer)};pushChunk=t=>{this.chunks.push(t),this.chunks.length>1e3&&this.chunks.shift()};destroy=()=>{this.pendingPayloads=[],this.payload=new Uint8Array(0),this.chunks=[]}}const I=(y,t)=>{const s=new Uint8Array(y),e=new Uint8Array(t),n=new Uint8Array(11+s.length+e.length);let a=0;return n[a++]=1,n[a++]=s[1],n[a++]=s[2],n[a++]=s[3],n[a++]=255,n[a++]=225,n[a++]=s.length>>8&255,n[a++]=s.length&255,n.set(s,a),a+=s.length,n[a++]=1,n[a++]=e.length>>8&255,n[a++]=e.length&255,n.set(e,a),n},T=y=>{let t=0;const s=new DataView(y.buffer),e=s.getUint8(t);if(t=t+1,e!==1)throw new Error("Invalid AVC version");const n=s.getUint8(t)&255;t=t+1;const a=s.getUint8(t)&255;t=t+1;const o=s.getUint8(t)&255;t=t+1;const c=`avc1.${Array.from([n,a,o],U=>U.toString(16).padStart(2,"0")).join("")}`,r=(s.getUint8(t)&3)-1;t=t+1;const g=s.getUint8(t)&31;t=t+1;const p=s.getUint16(t,!1);t=t+2;const l=new Uint8Array(s.buffer.slice(t,t+p));t=t+p;const d=s.getUint8(t)&31;t=t+1;const u=s.getUint16(t,!1);t=t+2;const f=new Uint8Array(s.buffer.slice(t,t+u));return t=t+u,{version:e,codec:c,profile:n,compatibility:a,level:o,lengthSizeMinusOne:r,numOfSequenceParameterSets:g,sequenceParameterSetLength:p,sps:l,numOfPictureParameterSets:d,pictureParameterSetLength:u,pps:f}},M=y=>{const t=new Uint8Array(4+y.length);return new DataView(t.buffer).setUint32(0,y.length,!1),t.set(y,4),t},C=y=>{let t=0;for(const n of y)t+=n.length;const s=new Uint8Array(t);let e=0;for(const n of y){const a=n;s.set(a,e),e+=a.length}return s},D=y=>{let t="unknown";switch(y){case 1:case 2:case 27:case 36:t="video";break;case 3:case 4:case 15:t="audio";break;case 6:t="subtitle";break;case 134:t="ad";break}return t};class x{pat;pmt;audioConfig;videoConfig;payloadMap=new Map;on={};constructor(){}parse=async t=>{let s=0;for(;!(s+188>t.byteLength);){if(t.getInt8(s)!=71){s++;continue}await this.parsePacket(t,s),s+=188}return s};parsePacket=async(t,s)=>{if(s+188>t.byteLength)throw new Error("Invalid TS packet");if(t.getUint8(s)!==71)throw new Error("Invalid TS packet");let e=s;const n=this.parseHeader(t,e);e+=4;const{transport_error_indicator:a,pid:o,payload_unit_start_indicator:h,adaptation_field_control:i}=n;if(a===1||o===void 0)return;let c=184;if(i===2||i===3){const r=t.getUint8(e);e+=1,this.parseAdaptationField(t,e),e+=r,c-=r}if(i===3&&(c-=1),i===1||i===3){const r=new Uint8Array(t.buffer.slice(e,e+c));if(o===0)return this.parsePAT(t,e);{const{programs:l=[]}=this.pat||{};if(l.find(u=>u.pmt_pid===o))return this.parsePMT(t,e)}const{streams:g=[]}=this.pmt||{},p=g.find(l=>l.elementary_pid===o);if(p){if(h===1){const l=this.payloadMap.get(o);if(l){switch(p.kind){case"audio":{const d=await this.parseAudio(l);this.on.chunk&&this.on.chunk(d)}break;case"video":{const d=await this.parseVideo(l);this.on.chunk&&this.on.chunk(d),await new Promise(u=>setTimeout(()=>u(!0),8))}break}this.payloadMap.delete(o)}}{this.payloadMap.has(o)||this.payloadMap.set(o,new Uint8Array);const l=this.payloadMap.get(o),d=new Uint8Array(l.byteLength+r.byteLength);d.set(l,0),d.set(r,l.byteLength),this.payloadMap.set(o,d)}}}};parseHeader=(t,s)=>{let e=s;const n=t.getUint8(e),a=t.getUint8(e+1),o=t.getUint8(e+2),h=t.getUint8(e+3),i=(a&128)>>7;if(i===1)return{sync_byte:n,transport_error_indicator:i};const c=(a&64)>>6,r=(a&32)>>5,g=(a&31)<<8|o,p=(h&192)>>6,l=h>>4&3,d=h&15;return{sync_byte:n,transport_error_indicator:i,payload_unit_start_indicator:c,transport_priority:r,pid:g,transport_scrambling_control:p,adaptation_field_control:l,continuity_counter:d}};parsePAT=(t,s)=>{let e=s,n;{const h=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==0)throw new Error("Invalid PAT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const l=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1,n={pointer_field:h,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:l,last_section_number:d}}const a=[];{const h=n.section_length-5-4,i=e+h;for(;e<i;){const c=t.getUint16(e),r=t.getUint16(e+2)&8191;e+=4,c!==0&&r>=32&&r<=8190&&a.push({program_number:c,pmt_pid:r})}}const o=t.getUint32(e);this.pat={header:n,programs:a,crc32:o},this.on.debug&&this.on.debug({pat:this.pat})};parsePMT=(t,s)=>{let e=s,n;{const h=t.getUint8(e);e+=1;const i=t.getUint8(e);if(e+=1,i!==2)throw new Error("Invalid PMT table_id");const c=t.getUint16(e)&4095;e+=2;const r=t.getUint16(e);e+=2;const g=(t.getUint8(e)&62)>>1,p=t.getUint8(e)&1;e+=1;const l=t.getUint8(e);e+=1;const d=t.getUint8(e);e+=1;const u=t.getUint16(e)&8191;e+=2;const f=t.getUint16(e)&4095;e+=2,n={pointer_field:h,table_id:i,section_length:c,transport_stream_id:r,version_number:g,current_next_indicator:p,section_number:l,last_section_number:d,pcr_pid:u,program_info_length:f}}const a=[];{const h=n.section_length-9-4,i=e+h;for(;e<i;){const c=t.getUint8(e),r=D(c),g=t.getUint16(e+1)&8191,p=t.getUint16(e+3)&4095;if(e+=5,g<32||g>8190){console.warn(`Invalid elementary_pid: 0x${g.toString(16)}`);continue}a.push({kind:r,stream_type:c,elementary_pid:g,es_info_length:p})}}const o=t.getUint32(e);this.pmt={header:n,streams:a,crc32:o},this.on.debug&&this.on.debug({pmt:this.pmt})};parseAdaptationField=(t,s)=>{let e=s,n,a,o,h;const i=t.getUint8(e),c=!!(i&128),r=!!(i&64),g=!!(i&32),p=!!(i&16),l=!!(i&8),d=!!(i&4),u=!!(i&2),f=!!(i&1);e+=1;const U=(_,b)=>{let m=BigInt(0);m|=BigInt(_.getUint16(b))<<25n,m|=BigInt(_.getUint16(b+1))<<17n,m|=BigInt(_.getUint16(b+2))<<9n,m|=BigInt(_.getUint16(b+3))<<1n,m|=BigInt(_.getUint16(b+4)>>7);const S=(_.getUint16(b+4)&1)<<8|_.getUint16(b+5);return m=m*300n+BigInt(S),m};if(p&&(n=U(t,e),e+=6),l&&(a=U(t,e),e+=6),d&&(o=t.getInt8(e),e+=1),u){const _=t.getUint8(e);e+=1,h=new Uint8Array(t.buffer,e,_),e+=_}return{discontinuity_indicator:c,random_access_indicator:r,elementary_stream_priority_indicator:g,pcr_flag:p,opcr_flag:l,splicing_point_flag:d,transport_private_data_flag:u,adaptation_field_extension_flag:f,pcr:n,opcr:a,splice_countdown:o,transport_private_data:h}};parseAudio=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts audio payload.");const h=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,l;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,l=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:h,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:l,pts:d,dts:u}}a=t.slice(e);{if(!this.audioConfig){const r=s.getUint8(e);if(e+=1,r===255){const g=s.getUint8(e),p=s.getUint8(e+1),l=(g&248)>>3&3,d=p>>6&3,u=48e3,f=`mp4a.40.${l}`,U=d===3?1:2;this.audioConfig={kind:"audio",codec:f,sampleRate:u,numberOfChannels:U},this.on.config&&this.on.config(this.audioConfig)}}const{dts:o=0,pts:h=0}=n,i=h-o,c=a.slice(7);return{kind:"audio",type:"key",dts:o,pts:h,cts:i,data:c}}};parseVideo=async t=>{const s=new DataView(t.buffer);let e=0,n,a;{const o=s.getUint8(e)===0&&s.getUint8(e+1)===0&&s.getUint8(e+2)===1;if(e+=3,!o)throw new Error("invalid ts video payload.");const h=s.getUint8(e);e+=1;const i=s.getUint8(e)<<8|s.getUint8(e+1);e+=2;let c,r,g,p,l;{const f=s.getUint8(e);e+=1,c=f>>4&3,r=(f>>3&1)===1,g=(f>>2&1)===1,p=(f>>1&1)===1,l=(f&1)===1}let d,u;{const f=s.getUint8(e);e+=1;const U=f>>6,_=s.getUint8(e);e+=1,(U&2)===2&&(d=this.parsePtsDts(s,e)),(U&1)===1?u=this.parsePtsDts(s,e+5):u=d,e+=_}n={stream_id:h,pes_packet_length:i,scrambling_control:c,priority:r,data_alignment:g,copyright:p,original_copy:l,pts:d,dts:u}}a=t.slice(e);{const o=this.getNalus(a);if(!this.videoConfig){let l,d;if(l=o.find(f=>f.type===7)?.nalu.slice(4),d=o.find(f=>f.type===8)?.nalu.slice(4),l&&d){const u=I(l,d),{codec:f}=T(u);this.videoConfig={kind:"video",codec:f,description:u,sps:l,pps:d},this.on.config&&this.on.config(this.videoConfig)}}const h=[];let i="delta";for(const l of o){const{type:d,nalu:u}=l;switch(d){case 6:case 9:h.push(u);break;case 1:i="delta",h.push(u);break;case 5:i="key",h.push(u);break}}const c=C(h),{dts:r=0,pts:g=0}=n,p=g-r;return{kind:"video",type:i,dts:r,pts:g,cts:p,data:c,nalus:h}}};parsePtsDts(t,s){const e=t.getUint8(s),n=t.getUint8(s+1),a=t.getUint8(s+2),o=t.getUint8(s+3),h=t.getUint8(s+4),i=(BigInt(e)&0b00001110n)<<29n|(BigInt(n)&0b11111111n)<<22n|(BigInt(a)&0b11111110n)<<14n|(BigInt(o)&0b11111111n)<<7n|(BigInt(h)&0b11111110n)>>1n;return Number(i)/90}getNalus=t=>{const s=[];let e=0;for(;!(e+4>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}e+=3;let n=e;const a=t[e]&31;for(e+=1;!(e+1>t.byteLength);){if(t[e]!==0||t[e+1]!==0||t[e+2]!==1){e+=1;continue}break}let o=e-n;if(t[e-1]===0&&(o-=1),o!==0){const h=t.slice(n,n+o),i=M(h);s.push({type:a,nalu:i})}}return s}}const k=(y,t)=>y.getUint8(t)<<16|y.getUint8(t+1)<<8|y.getUint8(t+2);class O{audioConfig;videoConfig;header;textDecoder=new TextDecoder("utf-8");on={};constructor(){}parse=async t=>{let s=0;for(this.header||(this.parseHeader(t,s),s+=9);this.isSurplusTag(t,s)!==!1;){const n=this.parseTagHeader(t,s+4),{tagType:a,dataSize:o,timestamp:h}=n;if(a){const i=this.parseTagBody(a,t,s+4+11,o);switch(a){case"script":this.on.info&&this.on.info(i);break;case"audio":{const{accPacketType:c}=i;if(c===0){const{codec:r,sampleRate:g,channelConfiguration:p}=i;this.audioConfig={kind:"audio",codec:r,sampleRate:g,numberOfChannels:p},this.on.config&&this.on.config(this.audioConfig)}else{const{cts:r,data:g}=i,p="key",l=r===void 0?void 0:r+h;this.on.chunk&&this.on.chunk({kind:"audio",type:p,dts:h,pts:l,cts:r,data:g})}}break;case"video":{const{avcPacketType:c}=i;if(c===0){const{codec:r,sps:g,pps:p,data:l}=i;this.videoConfig={kind:"video",codec:r,description:l,sps:g,pps:p},this.on.config&&this.on.config(this.videoConfig)}else{const{frameType:r,cts:g,data:p,nalus:l}=i,d=r===1?"key":"delta",u=g===void 0?void 0:g+h;this.on.chunk&&this.on.chunk({kind:"video",type:d,dts:h,pts:u,cts:g,data:p,nalus:l})}}break}s=s+4+11+o}await new Promise(i=>setTimeout(()=>i(!0),8))}return s};parseHeader=(t,s)=>{let e,n,a,o;e=t.getUint8(s)<<16|t.getUint8(s+1)<<8|t.getUint8(s+2),n=t.getUint8(3);{const i=t.getUint8(0).toString(2).padStart(5,"0").split(""),[,,c,,r]=i;a={audio:r==="1",video:c==="1"}}o=t.getUint32(5),this.header={signature:e,version:n,flags:a,dataOffset:o}};isSurplusTag=(t,s)=>{let e=!0;const n=t.byteLength;if(s+4>n)e=!1;else if(s+4+11>n)e=!1;else{const a=k(t,s+4+1);s+4+11+a>n&&(e=!1)}return e};parseTagHeader=(t,s)=>{let e,n,a,o,h;{const i=t.getUint8(s);let c;switch(i){case 18:c="script";break;case 8:c="audio";break;case 9:c="video";break}e=c}return n=k(t,s+1),a=k(t,s+4),o=t.getUint8(s+7),h=k(t,s+8),{tagType:e,dataSize:n,timestamp:a,timestampExtended:o,streamID:h}};parseTagBody=(t,s,e,n)=>{let a;switch(t){case"script":a=this.parseMetaData(s,e);break;case"audio":a=this.parseAudio(s,e,n);break;case"video":a=this.parseVideo(s,e,n);break}return a};parseMetaData=(t,s)=>{let e=s;{if(t.getUint8(e)!==2)throw new Error("Invalid AMF type for onMetaData (expected 0x02)");e=e+1}const n=t.getUint16(e,!1);e=e+2;{const h=new Int8Array(t.buffer.slice(e,e+n));if((this.textDecoder?.decode(h)||"")!=="onMetaData")throw new Error("Expected \'onMetaData\' string");e=e+n}const a=this.getAmfType(t,e);return e=e+1,this.getAMFValue(t,e,a).value};parseAudio=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,h=a>>2&3,i=a>>1&1,c=a&1;n=n+1;const r=t.getUint8(n);n=n+1;const g=e-2,p=new Uint8Array(t.buffer.slice(n,n+g));if(o===10&&r===0){const l=t.getUint8(n),d=t.getUint8(n+1),u=(l&248)>>3,f=(l&7)<<1|d>>7,U=(d&120)>>3,_=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350],b=`mp4a.40.${u}`,m=_[f];return{soundFormat:o,soundRate:h,soundSize:i,soundType:c,accPacketType:r,data:p,audioObjectType:u,samplingFrequencyIndex:f,channelConfiguration:U,codec:b,sampleRate:m}}return{soundFormat:o,soundRate:h,soundSize:i,soundType:c,accPacketType:r,data:p}};parseVideo=(t,s,e)=>{let n=s;const a=t.getUint8(n),o=a>>4&15,h=a&15;n=n+1;const i=t.getUint8(n);n=n+1;const c=k(t,n);n=n+3;const r=e-5,g=new Uint8Array(t.buffer.slice(n,n+r));switch(h){case 7:if(i===0){const p=T(g);return{frameType:o,codecID:h,avcPacketType:i,cts:c,data:g,...p}}else if(i===1){const p=[],l=n+e-5;for(;!(n+4>l);){const d=t.getUint32(n,!1),u=new Uint8Array(t.buffer.slice(n,n+4+d));n+=4+d,p.push(u)}return{frameType:o,codecID:h,avcPacketType:i,cts:c,data:g,nalus:p}}break;default:throw new Error("Unsupported codecID")}return{frameType:o,codecID:h,avcPacketType:i,cts:c,data:g}};getAmfType=(t,s)=>t.getUint8(s);getAMFName=(t,s,e)=>{const n=new Uint8Array(t.buffer.slice(s,s+e));return this.textDecoder?.decode(n)||""};getAMFValue=(t,s,e)=>{let n=s,a,o=0;switch(e){case 0:a=t.getFloat64(n,!1),o=8;break;case 1:a=!!t.getUint8(n),o=1;break;case 2:{a="";const i=t.getUint16(n,!1);n=n+2;const c=new Int8Array(t.buffer,n,i).filter(g=>g!==0);a=(this.textDecoder?.decode(c)||"").trim(),o=2+i}break;case 3:for(a={};n<t.byteLength;){const i=t.getUint16(n,!1);if(i===0)break;n=n+2;const c=this.getAMFName(t,n,i);n=n+i;const r=this.getAmfType(t,n);if(r===6)break;n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a[c]=g.value,o=2+i+1+g.length}break;case 8:{a={};const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=t.getUint16(n,!1);n=n+2;const g=this.getAMFName(t,n,r);n=n+r;const p=this.getAmfType(t,n);n=n+1;const l=this.getAMFValue(t,n,p);n=n+l.length,a[g]=l.value,o=2+r+1+l.length}}break;case 10:{a=[];const i=t.getUint32(n,!1);n=n+4;for(let c=0;c<i;c++){const r=this.getAmfType(t,n);n=n+1;const g=this.getAMFValue(t,n,r);n=n+g.length,a.push(g.value),o=1+g.length}}break}return{amfType:e,length:o,value:a}}}class L{pattern;cacher=new P;isParseing=!1;offset=0;on={};parser;constructor(){}init=t=>{switch(this.destroy(),this.pattern=t,this.pattern){case"flv":this.parser=new O;break;case"hls":this.parser=new x;break;default:throw new Error("is error pattern.")}this.parser.on.debug=s=>this.on.debug&&this.on.debug(s),this.parser.on.info=s=>this.on.info&&this.on.info(s),this.parser.on.config=s=>this.on.config&&this.on.config(s),this.parser.on.chunk=s=>{this.cacher.pushChunk(s),this.on.chunk&&this.on.chunk(s)}};push=t=>{this.cacher.push(t),this.isParseing===!1&&this.parse()};destroy=()=>{this.cacher.destroy(),this.isParseing=!1,this.offset=0};parse=async()=>{try{if(this.isParseing=!0,!this.pattern)throw new Error("You need to set the pattern.");if(!this.parser)throw new Error("You need to init parser.");for(;;){const t=this.cacher.next(this.offset);if(this.offset=0,!t)break;this.offset=await this.parser.parse(t)}this.isParseing=!1}catch{this.destroy()}}}const A=new L;A.on.debug=y=>postMessage({action:"onDebug",data:y}),A.on.info=y=>postMessage({action:"onInfo",data:y}),A.on.config=y=>postMessage({action:"onConfig",data:y}),A.on.chunk=y=>postMessage({action:"onChunk",data:y}),onmessage=y=>{const{action:t,data:s}=y.data,e=A[t];e&&e(s)}})();\n', v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", D], { type: "text/javascript;charset=utf-8" });
9
+ function R(h) {
10
10
  let o;
11
11
  try {
12
- if (o = T && (self.URL || self.webkitURL).createObjectURL(T), !o) throw "";
12
+ if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
13
13
  const a = new Worker(o, {
14
14
  name: h == null ? void 0 : h.name
15
15
  });
@@ -25,9 +25,9 @@ function L(h) {
25
25
  );
26
26
  }
27
27
  }
28
- class B {
28
+ class L {
29
29
  constructor() {
30
- m(this, "worker", new L());
30
+ m(this, "worker", new R());
31
31
  m(this, "on", {});
32
32
  m(this, "init", (o) => this.worker.postMessage({ action: "init", data: o }));
33
33
  m(this, "push", (o) => this.worker.postMessage({ action: "push", data: o }));
@@ -54,11 +54,11 @@ class B {
54
54
  }
55
55
  }
56
56
  const M = `(function(){"use strict";class r{audioDecoderConfig;audioDecoder;videoDecoderConfig;videoDecoder;hasKeyFrame=!1;on={audio:{},video:{}};constructor(){}audio={init:i=>{this.audio.destroy(),this.audioDecoderConfig={...i},this.audioDecoder=new AudioDecoder({output:e=>{this.on.audio.decode&&this.on.audio.decode(e)},error:e=>{this.on.audio.error&&this.on.audio.error(e)}}),this.audioDecoder.configure(this.audioDecoderConfig)},decode:i=>{if(!this.audioDecoder)return;const e=new EncodedAudioChunk(i);this.audioDecoder.decode(e)},flush:()=>{this.audioDecoder?.flush()},destroy:()=>{this.audioDecoderConfig=void 0,this.audioDecoder?.close(),this.audioDecoder=void 0}};video={init:i=>{this.video.destroy(),this.videoDecoderConfig={...i},this.videoDecoder=new VideoDecoder({output:async e=>{const d=await createImageBitmap(e),s=e.timestamp;e.close(),d.width>0&&d.height>0?this.on.video.decode&&this.on.video.decode({timestamp:s,bitmap:d}):d.close()},error:e=>{console.log("\\x1B[38;2;0;151;255m%c%s\\x1B[0m","color:#0097ff;","------->Breathe: e",e),this.on.video.error&&this.on.video.error(e)}}),this.videoDecoder.configure(this.videoDecoderConfig)},decode:i=>{if(this.videoDecoder&&(i.type==="key"&&(this.hasKeyFrame=!0),this.hasKeyFrame&&this.videoDecoder.decodeQueueSize<2)){const e=new EncodedVideoChunk(i);this.videoDecoder.decode(e)}},flush:()=>{this.videoDecoder?.flush()},destroy:()=>{this.videoDecoderConfig=void 0,this.videoDecoder?.close(),this.videoDecoder=void 0,this.hasKeyFrame=!1}}}const t=new r;t.on.audio.decode=o=>postMessage({type:"audio",action:"onDecode",data:o}),t.on.audio.error=o=>postMessage({type:"audio",action:"onError",data:o}),t.on.video.decode=o=>postMessage({type:"video",action:"onDecode",data:o}),t.on.video.error=o=>postMessage({type:"video",action:"onError",data:o}),onmessage=o=>{const{type:i,action:e,data:d}=o.data,s=t[i][e];s&&s(d)}})();
57
- `, v = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", M], { type: "text/javascript;charset=utf-8" });
57
+ `, T = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", M], { type: "text/javascript;charset=utf-8" });
58
58
  function F(h) {
59
59
  let o;
60
60
  try {
61
- if (o = v && (self.URL || self.webkitURL).createObjectURL(v), !o) throw "";
61
+ if (o = T && (self.URL || self.webkitURL).createObjectURL(T), !o) throw "";
62
62
  const a = new Worker(o, {
63
63
  name: h == null ? void 0 : h.name
64
64
  });
@@ -110,35 +110,35 @@ class N {
110
110
  };
111
111
  }
112
112
  }
113
- var E = Object.defineProperty, G = (h, o, a) => o in h ? E(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, f = (h, o, a) => G(h, typeof o != "symbol" ? o + "" : o, a);
113
+ var E = Object.defineProperty, G = (h, o, a) => o in h ? E(h, o, { enumerable: !0, configurable: !0, writable: !0, value: a }) : h[o] = a, y = (h, o, a) => G(h, typeof o != "symbol" ? o + "" : o, a);
114
114
  class O {
115
115
  constructor(o, a) {
116
- f(this, "inputStream", new MediaStream()), f(this, "outputStream", new MediaStream()), f(this, "inputGain", 1), f(this, "enhanceGain", 1), f(this, "bgsGain", 1), f(this, "bgmGain", 1), f(this, "outputGain", 1), f(this, "mixAudioMap", /* @__PURE__ */ new Map()), f(this, "audioContext", new AudioContext()), f(this, "sourceNode"), f(this, "inputGainNode"), f(this, "enhanceGainNode"), f(this, "bgsGainNode"), f(this, "bgmGainNode"), f(this, "analyserNode"), f(this, "analyserArrayData"), f(this, "outputGainNode"), f(this, "destinationNode"), f(this, "filterStream", (u) => u), f(this, "stop", () => {
116
+ y(this, "inputStream", new MediaStream()), y(this, "outputStream", new MediaStream()), y(this, "inputGain", 1), y(this, "enhanceGain", 1), y(this, "bgsGain", 1), y(this, "bgmGain", 1), y(this, "outputGain", 1), y(this, "mixAudioMap", /* @__PURE__ */ new Map()), y(this, "audioContext", new AudioContext()), y(this, "sourceNode"), y(this, "inputGainNode"), y(this, "enhanceGainNode"), y(this, "bgsGainNode"), y(this, "bgmGainNode"), y(this, "analyserNode"), y(this, "analyserArrayData"), y(this, "outputGainNode"), y(this, "destinationNode"), y(this, "filterStream", (u) => u), y(this, "stop", () => {
117
117
  {
118
118
  const u = this.inputStream.getTracks();
119
119
  for (const n of u)
120
120
  n.stop(), this.inputStream.removeTrack(n);
121
121
  }
122
- }), f(this, "getStream", () => this.filterStream(this.outputStream)), f(this, "setMute", (u = !0) => {
122
+ }), y(this, "getStream", () => this.filterStream(this.outputStream)), y(this, "setMute", (u = !0) => {
123
123
  u ? this.analyserNode.disconnect(this.outputGainNode) : this.analyserNode.connect(this.outputGainNode);
124
- }), f(this, "setInputGain", (u) => {
124
+ }), y(this, "setInputGain", (u) => {
125
125
  this.inputGain = u, this.inputGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
126
- }), f(this, "setEnhanceGain", async (u) => {
126
+ }), y(this, "setEnhanceGain", async (u) => {
127
127
  this.enhanceGain = u + 1, this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime);
128
- }), f(this, "setBgsGain", (u) => {
128
+ }), y(this, "setBgsGain", (u) => {
129
129
  this.bgsGain = u, this.bgsGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
130
- }), f(this, "setBgmGain", (u) => {
130
+ }), y(this, "setBgmGain", (u) => {
131
131
  this.bgmGain = u, this.bgmGainNode.gain.setValueAtTime(u, this.audioContext.currentTime);
132
- }), f(this, "setOutputGain", (u) => {
132
+ }), y(this, "setOutputGain", (u) => {
133
133
  this.outputGain = u, this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime);
134
- }), f(this, "getVolume", () => {
134
+ }), y(this, "getVolume", () => {
135
135
  const { analyserNode: u, analyserArrayData: n } = this;
136
136
  u.getByteFrequencyData(n);
137
137
  let r = 0;
138
138
  for (let i = 0; i < n.length; i++)
139
139
  r += n[i];
140
140
  return Math.ceil(r / n.length);
141
- }), f(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
141
+ }), y(this, "mixAudio", (u, n = "bgm") => new Promise(async (r, i) => {
142
142
  try {
143
143
  {
144
144
  const s = this.mixAudioMap.get(n);
@@ -151,10 +151,10 @@ class O {
151
151
  } catch (t) {
152
152
  i(t);
153
153
  }
154
- })), f(this, "mixAudioStop", (u) => {
154
+ })), y(this, "mixAudioStop", (u) => {
155
155
  const n = this.mixAudioMap.get(u);
156
156
  n == null || n.stop();
157
- }), f(this, "changeMix", (u, n) => {
157
+ }), y(this, "changeMix", (u, n) => {
158
158
  const r = u === "bgs" ? this.bgsGainNode : this.bgmGainNode;
159
159
  n ? r.connect(this.destinationNode) : r.disconnect(this.destinationNode);
160
160
  }), a && (this.audioContext = a), this.inputStream = o, this.sourceNode = this.audioContext.createMediaStreamSource(this.inputStream), this.inputGainNode = this.audioContext.createGain(), this.inputGainNode.gain.setValueAtTime(this.inputGain, this.audioContext.currentTime), this.enhanceGainNode = this.audioContext.createGain(), this.enhanceGainNode.gain.setValueAtTime(this.enhanceGain, this.audioContext.currentTime), this.bgsGainNode = this.audioContext.createGain(), this.bgsGainNode.gain.setValueAtTime(this.bgsGain, this.audioContext.currentTime), this.bgmGainNode = this.audioContext.createGain(), this.bgmGainNode.gain.setValueAtTime(this.bgmGain, this.audioContext.currentTime), this.analyserNode = this.audioContext.createAnalyser(), this.analyserNode.fftSize = 512, this.analyserArrayData = new Uint8Array(this.analyserNode.frequencyBinCount), this.outputGainNode = this.audioContext.createGain(), this.outputGainNode.gain.setValueAtTime(this.outputGain, this.audioContext.currentTime), this.destinationNode = this.audioContext.createMediaStreamDestination(), this.outputStream = this.destinationNode.stream;
@@ -173,27 +173,27 @@ const W = async (h, o) => {
173
173
  o.copyTo(s, { planeIndex: t });
174
174
  const l = new DataView(s.buffer), c = i.getChannelData(t);
175
175
  for (let d = 0; d < n; d++) {
176
- let y;
176
+ let p;
177
177
  switch (a) {
178
178
  case "s16":
179
179
  // 16-bit signed PCM (范围: -32768 ~ 32767)
180
180
  case "s16-planar":
181
- y = l.getInt16(d * 2, !0) / 32768;
181
+ p = l.getInt16(d * 2, !0) / 32768;
182
182
  break;
183
183
  case "f32":
184
184
  // 32-bit float (范围: -1.0 ~ 1.0)
185
185
  case "f32-planar":
186
- y = l.getFloat32(d * 4, !0);
186
+ p = l.getFloat32(d * 4, !0);
187
187
  break;
188
188
  case "u8":
189
189
  // 8-bit unsigned (范围: 0 ~ 255)
190
190
  case "u8-planar":
191
- y = (l.getUint8(d) - 128) / 128;
191
+ p = (l.getUint8(d) - 128) / 128;
192
192
  break;
193
193
  default:
194
194
  throw new Error(`Unsupported audio format: ${a}`);
195
195
  }
196
- c[d] = Math.max(-1, Math.min(1, y));
196
+ c[d] = Math.max(-1, Math.min(1, p));
197
197
  }
198
198
  }
199
199
  return i;
@@ -239,7 +239,7 @@ class V {
239
239
  }
240
240
  const S = `(function(){"use strict";class r{isRendering=!1;pendingFrames=[];offscreenCanvas;writable;writer;ctx;cutOption;baseTime=0;pause=!1;shader=["stream"];constructor(){}init=({offscreenCanvas:e,writable:t})=>{this.destroy(),this.offscreenCanvas=e,this.writable=t,this.writer=this.writable.getWriter(),this.ctx=this.offscreenCanvas.getContext("2d")};setBaseTime=e=>{this.baseTime=e};setShader=e=>{this.shader=e};setSize=({width:e,height:t})=>{this.offscreenCanvas&&(this.offscreenCanvas.width=e,this.offscreenCanvas.height=t)};destroy=()=>{this.isRendering=!1,this.pendingFrames=[],this.offscreenCanvas=void 0,this.ctx=void 0,this.baseTime=0};push=e=>{this.pendingFrames.push(e),this.isRendering===!1&&setTimeout(this.renderFrame,0)};setCut=e=>{this.cutOption=e};setPause=e=>{this.pause=e,this.isRendering===!1&&setTimeout(this.renderFrame,0)};calculateTimeUntilNextFrame=e=>{const t=performance.timeOrigin+performance.now(),i=this.baseTime+e/1e3-t;return Math.max(0,i)};renderFrame=async()=>{for(this.isRendering=!0;;){const e=this.pendingFrames.shift();if(!e)break;let{timestamp:t,bitmap:s}=e;if(this.cutOption){const{sx:a=0,sy:c=0,sw:m=s.width,sh:o=s.height}=this.cutOption;s=await createImageBitmap(s,a,c,m,o)}const i=this.calculateTimeUntilNextFrame(t);await new Promise(a=>setTimeout(()=>a(!0),i)),this.drawImage({timestamp:t,bitmap:s}),this.cutOption&&s.close()}this.isRendering=!1};drawImage=e=>{if(this.pause!==!0){if(this.shader.includes("stream")){const t=new VideoFrame(e.bitmap,{timestamp:e.timestamp});this.writer.write(t),t.close()}this.shader.includes("canvas")&&this.ctx&&this.offscreenCanvas&&this.ctx.drawImage(e.bitmap,0,0,this.offscreenCanvas.width,this.offscreenCanvas.height)}}}const h=new r;onmessage=n=>{const{action:e,data:t}=n.data,s=h[e];s&&s(t)}})();
241
241
  `, x = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", S], { type: "text/javascript;charset=utf-8" });
242
- function z(h) {
242
+ function j(h) {
243
243
  let o;
244
244
  try {
245
245
  if (o = x && (self.URL || self.webkitURL).createObjectURL(x), !o) throw "";
@@ -258,9 +258,9 @@ function z(h) {
258
258
  );
259
259
  }
260
260
  }
261
- class j {
261
+ class z {
262
262
  constructor() {
263
- m(this, "worker", new z());
263
+ m(this, "worker", new j());
264
264
  m(this, "init", ({ offscreenCanvas: o, writable: a }) => this.worker.postMessage({ action: "init", data: { offscreenCanvas: o, writable: a } }, [o, a]));
265
265
  m(this, "setShader", (o) => this.worker.postMessage({ action: "setShader", data: o }));
266
266
  m(this, "setBaseTime", (o) => this.worker.postMessage({ action: "setBaseTime", data: o }));
@@ -281,7 +281,7 @@ const $ = (h) => {
281
281
  for (const a of o)
282
282
  a.stop();
283
283
  }, A = () => {
284
- const h = new j(), o = document.createElement("canvas"), a = o.transferControlToOffscreen(), u = new MediaStreamTrackGenerator({ kind: "video" }), n = new MediaStream([u]), r = () => {
284
+ const h = new z(), o = document.createElement("canvas"), a = o.transferControlToOffscreen(), u = new MediaStreamTrackGenerator({ kind: "video" }), n = new MediaStream([u]), r = () => {
285
285
  h.destroy(), P(n);
286
286
  };
287
287
  return h.init({ offscreenCanvas: a, writable: u.writable }), { worker: h, canvas: o, stream: n, destroy: r };
@@ -336,14 +336,14 @@ const Y = (h) => {
336
336
  }
337
337
  return { size: u, header: n, data: r };
338
338
  };
339
- var q, I;
339
+ var q, U;
340
340
  class C {
341
341
  constructor(o = {}) {
342
342
  J(this, q, {
343
343
  timeout: 5 * 1e3,
344
344
  check: !1
345
345
  });
346
- J(this, I);
346
+ J(this, U);
347
347
  /**
348
348
  *
349
349
  * @param input string | URL | Request
@@ -351,13 +351,13 @@ class C {
351
351
  */
352
352
  m(this, "check", (o, a) => new Promise(async (u, n) => {
353
353
  var i;
354
- this.stop(), K(this, I, new AbortController());
354
+ this.stop(), K(this, U, new AbortController());
355
355
  const r = window.setTimeout(() => {
356
356
  var t;
357
- (t = U(this, I)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
358
- }, U(this, q).timeout);
357
+ (t = I(this, U)) == null || t.abort("Timeout."), n({ status: "timeout", reason: "" });
358
+ }, I(this, q).timeout);
359
359
  try {
360
- const t = await fetch(o, { ...a, method: "HEAD", signal: (i = U(this, I)) == null ? void 0 : i.signal });
360
+ const t = await fetch(o, { ...a, method: "HEAD", signal: (i = I(this, U)) == null ? void 0 : i.signal });
361
361
  t.status === 200 ? u({ status: "successed", reason: "" }) : n({ status: "failed", reason: `${t.status}` });
362
362
  } catch (t) {
363
363
  n({ status: "error", reason: t.message });
@@ -372,8 +372,8 @@ class C {
372
372
  m(this, "request", async (o, a) => new Promise(async (u, n) => {
373
373
  var r;
374
374
  try {
375
- U(this, q).check && await this.check(o, a), K(this, I, new AbortController());
376
- const i = await fetch(o, { ...a, signal: (r = U(this, I)) == null ? void 0 : r.signal });
375
+ I(this, q).check && await this.check(o, a), K(this, U, new AbortController());
376
+ const i = await fetch(o, { ...a, signal: (r = I(this, U)) == null ? void 0 : r.signal });
377
377
  u(i);
378
378
  } catch (i) {
379
379
  this.stop(), n(i);
@@ -384,14 +384,17 @@ class C {
384
384
  */
385
385
  m(this, "stop", () => {
386
386
  var o;
387
- ((o = U(this, I)) == null ? void 0 : o.signal.aborted) === !1 && U(this, I).abort("Actively stop.");
387
+ ((o = I(this, U)) == null ? void 0 : o.signal.aborted) === !1 && I(this, U).abort("Actively stop.");
388
388
  });
389
- K(this, q, { ...U(this, q), ...o });
389
+ K(this, q, { ...I(this, q), ...o });
390
390
  }
391
391
  }
392
- q = new WeakMap(), I = new WeakMap();
392
+ q = new WeakMap(), U = new WeakMap();
393
393
  class et {
394
- constructor() {
394
+ constructor(o = {}) {
395
+ m(this, "option", {
396
+ debug: !1
397
+ });
395
398
  m(this, "prFetch", new C());
396
399
  m(this, "prResolves", new H());
397
400
  m(this, "url", "");
@@ -437,7 +440,7 @@ class et {
437
440
  try {
438
441
  clearInterval(this.hls.getSegmentsTimer), this.prFetch.stop();
439
442
  } catch (i) {
440
- console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: error", i);
443
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: error", i);
441
444
  }
442
445
  (a = this.demuxerWorker) == null || a.destroy(), (u = this.decoderWorker) == null || u.destroy(), (n = this.renderWorker) == null || n.destroy(), P(this.stream);
443
446
  const o = [...this.cutRenders.keys()];
@@ -515,12 +518,13 @@ class et {
515
518
  * 初始化解复器
516
519
  */
517
520
  m(this, "initDemuxer", (o) => {
518
- this.demuxerWorker = new B(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
521
+ this.demuxerWorker = new L(), this.demuxerWorker.init(o), this.demuxerWorker.on.debug = (a) => {
522
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: debug", a);
519
523
  }, this.demuxerWorker.on.info = (a) => {
520
- this.on.demuxer.info && this.on.demuxer.info(a);
524
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: info", a), this.on.demuxer.info && this.on.demuxer.info(a);
521
525
  }, this.demuxerWorker.on.config = (a) => {
522
526
  var n, r;
523
- this.on.demuxer.config && this.on.demuxer.config(a);
527
+ this.option.debug && console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: config", a), this.on.demuxer.config && this.on.demuxer.config(a);
524
528
  const { kind: u } = a;
525
529
  switch (u) {
526
530
  case "audio":
@@ -538,7 +542,7 @@ class et {
538
542
  }
539
543
  }, this.demuxerWorker.on.chunk = (a) => {
540
544
  var n;
541
- if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), !this.decoderWorker) return;
545
+ if (this.on.demuxer.chunk && this.on.demuxer.chunk(a), console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->pr-player: chunk", a), !this.decoderWorker) return;
542
546
  const { kind: u } = a;
543
547
  switch (u) {
544
548
  case "audio":
@@ -558,8 +562,8 @@ class et {
558
562
  this.decoderWorker.video.decode({ type: r, timestamp: s, data: t });
559
563
  for (const l of e) {
560
564
  if (l.byteLength <= 4) continue;
561
- const { header: c, data: d } = Y(l), { nal_unit_type: y } = c;
562
- y === 6 && this.on.demuxer.sei && this.on.demuxer.sei(d);
565
+ const { header: c, data: d } = Y(l), { nal_unit_type: p } = c;
566
+ p === 6 && this.on.demuxer.sei && this.on.demuxer.sei(d);
563
567
  }
564
568
  }
565
569
  break;
@@ -574,7 +578,7 @@ class et {
574
578
  var a;
575
579
  (a = this.audioPlayer) == null || a.push(o), this.on.decoder.audio && this.on.decoder.audio(o);
576
580
  }, this.decoderWorker.on.audio.error = (o) => {
577
- this.stop(), this.on.error && this.on.error(o);
581
+ console.log("\x1B[38;2;0;151;255m%c%s\x1B[0m", "color:#0097ff;", "------->Breathe: e", o), this.on.error && this.on.error(o);
578
582
  }, this.decoderWorker.on.video.decode = async (o) => {
579
583
  var u, n;
580
584
  (u = this.renderWorker) == null || u.push(o);
@@ -665,6 +669,8 @@ class et {
665
669
  }
666
670
  }
667
671
  });
672
+ const { debug: a = !1 } = o;
673
+ this.option.debug = a;
668
674
  }
669
675
  }
670
676
  var commonjsGlobal = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}, indexMinimal = {}, minimal$1 = {}, aspromise, hasRequiredAspromise;
@@ -680,8 +686,8 @@ function requireAspromise() {
680
686
  if (i = !1, c)
681
687
  s(c);
682
688
  else {
683
- for (var d = new Array(arguments.length - 1), y = 0; y < d.length; )
684
- d[y++] = arguments[y];
689
+ for (var d = new Array(arguments.length - 1), p = 0; p < d.length; )
690
+ d[p++] = arguments[p];
685
691
  e.apply(null, d);
686
692
  }
687
693
  };
@@ -709,43 +715,43 @@ function requireBase64() {
709
715
  for (var a = new Array(64), u = new Array(123), n = 0; n < 64; )
710
716
  u[a[n] = n < 26 ? n + 65 : n < 52 ? n + 71 : n < 62 ? n - 4 : n - 59 | 43] = n++;
711
717
  o.encode = function(t, e, s) {
712
- for (var l = null, c = [], d = 0, y = 0, p; e < s; ) {
718
+ for (var l = null, c = [], d = 0, p = 0, f; e < s; ) {
713
719
  var w = t[e++];
714
- switch (y) {
720
+ switch (p) {
715
721
  case 0:
716
- c[d++] = a[w >> 2], p = (w & 3) << 4, y = 1;
722
+ c[d++] = a[w >> 2], f = (w & 3) << 4, p = 1;
717
723
  break;
718
724
  case 1:
719
- c[d++] = a[p | w >> 4], p = (w & 15) << 2, y = 2;
725
+ c[d++] = a[f | w >> 4], f = (w & 15) << 2, p = 2;
720
726
  break;
721
727
  case 2:
722
- c[d++] = a[p | w >> 6], c[d++] = a[w & 63], y = 0;
728
+ c[d++] = a[f | w >> 6], c[d++] = a[w & 63], p = 0;
723
729
  break;
724
730
  }
725
731
  d > 8191 && ((l || (l = [])).push(String.fromCharCode.apply(String, c)), d = 0);
726
732
  }
727
- return y && (c[d++] = a[p], c[d++] = 61, y === 1 && (c[d++] = 61)), l ? (d && l.push(String.fromCharCode.apply(String, c.slice(0, d))), l.join("")) : String.fromCharCode.apply(String, c.slice(0, d));
733
+ return p && (c[d++] = a[f], c[d++] = 61, p === 1 && (c[d++] = 61)), l ? (d && l.push(String.fromCharCode.apply(String, c.slice(0, d))), l.join("")) : String.fromCharCode.apply(String, c.slice(0, d));
728
734
  };
729
735
  var r = "invalid encoding";
730
736
  o.decode = function(t, e, s) {
731
- for (var l = s, c = 0, d, y = 0; y < t.length; ) {
732
- var p = t.charCodeAt(y++);
733
- if (p === 61 && c > 1)
737
+ for (var l = s, c = 0, d, p = 0; p < t.length; ) {
738
+ var f = t.charCodeAt(p++);
739
+ if (f === 61 && c > 1)
734
740
  break;
735
- if ((p = u[p]) === void 0)
741
+ if ((f = u[f]) === void 0)
736
742
  throw Error(r);
737
743
  switch (c) {
738
744
  case 0:
739
- d = p, c = 1;
745
+ d = f, c = 1;
740
746
  break;
741
747
  case 1:
742
- e[s++] = d << 2 | (p & 48) >> 4, d = p, c = 2;
748
+ e[s++] = d << 2 | (f & 48) >> 4, d = f, c = 2;
743
749
  break;
744
750
  case 2:
745
- e[s++] = (d & 15) << 4 | (p & 60) >> 2, d = p, c = 3;
751
+ e[s++] = (d & 15) << 4 | (f & 60) >> 2, d = f, c = 3;
746
752
  break;
747
753
  case 3:
748
- e[s++] = (d & 3) << 6 | p, c = 0;
754
+ e[s++] = (d & 3) << 6 | f, c = 0;
749
755
  break;
750
756
  }
751
757
  }
@@ -796,18 +802,18 @@ function requireFloat() {
796
802
  function h(r) {
797
803
  return typeof Float32Array < "u" ? function() {
798
804
  var i = new Float32Array([-0]), t = new Uint8Array(i.buffer), e = t[3] === 128;
799
- function s(y, p, w) {
800
- i[0] = y, p[w] = t[0], p[w + 1] = t[1], p[w + 2] = t[2], p[w + 3] = t[3];
805
+ function s(p, f, w) {
806
+ i[0] = p, f[w] = t[0], f[w + 1] = t[1], f[w + 2] = t[2], f[w + 3] = t[3];
801
807
  }
802
- function l(y, p, w) {
803
- i[0] = y, p[w] = t[3], p[w + 1] = t[2], p[w + 2] = t[1], p[w + 3] = t[0];
808
+ function l(p, f, w) {
809
+ i[0] = p, f[w] = t[3], f[w + 1] = t[2], f[w + 2] = t[1], f[w + 3] = t[0];
804
810
  }
805
811
  r.writeFloatLE = e ? s : l, r.writeFloatBE = e ? l : s;
806
- function c(y, p) {
807
- return t[0] = y[p], t[1] = y[p + 1], t[2] = y[p + 2], t[3] = y[p + 3], i[0];
812
+ function c(p, f) {
813
+ return t[0] = p[f], t[1] = p[f + 1], t[2] = p[f + 2], t[3] = p[f + 3], i[0];
808
814
  }
809
- function d(y, p) {
810
- return t[3] = y[p], t[2] = y[p + 1], t[1] = y[p + 2], t[0] = y[p + 3], i[0];
815
+ function d(p, f) {
816
+ return t[3] = p[f], t[2] = p[f + 1], t[1] = p[f + 2], t[0] = p[f + 3], i[0];
811
817
  }
812
818
  r.readFloatLE = e ? c : d, r.readFloatBE = e ? d : c;
813
819
  }() : function() {
@@ -828,60 +834,60 @@ function requireFloat() {
828
834
  else if (s < 11754943508222875e-54)
829
835
  e((d << 31 | Math.round(s / 1401298464324817e-60)) >>> 0, l, c);
830
836
  else {
831
- var y = Math.floor(Math.log(s) / Math.LN2), p = Math.round(s * Math.pow(2, -y) * 8388608) & 8388607;
832
- e((d << 31 | y + 127 << 23 | p) >>> 0, l, c);
837
+ var p = Math.floor(Math.log(s) / Math.LN2), f = Math.round(s * Math.pow(2, -p) * 8388608) & 8388607;
838
+ e((d << 31 | p + 127 << 23 | f) >>> 0, l, c);
833
839
  }
834
840
  }
835
841
  r.writeFloatLE = i.bind(null, o), r.writeFloatBE = i.bind(null, a);
836
842
  function t(e, s, l) {
837
- var c = e(s, l), d = (c >> 31) * 2 + 1, y = c >>> 23 & 255, p = c & 8388607;
838
- return y === 255 ? p ? NaN : d * (1 / 0) : y === 0 ? d * 1401298464324817e-60 * p : d * Math.pow(2, y - 150) * (p + 8388608);
843
+ var c = e(s, l), d = (c >> 31) * 2 + 1, p = c >>> 23 & 255, f = c & 8388607;
844
+ return p === 255 ? f ? NaN : d * (1 / 0) : p === 0 ? d * 1401298464324817e-60 * f : d * Math.pow(2, p - 150) * (f + 8388608);
839
845
  }
840
846
  r.readFloatLE = t.bind(null, u), r.readFloatBE = t.bind(null, n);
841
847
  }(), typeof Float64Array < "u" ? function() {
842
848
  var i = new Float64Array([-0]), t = new Uint8Array(i.buffer), e = t[7] === 128;
843
- function s(y, p, w) {
844
- i[0] = y, p[w] = t[0], p[w + 1] = t[1], p[w + 2] = t[2], p[w + 3] = t[3], p[w + 4] = t[4], p[w + 5] = t[5], p[w + 6] = t[6], p[w + 7] = t[7];
849
+ function s(p, f, w) {
850
+ i[0] = p, f[w] = t[0], f[w + 1] = t[1], f[w + 2] = t[2], f[w + 3] = t[3], f[w + 4] = t[4], f[w + 5] = t[5], f[w + 6] = t[6], f[w + 7] = t[7];
845
851
  }
846
- function l(y, p, w) {
847
- i[0] = y, p[w] = t[7], p[w + 1] = t[6], p[w + 2] = t[5], p[w + 3] = t[4], p[w + 4] = t[3], p[w + 5] = t[2], p[w + 6] = t[1], p[w + 7] = t[0];
852
+ function l(p, f, w) {
853
+ i[0] = p, f[w] = t[7], f[w + 1] = t[6], f[w + 2] = t[5], f[w + 3] = t[4], f[w + 4] = t[3], f[w + 5] = t[2], f[w + 6] = t[1], f[w + 7] = t[0];
848
854
  }
849
855
  r.writeDoubleLE = e ? s : l, r.writeDoubleBE = e ? l : s;
850
- function c(y, p) {
851
- return t[0] = y[p], t[1] = y[p + 1], t[2] = y[p + 2], t[3] = y[p + 3], t[4] = y[p + 4], t[5] = y[p + 5], t[6] = y[p + 6], t[7] = y[p + 7], i[0];
856
+ function c(p, f) {
857
+ return t[0] = p[f], t[1] = p[f + 1], t[2] = p[f + 2], t[3] = p[f + 3], t[4] = p[f + 4], t[5] = p[f + 5], t[6] = p[f + 6], t[7] = p[f + 7], i[0];
852
858
  }
853
- function d(y, p) {
854
- return t[7] = y[p], t[6] = y[p + 1], t[5] = y[p + 2], t[4] = y[p + 3], t[3] = y[p + 4], t[2] = y[p + 5], t[1] = y[p + 6], t[0] = y[p + 7], i[0];
859
+ function d(p, f) {
860
+ return t[7] = p[f], t[6] = p[f + 1], t[5] = p[f + 2], t[4] = p[f + 3], t[3] = p[f + 4], t[2] = p[f + 5], t[1] = p[f + 6], t[0] = p[f + 7], i[0];
855
861
  }
856
862
  r.readDoubleLE = e ? c : d, r.readDoubleBE = e ? d : c;
857
863
  }() : function() {
858
- function i(e, s, l, c, d, y) {
859
- var p = c < 0 ? 1 : 0;
860
- if (p && (c = -c), c === 0)
861
- e(0, d, y + s), e(1 / c > 0 ? (
864
+ function i(e, s, l, c, d, p) {
865
+ var f = c < 0 ? 1 : 0;
866
+ if (f && (c = -c), c === 0)
867
+ e(0, d, p + s), e(1 / c > 0 ? (
862
868
  /* positive */
863
869
  0
864
870
  ) : (
865
871
  /* negative 0 */
866
872
  2147483648
867
- ), d, y + l);
873
+ ), d, p + l);
868
874
  else if (isNaN(c))
869
- e(0, d, y + s), e(2146959360, d, y + l);
875
+ e(0, d, p + s), e(2146959360, d, p + l);
870
876
  else if (c > 17976931348623157e292)
871
- e(0, d, y + s), e((p << 31 | 2146435072) >>> 0, d, y + l);
877
+ e(0, d, p + s), e((f << 31 | 2146435072) >>> 0, d, p + l);
872
878
  else {
873
879
  var w;
874
880
  if (c < 22250738585072014e-324)
875
- w = c / 5e-324, e(w >>> 0, d, y + s), e((p << 31 | w / 4294967296) >>> 0, d, y + l);
881
+ w = c / 5e-324, e(w >>> 0, d, p + s), e((f << 31 | w / 4294967296) >>> 0, d, p + l);
876
882
  else {
877
883
  var b = Math.floor(Math.log(c) / Math.LN2);
878
- b === 1024 && (b = 1023), w = c * Math.pow(2, -b), e(w * 4503599627370496 >>> 0, d, y + s), e((p << 31 | b + 1023 << 20 | w * 1048576 & 1048575) >>> 0, d, y + l);
884
+ b === 1024 && (b = 1023), w = c * Math.pow(2, -b), e(w * 4503599627370496 >>> 0, d, p + s), e((f << 31 | b + 1023 << 20 | w * 1048576 & 1048575) >>> 0, d, p + l);
879
885
  }
880
886
  }
881
887
  }
882
888
  r.writeDoubleLE = i.bind(null, o, 0, 4), r.writeDoubleBE = i.bind(null, a, 4, 0);
883
889
  function t(e, s, l, c, d) {
884
- var y = e(c, d + s), p = e(c, d + l), w = (p >> 31) * 2 + 1, b = p >>> 20 & 2047, g = 4294967296 * (p & 1048575) + y;
890
+ var p = e(c, d + s), f = e(c, d + l), w = (f >> 31) * 2 + 1, b = f >>> 20 & 2047, g = 4294967296 * (f & 1048575) + p;
885
891
  return b === 2047 ? g ? NaN : w * (1 / 0) : b === 0 ? w * 5e-324 * g : w * Math.pow(2, b - 1075) * (g + 4503599627370496);
886
892
  }
887
893
  r.readDoubleLE = t.bind(null, u, 0, 4), r.readDoubleBE = t.bind(null, n, 4, 0);
@@ -1197,11 +1203,11 @@ function requireWriter() {
1197
1203
  g
1198
1204
  )).len, this;
1199
1205
  }, e.prototype.int32 = function(g) {
1200
- return g < 0 ? this._push(y, 10, a.fromNumber(g)) : this.uint32(g);
1206
+ return g < 0 ? this._push(p, 10, a.fromNumber(g)) : this.uint32(g);
1201
1207
  }, e.prototype.sint32 = function(g) {
1202
1208
  return this.uint32((g << 1 ^ g >> 31) >>> 0);
1203
1209
  };
1204
- function y(b, g, k) {
1210
+ function p(b, g, k) {
1205
1211
  for (; b.hi; )
1206
1212
  g[k++] = b.lo & 127 | 128, b.lo = (b.lo >>> 7 | b.hi << 25) >>> 0, b.hi >>>= 7;
1207
1213
  for (; b.lo > 127; )
@@ -1210,21 +1216,21 @@ function requireWriter() {
1210
1216
  }
1211
1217
  e.prototype.uint64 = function(g) {
1212
1218
  var k = a.from(g);
1213
- return this._push(y, k.length(), k);
1219
+ return this._push(p, k.length(), k);
1214
1220
  }, e.prototype.int64 = e.prototype.uint64, e.prototype.sint64 = function(g) {
1215
1221
  var k = a.from(g).zzEncode();
1216
- return this._push(y, k.length(), k);
1222
+ return this._push(p, k.length(), k);
1217
1223
  }, e.prototype.bool = function(g) {
1218
1224
  return this._push(l, 1, g ? 1 : 0);
1219
1225
  };
1220
- function p(b, g, k) {
1226
+ function f(b, g, k) {
1221
1227
  g[k] = b & 255, g[k + 1] = b >>> 8 & 255, g[k + 2] = b >>> 16 & 255, g[k + 3] = b >>> 24;
1222
1228
  }
1223
1229
  e.prototype.fixed32 = function(g) {
1224
- return this._push(p, 4, g >>> 0);
1230
+ return this._push(f, 4, g >>> 0);
1225
1231
  }, e.prototype.sfixed32 = e.prototype.fixed32, e.prototype.fixed64 = function(g) {
1226
1232
  var k = a.from(g);
1227
- return this._push(p, 4, k.lo)._push(p, 4, k.hi);
1233
+ return this._push(f, 4, k.lo)._push(f, 4, k.hi);
1228
1234
  }, e.prototype.sfixed64 = e.prototype.fixed64, e.prototype.float = function(g) {
1229
1235
  return this._push(h.float.writeFloatLE, 4, g);
1230
1236
  }, e.prototype.double = function(g) {
@@ -1233,8 +1239,8 @@ function requireWriter() {
1233
1239
  var w = h.Array.prototype.set ? function(g, k, _) {
1234
1240
  k.set(g, _);
1235
1241
  } : function(g, k, _) {
1236
- for (var R = 0; R < g.length; ++R)
1237
- k[_ + R] = g[R];
1242
+ for (var B = 0; B < g.length; ++B)
1243
+ k[_ + B] = g[B];
1238
1244
  };
1239
1245
  return e.prototype.bytes = function(g) {
1240
1246
  var k = g.length >>> 0;
@@ -1315,10 +1321,10 @@ function requireReader() {
1315
1321
  return new r(d);
1316
1322
  throw Error("illegal buffer");
1317
1323
  }, t = function() {
1318
- return h.Buffer ? function(y) {
1324
+ return h.Buffer ? function(p) {
1319
1325
  return (r.create = function(w) {
1320
1326
  return h.Buffer.isBuffer(w) ? new o(w) : i(w);
1321
- })(y);
1327
+ })(p);
1322
1328
  } : i;
1323
1329
  };
1324
1330
  r.create = t(), r.prototype._slice = h.Array.prototype.subarray || /* istanbul ignore next */
@@ -1398,16 +1404,16 @@ function requireReader() {
1398
1404
  var d = h.float.readDoubleLE(this.buf, this.pos);
1399
1405
  return this.pos += 8, d;
1400
1406
  }, r.prototype.bytes = function() {
1401
- var d = this.uint32(), y = this.pos, p = this.pos + d;
1402
- if (p > this.len)
1407
+ var d = this.uint32(), p = this.pos, f = this.pos + d;
1408
+ if (f > this.len)
1403
1409
  throw n(this, d);
1404
1410
  if (this.pos += d, Array.isArray(this.buf))
1405
- return this.buf.slice(y, p);
1406
- if (y === p) {
1411
+ return this.buf.slice(p, f);
1412
+ if (p === f) {
1407
1413
  var w = h.Buffer;
1408
1414
  return w ? w.alloc(0) : new this.buf.constructor(0);
1409
1415
  }
1410
- return this._slice.call(this.buf, y, p);
1416
+ return this._slice.call(this.buf, p, f);
1411
1417
  }, r.prototype.string = function() {
1412
1418
  var d = this.bytes();
1413
1419
  return u.read(d, 0, d.length);
@@ -1712,11 +1718,11 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1712
1718
  return this.encode(t, e).ldelim();
1713
1719
  }, n.decode = function(t, e, s) {
1714
1720
  t instanceof $Reader || (t = $Reader.create(t));
1715
- let l = e === void 0 ? t.len : t.pos + e, c = new $root.com.quick.voice.proto.LayoutData(), d, y;
1721
+ let l = e === void 0 ? t.len : t.pos + e, c = new $root.com.quick.voice.proto.LayoutData(), d, p;
1716
1722
  for (; t.pos < l; ) {
1717
- let p = t.uint32();
1718
- if (p === s) break;
1719
- switch (p >>> 3) {
1723
+ let f = t.uint32();
1724
+ if (f === s) break;
1725
+ switch (f >>> 3) {
1720
1726
  case 1: {
1721
1727
  c.roomId = t.string();
1722
1728
  break;
@@ -1728,21 +1734,21 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1728
1734
  case 3: {
1729
1735
  c.userMap === $util.emptyObject && (c.userMap = {});
1730
1736
  let w = t.uint32() + t.pos;
1731
- for (d = "", y = null; t.pos < w; ) {
1737
+ for (d = "", p = null; t.pos < w; ) {
1732
1738
  let b = t.uint32();
1733
1739
  switch (b >>> 3) {
1734
1740
  case 1:
1735
1741
  d = t.string();
1736
1742
  break;
1737
1743
  case 2:
1738
- y = $root.com.quick.voice.proto.UserInfo.decode(t, t.uint32());
1744
+ p = $root.com.quick.voice.proto.UserInfo.decode(t, t.uint32());
1739
1745
  break;
1740
1746
  default:
1741
1747
  t.skipType(b & 7);
1742
1748
  break;
1743
1749
  }
1744
1750
  }
1745
- c.userMap[d] = y;
1751
+ c.userMap[d] = p;
1746
1752
  break;
1747
1753
  }
1748
1754
  case 4: {
@@ -1750,7 +1756,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
1750
1756
  break;
1751
1757
  }
1752
1758
  default:
1753
- t.skipType(p & 7);
1759
+ t.skipType(f & 7);
1754
1760
  break;
1755
1761
  }
1756
1762
  }
@@ -2220,11 +2226,11 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2220
2226
  return this.encode(t, e).ldelim();
2221
2227
  }, n.decode = function(t, e, s) {
2222
2228
  t instanceof $Reader || (t = $Reader.create(t));
2223
- let l = e === void 0 ? t.len : t.pos + e, c = new $root.com.quick.voice.proto.CustomInfo(), d, y;
2229
+ let l = e === void 0 ? t.len : t.pos + e, c = new $root.com.quick.voice.proto.CustomInfo(), d, p;
2224
2230
  for (; t.pos < l; ) {
2225
- let p = t.uint32();
2226
- if (p === s) break;
2227
- switch (p >>> 3) {
2231
+ let f = t.uint32();
2232
+ if (f === s) break;
2233
+ switch (f >>> 3) {
2228
2234
  case 1: {
2229
2235
  c.roomId = t.string();
2230
2236
  break;
@@ -2232,21 +2238,21 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2232
2238
  case 2: {
2233
2239
  c.customKeyMap === $util.emptyObject && (c.customKeyMap = {});
2234
2240
  let w = t.uint32() + t.pos;
2235
- for (d = "", y = ""; t.pos < w; ) {
2241
+ for (d = "", p = ""; t.pos < w; ) {
2236
2242
  let b = t.uint32();
2237
2243
  switch (b >>> 3) {
2238
2244
  case 1:
2239
2245
  d = t.string();
2240
2246
  break;
2241
2247
  case 2:
2242
- y = t.string();
2248
+ p = t.string();
2243
2249
  break;
2244
2250
  default:
2245
2251
  t.skipType(b & 7);
2246
2252
  break;
2247
2253
  }
2248
2254
  }
2249
- c.customKeyMap[d] = y;
2255
+ c.customKeyMap[d] = p;
2250
2256
  break;
2251
2257
  }
2252
2258
  case 3: {
@@ -2254,7 +2260,7 @@ const $Reader = minimalExports.Reader, $Writer = minimalExports.Writer, $util =
2254
2260
  break;
2255
2261
  }
2256
2262
  default:
2257
- t.skipType(p & 7);
2263
+ t.skipType(f & 7);
2258
2264
  break;
2259
2265
  }
2260
2266
  }
@@ -2346,35 +2352,35 @@ class RoomUser {
2346
2352
  const r = this.getUpdateTimeKey();
2347
2353
  this.mc_audio && (this.mc_audio.remove = !0), this.mc_video && (this.mc_video.remove = !0), this.ss_audio && (this.ss_audio.remove = !0), this.ss_video && (this.ss_video.remove = !0);
2348
2354
  for (const c of u) {
2349
- const { type: d = 0, isEnable: y = !1, isMute: p = !1, updateTime: w, volume: b = 0 } = c;
2355
+ const { type: d = 0, isEnable: p = !1, isMute: f = !1, updateTime: w, volume: b = 0 } = c;
2350
2356
  switch (d) {
2351
2357
  case 0:
2352
2358
  {
2353
2359
  if (this.mc_audio || (this.mc_audio = createAudioInfo()), this.mc_audio.remove = !1, this.mc_audio.updateTime === w) break;
2354
- this.mc_audio.isEnable = !!y, this.mc_audio.isMute = !!p, this.mc_audio.updateTime = Number(w), this.mc_audio.volume = Number(b);
2360
+ this.mc_audio.isEnable = !!p, this.mc_audio.isMute = !!f, this.mc_audio.updateTime = Number(w), this.mc_audio.volume = Number(b);
2355
2361
  }
2356
2362
  break;
2357
2363
  case 1:
2358
2364
  {
2359
2365
  if (this.ss_audio || (this.ss_audio = createAudioInfo()), this.ss_audio.remove = !1, this.ss_audio.updateTime === w) break;
2360
- this.ss_audio.isEnable = !!y, this.ss_audio.isMute = !!p, this.ss_audio.updateTime = Number(w), this.ss_audio.volume = Number(b);
2366
+ this.ss_audio.isEnable = !!p, this.ss_audio.isMute = !!f, this.ss_audio.updateTime = Number(w), this.ss_audio.volume = Number(b);
2361
2367
  }
2362
2368
  break;
2363
2369
  }
2364
2370
  }
2365
2371
  for (const c of n) {
2366
- const { type: d = 0, isEnable: y, isMute: p, updateTime: w, width: b, height: g, x: k, y: _ } = c;
2372
+ const { type: d = 0, isEnable: p, isMute: f, updateTime: w, width: b, height: g, x: k, y: _ } = c;
2367
2373
  switch (d) {
2368
2374
  case 0:
2369
2375
  {
2370
2376
  if (this.mc_video || (this.mc_video = createVideoInfo()), this.mc_video.remove = !1, this.mc_video.updateTime === w) break;
2371
- this.mc_video.isEnable = !!y, this.mc_video.isMute = !!p, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = k || 0, this.mc_video.sy = _ || 0, this.mc_video.sw = b || 0, this.mc_video.sh = g || 0;
2377
+ this.mc_video.isEnable = !!p, this.mc_video.isMute = !!f, this.mc_video.updateTime = Number(w) || 0, this.mc_video.sx = k || 0, this.mc_video.sy = _ || 0, this.mc_video.sw = b || 0, this.mc_video.sh = g || 0;
2372
2378
  }
2373
2379
  break;
2374
2380
  case 1:
2375
2381
  {
2376
2382
  if (this.ss_video || (this.ss_video = createVideoInfo()), this.ss_video.remove = !1, this.ss_video.updateTime === w) break;
2377
- this.ss_video.isEnable = !!y, this.ss_video.isMute = !!p, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = k || 0, this.ss_video.sy = _ || 0, this.ss_video.sw = b || 0, this.ss_video.sh = g || 0;
2383
+ this.ss_video.isEnable = !!p, this.ss_video.isMute = !!f, this.ss_video.updateTime = Number(w) || 0, this.ss_video.sx = k || 0, this.ss_video.sy = _ || 0, this.ss_video.sw = b || 0, this.ss_video.sh = g || 0;
2378
2384
  }
2379
2385
  break;
2380
2386
  }
@@ -2401,7 +2407,7 @@ const parseSEI = (h) => {
2401
2407
  if (u = u + n, o = o + 1, n !== 255) break;
2402
2408
  }
2403
2409
  if (a === 5) {
2404
- const n = h.slice(o, o + 16), i = Array.from(n, (p) => p.toString(16).padStart(2, "0")).join("");
2410
+ const n = h.slice(o, o + 16), i = Array.from(n, (f) => f.toString(16).padStart(2, "0")).join("");
2405
2411
  o = o + 16;
2406
2412
  const t = u - 16, e = h.slice(o, o + t), s = com.quick.voice.proto.SeiData.decode(e), { event: l = 0 } = s, c = s.data;
2407
2413
  let d;
@@ -2417,9 +2423,12 @@ const parseSEI = (h) => {
2417
2423
  }
2418
2424
  };
2419
2425
  class QuickVoPlayer {
2420
- constructor() {
2426
+ constructor(o = {}) {
2427
+ m(this, "option", {
2428
+ debug: !1
2429
+ });
2421
2430
  m(this, "displayMode", "original");
2422
- m(this, "prPlayer", new et());
2431
+ m(this, "prPlayer");
2423
2432
  m(this, "dom");
2424
2433
  m(this, "room", {
2425
2434
  roomId: "",
@@ -2463,15 +2472,15 @@ class QuickVoPlayer {
2463
2472
  const r = new RoomUser();
2464
2473
  if (this.usersMap.set(o, r), r.init(a), r) {
2465
2474
  if (r.mc_video) {
2466
- const { sx: i, sy: t, sw: e, sh: s } = r.mc_video, l = `${r.userId}_mc_video`, { worker: c, stream: d, destroy: y } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2475
+ const { sx: i, sy: t, sw: e, sh: s } = r.mc_video, l = `${r.userId}_mc_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2467
2476
  r.mc_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.mc_video.stream = d, r.mc_video.destroy = () => {
2468
- y(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2477
+ p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2469
2478
  };
2470
2479
  }
2471
2480
  if (r.ss_video) {
2472
- const { sx: i, sy: t, sw: e, sh: s } = r.ss_video, l = `${r.userId}_ss_video`, { worker: c, stream: d, destroy: y } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2481
+ const { sx: i, sy: t, sw: e, sh: s } = r.ss_video, l = `${r.userId}_ss_video`, { worker: c, stream: d, destroy: p } = this.prPlayer.cut.create(l, { sx: i, sy: t, sw: e, sh: s });
2473
2482
  r.ss_video.worker = c, this.displayMode === "original" && c.setPause(!0), r.ss_video.stream = d, r.ss_video.destroy = () => {
2474
- y(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2483
+ p(), this.prPlayer.cut.remove(l), this.usersMap.delete(r.userId);
2475
2484
  };
2476
2485
  }
2477
2486
  }
@@ -2502,7 +2511,7 @@ class QuickVoPlayer {
2502
2511
  }
2503
2512
  const s = this.getAllUseUpdateKey();
2504
2513
  if (t !== s && this.on.users) {
2505
- const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: b, updateTime: g }) => ({ userId: d, mc_audio: y, mc_video: p, ss_audio: w, ss_video: b, updateTime: g }));
2514
+ const l = [...this.usersMap.values()], c = Array.from(l, ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: g }) => ({ userId: d, mc_audio: p, mc_video: f, ss_audio: w, ss_video: b, updateTime: g }));
2506
2515
  this.on.users(c);
2507
2516
  }
2508
2517
  }
@@ -2539,7 +2548,8 @@ class QuickVoPlayer {
2539
2548
  break;
2540
2549
  }
2541
2550
  });
2542
- this.prPlayer.on.demuxer.sei = this.onSEI, this.prPlayer.on.demuxer.chunk = (o) => {
2551
+ const { debug: a = !1 } = o;
2552
+ this.option.debug = a, this.prPlayer = new et({ debug: a }), this.prPlayer.on.demuxer.sei = this.onSEI, this.prPlayer.on.demuxer.chunk = (u) => {
2543
2553
  };
2544
2554
  }
2545
2555
  }