polotno-node 2.15.17 → 2.15.19
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/assets/html2canvas-DyNBkGVl.js +5 -0
- package/dist/assets/index-zOfyRUBK.js +344 -0
- package/dist/assets/{index.es-DGqSPkoI.js → index.es-Ci1IK4T_.js} +1 -1
- package/dist/assets/{jspdf.es.min-DQ47o5Bu.js → jspdf.es.min-kwORMdcW.js} +4 -4
- package/dist/assets/lib-BagY_77q.js +65 -0
- package/dist/assets/purify.es-D7J7JQWp.js +3 -0
- package/dist/index.html +1 -4
- package/package.json +11 -10
- package/dist/assets/chunk-DECur_0Z.js +0 -1
- package/dist/assets/html2canvas-CFzV-G5G.js +0 -5
- package/dist/assets/id3-D55z-fRR.js +0 -15
- package/dist/assets/index-QaF0YGOe.js +0 -330
- package/dist/assets/lib-DjVS41Qk.js +0 -65
- package/dist/assets/preload-helper-xBbMyY7u.js +0 -1
- package/dist/assets/purify.es-CuTrUsFy.js +0 -2
- /package/dist/assets/{typeof-B5P0Path.js → typeof-DmQ5kzpc.js} +0 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,C as r,D as i,E as a,F as o,G as s,H as c,I as l,J as u,K as d,L as f,M as p,N as m,O as h,P as g,Q as _,R as v,S as y,T as b,U as ee,V as te,W as ne,X as x,Y as S,Z as re,_ as ie,a as ae,at as oe,b as se,c as ce,ct as C,d as le,et as ue,f as de,g as fe,h as pe,i as me,it as he,j as ge,k as _e,l as ve,lt as ye,m as be,n as xe,nt as Se,o as w,ot as Ce,p as T,q as we,r as Te,rt as E,s as Ee,st as D,tt as O,u as De,v as Oe,w as ke,x as Ae,y as je,z as Me}from"./index-zOfyRUBK.js";var Ne=class{constructor(e){this.mutex=new ee,this.firstMediaStreamTimestamp=null,this.trackTimestampInfo=new WeakMap,this.output=e}onTrackClose(e){}validateAndNormalizeTimestamp(e,t,n){t+=e.source._timestampOffset;let r=this.trackTimestampInfo.get(e);if(!r){if(!n)throw Error(`First packet must be a key packet.`);r={maxTimestamp:t,maxTimestampBeforeLastKeyPacket:t},this.trackTimestampInfo.set(e,r)}if(t<0)throw Error(`Timestamps must be non-negative (got ${t}s).`);if(n&&(r.maxTimestampBeforeLastKeyPacket=r.maxTimestamp),t<r.maxTimestampBeforeLastKeyPacket)throw Error(`Timestamps cannot be smaller than the largest timestamp of the previous GOP (a GOP begins with a key packet and ends right before the next key packet). Got ${t}s, but largest timestamp is ${r.maxTimestampBeforeLastKeyPacket}s.`);return r.maxTimestamp=Math.max(r.maxTimestamp,t),t}},Pe=/<(?:(\d{2}):)?(\d{2}):(\d{2}).(\d{3})>/g,Fe=e=>{let t=Math.floor(e/(3600*1e3)),n=Math.floor(e%(3600*1e3)/(60*1e3)),r=Math.floor(e%(60*1e3)/1e3),i=e%1e3;return t.toString().padStart(2,`0`)+`:`+n.toString().padStart(2,`0`)+`:`+r.toString().padStart(2,`0`)+`.`+i.toString().padStart(3,`0`)},Ie=class{constructor(e){this.writer=e,this.helper=new Uint8Array(8),this.helperView=new DataView(this.helper.buffer),this.offsets=new WeakMap}writeU32(e){this.helperView.setUint32(0,e,!1),this.writer.write(this.helper.subarray(0,4))}writeU64(e){this.helperView.setUint32(0,Math.floor(e/2**32),!1),this.helperView.setUint32(4,e,!1),this.writer.write(this.helper.subarray(0,8))}writeAscii(e){for(let t=0;t<e.length;t++)this.helperView.setUint8(t%8,e.charCodeAt(t)),t%8==7&&this.writer.write(this.helper);e.length%8!=0&&this.writer.write(this.helper.subarray(0,e.length%8))}writeBox(e){if(this.offsets.set(e,this.writer.getPos()),e.contents&&!e.children)this.writeBoxHeader(e,e.size??e.contents.byteLength+8),this.writer.write(e.contents);else{let t=this.writer.getPos();if(this.writeBoxHeader(e,0),e.contents&&this.writer.write(e.contents),e.children)for(let t of e.children)t&&this.writeBox(t);let n=this.writer.getPos(),r=e.size??n-t;this.writer.seek(t),this.writeBoxHeader(e,r),this.writer.seek(n)}}writeBoxHeader(e,t){this.writeU32(e.largeSize?1:t),this.writeAscii(e.type),e.largeSize&&this.writeU64(t)}measureBoxHeader(e){return 8+(e.largeSize?8:0)}patchBox(e){let t=this.offsets.get(e);u(t!==void 0);let n=this.writer.getPos();this.writer.seek(t),this.writeBox(e),this.writer.seek(n)}measureBox(e){if(e.contents&&!e.children)return this.measureBoxHeader(e)+e.contents.byteLength;{let t=this.measureBoxHeader(e);if(e.contents&&(t+=e.contents.byteLength),e.children)for(let n of e.children)n&&(t+=this.measureBox(n));return t}}},k=new Uint8Array(8),A=new DataView(k.buffer),j=e=>[(e%256+256)%256],M=e=>(A.setUint16(0,e,!1),[k[0],k[1]]),Le=e=>(A.setInt16(0,e,!1),[k[0],k[1]]),Re=e=>(A.setUint32(0,e,!1),[k[1],k[2],k[3]]),N=e=>(A.setUint32(0,e,!1),[k[0],k[1],k[2],k[3]]),P=e=>(A.setInt32(0,e,!1),[k[0],k[1],k[2],k[3]]),F=e=>(A.setUint32(0,Math.floor(e/2**32),!1),A.setUint32(4,e,!1),[k[0],k[1],k[2],k[3],k[4],k[5],k[6],k[7]]),ze=e=>(A.setInt16(0,2**8*e,!1),[k[0],k[1]]),I=e=>(A.setInt32(0,2**16*e,!1),[k[0],k[1],k[2],k[3]]),L=e=>(A.setInt32(0,2**30*e,!1),[k[0],k[1],k[2],k[3]]),R=(e,t)=>{let n=[],r=e;do{let e=r&127;r>>=7,n.length>0&&(e|=128),n.push(e),t!==void 0&&t--}while(r>0||t);return n.reverse()},z=(e,t=!1)=>{let n=Array(e.length).fill(null).map((t,n)=>e.charCodeAt(n));return t&&n.push(0),n},B=e=>{let t=null;for(let n of e)(!t||n.timestamp>t.timestamp)&&(t=n);return t},Be=e=>{let t=Math.PI/180*e,n=Math.round(Math.cos(t)),r=Math.round(Math.sin(t));return[n,r,0,-r,n,0,0,0,1]},Ve=Be(0),He=e=>[I(e[0]),I(e[1]),L(e[2]),I(e[3]),I(e[4]),L(e[5]),I(e[6]),I(e[7]),L(e[8])],V=(e,t,n)=>({type:e,contents:t&&new Uint8Array(t.flat(10)),children:n}),H=(e,t,n,r,i)=>V(e,[j(t),Re(n),r??[]],i),Ue=e=>e.isQuickTime?V(`ftyp`,[z(`qt `),N(512),z(`qt `)]):e.fragmented?V(`ftyp`,[z(`iso5`),N(512),z(`iso5`),z(`iso6`),z(`mp41`)]):V(`ftyp`,[z(`isom`),N(512),z(`isom`),e.holdsAvc?z(`avc1`):[],z(`mp41`)]),U=e=>({type:`mdat`,largeSize:e}),We=e=>({type:`free`,size:e}),W=e=>V(`moov`,void 0,[Ge(e.creationTime,e.trackDatas),...e.trackDatas.map(t=>Ke(t,e.creationTime)),e.isFragmented?Dt(e.trackDatas):null,Ht(e)]),Ge=(e,t)=>{let n=Y(Math.max(0,...t.filter(e=>e.samples.length>0).map(e=>{let t=B(e.samples);return t.timestamp+t.duration})),cn),r=Math.max(0,...t.map(e=>e.track.id))+1,i=!O(e)||!O(n),a=i?F:N;return H(`mvhd`,+i,0,[a(e),a(e),N(cn),a(n),I(1),ze(1),Array(10).fill(0),He(Ve),Array(24).fill(0),N(r)])},Ke=(e,t)=>{let n=un(e);return V(`trak`,void 0,[qe(e,t),Je(e,t),n.name===void 0?null:V(`udta`,void 0,[V(`name`,[...D.encode(n.name)])])])},qe=(e,t)=>{let n=B(e.samples),r=Y(n?n.timestamp+n.duration:0,cn),i=!O(t)||!O(r),a=i?F:N,o;if(e.type===`video`){let t=e.track.metadata.rotation;o=Be(t??0)}else o=Ve;let s=2;return e.track.metadata.disposition?.default!==!1&&(s|=1),H(`tkhd`,+i,s,[a(t),a(t),N(e.track.id),N(0),a(r),Array(8).fill(0),M(0),M(e.track.id),ze(+(e.type===`audio`)),M(0),He(o),I(e.type===`video`?e.info.width:0),I(e.type===`video`?e.info.height:0)])},Je=(e,t)=>V(`mdia`,void 0,[Ye(e,t),Qe(!0,Xe[e.type],Ze[e.type]),$e(e)]),Ye=(e,t)=>{let n=B(e.samples),r=Y(n?n.timestamp+n.duration:0,e.timescale),i=!O(t)||!O(r),a=i?F:N;return H(`mdhd`,+i,0,[a(t),a(t),N(e.timescale),a(r),M(en(e.track.metadata.languageCode??`und`)),M(0)])},Xe={video:`vide`,audio:`soun`,subtitle:`text`},Ze={video:`MediabunnyVideoHandler`,audio:`MediabunnySoundHandler`,subtitle:`MediabunnyTextHandler`},Qe=(e,t,n,r=`\0\0\0\0`)=>H(`hdlr`,0,0,[e?z(`mhlr`):N(0),z(t),z(r),N(0),N(0),z(n,!0)]),$e=e=>V(`minf`,void 0,[et[e.type](),tt(),it(e)]),et={video:()=>H(`vmhd`,0,1,[M(0),M(0),M(0),M(0)]),audio:()=>H(`smhd`,0,0,[M(0),M(0)]),subtitle:()=>H(`nmhd`,0,0)},tt=()=>V(`dinf`,void 0,[nt()]),nt=()=>H(`dref`,0,0,[N(1)],[rt()]),rt=()=>H(`url `,0,1),it=e=>{let t=e.compositionTimeOffsetTable.length>1||e.compositionTimeOffsetTable.some(e=>e.sampleCompositionTimeOffset!==0);return V(`stbl`,void 0,[at(e),bt(e),t?Tt(e):null,t?Et(e):null,St(e),Ct(e),wt(e),xt(e)])},at=e=>{let t;if(e.type===`video`)t=ot(Jt(e.track.source._codec,e.info.decoderConfig.codec),e);else if(e.type===`audio`){let n=Xt(e.track.source._codec,e.muxer.isQuickTime);u(n),t=ft(n,e)}else e.type===`subtitle`&&(t=vt(Qt[e.track.source._codec],e));return u(t),H(`stsd`,0,0,[N(1)],[t])},ot=(e,t)=>V(e,[[,,,,,,].fill(0),M(1),M(0),M(0),Array(12).fill(0),M(t.info.width),M(t.info.height),N(4718592),N(4718592),N(0),M(1),Array(32).fill(0),M(24),Le(65535)],[Yt[t.track.source._codec](t),re(t.info.decoderConfig.colorSpace)?st(t):null]),st=e=>V(`colr`,[z(`nclx`),M(ne[e.info.decoderConfig.colorSpace.primaries]),M(we[e.info.decoderConfig.colorSpace.transfer]),M(d[e.info.decoderConfig.colorSpace.matrix]),j(!!e.info.decoderConfig.colorSpace.fullRange<<7)]),ct=e=>e.info.decoderConfig&&V(`avcC`,[...C(e.info.decoderConfig.description)]),lt=e=>e.info.decoderConfig&&V(`hvcC`,[...C(e.info.decoderConfig.description)]),ut=e=>{if(!e.info.decoderConfig)return null;let t=e.info.decoderConfig,n=t.codec.split(`.`),r=Number(n[1]),i=Number(n[2]),a=Number(n[3]),o=n[4]?Number(n[4]):1,s=n[8]?Number(n[8]):Number(t.colorSpace?.fullRange??0),c=(a<<4)+(o<<1)+s,l=n[5]?Number(n[5]):t.colorSpace?.primaries?ne[t.colorSpace.primaries]:2,u=n[6]?Number(n[6]):t.colorSpace?.transfer?we[t.colorSpace.transfer]:2,f=n[7]?Number(n[7]):t.colorSpace?.matrix?d[t.colorSpace.matrix]:2;return H(`vpcC`,1,0,[j(r),j(i),j(c),j(l),j(u),j(f),M(0)])},dt=e=>V(`av1C`,ge(e.info.decoderConfig.codec)),ft=(e,t)=>{let n=0,r,i=16;if(b.includes(t.track.source._codec)){let e=t.track.source._codec,{sampleSize:r}=l(e);i=8*r,i>16&&(n=1)}return r=n===0?[[,,,,,,].fill(0),M(1),M(n),M(0),N(0),M(t.info.numberOfChannels),M(i),M(0),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0)]:[[,,,,,,].fill(0),M(1),M(n),M(0),N(0),M(t.info.numberOfChannels),M(Math.min(i,16)),M(0),M(0),M(t.info.sampleRate<2**16?t.info.sampleRate:0),M(0),N(1),N(i/8),N(t.info.numberOfChannels*i/8),N(2)],V(e,r,[Zt(t.track.source._codec,t.muxer.isQuickTime)?.(t)??null])},pt=e=>{let t;switch(e.track.source._codec){case`aac`:t=64;break;case`mp3`:t=107;break;case`vorbis`:t=221;break;default:throw Error(`Unhandled audio codec: ${e.track.source._codec}`)}let n=[...j(t),...j(21),...Re(0),...N(0),...N(0)];if(e.info.decoderConfig.description){let t=C(e.info.decoderConfig.description);n=[...n,...j(5),...R(t.byteLength),...t]}return n=[...M(1),...j(0),...j(4),...R(n.length),...n,...j(6),...j(1),...j(2)],n=[...j(3),...R(n.length),...n],H(`esds`,0,0,n)},G=e=>V(`wave`,void 0,[mt(e),ht(e),V(`\0\0\0\0`)]),mt=e=>V(`frma`,[z(Xt(e.track.source._codec,e.muxer.isQuickTime))]),ht=e=>{let{littleEndian:t}=l(e.track.source._codec);return V(`enda`,[M(+t)])},gt=e=>{let t=e.info.numberOfChannels,n=3840,r=e.info.sampleRate,i=0,a=0,o=new Uint8Array,s=e.info.decoderConfig?.description;if(s){u(s.byteLength>=18);let e=se(C(s));t=e.outputChannelCount,n=e.preSkip,r=e.inputSampleRate,i=e.outputGain,a=e.channelMappingFamily,e.channelMappingTable&&(o=e.channelMappingTable)}return V(`dOps`,[j(0),j(t),M(n),N(r),Le(i),j(a),...o])},_t=e=>{let t=e.info.decoderConfig?.description;return u(t),H(`dfLa`,0,0,[...C(t).subarray(4)])},K=e=>{let{littleEndian:t,sampleSize:n}=l(e.track.source._codec);return H(`pcmC`,0,0,[j(+t),j(8*n)])},vt=(e,t)=>V(e,[[,,,,,,].fill(0),M(1)],[$t[t.track.source._codec](t)]),yt=e=>V(`vttC`,[...D.encode(e.info.config.description)]),bt=e=>H(`stts`,0,0,[N(e.timeToSampleTable.length),e.timeToSampleTable.map(e=>[N(e.sampleCount),N(e.sampleDelta)])]),xt=e=>{if(e.samples.every(e=>e.type===`key`))return null;let t=[...e.samples.entries()].filter(([,e])=>e.type===`key`);return H(`stss`,0,0,[N(t.length),t.map(([e])=>N(e+1))])},St=e=>H(`stsc`,0,0,[N(e.compactlyCodedChunkTable.length),e.compactlyCodedChunkTable.map(e=>[N(e.firstChunk),N(e.samplesPerChunk),N(1)])]),Ct=e=>{if(e.type===`audio`&&e.info.requiresPcmTransformation){let{sampleSize:t}=l(e.track.source._codec);return H(`stsz`,0,0,[N(t*e.info.numberOfChannels),N(e.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0))])}return H(`stsz`,0,0,[N(0),N(e.samples.length),e.samples.map(e=>N(e.size))])},wt=e=>e.finalizedChunks.length>0&&E(e.finalizedChunks).offset>=2**32?H(`co64`,0,0,[N(e.finalizedChunks.length),e.finalizedChunks.map(e=>F(e.offset))]):H(`stco`,0,0,[N(e.finalizedChunks.length),e.finalizedChunks.map(e=>N(e.offset))]),Tt=e=>H(`ctts`,1,0,[N(e.compositionTimeOffsetTable.length),e.compositionTimeOffsetTable.map(e=>[N(e.sampleCount),P(e.sampleCompositionTimeOffset)])]),Et=e=>{let t=1/0,n=-1/0,r=1/0,i=-1/0;u(e.compositionTimeOffsetTable.length>0),u(e.samples.length>0);for(let r=0;r<e.compositionTimeOffsetTable.length;r++){let i=e.compositionTimeOffsetTable[r];t=Math.min(t,i.sampleCompositionTimeOffset),n=Math.max(n,i.sampleCompositionTimeOffset)}for(let t=0;t<e.samples.length;t++){let n=e.samples[t];r=Math.min(r,Y(n.timestamp,e.timescale)),i=Math.max(i,Y(n.timestamp+n.duration,e.timescale))}let a=Math.max(-t,0);return i>=2**31?null:H(`cslg`,0,0,[P(a),P(t),P(n),P(r),P(i)])},Dt=e=>V(`mvex`,void 0,e.map(Ot)),Ot=e=>H(`trex`,0,0,[N(e.track.id),N(1),N(0),N(0),N(0)]),kt=(e,t)=>V(`moof`,void 0,[At(e),...t.map(Mt)]),At=e=>H(`mfhd`,0,0,[N(e)]),jt=e=>{let t=0,n=0,r=e.type===`delta`;return n|=+r,r?t|=1:t|=2,t<<24|n<<16|0},Mt=e=>V(`traf`,void 0,[Nt(e),Pt(e),Ft(e)]),Nt=e=>{u(e.currentChunk);let t=0;t|=8,t|=16,t|=32,t|=131072;let n=e.currentChunk.samples[1]??e.currentChunk.samples[0],r={duration:n.timescaleUnitsToNextSample,size:n.size,flags:jt(n)};return H(`tfhd`,0,t,[N(e.track.id),N(r.duration),N(r.size),N(r.flags)])},Pt=e=>(u(e.currentChunk),H(`tfdt`,1,0,[F(Y(e.currentChunk.startTimestamp,e.timescale))])),Ft=e=>{u(e.currentChunk);let t=e.currentChunk.samples.map(e=>e.timescaleUnitsToNextSample),n=e.currentChunk.samples.map(e=>e.size),r=e.currentChunk.samples.map(jt),i=e.currentChunk.samples.map(t=>Y(t.timestamp-t.decodeTimestamp,e.timescale)),a=new Set(t),o=new Set(n),s=new Set(r),c=new Set(i),l=s.size===2&&r[0]!==r[1],d=a.size>1,f=o.size>1,p=!l&&s.size>1,m=c.size>1||[...c].some(e=>e!==0),h=0;return h|=1,h|=4*l,h|=256*d,h|=512*f,h|=1024*p,h|=2048*m,H(`trun`,1,h,[N(e.currentChunk.samples.length),N(e.currentChunk.offset-e.currentChunk.moofOffset||0),l?N(r[0]):[],e.currentChunk.samples.map((e,a)=>[d?N(t[a]):[],f?N(n[a]):[],p?N(r[a]):[],m?P(i[a]):[]])])},It=e=>V(`mfra`,void 0,[...e.map(Lt),Rt()]),Lt=(e,t)=>H(`tfra`,1,0,[N(e.track.id),N(63),N(e.finalizedChunks.length),e.finalizedChunks.map(n=>[F(Y(n.samples[0].timestamp,e.timescale)),F(n.moofOffset),N(t+1),N(1),N(1)])]),Rt=()=>H(`mfro`,0,0,[N(0)]),zt=()=>V(`vtte`),Bt=(e,t,n,r,i)=>V(`vttc`,void 0,[i===null?null:V(`vsid`,[P(i)]),n===null?null:V(`iden`,[...D.encode(n)]),t===null?null:V(`ctim`,[...D.encode(Fe(t))]),r===null?null:V(`sttg`,[...D.encode(r)]),V(`payl`,[...D.encode(e)])]),Vt=e=>V(`vtta`,[...D.encode(e)]),Ht=e=>{let t=[],n=e.format._options.metadataFormat??`auto`,r=e.output._metadataTags;if(n===`mdir`||n===`auto`&&!e.isQuickTime){let e=Kt(r);e&&t.push(e)}else if(n===`mdta`){let e=qt(r);e&&t.push(e)}else (n===`udta`||n===`auto`&&e.isQuickTime)&&Ut(t,e.output._metadataTags);return t.length===0?null:V(`udta`,void 0,t)},Ut=(e,t)=>{for(let{key:n,value:r}of Se(t))switch(n){case`title`:e.push(q(`©nam`,r));break;case`description`:e.push(q(`©des`,r));break;case`artist`:e.push(q(`©ART`,r));break;case`album`:e.push(q(`©alb`,r));break;case`albumArtist`:e.push(q(`albr`,r));break;case`genre`:e.push(q(`©gen`,r));break;case`date`:e.push(q(`©day`,r.toISOString().slice(0,10)));break;case`comment`:e.push(q(`©cmt`,r));break;case`lyrics`:e.push(q(`©lyr`,r));break;case`raw`:break;case`discNumber`:case`discsTotal`:case`trackNumber`:case`tracksTotal`:case`images`:break;default:S(n)}if(t.raw)for(let n in t.raw){let r=t.raw[n];r==null||n.length!==4||e.some(e=>e.type===n)||(typeof r==`string`?e.push(q(n,r)):r instanceof Uint8Array&&e.push(V(n,Array.from(r))))}},q=(e,t)=>{let n=D.encode(t);return V(e,[M(n.length),M(en(`und`)),Array.from(n)])},Wt={"image/jpeg":13,"image/png":14,"image/bmp":27},Gt=(e,t)=>{let r=[];for(let{key:n,value:i}of Se(e))switch(n){case`title`:r.push({key:t?`title`:`©nam`,value:J(i)});break;case`description`:r.push({key:t?`description`:`©des`,value:J(i)});break;case`artist`:r.push({key:t?`artist`:`©ART`,value:J(i)});break;case`album`:r.push({key:t?`album`:`©alb`,value:J(i)});break;case`albumArtist`:r.push({key:t?`album_artist`:`aART`,value:J(i)});break;case`comment`:r.push({key:t?`comment`:`©cmt`,value:J(i)});break;case`genre`:r.push({key:t?`genre`:`©gen`,value:J(i)});break;case`lyrics`:r.push({key:t?`lyrics`:`©lyr`,value:J(i)});break;case`date`:r.push({key:t?`date`:`©day`,value:J(i.toISOString().slice(0,10))});break;case`images`:for(let e of i)e.kind===`coverFront`&&r.push({key:`covr`,value:V(`data`,[N(Wt[e.mimeType]??0),N(0),Array.from(e.data)])});break;case`trackNumber`:if(t){let t=e.tracksTotal===void 0?i.toString():`${i}/${e.tracksTotal}`;r.push({key:`track`,value:J(t)})}else r.push({key:`trkn`,value:V(`data`,[N(0),N(0),M(0),M(i),M(e.tracksTotal??0),M(0)])});break;case`discNumber`:t||r.push({key:`disc`,value:V(`data`,[N(0),N(0),M(0),M(i),M(e.discsTotal??0),M(0)])});break;case`tracksTotal`:case`discsTotal`:break;case`raw`:break;default:S(n)}if(e.raw)for(let i in e.raw){let a=e.raw[i];a==null||!t&&i.length!==4||r.some(e=>e.key===i)||(typeof a==`string`?r.push({key:i,value:J(a)}):a instanceof Uint8Array?r.push({key:i,value:V(`data`,[N(0),N(0),Array.from(a)])}):a instanceof n&&r.push({key:i,value:V(`data`,[N(Wt[a.mimeType]??0),N(0),Array.from(a.data)])}))}return r},Kt=e=>{let t=Gt(e,!1);return t.length===0?null:H(`meta`,0,0,void 0,[Qe(!1,`mdir`,``,`appl`),V(`ilst`,void 0,t.map(e=>V(e.key,void 0,[e.value])))])},qt=e=>{let t=Gt(e,!0);return t.length===0?null:V(`meta`,void 0,[Qe(!1,`mdta`,``),H(`keys`,0,0,[N(t.length)],t.map(e=>V(`mdta`,[...D.encode(e.key)]))),V(`ilst`,void 0,t.map((e,t)=>V(String.fromCharCode(...N(t+1)),void 0,[e.value])))])},J=e=>V(`data`,[N(1),N(0),...D.encode(e)]),Jt=(e,t)=>{switch(e){case`avc`:return t.startsWith(`avc3`)?`avc3`:`avc1`;case`hevc`:return`hvc1`;case`vp8`:return`vp08`;case`vp9`:return`vp09`;case`av1`:return`av01`}},Yt={avc:ct,hevc:lt,vp8:ut,vp9:ut,av1:dt},Xt=(e,t)=>{switch(e){case`aac`:return`mp4a`;case`mp3`:return`mp4a`;case`opus`:return`Opus`;case`vorbis`:return`mp4a`;case`flac`:return`fLaC`;case`ulaw`:return`ulaw`;case`alaw`:return`alaw`;case`pcm-u8`:return`raw `;case`pcm-s8`:return`sowt`}if(t)switch(e){case`pcm-s16`:return`sowt`;case`pcm-s16be`:return`twos`;case`pcm-s24`:return`in24`;case`pcm-s24be`:return`in24`;case`pcm-s32`:return`in32`;case`pcm-s32be`:return`in32`;case`pcm-f32`:return`fl32`;case`pcm-f32be`:return`fl32`;case`pcm-f64`:return`fl64`;case`pcm-f64be`:return`fl64`}else switch(e){case`pcm-s16`:return`ipcm`;case`pcm-s16be`:return`ipcm`;case`pcm-s24`:return`ipcm`;case`pcm-s24be`:return`ipcm`;case`pcm-s32`:return`ipcm`;case`pcm-s32be`:return`ipcm`;case`pcm-f32`:return`fpcm`;case`pcm-f32be`:return`fpcm`;case`pcm-f64`:return`fpcm`;case`pcm-f64be`:return`fpcm`}},Zt=(e,t)=>{switch(e){case`aac`:return pt;case`mp3`:return pt;case`opus`:return gt;case`vorbis`:return pt;case`flac`:return _t}if(t)switch(e){case`pcm-s24`:return G;case`pcm-s24be`:return G;case`pcm-s32`:return G;case`pcm-s32be`:return G;case`pcm-f32`:return G;case`pcm-f32be`:return G;case`pcm-f64`:return G;case`pcm-f64be`:return G}else switch(e){case`pcm-s16`:return K;case`pcm-s16be`:return K;case`pcm-s24`:return K;case`pcm-s24be`:return K;case`pcm-s32`:return K;case`pcm-s32be`:return K;case`pcm-f32`:return K;case`pcm-f32be`:return K;case`pcm-f64`:return K;case`pcm-f64be`:return K}return null},Qt={webvtt:`wvtt`},$t={webvtt:yt},en=e=>{u(e.length===3);let t=0;for(let n=0;n<3;n++)t<<=5,t+=e.charCodeAt(n)-96;return t},tn=class{constructor(){this.ensureMonotonicity=!1,this.trackedWrites=null,this.trackedStart=-1,this.trackedEnd=-1}start(){}maybeTrackWrites(e){if(!this.trackedWrites)return;let t=this.getPos();if(t<this.trackedStart){if(t+e.byteLength<=this.trackedStart)return;e=e.subarray(this.trackedStart-t),t=0}let n=t+e.byteLength-this.trackedStart,r=this.trackedWrites.byteLength;for(;r<n;)r*=2;if(r!==this.trackedWrites.byteLength){let e=new Uint8Array(r);e.set(this.trackedWrites,0),this.trackedWrites=e}this.trackedWrites.set(e,t-this.trackedStart),this.trackedEnd=Math.max(this.trackedEnd,t+e.byteLength)}startTrackingWrites(){this.trackedWrites=new Uint8Array(2**10),this.trackedStart=this.getPos(),this.trackedEnd=this.trackedStart}stopTrackingWrites(){if(!this.trackedWrites)throw Error(`Internal error: Can't get tracked writes since nothing was tracked.`);let e={data:this.trackedWrites.subarray(0,this.trackedEnd-this.trackedStart),start:this.trackedStart,end:this.trackedEnd};return this.trackedWrites=null,e}},nn=2**16,rn=2**32,an=class extends tn{constructor(e){if(super(),this.pos=0,this.maxPos=0,this.target=e,this.supportsResize=`resize`in new ArrayBuffer(0),this.supportsResize)try{this.buffer=new ArrayBuffer(nn,{maxByteLength:rn})}catch{this.buffer=new ArrayBuffer(nn),this.supportsResize=!1}else this.buffer=new ArrayBuffer(nn);this.bytes=new Uint8Array(this.buffer)}ensureSize(e){let t=this.buffer.byteLength;for(;t<e;)t*=2;if(t!==this.buffer.byteLength){if(t>rn)throw Error(`ArrayBuffer exceeded maximum size of ${rn} bytes. Please consider using another target.`);if(this.supportsResize)this.buffer.resize(t);else{let e=new ArrayBuffer(t),n=new Uint8Array(e);n.set(this.bytes,0),this.buffer=e,this.bytes=n}}}write(e){this.maybeTrackWrites(e),this.ensureSize(this.pos+e.byteLength),this.bytes.set(e,this.pos),this.target.onwrite?.(this.pos,this.pos+e.byteLength),this.pos+=e.byteLength,this.maxPos=Math.max(this.maxPos,this.pos)}seek(e){this.pos=e}getPos(){return this.pos}async flush(){}async finalize(){this.ensureSize(this.pos),this.target.buffer=this.buffer.slice(0,Math.max(this.maxPos,this.pos))}async close(){}getSlice(e,t){return this.bytes.slice(e,t)}};ae();var on=class{constructor(){this._output=null,this.onwrite=null}},sn=class extends on{constructor(){super(...arguments),this.buffer=null}_createWriter(){return new an(this)}},cn=1e3,ln=2082844800,un=e=>{let t={},n=e.track;return n.metadata.name!==void 0&&(t.name=n.metadata.name),t},Y=(e,t,n=!0)=>{let r=e*t;return n?Math.round(r):r},dn=class extends Ne{constructor(e,t){super(e),this.auxTarget=new sn,this.auxWriter=this.auxTarget._createWriter(),this.auxBoxWriter=new Ie(this.auxWriter),this.mdat=null,this.ftypSize=null,this.trackDatas=[],this.allTracksKnown=he(),this.creationTime=Math.floor(Date.now()/1e3)+ln,this.finalizedChunks=[],this.nextFragmentNumber=1,this.maxWrittenTimestamp=-1/0,this.format=t,this.writer=e._writer,this.boxWriter=new Ie(this.writer),this.isQuickTime=t instanceof hn;let n=this.writer instanceof an?`in-memory`:!1;this.fastStart=t._options.fastStart??n,this.isFragmented=this.fastStart===`fragmented`,(this.fastStart===`in-memory`||this.isFragmented)&&(this.writer.ensureMonotonicity=!0),this.minimumFragmentDuration=t._options.minimumFragmentDuration??1}async start(){let e=await this.mutex.acquire(),t=this.output._tracks.some(e=>e.type===`video`&&e.source._codec===`avc`);if(this.format._options.onFtyp&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(Ue({isQuickTime:this.isQuickTime,holdsAvc:t,fragmented:this.isFragmented})),this.format._options.onFtyp){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onFtyp(e,t)}if(this.ftypSize=this.writer.getPos(),this.fastStart!==`in-memory`)if(this.fastStart===`reserve`){for(let e of this.output._tracks)if(e.metadata.maximumPacketCount===void 0)throw Error(`All tracks must specify maximumPacketCount in their metadata when using fastStart: 'reserve'.`)}else this.isFragmented||(this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=U(!0),this.boxWriter.writeBox(this.mdat));await this.writer.flush(),e()}allTracksAreKnown(){for(let e of this.output._tracks)if(!e.source._closed&&!this.trackDatas.some(t=>t.track===e))return!1;return!0}async getMimeType(){await this.allTracksKnown.promise;let e=this.trackDatas.map(e=>e.type===`video`||e.type===`audio`?e.info.decoderConfig.codec:{webvtt:`wvtt`}[e.track.source._codec]);return Ee({isQuickTime:this.isQuickTime,hasVideo:this.trackDatas.some(e=>e.type===`video`),hasAudio:this.trackDatas.some(e=>e.type===`audio`),codecStrings:e})}getVideoTrackData(e,t,n){let r=this.trackDatas.find(t=>t.track===e);if(r)return r;Me(n),u(n),u(n.decoderConfig);let i={...n.decoderConfig};u(i.codedWidth!==void 0),u(i.codedHeight!==void 0);let a=!1;if(e.source._codec===`avc`&&!i.description){let e=ie(t.data);if(!e)throw Error(`Couldn't extract an AVCDecoderConfigurationRecord from the AVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.264) when not providing a description, or provide a description (must be an AVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in AVCC format.`);i.description=Ae(e),a=!0}else if(e.source._codec===`hevc`&&!i.description){let e=Oe(t.data);if(!e)throw Error(`Couldn't extract an HEVCDecoderConfigurationRecord from the HEVC packet. Make sure the packets are in Annex B format (as specified in ITU-T-REC-H.265) when not providing a description, or provide a description (must be an HEVCDecoderConfigurationRecord as specified in ISO 14496-15) and ensure the packets are in HEVC format.`);i.description=y(e),a=!0}let o=_(1/(e.metadata.frameRate??57600),1e6).denominator,s={muxer:this,track:e,type:`video`,info:{width:i.codedWidth,height:i.codedHeight,decoderConfig:i,requiresAnnexBTransformation:a},timescale:o,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(s),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),s}getAudioTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;f(t),u(t),u(t.decoderConfig);let r={muxer:this,track:e,type:`audio`,info:{numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate,decoderConfig:t.decoderConfig,requiresPcmTransformation:!this.isFragmented&&b.includes(e.source._codec)},timescale:t.decoderConfig.sampleRate,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[]};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}getSubtitleTrackData(e,t){let n=this.trackDatas.find(t=>t.track===e);if(n)return n;v(t),u(t),u(t.config);let r={muxer:this,track:e,type:`subtitle`,info:{config:t.config},timescale:1e3,samples:[],sampleQueue:[],timestampProcessingQueue:[],timeToSampleTable:[],compositionTimeOffsetTable:[],lastTimescaleUnits:null,lastSample:null,finalizedChunks:[],currentChunk:null,compactlyCodedChunkTable:[],lastCueEndTimestamp:0,cueQueue:[],nextSourceId:0,cueToSourceId:new WeakMap};return this.trackDatas.push(r),this.trackDatas.sort((e,t)=>e.track.id-t.track.id),this.allTracksAreKnown()&&this.allTracksKnown.resolve(),r}async addEncodedVideoPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getVideoTrackData(e,t,n),i=t.data;if(r.info.requiresAnnexBTransformation){let e=je(i);if(e.length===0)throw Error(`Failed to transform packet data. Make sure all packets are provided in Annex B format, as specified in ITU-T-REC-H.264 and ITU-T-REC-H.265.`);i=fe(e,4)}let a=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),o=this.createSampleForTrack(r,i,a,t.duration,t.type);await this.registerSample(r,o)}finally{r()}}async addEncodedAudioPacket(e,t,n){let r=await this.mutex.acquire();try{let r=this.getAudioTrackData(e,n),i=this.validateAndNormalizeTimestamp(r.track,t.timestamp,t.type===`key`),a=this.createSampleForTrack(r,t.data,i,t.duration,t.type);r.info.requiresPcmTransformation&&await this.maybePadWithSilence(r,i),await this.registerSample(r,a)}finally{r()}}async maybePadWithSilence(e,t){let n=E(e.samples),r=n?n.timestamp+n.duration:0,i=t-r,a=Y(i,e.timescale);if(a>0){let{sampleSize:t,silentValue:n}=l(e.info.decoderConfig.codec),o=a*e.info.numberOfChannels,s=new Uint8Array(t*o).fill(n),c=this.createSampleForTrack(e,new Uint8Array(s.buffer),r,i,`key`);await this.registerSample(e,c)}}async addSubtitleCue(e,t,n){let r=await this.mutex.acquire();try{let r=this.getSubtitleTrackData(e,n);this.validateAndNormalizeTimestamp(r.track,t.timestamp,!0),e.source._codec===`webvtt`&&(r.cueQueue.push(t),await this.processWebVTTCues(r,t.timestamp))}finally{r()}}async processWebVTTCues(e,t){for(;e.cueQueue.length>0;){let n=new Set([]);for(let r of e.cueQueue)u(r.timestamp<=t),u(e.lastCueEndTimestamp<=r.timestamp+r.duration),n.add(Math.max(r.timestamp,e.lastCueEndTimestamp)),n.add(r.timestamp+r.duration);let r=[...n].sort((e,t)=>e-t),i=r[0],a=r[1]??i;if(t<a)break;if(e.lastCueEndTimestamp<i){this.auxWriter.seek(0);let t=zt();this.auxBoxWriter.writeBox(t);let n=this.auxWriter.getSlice(0,this.auxWriter.getPos()),r=this.createSampleForTrack(e,n,e.lastCueEndTimestamp,i-e.lastCueEndTimestamp,`key`);await this.registerSample(e,r),e.lastCueEndTimestamp=i}this.auxWriter.seek(0);for(let t=0;t<e.cueQueue.length;t++){let n=e.cueQueue[t];if(n.timestamp>=a)break;Pe.lastIndex=0;let r=Pe.test(n.text),o=n.timestamp+n.duration,s=e.cueToSourceId.get(n);if(s===void 0&&a<o&&(s=e.nextSourceId++,e.cueToSourceId.set(n,s)),n.notes){let e=Vt(n.notes);this.auxBoxWriter.writeBox(e)}let c=Bt(n.text,r?i:null,n.identifier??null,n.settings??null,s??null);this.auxBoxWriter.writeBox(c),o===a&&e.cueQueue.splice(t--,1)}let o=this.auxWriter.getSlice(0,this.auxWriter.getPos()),s=this.createSampleForTrack(e,o,i,a-i,`key`);await this.registerSample(e,s),e.lastCueEndTimestamp=a}}createSampleForTrack(e,t,n,r,i){return{timestamp:n,decodeTimestamp:n,duration:r,data:t,size:t.byteLength,type:i,timescaleUnitsToNextSample:Y(r,e.timescale)}}processTimestamps(e,t){if(e.timestampProcessingQueue.length===0)return;if(e.type===`audio`&&e.info.requiresPcmTransformation){let t=0;for(let n=0;n<e.timestampProcessingQueue.length;n++){let r=e.timestampProcessingQueue[n],i=Y(r.duration,e.timescale);t+=i}if(e.timeToSampleTable.length===0)e.timeToSampleTable.push({sampleCount:t,sampleDelta:1});else{let n=E(e.timeToSampleTable);n.sampleCount+=t}e.timestampProcessingQueue.length=0;return}let n=e.timestampProcessingQueue.map(e=>e.timestamp).sort((e,t)=>e-t);for(let t=0;t<e.timestampProcessingQueue.length;t++){let r=e.timestampProcessingQueue[t];r.decodeTimestamp=n[t],!this.isFragmented&&e.lastTimescaleUnits===null&&(r.decodeTimestamp=0);let i=Y(r.timestamp-r.decodeTimestamp,e.timescale),a=Y(r.duration,e.timescale);if(e.lastTimescaleUnits!==null){u(e.lastSample);let t=Y(r.decodeTimestamp,e.timescale,!1),n=Math.round(t-e.lastTimescaleUnits);if(u(n>=0),e.lastTimescaleUnits+=n,e.lastSample.timescaleUnitsToNextSample=n,!this.isFragmented){let t=E(e.timeToSampleTable);if(u(t),t.sampleCount===1){t.sampleDelta=n;let r=e.timeToSampleTable[e.timeToSampleTable.length-2];r&&r.sampleDelta===n&&(r.sampleCount++,e.timeToSampleTable.pop(),t=r)}else t.sampleDelta!==n&&(t.sampleCount--,e.timeToSampleTable.push(t={sampleCount:1,sampleDelta:n}));t.sampleDelta===a?t.sampleCount++:e.timeToSampleTable.push({sampleCount:1,sampleDelta:a});let r=E(e.compositionTimeOffsetTable);u(r),r.sampleCompositionTimeOffset===i?r.sampleCount++:e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i})}}else e.lastTimescaleUnits=Y(r.decodeTimestamp,e.timescale,!1),this.isFragmented||(e.timeToSampleTable.push({sampleCount:1,sampleDelta:a}),e.compositionTimeOffsetTable.push({sampleCount:1,sampleCompositionTimeOffset:i}));e.lastSample=r}if(e.timestampProcessingQueue.length=0,u(e.lastSample),u(e.lastTimescaleUnits!==null),t!==void 0&&e.lastSample.timescaleUnitsToNextSample===0){u(t.type===`key`);let n=Y(t.timestamp,e.timescale,!1),r=Math.round(n-e.lastTimescaleUnits);e.lastSample.timescaleUnitsToNextSample=r}}async registerSample(e,t){t.type===`key`&&this.processTimestamps(e,t),e.timestampProcessingQueue.push(t),this.isFragmented?(e.sampleQueue.push(t),await this.interleaveSamples()):this.fastStart===`reserve`?await this.registerSampleFastStartReserve(e,t):await this.addSampleToTrack(e,t)}async addSampleToTrack(e,t){if(!this.isFragmented&&(e.samples.push(t),this.fastStart===`reserve`)){let t=e.track.metadata.maximumPacketCount;if(u(t!==void 0),e.samples.length>t)throw Error(`Track #${e.track.id} has already reached the maximum packet count (${t}). Either add less packets or increase the maximum packet count.`)}let n=!1;if(!e.currentChunk)n=!0;else{e.currentChunk.startTimestamp=Math.min(e.currentChunk.startTimestamp,t.timestamp);let r=t.timestamp-e.currentChunk.startTimestamp;if(this.isFragmented){let i=this.trackDatas.every(n=>{if(e===n)return t.type===`key`;let r=n.sampleQueue[0];return r?r.type===`key`:n.track.source._closed});r>=this.minimumFragmentDuration&&i&&t.timestamp>this.maxWrittenTimestamp&&(n=!0,await this.finalizeFragment())}else n=r>=.5}n&&(e.currentChunk&&await this.finalizeCurrentChunk(e),e.currentChunk={startTimestamp:t.timestamp,samples:[],offset:null,moofOffset:null}),u(e.currentChunk),e.currentChunk.samples.push(t),this.isFragmented&&(this.maxWrittenTimestamp=Math.max(this.maxWrittenTimestamp,t.timestamp))}async finalizeCurrentChunk(e){if(u(!this.isFragmented),!e.currentChunk)return;e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk);let t=e.currentChunk.samples.length;if(e.type===`audio`&&e.info.requiresPcmTransformation&&(t=e.currentChunk.samples.reduce((t,n)=>t+Y(n.duration,e.timescale),0)),(e.compactlyCodedChunkTable.length===0||E(e.compactlyCodedChunkTable).samplesPerChunk!==t)&&e.compactlyCodedChunkTable.push({firstChunk:e.finalizedChunks.length,samplesPerChunk:t}),this.fastStart===`in-memory`){e.currentChunk.offset=0;return}e.currentChunk.offset=this.writer.getPos();for(let t of e.currentChunk.samples)u(t.data),this.writer.write(t.data),t.data=null;await this.writer.flush()}async interleaveSamples(e=!1){if(u(this.isFragmented),!(!e&&!this.allTracksAreKnown()))outer:for(;;){let t=null,n=1/0;for(let r of this.trackDatas){if(!e&&r.sampleQueue.length===0&&!r.track.source._closed)break outer;r.sampleQueue.length>0&&r.sampleQueue[0].timestamp<n&&(t=r,n=r.sampleQueue[0].timestamp)}if(!t)break;let r=t.sampleQueue.shift();await this.addSampleToTrack(t,r)}}async finalizeFragment(e=!0){u(this.isFragmented);let t=this.nextFragmentNumber++;if(t===1){this.format._options.onMoov&&this.writer.startTrackingWrites();let e=W(this);if(this.boxWriter.writeBox(e),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}let n=this.trackDatas.filter(e=>e.currentChunk),r=kt(t,n),i=this.writer.getPos(),a=i+this.boxWriter.measureBox(r),o=a+8,s=1/0;for(let e of n){e.currentChunk.offset=o,e.currentChunk.moofOffset=i;for(let t of e.currentChunk.samples)o+=t.size;s=Math.min(s,e.currentChunk.startTimestamp)}let c=o-a,l=c>=2**32;if(l)for(let e of n)e.currentChunk.offset+=8;this.format._options.onMoof&&this.writer.startTrackingWrites();let d=kt(t,n);if(this.boxWriter.writeBox(d),this.format._options.onMoof){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoof(e,t,s)}u(this.writer.getPos()===a),this.format._options.onMdat&&this.writer.startTrackingWrites();let f=U(l);f.size=c,this.boxWriter.writeBox(f),this.writer.seek(a+(l?16:8));for(let e of n)for(let t of e.currentChunk.samples)this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}for(let e of n)e.finalizedChunks.push(e.currentChunk),this.finalizedChunks.push(e.currentChunk),e.currentChunk=null;e&&await this.writer.flush()}async registerSampleFastStartReserve(e,t){if(this.allTracksAreKnown()){if(!this.mdat){let e=W(this),t=this.boxWriter.measureBox(e)+this.computeSampleTableSizeUpperBound()+4096;u(this.ftypSize!==null),this.writer.seek(this.ftypSize+t),this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat=U(!0),this.boxWriter.writeBox(this.mdat);for(let e of this.trackDatas){for(let t of e.sampleQueue)await this.addSampleToTrack(e,t);e.sampleQueue.length=0}}await this.addSampleToTrack(e,t)}else e.sampleQueue.push(t)}computeSampleTableSizeUpperBound(){u(this.fastStart===`reserve`);let e=0;for(let t of this.trackDatas){let n=t.track.metadata.maximumPacketCount;u(n!==void 0),e+=8*Math.ceil(2/3*n),e+=4*n,e+=8*Math.ceil(2/3*n),e+=12*Math.ceil(2/3*n),e+=4*n,e+=8*n}return e}async onTrackClose(e){let t=await this.mutex.acquire();if(e.type===`subtitle`&&e.source._codec===`webvtt`){let t=this.trackDatas.find(t=>t.track===e);t&&await this.processWebVTTCues(t,1/0)}this.allTracksAreKnown()&&this.allTracksKnown.resolve(),this.isFragmented&&await this.interleaveSamples(),t()}async finalize(){let e=await this.mutex.acquire();this.allTracksKnown.resolve();for(let e of this.trackDatas)e.type===`subtitle`&&e.track.source._codec===`webvtt`&&await this.processWebVTTCues(e,1/0);if(this.isFragmented){await this.interleaveSamples(!0);for(let e of this.trackDatas)this.processTimestamps(e);await this.finalizeFragment(!1)}else for(let e of this.trackDatas)this.processTimestamps(e),await this.finalizeCurrentChunk(e);if(this.fastStart===`in-memory`){this.mdat=U(!1);let e;for(let t=0;t<2;t++){let t=W(this),n=this.boxWriter.measureBox(t);e=this.boxWriter.measureBox(this.mdat);let r=this.writer.getPos()+n+e;for(let t of this.finalizedChunks){t.offset=r;for(let{data:n}of t.samples)u(n),r+=n.byteLength,e+=n.byteLength}if(r<2**32)break;e>=2**32&&(this.mdat.largeSize=!0)}this.format._options.onMoov&&this.writer.startTrackingWrites();let t=W(this);if(this.boxWriter.writeBox(t),this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}this.format._options.onMdat&&this.writer.startTrackingWrites(),this.mdat.size=e,this.boxWriter.writeBox(this.mdat);for(let e of this.finalizedChunks)for(let t of e.samples)u(t.data),this.writer.write(t.data),t.data=null;if(this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}}else if(this.isFragmented){let e=this.writer.getPos(),t=It(this.trackDatas);this.boxWriter.writeBox(t);let n=this.writer.getPos()-e;this.writer.seek(this.writer.getPos()-4),this.boxWriter.writeU32(n)}else{u(this.mdat);let e=this.boxWriter.offsets.get(this.mdat);u(e!==void 0);let t=this.writer.getPos()-e;if(this.mdat.size=t,this.mdat.largeSize=t>=2**32,this.boxWriter.patchBox(this.mdat),this.format._options.onMdat){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMdat(e,t)}let n=W(this);if(this.fastStart===`reserve`){u(this.ftypSize!==null),this.writer.seek(this.ftypSize),this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);let e=this.boxWriter.offsets.get(this.mdat)-this.writer.getPos();this.boxWriter.writeBox(We(e))}else this.format._options.onMoov&&this.writer.startTrackingWrites(),this.boxWriter.writeBox(n);if(this.format._options.onMoov){let{data:e,start:t}=this.writer.stopTrackingWrites();this.format._options.onMoov(e,t)}}e()}},fn=class{getSupportedVideoCodecs(){return this.getSupportedCodecs().filter(e=>i.includes(e))}getSupportedAudioCodecs(){return this.getSupportedCodecs().filter(e=>r.includes(e))}getSupportedSubtitleCodecs(){return this.getSupportedCodecs().filter(e=>a.includes(e))}_codecUnsupportedHint(e){return``}},pn=class extends fn{constructor(e={}){if(!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(e.fastStart!==void 0&&![!1,`in-memory`,`reserve`,`fragmented`].includes(e.fastStart))throw TypeError(`options.fastStart, when provided, must be false, 'in-memory', 'reserve', or 'fragmented'.`);if(e.minimumFragmentDuration!==void 0&&(!Number.isFinite(e.minimumFragmentDuration)||e.minimumFragmentDuration<0))throw TypeError(`options.minimumFragmentDuration, when provided, must be a non-negative number.`);if(e.onFtyp!==void 0&&typeof e.onFtyp!=`function`)throw TypeError(`options.onFtyp, when provided, must be a function.`);if(e.onMoov!==void 0&&typeof e.onMoov!=`function`)throw TypeError(`options.onMoov, when provided, must be a function.`);if(e.onMdat!==void 0&&typeof e.onMdat!=`function`)throw TypeError(`options.onMdat, when provided, must be a function.`);if(e.onMoof!==void 0&&typeof e.onMoof!=`function`)throw TypeError(`options.onMoof, when provided, must be a function.`);if(e.metadataFormat!==void 0&&![`mdir`,`mdta`,`udta`,`auto`].includes(e.metadataFormat))throw TypeError(`options.metadataFormat, when provided, must be either 'auto', 'mdir', 'mdta', or 'udta'.`);super(),this._options=e}getSupportedTrackCounts(){return{video:{min:0,max:1/0},audio:{min:0,max:1/0},subtitle:{min:0,max:1/0},total:{min:1,max:2**32-1}}}get supportsVideoRotationMetadata(){return!0}_createMuxer(e){return new dn(e,this)}},mn=class extends pn{constructor(e){super(e)}get _name(){return`MP4`}get fileExtension(){return`.mp4`}get mimeType(){return`video/mp4`}getSupportedCodecs(){return[...i,...ke,`pcm-s16`,`pcm-s16be`,`pcm-s24`,`pcm-s24be`,`pcm-s32`,`pcm-s32be`,`pcm-f32`,`pcm-f32be`,`pcm-f64`,`pcm-f64be`,...a]}_codecUnsupportedHint(e){return new hn().getSupportedCodecs().includes(e)?` Switching to MOV will grant support for this codec.`:``}},hn=class extends pn{constructor(e){super(e)}get _name(){return`MOV`}get fileExtension(){return`.mov`}get mimeType(){return`video/quicktime`}getSupportedCodecs(){return[...i,...r]}_codecUnsupportedHint(e){return new mn().getSupportedCodecs().includes(e)?` Switching to MP4 will grant support for this codec.`:``}},gn=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!i.includes(e.codec))throw TypeError(`Invalid video codec '${e.codec}'. Must be one of: ${i.join(`, `)}.`);if(!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate must be a positive integer or a quality.`);if(e.keyFrameInterval!==void 0&&(!Number.isFinite(e.keyFrameInterval)||e.keyFrameInterval<0))throw TypeError(`config.keyFrameInterval, when provided, must be a non-negative number.`);if(e.sizeChangeBehavior!==void 0&&![`deny`,`passThrough`,`fill`,`contain`,`cover`].includes(e.sizeChangeBehavior))throw TypeError(`config.sizeChangeBehavior, when provided, must be 'deny', 'passThrough', 'fill', 'contain' or 'cover'.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);_n(e.codec,e)},_n=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.alpha!==void 0&&![`discard`,`keep`].includes(t.alpha))throw TypeError(`options.alpha, when provided, must be 'discard' or 'keep'.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.latencyMode!==void 0&&![`quality`,`realtime`].includes(t.latencyMode))throw TypeError(`latencyMode, when provided, must be 'quality' or 'realtime'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&g(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`);if(t.hardwareAcceleration!==void 0&&![`no-preference`,`prefer-hardware`,`prefer-software`].includes(t.hardwareAcceleration))throw TypeError(`hardwareAcceleration, when provided, must be 'no-preference', 'prefer-hardware' or 'prefer-software'.`);if(t.scalabilityMode!==void 0&&typeof t.scalabilityMode!=`string`)throw TypeError(`scalabilityMode, when provided, must be a string.`);if(t.contentHint!==void 0&&typeof t.contentHint!=`string`)throw TypeError(`contentHint, when provided, must be a string.`)},vn=e=>{let n=e.bitrate instanceof X?e.bitrate._toVideoBitrate(e.codec,e.width,e.height):e.bitrate;return{codec:e.fullCodecString??t(e.codec,e.width,e.height,n),width:e.width,height:e.height,bitrate:n,bitrateMode:e.bitrateMode,alpha:e.alpha??`discard`,framerate:e.framerate,latencyMode:e.latencyMode,hardwareAcceleration:e.hardwareAcceleration,scalabilityMode:e.scalabilityMode,contentHint:e.contentHint,...m(e.codec)}},yn=e=>{if(!e||typeof e!=`object`)throw TypeError(`Encoding config must be an object.`);if(!r.includes(e.codec))throw TypeError(`Invalid audio codec '${e.codec}'. Must be one of: ${r.join(`, `)}.`);if(e.bitrate===void 0&&(!b.includes(e.codec)||e.codec===`flac`))throw TypeError(`config.bitrate must be provided for compressed audio codecs.`);if(e.bitrate!==void 0&&!(e.bitrate instanceof X)&&(!Number.isInteger(e.bitrate)||e.bitrate<=0))throw TypeError(`config.bitrate, when provided, must be a positive integer or a quality.`);if(e.onEncodedPacket!==void 0&&typeof e.onEncodedPacket!=`function`)throw TypeError(`config.onEncodedChunk, when provided, must be a function.`);if(e.onEncoderConfig!==void 0&&typeof e.onEncoderConfig!=`function`)throw TypeError(`config.onEncoderConfig, when provided, must be a function.`);bn(e.codec,e)},bn=(e,t)=>{if(!t||typeof t!=`object`)throw TypeError(`Encoding options must be an object.`);if(t.bitrateMode!==void 0&&![`constant`,`variable`].includes(t.bitrateMode))throw TypeError(`bitrateMode, when provided, must be 'constant' or 'variable'.`);if(t.fullCodecString!==void 0&&typeof t.fullCodecString!=`string`)throw TypeError(`fullCodecString, when provided, must be a string.`);if(t.fullCodecString!==void 0&&g(t.fullCodecString)!==e)throw TypeError(`fullCodecString, when provided, must be a string that matches the specified codec (${e}).`)},xn=e=>{let t=e.bitrate instanceof X?e.bitrate._toAudioBitrate(e.codec):e.bitrate;return{codec:e.fullCodecString??_e(e.codec,e.numberOfChannels,e.sampleRate),numberOfChannels:e.numberOfChannels,sampleRate:e.sampleRate,bitrate:t,bitrateMode:e.bitrateMode,...p(e.codec)}},X=class{constructor(e){this._factor=e}_toVideoBitrate(e,t,n){let r=3e6*(t*n/(1920*1080))**.95*{avc:1,hevc:.6,vp9:.6,av1:.4,vp8:1.2}[e]*this._factor;return Math.ceil(r/1e3)*1e3}_toAudioBitrate(e){if(b.includes(e)||e===`flac`)return;let t={aac:128e3,opus:64e3,mp3:16e4,vorbis:64e3}[e];if(!t)throw Error(`Unhandled codec: ${e}`);let n=t*this._factor;return e===`aac`?n=[96e3,128e3,16e4,192e3].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e):e===`opus`||e===`vorbis`?n=Math.max(6e3,n):e===`mp3`&&(n=[8e3,16e3,24e3,32e3,4e4,48e3,64e3,8e4,96e3,112e3,128e3,16e4,192e3,224e3,256e3,32e4].reduce((e,t)=>Math.abs(t-n)<Math.abs(e-n)?t:e)),Math.round(n/1e3)*1e3}},Sn=new X(2),Cn=async(t,n={})=>{let{width:r=1280,height:a=720,bitrate:o=1e6,...s}=n;if(!i.includes(t))return!1;if(!Number.isInteger(r)||r<=0)throw TypeError(`width must be a positive integer.`);if(!Number.isInteger(a)||a<=0)throw TypeError(`height must be a positive integer.`);if(!(o instanceof X)&&(!Number.isInteger(o)||o<=0))throw TypeError(`bitrate must be a positive integer or a quality.`);_n(t,s);let c=null;return pe.length>0&&(c??=vn({codec:t,width:r,height:a,bitrate:o,framerate:void 0,...s}),pe.some(e=>e.supports(t,c)))?!0:typeof VideoEncoder>`u`||(r%2==1||a%2==1)&&(t===`avc`||t===`hevc`)||(c??=vn({codec:t,width:r,height:a,bitrate:o,framerate:void 0,...s,alpha:`discard`}),!(await VideoEncoder.isConfigSupported(c)).supported)?!1:e()?new Promise(async e=>{try{let t=new VideoEncoder({output:()=>{},error:()=>e(!1)});t.configure(c);let n=new Uint8Array(r*a*4),i=new VideoFrame(n,{format:`RGBA`,codedWidth:r,codedHeight:a,timestamp:0});t.encode(i),i.close(),await t.flush(),e(!0)}catch{e(!1)}}):!0},wn=async(e,t={})=>{let{numberOfChannels:n=2,sampleRate:i=48e3,bitrate:a=128e3,...o}=t;if(!r.includes(e))return!1;if(!Number.isInteger(n)||n<=0)throw TypeError(`numberOfChannels must be a positive integer.`);if(!Number.isInteger(i)||i<=0)throw TypeError(`sampleRate must be a positive integer.`);if(!(a instanceof X)&&(!Number.isInteger(a)||a<=0))throw TypeError(`bitrate must be a positive integer.`);bn(e,o);let s=null;return be.length>0&&(s??=xn({codec:e,numberOfChannels:n,sampleRate:i,bitrate:a,...o}),be.some(t=>t.supports(e,s)))||b.includes(e)?!0:typeof AudioEncoder>`u`?!1:(s??=xn({codec:e,numberOfChannels:n,sampleRate:i,bitrate:a,...o}),(await AudioEncoder.isConfigSupported(s)).supported===!0)},Tn=async(e,t)=>{for(let n of e)if(await Cn(n,t))return n;return null},En=async(e,t)=>{for(let n of e)if(await wn(n,t))return n;return null},Dn=class{constructor(){this._connectedTrack=null,this._closingPromise=null,this._closed=!1,this._timestampOffset=0}_ensureValidAdd(){if(!this._connectedTrack)throw Error(`Source is not connected to an output track.`);if(this._connectedTrack.output.state===`canceled`)throw Error(`Output has been canceled.`);if(this._connectedTrack.output.state===`finalizing`||this._connectedTrack.output.state===`finalized`)throw Error(`Output has been finalized.`);if(this._connectedTrack.output.state===`pending`)throw Error(`Output has not started.`);if(this._closed)throw Error(`Source is closed.`)}async _start(){}async _flushAndClose(e){}close(){if(this._closingPromise)return;let e=this._connectedTrack;if(!e)throw Error(`Cannot call close without connecting the source to an output track.`);if(e.output.state===`pending`)throw Error(`Cannot call close before output has been started.`);this._closingPromise=(async()=>{await this._flushAndClose(!1),this._closed=!0,!(e.output.state===`finalizing`||e.output.state===`finalized`)&&e.output._muxer.onTrackClose(e)})()}async _flushOrWaitForOngoingClose(e){return this._closingPromise?this._closingPromise:this._flushAndClose(e)}},On=class extends Dn{constructor(e){if(super(),this._connectedTrack=null,!i.includes(e))throw TypeError(`Invalid video codec '${e}'. Must be one of: ${i.join(`, `)}.`);this._codec=e}},kn=class{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastMultipleOfKeyFrameInterval=-1,this.codedWidth=null,this.codedHeight=null,this.resizeCanvas=null,this.customEncoder=null,this.customEncoderCallSerializer=new s,this.customEncoderQueueSize=0,this.alphaEncoder=null,this.splitter=null,this.splitterCreationFailed=!1,this.alphaFrameQueue=[],this.error=null,this.errorNeedsNewStack=!0}async add(t,n,r){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.codedWidth!==null&&this.codedHeight!==null){if(t.codedWidth!==this.codedWidth||t.codedHeight!==this.codedHeight){let r=this.encodingConfig.sizeChangeBehavior??`deny`;if(r!==`passThrough`){if(r===`deny`)throw Error(`Video sample size must remain constant. Expected ${this.codedWidth}x${this.codedHeight}, got ${t.codedWidth}x${t.codedHeight}. To allow the sample size to change over time, set \`sizeChangeBehavior\` to a value other than 'strict' in the encoding options.`);{let i=!1;this.resizeCanvas||(typeof document<`u`?(this.resizeCanvas=document.createElement(`canvas`),this.resizeCanvas.width=this.codedWidth,this.resizeCanvas.height=this.codedHeight):this.resizeCanvas=new OffscreenCanvas(this.codedWidth,this.codedHeight),i=!0);let a=this.resizeCanvas.getContext(`2d`,{alpha:e()});u(a),i||(e()?(a.fillStyle=`black`,a.fillRect(0,0,this.codedWidth,this.codedHeight)):a.clearRect(0,0,this.codedWidth,this.codedHeight)),t.drawWithFit(a,{fit:r}),n&&t.close(),t=new De(this.resizeCanvas,{timestamp:t.timestamp,duration:t.duration,rotation:t.rotation}),n=!0}}}}else this.codedWidth=t.codedWidth,this.codedHeight=t.codedHeight;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(t),this.encoderInitialized||await this.ensureEncoderPromise),u(this.encoderInitialized);let i=this.encodingConfig.keyFrameInterval??5,a=Math.floor(t.timestamp/i),o={...r,keyFrame:r?.keyFrame||i===0||a!==this.lastMultipleOfKeyFrameInterval};if(this.lastMultipleOfKeyFrameInterval=a,this.customEncoder){this.customEncoderQueueSize++;let e=t.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(e,o)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{e.close()});this.customEncoderQueueSize>=4&&await n}else{u(this.encoder);let e=t.toVideoFrame();if(!this.alphaEncoder)this.encoder.encode(e,o),e.close();else if(e.format&&!e.format.includes(`A`)||this.splitterCreationFailed)this.alphaFrameQueue.push(null),this.encoder.encode(e,o),e.close();else{let t=e.displayWidth,n=e.displayHeight;if(!this.splitter)try{this.splitter=new An(t,n)}catch(t){console.error(`Due to an error, only color data will be encoded.`,t),this.splitterCreationFailed=!0,this.alphaFrameQueue.push(null),this.encoder.encode(e,o),e.close()}if(this.splitter){let t=this.splitter.extractColor(e),n=this.splitter.extractAlpha(e);this.alphaFrameQueue.push(n),this.encoder.encode(t,o),t.close(),e.close()}}n&&t.close(),this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0}))}await this.muxer.mutex.currentPromise}finally{n&&t.close()}}ensureEncoder(e){let t=Error();this.ensureEncoderPromise=(async()=>{let n=vn({width:e.codedWidth,height:e.codedHeight,...this.encodingConfig,framerate:this.source._connectedTrack?.metadata.frameRate});this.encodingConfig.onEncoderConfig?.(n);let r=pe.find(e=>e.supports(this.encodingConfig.codec,n));if(r)this.customEncoder=new r,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=n,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof T))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);this.encodingConfig.onEncodedPacket?.(e,t),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else{if(typeof VideoEncoder>`u`)throw Error(`VideoEncoder is not supported by this browser.`);if(n.alpha=`discard`,this.encodingConfig.alpha===`keep`&&(n.latencyMode=`quality`),(n.width%2==1||n.height%2==1)&&(this.encodingConfig.codec===`avc`||this.encodingConfig.codec===`hevc`))throw Error(`The dimensions ${n.width}x${n.height} are not supported for codec '${this.encodingConfig.codec}'; both width and height must be even numbers. Make sure to round your dimensions to the nearest even number.`);if(!(await VideoEncoder.isConfigSupported(n)).supported)throw Error(`This specific encoder configuration (${n.codec}, ${n.bitrate} bps, ${n.width}x${n.height}, hardware acceleration: ${n.hardwareAcceleration??`no-preference`}) is not supported by this browser. Consider using another codec or changing your video parameters.`);let e=[],r=[],i=0,a=0,o=(e,t,n)=>{let r={};if(t){let e=new Uint8Array(t.byteLength);t.copyTo(e),r.alpha=e}let i=T.fromEncodedChunk(e,r);this.encodingConfig.onEncodedPacket?.(i,n),this.muxer.addEncodedVideoPacket(this.source._connectedTrack,i,n).catch(e=>{this.error??=e,this.errorNeedsNewStack=!1})};this.encoder=new VideoEncoder({output:(t,n)=>{if(!this.alphaEncoder){o(t,null,n);return}let s=this.alphaFrameQueue.shift();u(s!==void 0),s?(this.alphaEncoder.encode(s,{keyFrame:t.type===`key`}),a++,s.close(),e.push({chunk:t,meta:n})):a===0?o(t,null,n):(r.push(i+a),e.push({chunk:t,meta:n}))},error:e=>{e.stack=t.stack,this.error??=e}}),this.encoder.configure(n),this.encodingConfig.alpha===`keep`&&(this.alphaEncoder=new VideoEncoder({output:(t,n)=>{a--;let s=e.shift();for(u(s!==void 0),o(s.chunk,t,s.meta),i++;r.length>0&&r[0]===i;){r.shift();let t=e.shift();u(t!==void 0),o(t.chunk,null,t.meta)}},error:e=>{e.stack=t.stack,this.error??=e}}),this.alphaEncoder.configure(n))}u(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||(await this.encoder.flush(),await this.alphaEncoder?.flush()),this.encoder.state!==`closed`&&this.encoder.close(),this.alphaEncoder&&this.alphaEncoder.state!==`closed`&&this.alphaEncoder.close(),this.alphaFrameQueue.forEach(e=>e?.close()),this.splitter?.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=Error().stack),this.error}},An=class{constructor(e,t){this.lastFrame=null,typeof OffscreenCanvas<`u`?this.canvas=new OffscreenCanvas(e,t):(this.canvas=document.createElement(`canvas`),this.canvas.width=e,this.canvas.height=t);let n=this.canvas.getContext(`webgl2`,{alpha:!0});if(!n)throw Error(`Couldn't acquire WebGL 2 context.`);this.gl=n,this.colorProgram=this.createColorProgram(),this.alphaProgram=this.createAlphaProgram(),this.vao=this.createVAO(),this.sourceTexture=this.createTexture(),this.alphaResolutionLocation=this.gl.getUniformLocation(this.alphaProgram,`u_resolution`),this.gl.useProgram(this.colorProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.colorProgram,`u_sourceTexture`),0),this.gl.useProgram(this.alphaProgram),this.gl.uniform1i(this.gl.getUniformLocation(this.alphaProgram,`u_sourceTexture`),0)}createVertexShader(){return this.createShader(this.gl.VERTEX_SHADER,`#version 300 es
|
|
2
|
+
in vec2 a_position;
|
|
3
|
+
in vec2 a_texCoord;
|
|
4
|
+
out vec2 v_texCoord;
|
|
5
|
+
|
|
6
|
+
void main() {
|
|
7
|
+
gl_Position = vec4(a_position, 0.0, 1.0);
|
|
8
|
+
v_texCoord = a_texCoord;
|
|
9
|
+
}
|
|
10
|
+
`)}createColorProgram(){let e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,`#version 300 es
|
|
11
|
+
precision highp float;
|
|
12
|
+
|
|
13
|
+
uniform sampler2D u_sourceTexture;
|
|
14
|
+
in vec2 v_texCoord;
|
|
15
|
+
out vec4 fragColor;
|
|
16
|
+
|
|
17
|
+
void main() {
|
|
18
|
+
vec4 source = texture(u_sourceTexture, v_texCoord);
|
|
19
|
+
fragColor = vec4(source.rgb, 1.0);
|
|
20
|
+
}
|
|
21
|
+
`),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,t),this.gl.linkProgram(n),n}createAlphaProgram(){let e=this.createVertexShader(),t=this.createShader(this.gl.FRAGMENT_SHADER,`#version 300 es
|
|
22
|
+
precision highp float;
|
|
23
|
+
|
|
24
|
+
uniform sampler2D u_sourceTexture;
|
|
25
|
+
uniform vec2 u_resolution; // The width and height of the canvas
|
|
26
|
+
in vec2 v_texCoord;
|
|
27
|
+
out vec4 fragColor;
|
|
28
|
+
|
|
29
|
+
// This function determines the value for a single byte in the YUV stream
|
|
30
|
+
float getByteValue(float byteOffset) {
|
|
31
|
+
float width = u_resolution.x;
|
|
32
|
+
float height = u_resolution.y;
|
|
33
|
+
|
|
34
|
+
float yPlaneSize = width * height;
|
|
35
|
+
|
|
36
|
+
if (byteOffset < yPlaneSize) {
|
|
37
|
+
// This byte is in the luma plane. Find the corresponding pixel coordinates to sample from
|
|
38
|
+
float y = floor(byteOffset / width);
|
|
39
|
+
float x = mod(byteOffset, width);
|
|
40
|
+
|
|
41
|
+
// Add 0.5 to sample the center of the texel
|
|
42
|
+
vec2 sampleCoord = (vec2(x, y) + 0.5) / u_resolution;
|
|
43
|
+
|
|
44
|
+
// The luma value is the alpha from the source texture
|
|
45
|
+
return texture(u_sourceTexture, sampleCoord).a;
|
|
46
|
+
} else {
|
|
47
|
+
// Write a fixed value for chroma and beyond
|
|
48
|
+
return 128.0 / 255.0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
void main() {
|
|
53
|
+
// Each fragment writes 4 bytes (R, G, B, A)
|
|
54
|
+
float pixelIndex = floor(gl_FragCoord.y) * u_resolution.x + floor(gl_FragCoord.x);
|
|
55
|
+
float baseByteOffset = pixelIndex * 4.0;
|
|
56
|
+
|
|
57
|
+
vec4 result;
|
|
58
|
+
for (int i = 0; i < 4; i++) {
|
|
59
|
+
float currentByteOffset = baseByteOffset + float(i);
|
|
60
|
+
result[i] = getByteValue(currentByteOffset);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fragColor = result;
|
|
64
|
+
}
|
|
65
|
+
`),n=this.gl.createProgram();return this.gl.attachShader(n,e),this.gl.attachShader(n,t),this.gl.linkProgram(n),n}createShader(e,t){let n=this.gl.createShader(e);return this.gl.shaderSource(n,t),this.gl.compileShader(n),this.gl.getShaderParameter(n,this.gl.COMPILE_STATUS)||console.error(`Shader compile error:`,this.gl.getShaderInfoLog(n)),n}createVAO(){let e=this.gl.createVertexArray();this.gl.bindVertexArray(e);let t=new Float32Array([-1,-1,0,1,1,-1,1,1,-1,1,0,0,1,1,1,0]),n=this.gl.createBuffer();this.gl.bindBuffer(this.gl.ARRAY_BUFFER,n),this.gl.bufferData(this.gl.ARRAY_BUFFER,t,this.gl.STATIC_DRAW);let r=this.gl.getAttribLocation(this.colorProgram,`a_position`),i=this.gl.getAttribLocation(this.colorProgram,`a_texCoord`);return this.gl.enableVertexAttribArray(r),this.gl.vertexAttribPointer(r,2,this.gl.FLOAT,!1,16,0),this.gl.enableVertexAttribArray(i),this.gl.vertexAttribPointer(i,2,this.gl.FLOAT,!1,16,8),e}createTexture(){let e=this.gl.createTexture();return this.gl.bindTexture(this.gl.TEXTURE_2D,e),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_S,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_WRAP_T,this.gl.CLAMP_TO_EDGE),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MIN_FILTER,this.gl.LINEAR),this.gl.texParameteri(this.gl.TEXTURE_2D,this.gl.TEXTURE_MAG_FILTER,this.gl.LINEAR),e}updateTexture(e){this.lastFrame!==e&&((e.displayWidth!==this.canvas.width||e.displayHeight!==this.canvas.height)&&(this.canvas.width=e.displayWidth,this.canvas.height=e.displayHeight),this.gl.activeTexture(this.gl.TEXTURE0),this.gl.bindTexture(this.gl.TEXTURE_2D,this.sourceTexture),this.gl.texImage2D(this.gl.TEXTURE_2D,0,this.gl.RGBA,this.gl.RGBA,this.gl.UNSIGNED_BYTE,e),this.lastFrame=e)}extractColor(e){return this.updateTexture(e),this.gl.useProgram(this.colorProgram),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4),new VideoFrame(this.canvas,{timestamp:e.timestamp,duration:e.duration??void 0,alpha:`discard`})}extractAlpha(e){this.updateTexture(e),this.gl.useProgram(this.alphaProgram),this.gl.uniform2f(this.alphaResolutionLocation,this.canvas.width,this.canvas.height),this.gl.viewport(0,0,this.canvas.width,this.canvas.height),this.gl.clear(this.gl.COLOR_BUFFER_BIT),this.gl.bindVertexArray(this.vao),this.gl.drawArrays(this.gl.TRIANGLE_STRIP,0,4);let{width:t,height:n}=this.canvas,r=Math.ceil(t/2)*Math.ceil(n/2),i=t*n+r*2,a=Math.ceil(i/(t*4)),o=new Uint8Array(4*t*a);this.gl.readPixels(0,0,t,a,this.gl.RGBA,this.gl.UNSIGNED_BYTE,o),o=o.subarray(0,i),u(o[t*n]===128),u(o[o.length-1]===128);let s={format:`I420`,codedWidth:t,codedHeight:n,timestamp:e.timestamp,duration:e.duration??void 0,transfer:[o.buffer]};return new VideoFrame(o,s)}close(){this.gl.getExtension(`WEBGL_lose_context`)?.loseContext(),this.gl=null}},jn=class extends On{constructor(e,t){if(!(typeof HTMLCanvasElement<`u`&&e instanceof HTMLCanvasElement)&&!(typeof OffscreenCanvas<`u`&&e instanceof OffscreenCanvas))throw TypeError(`canvas must be an HTMLCanvasElement or OffscreenCanvas.`);gn(t),super(t.codec),this._encoder=new kn(this,t),this._canvas=e}add(e,t=0,n){if(!Number.isFinite(e)||e<0)throw TypeError(`timestamp must be a non-negative number.`);if(!Number.isFinite(t)||t<0)throw TypeError(`duration must be a non-negative number.`);let r=new De(this._canvas,{timestamp:e,duration:t});return this._encoder.add(r,!0,n)}_flushAndClose(e){return this._encoder.flushAndClose(e)}},Mn=class extends Dn{constructor(e){if(super(),this._connectedTrack=null,!r.includes(e))throw TypeError(`Invalid audio codec '${e}'. Must be one of: ${r.join(`, `)}.`);this._codec=e}},Nn=class{constructor(e,t){this.source=e,this.encodingConfig=t,this.ensureEncoderPromise=null,this.encoderInitialized=!1,this.encoder=null,this.muxer=null,this.lastNumberOfChannels=null,this.lastSampleRate=null,this.isPcmEncoder=!1,this.outputSampleSize=null,this.writeOutputValue=null,this.customEncoder=null,this.customEncoderCallSerializer=new s,this.customEncoderQueueSize=0,this.lastEndSampleIndex=null,this.error=null,this.errorNeedsNewStack=!0}async add(e,t){try{if(this.checkForEncoderError(),this.source._ensureValidAdd(),this.lastNumberOfChannels!==null&&this.lastSampleRate!==null){if(e.numberOfChannels!==this.lastNumberOfChannels||e.sampleRate!==this.lastSampleRate)throw Error(`Audio parameters must remain constant. Expected ${this.lastNumberOfChannels} channels at ${this.lastSampleRate} Hz, got ${e.numberOfChannels} channels at ${e.sampleRate} Hz.`)}else this.lastNumberOfChannels=e.numberOfChannels,this.lastSampleRate=e.sampleRate;this.encoderInitialized||(this.ensureEncoderPromise||this.ensureEncoder(e),this.encoderInitialized||await this.ensureEncoderPromise),u(this.encoderInitialized);{let t=Math.round(e.timestamp*e.sampleRate),n=Math.round((e.timestamp+e.duration)*e.sampleRate);if(this.lastEndSampleIndex===null)this.lastEndSampleIndex=n;else{let n=t-this.lastEndSampleIndex;if(n>=64){let t=new ve({data:new Float32Array(n*e.numberOfChannels),format:`f32-planar`,sampleRate:e.sampleRate,numberOfChannels:e.numberOfChannels,numberOfFrames:n,timestamp:this.lastEndSampleIndex/e.sampleRate});await this.add(t,!0)}this.lastEndSampleIndex+=e.numberOfFrames}}if(this.customEncoder){this.customEncoderQueueSize++;let t=e.clone(),n=this.customEncoderCallSerializer.call(()=>this.customEncoder.encode(t)).then(()=>this.customEncoderQueueSize--).catch(e=>this.error??=e).finally(()=>{t.close()});this.customEncoderQueueSize>=4&&await n,await this.muxer.mutex.currentPromise}else if(this.isPcmEncoder)await this.doPcmEncoding(e,t);else{u(this.encoder);let n=e.toAudioData();this.encoder.encode(n),n.close(),t&&e.close(),this.encoder.encodeQueueSize>=4&&await new Promise(e=>this.encoder.addEventListener(`dequeue`,e,{once:!0})),await this.muxer.mutex.currentPromise}}finally{t&&e.close()}}async doPcmEncoding(e,t){u(this.outputSampleSize),u(this.writeOutputValue);let{numberOfChannels:n,numberOfFrames:r,sampleRate:i,timestamp:a}=e,o=2048,s=[];for(let t=0;t<r;t+=o){let r=Math.min(o,e.numberOfFrames-t),i=r*n*this.outputSampleSize,a=new ArrayBuffer(i),c=new DataView(a);s.push({frameCount:r,view:c})}let c=e.allocationSize({planeIndex:0,format:`f32-planar`}),l=new Float32Array(c/Float32Array.BYTES_PER_ELEMENT);for(let t=0;t<n;t++){e.copyTo(l,{planeIndex:t,format:`f32-planar`});for(let e=0;e<s.length;e++){let{frameCount:r,view:i}=s[e];for(let a=0;a<r;a++)this.writeOutputValue(i,(a*n+t)*this.outputSampleSize,l[e*o+a])}}t&&e.close();let d={decoderConfig:{codec:this.encodingConfig.codec,numberOfChannels:n,sampleRate:i}};for(let e=0;e<s.length;e++){let{frameCount:t,view:n}=s[e],r=n.buffer,c=e*o,l=new T(new Uint8Array(r),`key`,a+c/i,t/i);this.encodingConfig.onEncodedPacket?.(l,d),await this.muxer.addEncodedAudioPacket(this.source._connectedTrack,l,d)}}ensureEncoder(e){let t=Error();this.ensureEncoderPromise=(async()=>{let{numberOfChannels:n,sampleRate:r}=e,i=xn({numberOfChannels:n,sampleRate:r,...this.encodingConfig});this.encodingConfig.onEncoderConfig?.(i);let a=be.find(e=>e.supports(this.encodingConfig.codec,i));if(a)this.customEncoder=new a,this.customEncoder.codec=this.encodingConfig.codec,this.customEncoder.config=i,this.customEncoder.onPacket=(e,t)=>{if(!(e instanceof T))throw TypeError(`The first argument passed to onPacket must be an EncodedPacket.`);if(t!==void 0&&(!t||typeof t!=`object`))throw TypeError(`The second argument passed to onPacket must be an object or undefined.`);this.encodingConfig.onEncodedPacket?.(e,t),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,e,t).catch(e=>{this.error??=e,this.errorNeedsNewStack=!1})},await this.customEncoder.init();else if(b.includes(this.encodingConfig.codec))this.initPcmEncoder();else{if(typeof AudioEncoder>`u`)throw Error(`AudioEncoder is not supported by this browser.`);if(!(await AudioEncoder.isConfigSupported(i)).supported)throw Error(`This specific encoder configuration (${i.codec}, ${i.bitrate} bps, ${i.numberOfChannels} channels, ${i.sampleRate} Hz) is not supported by this browser. Consider using another codec or changing your audio parameters.`);this.encoder=new AudioEncoder({output:(e,t)=>{if(this.encodingConfig.codec===`aac`&&t?.decoderConfig){let e=!1;if(e=!t.decoderConfig.description||t.decoderConfig.description.byteLength<2?!0:o(C(t.decoderConfig.description)).objectType===0,e){let e=Number(E(i.codec.split(`.`)));t.decoderConfig.description=h({objectType:e,numberOfChannels:t.decoderConfig.numberOfChannels,sampleRate:t.decoderConfig.sampleRate})}}let n=T.fromEncodedChunk(e);this.encodingConfig.onEncodedPacket?.(n,t),this.muxer.addEncodedAudioPacket(this.source._connectedTrack,n,t).catch(e=>{this.error??=e,this.errorNeedsNewStack=!1})},error:e=>{e.stack=t.stack,this.error??=e}}),this.encoder.configure(i)}u(this.source._connectedTrack),this.muxer=this.source._connectedTrack.output._muxer,this.encoderInitialized=!0})()}initPcmEncoder(){this.isPcmEncoder=!0;let e=this.encodingConfig.codec,{dataType:t,sampleSize:n,littleEndian:r}=l(e);switch(this.outputSampleSize=n,n){case 1:t===`unsigned`?this.writeOutputValue=(e,t,n)=>e.setUint8(t,x((n+1)*127.5,0,255)):t===`signed`?this.writeOutputValue=(e,t,n)=>{e.setInt8(t,x(Math.round(n*128),-128,127))}:t===`ulaw`?this.writeOutputValue=(e,t,n)=>{let r=x(Math.floor(n*32767),-32768,32767);e.setUint8(t,de(r))}:t===`alaw`?this.writeOutputValue=(e,t,n)=>{let r=x(Math.floor(n*32767),-32768,32767);e.setUint8(t,le(r))}:u(!1);break;case 2:t===`unsigned`?this.writeOutputValue=(e,t,n)=>e.setUint16(t,x((n+1)*32767.5,0,65535),r):t===`signed`?this.writeOutputValue=(e,t,n)=>e.setInt16(t,x(Math.round(n*32767),-32768,32767),r):u(!1);break;case 3:t===`unsigned`?this.writeOutputValue=(e,t,n)=>Ce(e,t,x((n+1)*8388607.5,0,16777215),r):t===`signed`?this.writeOutputValue=(e,t,n)=>oe(e,t,x(Math.round(n*8388607),-8388608,8388607),r):u(!1);break;case 4:t===`unsigned`?this.writeOutputValue=(e,t,n)=>e.setUint32(t,x((n+1)*2147483647.5,0,4294967295),r):t===`signed`?this.writeOutputValue=(e,t,n)=>e.setInt32(t,x(Math.round(n*2147483647),-2147483648,2147483647),r):t===`float`?this.writeOutputValue=(e,t,n)=>e.setFloat32(t,n,r):u(!1);break;case 8:t===`float`?this.writeOutputValue=(e,t,n)=>e.setFloat64(t,n,r):u(!1);break;default:S(n),u(!1)}}async flushAndClose(e){e||this.checkForEncoderError(),this.customEncoder?(e||this.customEncoderCallSerializer.call(()=>this.customEncoder.flush()),await this.customEncoderCallSerializer.call(()=>this.customEncoder.close())):this.encoder&&(e||await this.encoder.flush(),this.encoder.state!==`closed`&&this.encoder.close()),e||this.checkForEncoderError()}getQueueSize(){return this.customEncoder?this.customEncoderQueueSize:this.isPcmEncoder?0:this.encoder?.encodeQueueSize??0}checkForEncoderError(){if(this.error)throw this.errorNeedsNewStack&&(this.error.stack=Error().stack),this.error}},Pn=class extends Mn{constructor(e){yn(e),super(e.codec),this._accumulatedTime=0,this._encoder=new Nn(this,e)}async add(e){if(!(e instanceof AudioBuffer))throw TypeError(`audioBuffer must be an AudioBuffer.`);let t=ve._fromAudioBuffer(e,this._accumulatedTime);this._accumulatedTime+=e.duration;for(let e of t)await this._encoder.add(e,!0)}_flushAndClose(e){return this._encoder.flushAndClose(e)}},Fn=class extends Dn{constructor(e){if(super(),this._connectedTrack=null,!a.includes(e))throw TypeError(`Invalid subtitle codec '${e}'. Must be one of: ${a.join(`, `)}.`);this._codec=e}},In=[`video`,`audio`,`subtitle`],Ln=e=>{if(!e||typeof e!=`object`)throw TypeError(`metadata must be an object.`);if(e.languageCode!==void 0&&!ue(e.languageCode))throw TypeError(`metadata.languageCode, when provided, must be a three-letter, ISO 639-2/T language code.`);if(e.name!==void 0&&typeof e.name!=`string`)throw TypeError(`metadata.name, when provided, must be a string.`);if(e.disposition!==void 0&&c(e.disposition),e.maximumPacketCount!==void 0&&(!Number.isInteger(e.maximumPacketCount)||e.maximumPacketCount<0))throw TypeError(`metadata.maximumPacketCount, when provided, must be a non-negative integer.`)},Rn=class{constructor(e){if(this.state=`pending`,this._tracks=[],this._startPromise=null,this._cancelPromise=null,this._finalizePromise=null,this._mutex=new ee,this._metadataTags={},!e||typeof e!=`object`)throw TypeError(`options must be an object.`);if(!(e.format instanceof fn))throw TypeError(`options.format must be an OutputFormat.`);if(!(e.target instanceof on))throw TypeError(`options.target must be a Target.`);if(e.target._output)throw Error(`Target is already used for another output.`);e.target._output=this,this.format=e.format,this.target=e.target,this._writer=e.target._createWriter(),this._muxer=e.format._createMuxer(this)}addVideoTrack(e,t={}){if(!(e instanceof On))throw TypeError(`source must be a VideoSource.`);if(Ln(t),t.rotation!==void 0&&![0,90,180,270].includes(t.rotation))throw TypeError(`Invalid video rotation: ${t.rotation}. Has to be 0, 90, 180 or 270.`);if(!this.format.supportsVideoRotationMetadata&&t.rotation)throw Error(`${this.format._name} does not support video rotation metadata.`);if(t.frameRate!==void 0&&(!Number.isFinite(t.frameRate)||t.frameRate<=0))throw TypeError(`Invalid video frame rate: ${t.frameRate}. Must be a positive number.`);this._addTrack(`video`,e,t)}addAudioTrack(e,t={}){if(!(e instanceof Mn))throw TypeError(`source must be an AudioSource.`);Ln(t),this._addTrack(`audio`,e,t)}addSubtitleTrack(e,t={}){if(!(e instanceof Fn))throw TypeError(`source must be a SubtitleSource.`);Ln(t),this._addTrack(`subtitle`,e,t)}setMetadataTags(e){if(te(e),this.state!==`pending`)throw Error(`Cannot set metadata tags after output has been started or canceled.`);this._metadataTags=e}_addTrack(e,t,n){if(this.state!==`pending`)throw Error(`Cannot add track after output has been started or canceled.`);if(t._connectedTrack)throw Error(`Source is already used for a track.`);let r=this.format.getSupportedTrackCounts(),i=this._tracks.reduce((t,n)=>t+ +(n.type===e),0),a=r[e].max;if(i===a)throw Error(a===0?`${this.format._name} does not support ${e} tracks.`:`${this.format._name} does not support more than ${a} ${e} track${a===1?``:`s`}.`);let o=r.total.max;if(this._tracks.length===o)throw Error(`${this.format._name} does not support more than ${o} tracks${o===1?``:`s`} in total.`);let s={id:this._tracks.length+1,output:this,type:e,source:t,metadata:n};if(s.type===`video`){let e=this.format.getSupportedVideoCodecs();if(e.length===0)throw Error(`${this.format._name} does not support video tracks.`+this.format._codecUnsupportedHint(s.source._codec));if(!e.includes(s.source._codec))throw Error(`Codec '${s.source._codec}' cannot be contained within ${this.format._name}. Supported video codecs are: ${e.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(s.source._codec))}else if(s.type===`audio`){let e=this.format.getSupportedAudioCodecs();if(e.length===0)throw Error(`${this.format._name} does not support audio tracks.`+this.format._codecUnsupportedHint(s.source._codec));if(!e.includes(s.source._codec))throw Error(`Codec '${s.source._codec}' cannot be contained within ${this.format._name}. Supported audio codecs are: ${e.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(s.source._codec))}else if(s.type===`subtitle`){let e=this.format.getSupportedSubtitleCodecs();if(e.length===0)throw Error(`${this.format._name} does not support subtitle tracks.`+this.format._codecUnsupportedHint(s.source._codec));if(!e.includes(s.source._codec))throw Error(`Codec '${s.source._codec}' cannot be contained within ${this.format._name}. Supported subtitle codecs are: ${e.map(e=>`'${e}'`).join(`, `)}.`+this.format._codecUnsupportedHint(s.source._codec))}this._tracks.push(s),t._connectedTrack=s}async start(){let e=this.format.getSupportedTrackCounts();for(let t of In){let n=this._tracks.reduce((e,n)=>e+ +(n.type===t),0),r=e[t].min;if(n<r)throw Error(r===e[t].max?`${this.format._name} requires exactly ${r} ${t} track${r===1?``:`s`}.`:`${this.format._name} requires at least ${r} ${t} track${r===1?``:`s`}.`)}let t=e.total.min;if(this._tracks.length<t)throw Error(t===e.total.max?`${this.format._name} requires exactly ${t} track${t===1?``:`s`}.`:`${this.format._name} requires at least ${t} track${t===1?``:`s`}.`);if(this.state===`canceled`)throw Error(`Output has been canceled.`);return this._startPromise?(console.warn(`Output has already been started.`),this._startPromise):this._startPromise=(async()=>{this.state=`started`,this._writer.start();let e=await this._mutex.acquire();await this._muxer.start();let t=this._tracks.map(e=>e.source._start());await Promise.all(t),e()})()}getMimeType(){return this._muxer.getMimeType()}async cancel(){if(this._cancelPromise)return console.warn(`Output has already been canceled.`),this._cancelPromise;if(this.state===`finalizing`||this.state===`finalized`){console.warn(`Output has already been finalized.`);return}return this._cancelPromise=(async()=>{this.state=`canceled`;let e=await this._mutex.acquire(),t=this._tracks.map(e=>e.source._flushOrWaitForOngoingClose(!0));await Promise.all(t),await this._writer.close(),e()})()}async finalize(){if(this.state===`pending`)throw Error(`Cannot finalize before starting.`);if(this.state===`canceled`)throw Error(`Cannot finalize after canceling.`);return this._finalizePromise?(console.warn(`Output has already been finalized.`),this._finalizePromise):this._finalizePromise=(async()=>{this.state=`finalizing`;let e=await this._mutex.acquire(),t=this._tracks.map(e=>e.source._flushOrWaitForOngoingClose(!1));await Promise.all(t),await this._muxer.finalize(),await this._writer.flush(),await this._writer.finalize(),this.state=`finalized`,e()})()}};function Z(){try{if(typeof DOMException<`u`)return new DOMException(`The operation was aborted.`,`AbortError`);throw Error(`DOMException is not available`)}catch{let e=Error(`The operation was aborted.`);return e.name=`AbortError`,e}}function Q(e){return!!e&&typeof e==`object`&&`name`in e&&e.name===`AbortError`}function $(e){if(e?.aborted)throw Z()}function zn(e){return Math.round(e/2)*2}function Bn(e){return e.pages.reduce((e,t)=>e+(t.duration||5e3),0)}function Vn(e){let t=0;return e.pages.map(e=>{let n=t,r=e.duration||5e3;return t=n+r,{id:e.id,startTime:n,duration:r}})}function Hn(e){let t=e.width,n=e.height;for(let r of e.pages){let i=r.width===`auto`?e.width:r.width,a=r.height===`auto`?e.height:r.height;t=Math.max(t,i),n=Math.max(n,a)}return{width:zn(t),height:zn(n)}}function Un(e){let t=[],n=0;for(let r of e.pages){let e=r.duration||5e3;for(let i of r.children)if(i.type===`video`){let r=i.volume===void 0?1:i.volume;if(r===0)continue;let a=i.startTime||0,o=i.endTime||1,s=i.duration||5e3;t.push({id:i.id,src:i.src,volume:r,startTime:a,endTime:o,duration:s,pageStartTime:n,pageDuration:e})}n+=e}return t}function Wn(e,t){let n=[];for(let r of e.pages)n.push({pageId:r.id,width:r.width,height:r.height}),r.set({width:t.width,height:t.height});return n}function Gn(e,t){for(let{pageId:n,width:r,height:i}of t){let t=e.pages.find(e=>e.id===n);t&&t.set({width:r,height:i})}}function Kn(e,t){let n=ye(),r=n.sceneCanvas._canvas;if(r.width=e.width*t,r.height=e.height*t,r.width<=0||r.height<=0)throw Error(`Invalid canvas dimensions: ${r.width}x${r.height}`);return{canvas:r,canvases:n}}async function qn(e,t){let n=new Rn({target:new sn,format:new mn}),r=await Tn(n.format.getSupportedVideoCodecs(),{width:e.width,height:e.height});if(!r)throw Error(`Your browser doesn't support video encoding.`);let i=new jn(e,{codec:r,bitrate:Sn});return n.addVideoTrack(i,{frameRate:t}),{output:n,canvasSource:i}}async function Jn(e,t,n){if(!n)return{audioBufferSource:null};let r=t.audios&&t.audios.length>0,i=Un(t).length>0;if(!r&&!i)return{audioBufferSource:null};let a=e.format.getSupportedAudioCodecs(),o=[`aac`,`mp3`,`flac`],s=[...o.filter(e=>a.includes(e)),...a.filter(e=>!o.includes(e))],c=await En(s,{numberOfChannels:2,sampleRate:44100});if(!c)return console.warn(`[polotno-video-export] Browser doesn't support audio encoding, video will be generated without audio. Tried codecs: `+s.join(`, `)),{audioBufferSource:null};let l=new Pn({codec:c,bitrate:Sn});return e.addAudioTrack(l),{audioBufferSource:l,audioCodec:c}}function Yn(e,t,n){let r=t[n];return r&&e>=r.startTime&&e<r.startTime+r.duration?n:t.findIndex(t=>e>=t.startTime&&e<t.startTime+t.duration)}async function Xn(e,t,n,r,i){e.setCurrentTime(t),await e._toCanvas({pixelRatio:r,pageId:e.pages[n]?.id,_skipTimeout:!0,_exportCanvases:i})}async function Zn(e,t,n,r,i,a,o,s,c){let l=1e3/a,u=Math.floor(i/1e3*a)||1;try{$(c),e.setElementsPixelRatio(o);let d=-1,f=0;for(let p=0;p<u;p++){$(c);let m=Date.now(),h=p/a,g=1/a,_=h*1e3;p===0&&(_=1),p===u-1&&(_=Math.min(i-1,(p+1)*l-1));let v=Yn(_,r,d);if(v!==d&&v>=0&&(e.activePage.set({_rendering:!1}),e.selectPage(e.pages[v].id),e.activePage.set({_rendering:!0}),await e.waitLoading(),$(c),d=v),await Xn(e,_,v,o,n),$(c),await t.add(h,g),s){let e=Date.now();if(p===u-1||e-f>=300){let t=e-m;s((p+1)/u*.95,t),f=e}}}}finally{e.pages.forEach(e=>{e.set({_rendering:!1})}),e.setCurrentTime(0)}}async function Qn(e,t){let n=await fetch(e,t?{signal:t}:void 0);if(!n.ok)throw Error(`Failed to download audio from ${e}`);return n.arrayBuffer()}async function $n(e,t){return e.decodeAudioData(t)}function er(e){return e.startsWith(`data:`)}function tr(e){return e.startsWith(`file://`)}function nr(e){return e.startsWith(`http://`)||e.startsWith(`https://`)}function rr(e){let t=e.split(`,`)[1],n=atob(t),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return r.buffer}async function ir(e,t){try{return nr(e)?new xe({source:new me(e),formats:w}):er(e)?new xe({source:new Te(rr(e)),formats:w}):(tr(e),new xe({source:new Te(await(await fetch(e,t?{signal:t}:void 0)).arrayBuffer()),formats:w}))}catch(n){return Q(n)||t?.aborted||console.error(`Failed to create input from ${e.slice(0,50)}:`,n),null}}async function ar(e,t){try{$(t);let n=await ir(e,t);if(!n)return console.log(`[polotno-video-export] checkVideoAudio: createInputFromSource returned null for ${e.slice(0,80)}`),{hasAudio:!1,input:null};let r=await n.getAudioTracks();if(t?.aborted)throw n.dispose(),Z();return r.length===0?(n.dispose(),{hasAudio:!1,input:null}):{hasAudio:!0,input:n}}catch(n){if(Q(n))throw n;if(t?.aborted)throw Z();return console.error(`Failed to check audio for ${e.slice(0,50)}:`,n),{hasAudio:!1,input:null}}}function or(e,t){let n=e.audios||[],r=Un(e);return{storeAudios:n.map(e=>({audio:e,bufferPromise:Qn(e.src,t).catch(n=>(Q(n)||t?.aborted||console.error(`Failed to download audio ${e.src}:`,n),null))})),videoAudios:r.map(e=>({video:e,inputPromise:ar(e.src,t).catch(e=>{if(Q(e)||t?.aborted)return{hasAudio:!1,input:null};throw e})}))}}function sr(e,t,n){let r=(e.delay||0)/1e3,i=e.volume===void 0?1:e.volume,a=e.startTime||0,o=e.endTime||1,s=e.duration||n.totalDuration,c=a*s/1e3,l=s*(o-a)/1e3,u=r,d=c,f=Math.min(l,t.duration-c);if(u<0&&(d+=Math.abs(u),f-=Math.abs(u),u=0),f<=0||d>=t.duration)return;let p=n.offlineContext.createBufferSource();p.buffer=t;let m=n.offlineContext.createGain();m.gain.value=i,p.connect(m),m.connect(n.offlineContext.destination),p.start(u,d,f)}function cr(e,t,n){let r=e.startTime*e.duration/1e3,i=e.duration*(e.endTime-e.startTime)/1e3,a=e.pageStartTime/1e3,o=Math.max(0,a),s=Math.max(0,r),c=Math.min(i,t.duration-s,e.pageDuration/1e3);if(c<=0||s>=t.duration)return;let l=n.offlineContext.createBufferSource();l.buffer=t;let u=n.offlineContext.createGain();u.gain.value=e.volume,l.connect(u),u.connect(n.offlineContext.destination),l.start(o,s,c)}async function lr(e,t,n,r,i,a,o){$(o);let s=i||or(e,o);if(s.storeAudios.length+s.videoAudios.length===0)return;let c=44100,l=typeof r==`string`?r:typeof r?.codec==`string`?r.codec:void 0,u=l?.includes(`opus`)?960:1024,d=l===`aac`?3:l?.includes(`opus`)?2:0,f=Math.floor(n/1e3*c),p=Math.floor(f/u)*u,m=d*u,h=Math.max(u,p-m),g=new OfflineAudioContext(2,h,c),_={offlineContext:g,sampleRate:c,totalDuration:n};a?.(.95);let[v,y]=await Promise.all([Promise.all(s.storeAudios.map(async({audio:e,bufferPromise:t})=>{try{$(o);let n=await t;return $(o),n?{audio:e,audioBuffer:await $n(g,n)}:null}catch(t){if(Q(t))throw t;return console.error(`Failed to process audio ${e.src}:`,t),null}})),Promise.all(s.videoAudios.map(async({video:e,inputPromise:t})=>{try{$(o);let{hasAudio:n,input:r}=await t;if($(o),!n||!r)return console.log(`[polotno-video-export] Video ${e.id} has no audio track or input failed. hasAudio=${n}, input=${!!r}`),null;let i=await r.getPrimaryAudioTrack();if(!i)return console.log(`[polotno-video-export] Video ${e.id} getPrimaryAudioTrack returned null`),r.dispose(),null;let a=new ce(i),s=[];for await(let e of a.buffers())$(o),s.push(e.buffer);if(r.dispose(),$(o),s.length===0)return console.log(`[polotno-video-export] Video ${e.id} AudioBufferSink returned 0 buffers`),null;let c=s.reduce((e,t)=>e+t.length,0),l=g.createBuffer(s[0].numberOfChannels,c,s[0].sampleRate),u=0;for(let e of s){for(let t=0;t<e.numberOfChannels;t++)l.getChannelData(t).set(e.getChannelData(t),u);u+=e.length}return{video:e,audioBuffer:l}}catch(t){if(Q(t))throw t;return console.error(`Failed to extract video audio ${e.src}:`,t),null}}))]);a?.(.97),$(o);for(let e of v)e&&sr(e.audio,e.audioBuffer,_);for(let e of y)e&&cr(e.video,e.audioBuffer,_);$(o);let b=await g.startRendering();a?.(.99),$(o),await t.add(b)}async function ur({store:e,fps:t=30,pixelRatio:n=1,onProgress:r,includeAudio:i=!0,signal:a}){let o=Hn(e),s=Wn(e,o),c=null,l=null,u=null,d=null,f=!1;if(a){$(a);let e=()=>{try{l?.close()}catch{}try{u?.close()}catch{}c?.cancel().catch(()=>{})};a.addEventListener(`abort`,e,{once:!0}),d=()=>a.removeEventListener(`abort`,e)}try{$(a);let s=Bn(e);if(s===0)throw Error(`Video duration is 0`);let d=Vn(e),{canvas:p,canvases:m}=Kn(o,n),h=await qn(p,t);c=h.output,l=h.canvasSource;let g=await Jn(c,e,i);u=g.audioBufferSource||null;let _=g.audioCodec;$(a),await c.start(),await Zn(e,l,m,d,s,t,n,r,a),l.close();let v=u?or(e,a):null;u&&v&&(await lr(e,u,s,_,v,r,a),u.close()),$(a),await c.finalize();let y=c.target,b=new Blob([y.buffer],{type:c.format.mimeType});return f=!0,b}catch(e){throw Q(e)?e:a?.aborted?Z():e}finally{if(d?.(),!f&&c)try{await c.cancel()}catch{}Gn(e,s)}}export{ur as storeToVideo};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
function e(e,t){(t==null||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function t(e){if(Array.isArray(e))return e}function n(e,t){var n=e==null?null:typeof Symbol<`u`&&e[Symbol.iterator]||e[`@@iterator`];if(n!=null){var r,i,a,o,s=[],c=!0,l=!1;try{if(a=(n=n.call(e)).next,t!==0)for(;!(c=(r=a.call(n)).done)&&(s.push(r.value),s.length!==t);c=!0);}catch(e){l=!0,i=e}finally{try{if(!c&&n.return!=null&&(o=n.return(),Object(o)!==o))return}finally{if(l)throw i}}return s}}function r(){throw TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
2
|
+
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function i(e,i){return t(e)||n(e,i)||a(e,i)||r()}function a(t,n){if(t){if(typeof t==`string`)return e(t,n);var r={}.toString.call(t).slice(8,-1);return r===`Object`&&t.constructor&&(r=t.constructor.name),r===`Map`||r===`Set`?Array.from(t):r===`Arguments`||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?e(t,n):void 0}}var o=Object.entries,s=Object.setPrototypeOf,c=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,d=Object.freeze,f=Object.seal,p=Object.create,ee=typeof Reflect<`u`&&Reflect,te=ee.apply,ne=ee.construct;d||=function(e){return e},f||=function(e){return e},te||=function(e,t){var n=[...arguments].slice(2);return e.apply(t,n)},ne||=function(e){return new e(...[...arguments].slice(1))};var m=w(Array.prototype.forEach),re=w(Array.prototype.lastIndexOf),ie=w(Array.prototype.pop),h=w(Array.prototype.push),ae=w(Array.prototype.splice),g=Array.isArray,_=w(String.prototype.toLowerCase),oe=w(String.prototype.toString),se=w(String.prototype.match),v=w(String.prototype.replace),ce=w(String.prototype.indexOf),le=w(String.prototype.trim),y=w(Number.prototype.toString),b=w(Boolean.prototype.toString),ue=typeof BigInt>`u`?null:w(BigInt.prototype.toString),de=typeof Symbol>`u`?null:w(Symbol.prototype.toString),x=w(Object.prototype.hasOwnProperty),S=w(Object.prototype.toString),C=w(RegExp.prototype.test),fe=T(TypeError);function w(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);var n=[...arguments].slice(1);return te(e,t,n)}}function T(e){return function(){return ne(e,[...arguments])}}function E(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:_;if(s&&s(e,null),!g(t))return e;let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(c(t)||(t[r]=e),i=e)}e[i]=!0}return e}function D(e){for(let t=0;t<e.length;t++)x(e,t)||(e[t]=null);return e}function O(e){let t=p(null);for(let r of o(e)){var n=i(r,2);let a=n[0],o=n[1];x(e,a)&&(g(o)?t[a]=D(o):o&&typeof o==`object`&&o.constructor===Object?t[a]=O(o):t[a]=o)}return t}function pe(e){switch(typeof e){case`string`:return e;case`number`:return y(e);case`boolean`:return b(e);case`bigint`:return ue?ue(e):`0`;case`symbol`:return de?de(e):`Symbol()`;case`undefined`:return S(e);case`function`:case`object`:{if(e===null)return S(e);let t=e,n=k(t,`toString`);if(typeof n==`function`){let e=n(t);return typeof e==`string`?e:S(e)}return S(e)}default:return S(e)}}function k(e,t){for(;e!==null;){let n=u(e,t);if(n){if(n.get)return w(n.get);if(typeof n.value==`function`)return w(n.value)}e=l(e)}function n(){return null}return n}function me(e){try{return C(e,``),!0}catch{return!1}}var he=d(`a.abbr.acronym.address.area.article.aside.audio.b.bdi.bdo.big.blink.blockquote.body.br.button.canvas.caption.center.cite.code.col.colgroup.content.data.datalist.dd.decorator.del.details.dfn.dialog.dir.div.dl.dt.element.em.fieldset.figcaption.figure.font.footer.form.h1.h2.h3.h4.h5.h6.head.header.hgroup.hr.html.i.img.input.ins.kbd.label.legend.li.main.map.mark.marquee.menu.menuitem.meter.nav.nobr.ol.optgroup.option.output.p.picture.pre.progress.q.rp.rt.ruby.s.samp.search.section.select.shadow.slot.small.source.spacer.span.strike.strong.style.sub.summary.sup.table.tbody.td.template.textarea.tfoot.th.thead.time.tr.track.tt.u.ul.var.video.wbr`.split(`.`)),ge=d(`svg.a.altglyph.altglyphdef.altglyphitem.animatecolor.animatemotion.animatetransform.circle.clippath.defs.desc.ellipse.enterkeyhint.exportparts.filter.font.g.glyph.glyphref.hkern.image.inputmode.line.lineargradient.marker.mask.metadata.mpath.part.path.pattern.polygon.polyline.radialgradient.rect.stop.style.switch.symbol.text.textpath.title.tref.tspan.view.vkern`.split(`.`)),_e=d([`feBlend`,`feColorMatrix`,`feComponentTransfer`,`feComposite`,`feConvolveMatrix`,`feDiffuseLighting`,`feDisplacementMap`,`feDistantLight`,`feDropShadow`,`feFlood`,`feFuncA`,`feFuncB`,`feFuncG`,`feFuncR`,`feGaussianBlur`,`feImage`,`feMerge`,`feMergeNode`,`feMorphology`,`feOffset`,`fePointLight`,`feSpecularLighting`,`feSpotLight`,`feTile`,`feTurbulence`]),ve=d([`animate`,`color-profile`,`cursor`,`discard`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`foreignobject`,`hatch`,`hatchpath`,`mesh`,`meshgradient`,`meshpatch`,`meshrow`,`missing-glyph`,`script`,`set`,`solidcolor`,`unknown`,`use`]),ye=d(`math.menclose.merror.mfenced.mfrac.mglyph.mi.mlabeledtr.mmultiscripts.mn.mo.mover.mpadded.mphantom.mroot.mrow.ms.mspace.msqrt.mstyle.msub.msup.msubsup.mtable.mtd.mtext.mtr.munder.munderover.mprescripts`.split(`.`)),be=d([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),xe=d([`#text`]),Se=d(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.controls.controlslist.coords.crossorigin.datetime.decoding.default.dir.disabled.disablepictureinpicture.disableremoteplayback.download.draggable.enctype.enterkeyhint.exportparts.face.for.headers.height.hidden.high.href.hreflang.id.inert.inputmode.integrity.ismap.kind.label.lang.list.loading.loop.low.max.maxlength.media.method.min.minlength.multiple.muted.name.nonce.noshade.novalidate.nowrap.open.optimum.part.pattern.placeholder.playsinline.popover.popovertarget.popovertargetaction.poster.preload.pubdate.radiogroup.readonly.rel.required.rev.reversed.role.rows.rowspan.spellcheck.scope.selected.shape.size.sizes.slot.span.srclang.start.src.srcset.step.style.summary.tabindex.title.translate.type.usemap.valign.value.width.wrap.xmlns`.split(`.`)),Ce=d(`accent-height.accumulate.additive.alignment-baseline.amplitude.ascent.attributename.attributetype.azimuth.basefrequency.baseline-shift.begin.bias.by.class.clip.clippathunits.clip-path.clip-rule.color.color-interpolation.color-interpolation-filters.color-profile.color-rendering.cx.cy.d.dx.dy.diffuseconstant.direction.display.divisor.dur.edgemode.elevation.end.exponent.fill.fill-opacity.fill-rule.filter.filterunits.flood-color.flood-opacity.font-family.font-size.font-size-adjust.font-stretch.font-style.font-variant.font-weight.fx.fy.g1.g2.glyph-name.glyphref.gradientunits.gradienttransform.height.href.id.image-rendering.in.in2.intercept.k.k1.k2.k3.k4.kerning.keypoints.keysplines.keytimes.lang.lengthadjust.letter-spacing.kernelmatrix.kernelunitlength.lighting-color.local.marker-end.marker-mid.marker-start.markerheight.markerunits.markerwidth.maskcontentunits.maskunits.max.mask.mask-type.media.method.mode.min.name.numoctaves.offset.operator.opacity.order.orient.orientation.origin.overflow.paint-order.path.pathlength.patterncontentunits.patterntransform.patternunits.points.preservealpha.preserveaspectratio.primitiveunits.r.rx.ry.radius.refx.refy.repeatcount.repeatdur.restart.result.rotate.scale.seed.shape-rendering.slope.specularconstant.specularexponent.spreadmethod.startoffset.stddeviation.stitchtiles.stop-color.stop-opacity.stroke-dasharray.stroke-dashoffset.stroke-linecap.stroke-linejoin.stroke-miterlimit.stroke-opacity.stroke.stroke-width.style.surfacescale.systemlanguage.tabindex.tablevalues.targetx.targety.transform.transform-origin.text-anchor.text-decoration.text-rendering.textlength.type.u1.u2.unicode.values.viewbox.visibility.version.vert-adv-y.vert-origin-x.vert-origin-y.width.word-spacing.wrap.writing-mode.xchannelselector.ychannelselector.x.x1.x2.xmlns.y.y1.y2.z.zoomandpan`.split(`.`)),we=d(`accent.accentunder.align.bevelled.close.columnalign.columnlines.columnspacing.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lquote.lspace.mathbackground.mathcolor.mathsize.mathvariant.maxsize.minsize.movablelimits.notation.numalign.open.rowalign.rowlines.rowspacing.rowspan.rspace.rquote.scriptlevel.scriptminsize.scriptsizemultiplier.selection.separator.separators.stretchy.subscriptshift.supscriptshift.symmetric.voffset.width.xmlns`.split(`.`)),Te=d([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ee=f(/{{[\w\W]*|^[\w\W]*}}/g),De=f(/<%[\w\W]*|^[\w\W]*%>/g),Oe=f(/\${[\w\W]*/g),ke=f(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ae=f(/^aria-[\-\w]+$/),je=f(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Me=f(/^(?:\w+script|data):/i),Ne=f(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pe=f(/^html$/i),Fe=f(/^[a-z][.\w]*(-[.\w]+)+$/i),A={element:1,text:3,progressingInstruction:7,comment:8,document:9},Ie=function(){return typeof window>`u`?null:window},Le=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Re=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function ze(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Ie(),t=e=>ze(e);if(t.version=`3.4.3`,t.removed=[],!e||!e.document||e.document.nodeType!==A.document||!e.Element)return t.isSupported=!1,t;let n=e.document,r=n,i=r.currentScript,a=e.DocumentFragment,s=e.HTMLTemplateElement,c=e.Node,l=e.Element,u=e.NodeFilter,f=e.NamedNodeMap,ee=f===void 0?e.NamedNodeMap||e.MozNamedAttrMap:f,te=e.HTMLFormElement,ne=e.DOMParser,y=e.trustedTypes,b=l.prototype,ue=k(b,`cloneNode`),de=k(b,`remove`),S=k(b,`nextSibling`),w=k(b,`childNodes`),T=k(b,`parentNode`);if(typeof s==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let D,j=``,Be=n,Ve=Be.implementation,He=Be.createNodeIterator,Ue=Be.createDocumentFragment,We=Be.getElementsByTagName,Ge=r.importNode,M=Re();t.isSupported=typeof o==`function`&&typeof T==`function`&&Ve&&Ve.createHTMLDocument!==void 0;let Ke=Ee,qe=De,Je=Oe,Ye=ke,Xe=Ae,Ze=Me,Qe=Ne,$e=Fe,et=je,N=null,tt=E({},[...he,...ge,..._e,...ye,...xe]),P=null,nt=E({},[...Se,...Ce,...we,...Te]),F=Object.seal(p(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),I=null,L=null,R=Object.seal(p(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),rt=!0,it=!0,at=!1,ot=!0,z=!1,B=!0,V=!1,st=!1,ct=!1,H=!1,lt=!1,ut=!1,dt=!0,ft=!1,pt=`user-content-`,mt=!0,U=!1,W={},G=null,ht=E({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),gt=null,_t=E({},[`audio`,`video`,`img`,`source`,`image`,`track`]),vt=null,yt=E({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),bt=`http://www.w3.org/1998/Math/MathML`,xt=`http://www.w3.org/2000/svg`,K=`http://www.w3.org/1999/xhtml`,q=K,St=!1,Ct=null,wt=E({},[bt,xt,K],oe),Tt=E({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Et=E({},[`annotation-xml`]),Dt=E({},[`title`,`style`,`font`,`a`,`script`]),J=null,Ot=[`application/xhtml+xml`,`text/html`],Y=null,X=null,kt=n.createElement(`form`),At=function(e){return e instanceof RegExp||e instanceof Function},jt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(X&&X===e)return;(!e||typeof e!=`object`)&&(e={}),e=O(e),J=Ot.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,Y=J===`application/xhtml+xml`?oe:_,N=x(e,`ALLOWED_TAGS`)&&g(e.ALLOWED_TAGS)?E({},e.ALLOWED_TAGS,Y):tt,P=x(e,`ALLOWED_ATTR`)&&g(e.ALLOWED_ATTR)?E({},e.ALLOWED_ATTR,Y):nt,Ct=x(e,`ALLOWED_NAMESPACES`)&&g(e.ALLOWED_NAMESPACES)?E({},e.ALLOWED_NAMESPACES,oe):wt,vt=x(e,`ADD_URI_SAFE_ATTR`)&&g(e.ADD_URI_SAFE_ATTR)?E(O(yt),e.ADD_URI_SAFE_ATTR,Y):yt,gt=x(e,`ADD_DATA_URI_TAGS`)&&g(e.ADD_DATA_URI_TAGS)?E(O(_t),e.ADD_DATA_URI_TAGS,Y):_t,G=x(e,`FORBID_CONTENTS`)&&g(e.FORBID_CONTENTS)?E({},e.FORBID_CONTENTS,Y):ht,I=x(e,`FORBID_TAGS`)&&g(e.FORBID_TAGS)?E({},e.FORBID_TAGS,Y):O({}),L=x(e,`FORBID_ATTR`)&&g(e.FORBID_ATTR)?E({},e.FORBID_ATTR,Y):O({}),W=x(e,`USE_PROFILES`)?e.USE_PROFILES&&typeof e.USE_PROFILES==`object`?O(e.USE_PROFILES):e.USE_PROFILES:!1,rt=e.ALLOW_ARIA_ATTR!==!1,it=e.ALLOW_DATA_ATTR!==!1,at=e.ALLOW_UNKNOWN_PROTOCOLS||!1,ot=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,z=e.SAFE_FOR_TEMPLATES||!1,B=e.SAFE_FOR_XML!==!1,V=e.WHOLE_DOCUMENT||!1,H=e.RETURN_DOM||!1,lt=e.RETURN_DOM_FRAGMENT||!1,ut=e.RETURN_TRUSTED_TYPE||!1,ct=e.FORCE_BODY||!1,dt=e.SANITIZE_DOM!==!1,ft=e.SANITIZE_NAMED_PROPS||!1,mt=e.KEEP_CONTENT!==!1,U=e.IN_PLACE||!1,et=me(e.ALLOWED_URI_REGEXP)?e.ALLOWED_URI_REGEXP:je,q=typeof e.NAMESPACE==`string`?e.NAMESPACE:K,Tt=x(e,`MATHML_TEXT_INTEGRATION_POINTS`)&&e.MATHML_TEXT_INTEGRATION_POINTS&&typeof e.MATHML_TEXT_INTEGRATION_POINTS==`object`?O(e.MATHML_TEXT_INTEGRATION_POINTS):E({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Et=x(e,`HTML_INTEGRATION_POINTS`)&&e.HTML_INTEGRATION_POINTS&&typeof e.HTML_INTEGRATION_POINTS==`object`?O(e.HTML_INTEGRATION_POINTS):E({},[`annotation-xml`]);let t=x(e,`CUSTOM_ELEMENT_HANDLING`)&&e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING==`object`?O(e.CUSTOM_ELEMENT_HANDLING):p(null);if(F=p(null),x(t,`tagNameCheck`)&&At(t.tagNameCheck)&&(F.tagNameCheck=t.tagNameCheck),x(t,`attributeNameCheck`)&&At(t.attributeNameCheck)&&(F.attributeNameCheck=t.attributeNameCheck),x(t,`allowCustomizedBuiltInElements`)&&typeof t.allowCustomizedBuiltInElements==`boolean`&&(F.allowCustomizedBuiltInElements=t.allowCustomizedBuiltInElements),z&&(it=!1),lt&&(H=!0),W&&(N=E({},xe),P=p(null),W.html===!0&&(E(N,he),E(P,Se)),W.svg===!0&&(E(N,ge),E(P,Ce),E(P,Te)),W.svgFilters===!0&&(E(N,_e),E(P,Ce),E(P,Te)),W.mathMl===!0&&(E(N,ye),E(P,we),E(P,Te))),R.tagCheck=null,R.attributeCheck=null,x(e,`ADD_TAGS`)&&(typeof e.ADD_TAGS==`function`?R.tagCheck=e.ADD_TAGS:g(e.ADD_TAGS)&&(N===tt&&(N=O(N)),E(N,e.ADD_TAGS,Y))),x(e,`ADD_ATTR`)&&(typeof e.ADD_ATTR==`function`?R.attributeCheck=e.ADD_ATTR:g(e.ADD_ATTR)&&(P===nt&&(P=O(P)),E(P,e.ADD_ATTR,Y))),x(e,`ADD_URI_SAFE_ATTR`)&&g(e.ADD_URI_SAFE_ATTR)&&E(vt,e.ADD_URI_SAFE_ATTR,Y),x(e,`FORBID_CONTENTS`)&&g(e.FORBID_CONTENTS)&&(G===ht&&(G=O(G)),E(G,e.FORBID_CONTENTS,Y)),x(e,`ADD_FORBID_CONTENTS`)&&g(e.ADD_FORBID_CONTENTS)&&(G===ht&&(G=O(G)),E(G,e.ADD_FORBID_CONTENTS,Y)),mt&&(N[`#text`]=!0),V&&E(N,[`html`,`head`,`body`]),N.table&&(E(N,[`tbody`]),delete I.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw fe(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw fe(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);D=e.TRUSTED_TYPES_POLICY,j=D.createHTML(``)}else D===void 0&&(D=Le(y,i)),D!==null&&typeof j==`string`&&(j=D.createHTML(``));d&&d(e),X=e},Mt=E({},[...ge,..._e,...ve]),Nt=E({},[...ye,...be]),Pt=function(e){let t=T(e);(!t||!t.tagName)&&(t={namespaceURI:q,tagName:`template`});let n=_(e.tagName),r=_(t.tagName);return Ct[e.namespaceURI]?e.namespaceURI===xt?t.namespaceURI===K?n===`svg`:t.namespaceURI===bt?n===`svg`&&(r===`annotation-xml`||Tt[r]):!!Mt[n]:e.namespaceURI===bt?t.namespaceURI===K?n===`math`:t.namespaceURI===xt?n===`math`&&Et[r]:!!Nt[n]:e.namespaceURI===K?t.namespaceURI===xt&&!Et[r]||t.namespaceURI===bt&&!Tt[r]?!1:!Nt[n]&&(Dt[n]||!Mt[n]):!!(J===`application/xhtml+xml`&&Ct[e.namespaceURI]):!1},Z=function(e){h(t.removed,{element:e});try{T(e).removeChild(e)}catch{de(e)}},Q=function(e,n){try{h(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{h(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(H||lt)try{Z(n)}catch{}else try{n.setAttribute(e,``)}catch{}},Ft=function(e){let t=null,r=null;if(ct)e=`<remove></remove>`+e;else{let t=se(e,/^[\r\n\t ]+/);r=t&&t[0]}J===`application/xhtml+xml`&&q===K&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=D?D.createHTML(e):e;if(q===K)try{t=new ne().parseFromString(i,J)}catch{}if(!t||!t.documentElement){t=Ve.createDocument(q,`template`,null);try{t.documentElement.innerHTML=St?j:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),q===K?We.call(t,V?`html`:`body`)[0]:V?t.documentElement:a},It=function(e){return He.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT|u.SHOW_PROCESSING_INSTRUCTION|u.SHOW_CDATA_SECTION,null)},Lt=function(e){return e instanceof te&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof ee)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},Rt=function(e){return typeof c==`function`&&e instanceof c};function $(e,n,r){m(e,e=>{e.call(t,n,r,X)})}let zt=function(e){let n=null;if($(M.beforeSanitizeElements,e,null),Lt(e))return Z(e),!0;let r=Y(e.nodeName);if($(M.uponSanitizeElement,e,{tagName:r,allowedTags:N}),B&&e.hasChildNodes()&&!Rt(e.firstElementChild)&&C(/<[/\w!]/g,e.innerHTML)&&C(/<[/\w!]/g,e.textContent)||B&&e.namespaceURI===K&&r===`style`&&Rt(e.firstElementChild)||e.nodeType===A.progressingInstruction||B&&e.nodeType===A.comment&&C(/<[/\w]/g,e.data))return Z(e),!0;if(I[r]||!(R.tagCheck instanceof Function&&R.tagCheck(r))&&!N[r]){if(!I[r]&&Ht(r)&&(F.tagNameCheck instanceof RegExp&&C(F.tagNameCheck,r)||F.tagNameCheck instanceof Function&&F.tagNameCheck(r)))return!1;if(mt&&!G[r]){let t=T(e)||e.parentNode,n=w(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=ue(n[i],!0);t.insertBefore(r,S(e))}}}return Z(e),!0}return e instanceof l&&!Pt(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&C(/<\/no(script|embed|frames)/i,e.innerHTML)?(Z(e),!0):(z&&e.nodeType===A.text&&(n=e.textContent,m([Ke,qe,Je],e=>{n=v(n,e,` `)}),e.textContent!==n&&(h(t.removed,{element:e.cloneNode()}),e.textContent=n)),$(M.afterSanitizeElements,e,null),!1)},Bt=function(e,t,r){if(L[t]||dt&&(t===`id`||t===`name`)&&(r in n||r in kt))return!1;let i=P[t]||R.attributeCheck instanceof Function&&R.attributeCheck(t,e);if(!(it&&!L[t]&&C(Ye,t))&&!(rt&&C(Xe,t))){if(!i||L[t]){if(!(Ht(e)&&(F.tagNameCheck instanceof RegExp&&C(F.tagNameCheck,e)||F.tagNameCheck instanceof Function&&F.tagNameCheck(e))&&(F.attributeNameCheck instanceof RegExp&&C(F.attributeNameCheck,t)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(t,e))||t===`is`&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&C(F.tagNameCheck,r)||F.tagNameCheck instanceof Function&&F.tagNameCheck(r))))return!1}else if(!vt[t]&&!C(et,v(r,Qe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&ce(r,`data:`)===0&>[e])&&!(at&&!C(Ze,v(r,Qe,``)))&&r)return!1}return!0},Vt=E({},[`annotation-xml`,`color-profile`,`font-face`,`font-face-format`,`font-face-name`,`font-face-src`,`font-face-uri`,`missing-glyph`]),Ht=function(e){return!Vt[_(e)]&&C($e,e)},Ut=function(e){$(M.beforeSanitizeAttributes,e,null);let n=e.attributes;if(!n||Lt(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:P,forceKeepAttr:void 0},i=n.length;for(;i--;){let a=n[i],o=a.name,s=a.namespaceURI,c=a.value,l=Y(o),u=c,d=o===`value`?u:le(u);if(r.attrName=l,r.attrValue=d,r.keepAttr=!0,r.forceKeepAttr=void 0,$(M.uponSanitizeAttribute,e,r),d=r.attrValue,ft&&(l===`id`||l===`name`)&&ce(d,pt)!==0&&(Q(o,e),d=pt+d),B&&C(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,d)){Q(o,e);continue}if(l===`attributename`&&se(d,`href`)){Q(o,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){Q(o,e);continue}if(!ot&&C(/\/>/i,d)){Q(o,e);continue}z&&m([Ke,qe,Je],e=>{d=v(d,e,` `)});let f=Y(e.nodeName);if(!Bt(f,l,d)){Q(o,e);continue}if(D&&typeof y==`object`&&typeof y.getAttributeType==`function`&&!s)switch(y.getAttributeType(f,l)){case`TrustedHTML`:d=D.createHTML(d);break;case`TrustedScriptURL`:d=D.createScriptURL(d);break}if(d!==u)try{s?e.setAttributeNS(s,o,d):e.setAttribute(o,d),Lt(e)?Z(e):ie(t.removed)}catch{Q(o,e)}}$(M.afterSanitizeAttributes,e,null)},Wt=function(e){let t=null,n=It(e);for($(M.beforeSanitizeShadowDOM,e,null);t=n.nextNode();)$(M.uponSanitizeShadowNode,t,null),zt(t),Ut(t),t.content instanceof a&&Wt(t.content);$(M.afterSanitizeShadowDOM,e,null)},Gt=function(e){if(e.nodeType===A.element&&e.shadowRoot instanceof a){let t=e.shadowRoot;Gt(t),Wt(t)}let t=e.childNodes;if(!t)return;let n=[];m(t,e=>{h(n,e)});for(let e of n)Gt(e)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,s=null,l=null;if(St=!e,St&&(e=`<!-->`),typeof e!=`string`&&!Rt(e)&&(e=pe(e),typeof e!=`string`))throw fe(`dirty is not a string, aborting`);if(!t.isSupported)return e;if(st||jt(n),t.removed=[],typeof e==`string`&&(U=!1),U){let t=e.nodeName;if(typeof t==`string`){let e=Y(t);if(!N[e]||I[e])throw fe(`root node is forbidden and cannot be sanitized in-place`)}Gt(e)}else if(e instanceof c)i=Ft(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===A.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o),Gt(o);else{if(!H&&!z&&!V&&e.indexOf(`<`)===-1)return D&&ut?D.createHTML(e):e;if(i=Ft(e),!i)return H?null:ut?j:``}i&&ct&&Z(i.firstChild);let u=It(U?e:i);for(;s=u.nextNode();)zt(s),Ut(s),s.content instanceof a&&Wt(s.content);if(U)return e;if(H){if(z){i.normalize();let e=i.innerHTML;m([Ke,qe,Je],t=>{e=v(e,t,` `)}),i.innerHTML=e}if(lt)for(l=Ue.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(P.shadowroot||P.shadowrootmode)&&(l=Ge.call(r,l,!0)),l}let d=V?i.outerHTML:i.innerHTML;return V&&N[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&C(Pe,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
|
|
3
|
+
`+d),z&&m([Ke,qe,Je],e=>{d=v(d,e,` `)}),D&&ut?D.createHTML(d):d},t.setConfig=function(){jt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),st=!0},t.clearConfig=function(){X=null,st=!1},t.isValidAttribute=function(e,t,n){return X||jt({}),Bt(Y(e),Y(t),n)},t.addHook=function(e,t){typeof t==`function`&&h(M[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=re(M[e],t);return n===-1?void 0:ae(M[e],n,1)[0]}return ie(M[e])},t.removeHooks=function(e){M[e]=[]},t.removeAllHooks=function(){M=Re()},t}var j=ze();export{j as default};
|
package/dist/index.html
CHANGED
|
@@ -8,10 +8,7 @@
|
|
|
8
8
|
}
|
|
9
9
|
</style>
|
|
10
10
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
11
|
-
<script type="module" crossorigin src="./assets/index-
|
|
12
|
-
<link rel="modulepreload" crossorigin href="./assets/chunk-DECur_0Z.js">
|
|
13
|
-
<link rel="modulepreload" crossorigin href="./assets/preload-helper-xBbMyY7u.js">
|
|
14
|
-
<link rel="modulepreload" crossorigin href="./assets/id3-D55z-fRR.js">
|
|
11
|
+
<script type="module" crossorigin src="./assets/index-zOfyRUBK.js"></script>
|
|
15
12
|
</head>
|
|
16
13
|
<body>
|
|
17
14
|
<div id="root"></div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polotno-node",
|
|
3
|
-
"version": "2.15.
|
|
3
|
+
"version": "2.15.19",
|
|
4
4
|
"description": "Polotno workflow from NodeJS",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -23,26 +23,27 @@
|
|
|
23
23
|
"browserslist": "> 0.5%, last 2 versions, not dead",
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@polotno/video-export": "^0.0.11",
|
|
26
|
-
"axios": "^1.
|
|
26
|
+
"axios": "^1.16.1",
|
|
27
27
|
"dotenv": "^17.4.2",
|
|
28
28
|
"fluent-ffmpeg": "^2.1.3",
|
|
29
29
|
"jspdf": "^4.2.1",
|
|
30
30
|
"patch-package": "^8.0.1",
|
|
31
|
-
"pixelmatch": "^7.
|
|
31
|
+
"pixelmatch": "^7.2.0",
|
|
32
32
|
"pngjs": "^7.0.0",
|
|
33
33
|
"react": "^18.3.1",
|
|
34
34
|
"react-dom": "^18.3.1",
|
|
35
|
-
"vite": "^8.0.
|
|
36
|
-
"vitest": "^4.1.
|
|
37
|
-
"web-audio-api": "^1.
|
|
35
|
+
"vite": "^8.0.13",
|
|
36
|
+
"vitest": "^4.1.6",
|
|
37
|
+
"web-audio-api": "^1.5.1"
|
|
38
38
|
},
|
|
39
39
|
"author": "Anton Lavrenov",
|
|
40
40
|
"license": "MIT",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@sparticuz/chromium": "^
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"puppeteer
|
|
42
|
+
"@sparticuz/chromium": "^148.0.0",
|
|
43
|
+
"mediabunny": "1.27.3",
|
|
44
|
+
"polotno": "^2.41.0",
|
|
45
|
+
"puppeteer": "25.0.2",
|
|
46
|
+
"puppeteer-core": "25.0.2",
|
|
46
47
|
"tmp": "^0.2.5"
|
|
47
48
|
},
|
|
48
49
|
"bugs": {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,n)=>{let r={};for(var i in e)t(r,i,{get:e[i],enumerable:!0});return n||t(r,Symbol.toStringTag,{value:`Module`}),r},c=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},l=(n,r,a)=>(a=n==null?{}:e(i(n)),c(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));export{s as n,l as r,o as t};
|