@stlite/desktop 0.95.0 → 0.97.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/bin/dump_artifacts.js +1 -1
- package/build/assets/{ErrorOutline.esm-C-dv9Xq1-skkXNqDc.js → ErrorOutline.esm-lsdlHF0t-DG4LSxex.js} +1 -1
- package/build/assets/{FileDownload.esm-ORp-UC-S-BrsUfuH5.js → FileDownload.esm-B67hf_fm-CYQKuYJG.js} +1 -1
- package/build/assets/FileHelper-CfZ5yPb2-CNHTcjh9.js +5 -0
- package/build/assets/{FormClearHelper-DtwjWakY-CxfcniD6.js → FormClearHelper-XrLdNEJa-DVEjd1cV.js} +1 -1
- package/build/assets/IFrameUtil-8kJzIdKx-BKMrKnrz.js +1 -0
- package/build/assets/{InputInstructions-CshBE9XZ-BbegIdTI.js → InputInstructions-UPXPLzmg-Q7bu80af.js} +2 -2
- package/build/assets/Particles-BG5hjQKX-C7A0Knla.js +1 -0
- package/build/assets/ProgressBar-E3DTwBEC-BjaNqN1B.js +2 -0
- package/build/assets/StreamlitSyntaxHighlighter-CzihVVQU-DKtwdTjA.js +9 -0
- package/build/assets/TableChart.esm-DTCdMC22-C2aHYx-P.js +1 -0
- package/build/assets/{Toolbar-Cc8tCeKL-JHIp2NvW.js → Toolbar-DencJ98c--L3IVNu_.js} +1 -1
- package/build/assets/UploadFileInfo-DdcsXhjv-m2CBXl3F.js +1 -0
- package/build/assets/WidgetLabelHelpIconInline-DFAc7fKv-BB1k3kRL.js +1 -0
- package/build/assets/_baseAssignValue-D2hePX0_-CX8WO6Yp.js +1 -0
- package/build/assets/_baseIndexOf-OsCSwRmV--aVpkM1d.js +1 -0
- package/build/assets/{base-input-DbV2D5sF-DJkpBRM1.js → base-input-BPl9JMAl-yC1GT4Gd.js} +4 -4
- package/build/assets/{checkbox-CG80fxUD-CavQvTtP.js → checkbox-BCtTdZut-CgBE95kP.js} +2 -2
- package/build/assets/createDownloadLinkElement-D-zJ1ZGH-MUElf4MM.js +1 -0
- package/build/assets/createSuper-Csct9QVD-vLz3pY3G.js +1 -0
- package/build/assets/data-grid-overlay-editor-58Vv1cYM-BTQbyoqC.js +1 -0
- package/build/assets/{downloader-DcCTL3Wz-CqotLrf1.js → downloader-DcCTL3Wz-CCWe5qlA.js} +1 -1
- package/build/assets/embed-4M_Y1tyc-DYkZAF8O.js +195 -0
- package/build/assets/{es6--XPcqeHG-DdkxL8eW.js → es6--XPcqeHG-7ATg0sOb.js} +2 -2
- package/build/assets/formatMoment-DEtsTHwA-BeQagUzn.js +1 -0
- package/build/assets/formatNumber-ep44bWil-jKcj-W8C.js +1 -0
- package/build/assets/iconPosition-D6yC8Xnj-BF1h45AJ.js +1 -0
- package/build/assets/iframeResizer.contentWindow-nTwp-zqr-CtsMNeCZ.js +1 -0
- package/build/assets/index--TzMnXzp-DAvnEXlj.js +1 -0
- package/build/assets/index--qHBza9B-Cw3TTMgu.js +1 -0
- package/build/assets/index-B-mlHTWW-DxFrd5NG.js +1 -0
- package/build/assets/{index-CiBn_-AR-CMINgD7R.js → index-B-vlNoRi-Cx4hHKp7.js} +1 -1
- package/build/assets/index-B7jXK8tg-DQuHfWI9.js +1 -0
- package/build/assets/index-BFmSYBo1-C1-2gL1R.js +2 -0
- package/build/assets/{index-SbKh1OIB-BjfuWdcF.js → index-BIskStic-GEaJjVf4.js} +4 -4
- package/build/assets/index-BmOxzNZt-CNMeXzFc.js +1 -0
- package/build/assets/index-BmPxToPj-BM0EGyRT.js +1 -0
- package/build/assets/index-BmXuG0WA-D_Ql4e0d.js +3 -0
- package/build/assets/index-BtV4cH-G-DZqE8EFk.js +1 -0
- package/build/assets/index-BwXCTp7d-CbCsXHhb.js +6 -0
- package/build/assets/index-BwaRZjpn-BcW7Mc-p.js +1 -0
- package/build/assets/index-BzkAb_Ru-BoJQq1Du.js +1 -0
- package/build/assets/index-C5pyI-9n-BoqvCp9L.js +3 -0
- package/build/assets/index-CHTMxzEE-CdrOqTD2.js +1 -0
- package/build/assets/index-CJJUSpBk-Cjx3_stH.js +2 -0
- package/build/assets/index-CVld_lKx-CBWAU0gM.js +14 -0
- package/build/assets/index-CWwI7Day-CBbcYz7C.js +3 -0
- package/build/assets/{index-D2j0kQLw-67iH-2yA.js → index-CYKyPdc--DXQt2pbH.js} +1 -1
- package/build/assets/index-CYavJtAA-CEB9mFy5.js +11 -0
- package/build/assets/index-C_AtJDfm-C2sFKVUp.js +1 -0
- package/build/assets/index-Cc93rxqK-qmLHI1ce.js +1 -0
- package/build/assets/index-CgwImjw9-vhGwcoU0.js +1 -0
- package/build/assets/{index-BqCY3Zlk-mm_Bt8ZF.js → index-CiGWj_Vp-n6pbS_He.js} +1 -1
- package/build/assets/index-Cp9lKUfY-DCgJbJZE.js +1 -0
- package/build/assets/index-CrLOtTTY-_bXB7Npw.js +2 -0
- package/build/assets/{index-CNKtyIol-BPke8suV.js → index-CuAftQdk-D76l7Kt4.js} +1 -1
- package/build/assets/index-D0DUjycF-DZpBbVrj.js +263 -0
- package/build/assets/index-D1pkaPju-DGUZOgpo.js +1 -0
- package/build/assets/index-D6IEgvdJ-B-rltr1-.js +1 -0
- package/build/assets/index-D9TZavtE.css +1 -0
- package/build/assets/index-DQ7wfL_P-DAp2jN40.js +2 -0
- package/build/assets/{index-y3ITDERN-Ccy-wRE2.js → index-DR-j-FYy-DJdOMdE8.js} +1 -1
- package/build/assets/index-DUNdG0N4-BKyH_Fci.js +2 -0
- package/build/assets/index-Df-1Z3LJ-bsVAaBS1.js +1 -0
- package/build/assets/index-Dfye6cAn-CH-9suNF.js +1 -0
- package/build/assets/index-DhMU6AlU-DzPhysZa.js +3789 -0
- package/build/assets/index-DjAHjI25-oZ9XAxp1.js +27 -0
- package/build/assets/index-DlPzHASD-B0KSeIYY.js +1 -0
- package/build/assets/index-DrLK8ov3-Stod2ydK.js +2 -0
- package/build/assets/index-DtFJwl5H-Dn2VZIyI.js +1 -0
- package/build/assets/index-DuZXLtJ1-BxktJ87b.js +1 -0
- package/build/assets/index-H5hDyygX-DMvEgj-E.js +1 -0
- package/build/assets/index-LD7yKakY-9tfSlqzu.js +1 -0
- package/build/assets/index-LeNVxf2A-B46Z4XAZ.js +1 -0
- package/build/assets/index-QsvFitQg-IS60zSNc.js +1 -0
- package/build/assets/index-YCKUmi7k-wKVbmOTE.js +1 -0
- package/build/assets/{index-DeKEPgyN-DF3OyxuW.js → index-f_0uAugs-KaRkqnk8.js} +1 -1
- package/build/assets/index-nhNM5UeG.js +185 -0
- package/build/assets/index-pi_S-NOw-DHRw2FEx.js +198 -0
- package/build/assets/index-saRTHQRt-Cep0ox_U.js +1 -0
- package/build/assets/{input-DNUwcYWK-C9eVW6-S.js → input-BZGQFBY5-B-EqzVpf.js} +2 -2
- package/build/assets/main-DD_nsVBV-B-nG1zNN.js +13 -0
- package/build/assets/{memory-B3L1Fctl-CQ-Y_gc6.js → memory-B3L1Fctl-Dwxd_AN8.js} +1 -1
- package/build/assets/moment-CU6QKNej-DcQX_LE0.js +4 -0
- package/build/assets/number-overlay-editor--_WCmOH8-DebLrQQ4.js +9 -0
- package/build/assets/numbro-CBbENDeu-C6X7Pww4.js +1 -0
- package/build/assets/pandasStylerUtils-DlCnQunN-DDd07kWa.js +1 -0
- package/build/assets/possibleConstructorReturn-i7eTFBhJ-BnzuGOIJ.js +1 -0
- package/build/assets/record-CvRL89xC-Cpipd1Kv.js +1 -0
- package/build/assets/{sandbox-ChAzL-i--DqMwo4R7.js → sandbox-ChAzL-i--CrJOWfYj.js} +1 -1
- package/build/assets/styled-components-Dq_iSDU9-i1eh3pWs.js +1 -0
- package/build/assets/threshold-eWsxmMyL-jpRnj60B.js +1 -0
- package/build/assets/{timepicker-CkLW19xP-CTuglWU6.js → timepicker-CL-801So-Sc5MVKGZ.js} +3 -3
- package/build/assets/timer-DAAwtI0i-CB52lra-.js +1 -0
- package/build/assets/toConsumableArray-CCohTQYb-ClE5WF0y.js +3 -0
- package/build/assets/uniqueId-CWWNkcH4-CJJowNJ2.js +1 -0
- package/build/assets/urls-CuMqgoDl-BWqF1s4U.js +1 -0
- package/build/assets/{useBasicWidgetState-BTyLgyXa-DI96f9E0.js → useBasicWidgetState-BYeS5Lnw-COvJBdtg.js} +1 -1
- package/build/assets/useIntlLocale-D1zv6Q2y-BpOVDRdF.js +12 -0
- package/build/assets/{useTextInputAutoExpand-YLx_K1sh-DhWKaGOV.js → useTextInputAutoExpand-DEesfW0v-Cv12Lx8Q.js} +2 -2
- package/build/assets/{useUpdateUiValue-B9j1K8e5-CIeTAxHC.js → useUpdateUiValue-DDoOKBFH-DrpUtoEl.js} +1 -1
- package/build/assets/useWaveformController-Betfr4kn-B9JLTJ93.js +1 -0
- package/build/assets/value-DwxUZIyI-CNuykc50.js +1 -0
- package/build/assets/wavesurfer.esm-idh1jvYE-D4Wwdy60.js +74 -0
- package/build/assets/withCalculatedWidth-ZZ9bYZZd-CtbnrMaD.js +1 -0
- package/build/assets/withFullScreenWrapper-B-PKqZVg-DWJ8sEV7.js +1 -0
- package/build/index.html +2 -2
- package/package.json +3 -3
- package/wheels/streamlit-1.53.1-cp313-none-any.whl +0 -0
- package/build/assets/FileHelper-DQKV3o5U-qFf0CL_R.js +0 -5
- package/build/assets/Particles-DbEEaBdi-Cslh0fnd.js +0 -1
- package/build/assets/ProgressBar-ohpf-YR2-PWD0xacp.js +0 -2
- package/build/assets/UploadFileInfo-B5SttewO-BfvME59S.js +0 -1
- package/build/assets/createDownloadLinkElement-CbRjLJ8e-NbV49OP9.js +0 -1
- package/build/assets/createSuper-BlgWzn8_-h1vcwEzv.js +0 -1
- package/build/assets/data-grid-overlay-editor-DsmOmCoE-DU0EvyVM.js +0 -1
- package/build/assets/iframeResizer.contentWindow-DEXh82Lp-CG3rnwWO.js +0 -1
- package/build/assets/index-3Q8l-56I-Bp9UZWPZ.js +0 -27
- package/build/assets/index-8FM--PX3-C2rsm2es.js +0 -1
- package/build/assets/index-B1y_Hrx0-DDwLQ3XW.js +0 -1
- package/build/assets/index-BECG__WC-DerPiN--.js +0 -1
- package/build/assets/index-BQn4Faen-CVQ5ESXY.js +0 -3
- package/build/assets/index-BReUOw2L-emeACiGh.js +0 -1371
- package/build/assets/index-BiS_E3zu-CwIGZcqG.js +0 -1
- package/build/assets/index-BmlZuG1z-BtaDcb9o.js +0 -1
- package/build/assets/index-BvblFOYP.js +0 -691
- package/build/assets/index-Bzy7yu67-C3L4ShMk.js +0 -2
- package/build/assets/index-C7cG_aL6-BWm5S1-m.js +0 -3789
- package/build/assets/index-CO05R5cS-DHfFy15g.js +0 -1
- package/build/assets/index-CQfw52g6-BJ-a84bb.js +0 -1
- package/build/assets/index-CTvmRzFN-By1zFrdQ.js +0 -2
- package/build/assets/index-Cb_C2vCk-DrzTyNQF.js +0 -198
- package/build/assets/index-CnMc0ayy-CKIU12h5.js +0 -1
- package/build/assets/index-D0Ry9mHz-DBJluHQV.js +0 -3
- package/build/assets/index-D42P77wj-jZCT0fQL.js +0 -1
- package/build/assets/index-D7LfqMh3-DvKIa3UK.js +0 -1
- package/build/assets/index-DD64_I3e-Cxdt0Oji.js +0 -1
- package/build/assets/index-DEYeMrzr-DP5rSRot.js +0 -1
- package/build/assets/index-DTog-cZN-vTBq72Ci.js +0 -1
- package/build/assets/index-DU0kTHM_-CInhbPr8.js +0 -12
- package/build/assets/index-DnTjZ9IR.css +0 -1
- package/build/assets/index-DrS8S2M--C4mGh6T8.js +0 -1
- package/build/assets/index-DxTzjSNF-B-v_CQEN.js +0 -2
- package/build/assets/index-IXLMpVV4-D8dPiMEz.js +0 -2
- package/build/assets/index-Ray843Xd-CpBr9wfH.js +0 -1
- package/build/assets/index-S-A7KecP-DJ0BKtLt.js +0 -1
- package/build/assets/index-Uvv6so0Q-Lbl8GAad.js +0 -1
- package/build/assets/index-YbT2v6Cb-CoC81Jcm.js +0 -1
- package/build/assets/index-vRM8HrbM-CZbE9IiJ.js +0 -3
- package/build/assets/inherits-CYghrBFU-Cf4k8aUQ.js +0 -1
- package/build/assets/number-overlay-editor-C2e7pY6x-BnC-vP7l.js +0 -9
- package/build/assets/record-DJsfODTt-CK8X1liM.js +0 -1
- package/build/assets/slicedToArray-D4uL3Bzl-95JmZlNK.js +0 -2
- package/build/assets/uniqueId-C6wp_e1D-D_RnWRJW.js +0 -1
- package/build/assets/wavesurfer.esm-CzjpjtNs-CtBzisOM.js +0 -74
- package/build/assets/withFullScreenWrapper-DqrJMIkm-BwrYir6f.js +0 -1
- package/wheels/streamlit-1.51.0-cp313-none-any.whl +0 -0
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
function C(l,t,e,i){return new(e||(e=Promise))(function(s,n){function a(r){try{h(i.next(r))}catch(o){n(o)}}function c(r){try{h(i.throw(r))}catch(o){n(o)}}function h(r){var o;r.done?s(r.value):(o=r.value,o instanceof e?o:new e(function(p){p(o)})).then(a,c)}h((i=i.apply(l,t||[])).next())})}class T{constructor(){this.listeners={}}on(t,e,i){if(this.listeners[t]||(this.listeners[t]=new Set),i?.once){const s=(...n)=>{this.un(t,s),e(...n)};return this.listeners[t].add(s),()=>this.un(t,s)}return this.listeners[t].add(e),()=>this.un(t,e)}un(t,e){var i;(i=this.listeners[t])===null||i===void 0||i.delete(e)}once(t,e){return this.on(t,e,{once:!0})}unAll(){this.listeners={}}emit(t,...e){this.listeners[t]&&this.listeners[t].forEach(i=>i(...e))}}const L={decode:function(l,t){return C(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});try{return yield e.decodeAudioData(l)}finally{e.close()}})},createBuffer:function(l,t){if(!l||l.length===0)throw new Error("channelData must be a non-empty array");if(t<=0)throw new Error("duration must be greater than 0");if(typeof l[0]=="number"&&(l=[l]),!l[0]||l[0].length===0)throw new Error("channelData must contain non-empty channel arrays");(function(i){const s=i[0];if(s.some(n=>n>1||n<-1)){const n=s.length;let a=0;for(let c=0;c<n;c++){const h=Math.abs(s[c]);h>a&&(a=h)}for(const c of i)for(let h=0;h<n;h++)c[h]/=a}})(l);const e=l.map(i=>i instanceof Float32Array?i:Float32Array.from(i));return{duration:t,length:e[0].length,sampleRate:e[0].length/t,numberOfChannels:e.length,getChannelData:i=>{const s=e[i];if(!s)throw new Error(`Channel ${i} not found`);return s},copyFromChannel:AudioBuffer.prototype.copyFromChannel,copyToChannel:AudioBuffer.prototype.copyToChannel}}};function X(l,t){const e=t.xmlns?document.createElementNS(t.xmlns,l):document.createElement(l);for(const[i,s]of Object.entries(t))if(i==="children"&&s)for(const[n,a]of Object.entries(s))a instanceof Node?e.appendChild(a):typeof a=="string"?e.appendChild(document.createTextNode(a)):e.appendChild(X(n,a));else i==="style"?Object.assign(e.style,s):i==="textContent"?e.textContent=s:e.setAttribute(i,s.toString());return e}function _(l,t,e){const i=X(l,t||{});return e?.appendChild(i),i}var V=Object.freeze({__proto__:null,createElement:_,default:_});const Y={fetchBlob:function(l,t,e){return C(this,void 0,void 0,function*(){const i=yield fetch(l,e);if(i.status>=400)throw new Error(`Failed to fetch ${l}: ${i.status} (${i.statusText})`);return(function(s,n){C(this,void 0,void 0,function*(){if(!s.body||!s.headers)return;const a=s.body.getReader(),c=Number(s.headers.get("Content-Length"))||0;let h=0;const r=o=>{h+=o?.length||0;const p=Math.round(h/c*100);n(p)};try{for(;;){const o=yield a.read();if(o.done)break;r(o.value)}}catch(o){console.warn("Progress tracking error:",o)}})})(i.clone(),t),i.blob()})}};class J extends T{constructor(t){super(),this.isExternalMedia=!1,t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),t.mediaControls&&(this.media.controls=!0),t.autoplay&&(this.media.autoplay=!0),t.playbackRate!=null&&this.onMediaEvent("canplay",()=>{t.playbackRate!=null&&(this.media.playbackRate=t.playbackRate)},{once:!0})}onMediaEvent(t,e,i){return this.media.addEventListener(t,e,i),()=>this.media.removeEventListener(t,e,i)}getSrc(){return this.media.currentSrc||this.media.src||""}revokeSrc(){const t=this.getSrc();t.startsWith("blob:")&&URL.revokeObjectURL(t)}canPlayType(t){return this.media.canPlayType(t)!==""}setSrc(t,e){const i=this.getSrc();if(t&&i===t)return;this.revokeSrc();const s=e instanceof Blob&&(this.canPlayType(e.type)||!t)?URL.createObjectURL(e):t;if(i&&this.media.removeAttribute("src"),s||t)try{this.media.src=s}catch{this.media.src=t}}destroy(){this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.media=t}play(){return C(this,void 0,void 0,function*(){try{return yield this.media.play()}catch(t){if(t instanceof DOMException&&t.name==="AbortError")return;throw t}})}pause(){this.media.pause()}isPlaying(){return!this.media.paused&&!this.media.ended}setTime(t){this.media.currentTime=Math.max(0,Math.min(t,this.getDuration()))}getDuration(){return this.media.duration}getCurrentTime(){return this.media.currentTime}getVolume(){return this.media.volume}setVolume(t){this.media.volume=t}getMuted(){return this.media.muted}setMuted(t){this.media.muted=t}getPlaybackRate(){return this.media.playbackRate}isSeeking(){return this.media.seeking}setPlaybackRate(t,e){e!=null&&(this.media.preservesPitch=e),this.media.playbackRate=t}getMediaElement(){return this.media}setSinkId(t){return this.media.setSinkId(t)}}function A(l){return l<0?0:l>1?1:l}function K({maxTop:l,maxBottom:t,halfHeight:e,vScale:i}){const s=Math.round(l*e*i);return{topHeight:s,totalHeight:s+Math.round(t*e*i)||1}}function Q({barAlign:l,halfHeight:t,topHeight:e,totalHeight:i,canvasHeight:s}){return l==="top"?0:l==="bottom"?s-i:t-e}function I(l,t,e){const i=t-l.left,s=e-l.top;return[i/l.width,s/l.height]}function U(l){return!!(l.barWidth||l.barGap||l.barAlign)}function $(l,t){if(!U(t))return l;const e=t.barWidth||.5,i=e+(t.barGap||e/2);return i===0?l:Math.floor(l/i)*i}function F({scrollLeft:l,totalWidth:t,numCanvases:e}){if(t===0)return[0];const i=l/t,s=Math.floor(i*e);return[s-1,s,s+1]}function j({scrollLeft:l,clientWidth:t,scrollWidth:e}){return e===0?{startX:0,endX:0}:{startX:l/e,endX:(l+t)/e}}class Z extends T{constructor(t,e){super(),this.timeouts=[],this.isScrollable=!1,this.audioData=null,this.resizeObserver=null,this.lastContainerWidth=0,this.isDragging=!1,this.subscriptions=[],this.unsubscribeOnScroll=[],this.dragUnsubscribe=null,this.subscriptions=[],this.options=t;const i=this.parentFromOptionsContainer(t.container);this.parent=i;const[s,n]=this.initHtml();i.appendChild(s),this.container=s,this.scrollContainer=n.querySelector(".scroll"),this.wrapper=n.querySelector(".wrapper"),this.canvasWrapper=n.querySelector(".canvases"),this.progressWrapper=n.querySelector(".progress"),this.cursor=n.querySelector(".cursor"),e&&n.appendChild(e),this.initEvents()}parentFromOptionsContainer(t){let e;if(typeof t=="string"?e=document.querySelector(t):t instanceof HTMLElement&&(e=t),!e)throw new Error("Container not found");return e}initEvents(){if(this.wrapper.addEventListener("click",t=>{const e=this.wrapper.getBoundingClientRect(),[i,s]=I(e,t.clientX,t.clientY);this.emit("click",i,s)}),this.wrapper.addEventListener("dblclick",t=>{const e=this.wrapper.getBoundingClientRect(),[i,s]=I(e,t.clientX,t.clientY);this.emit("dblclick",i,s)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollContainer.addEventListener("scroll",()=>{const{scrollLeft:t,scrollWidth:e,clientWidth:i}=this.scrollContainer,{startX:s,endX:n}=j({scrollLeft:t,scrollWidth:e,clientWidth:i});this.emit("scroll",s,n,t,t+i)}),typeof ResizeObserver=="function"){const t=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{t().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){this.dragUnsubscribe||(this.dragUnsubscribe=(function(t,e,i,s,n=3,a=0,c=100){if(!t)return()=>{};const h=new Map,r=matchMedia("(pointer: coarse)").matches;let o=()=>{};const p=m=>{if(m.button!==a||(h.set(m.pointerId,m),h.size>1))return;let d=m.clientX,u=m.clientY,v=!1;const g=Date.now(),P=f=>{if(f.defaultPrevented||h.size>1||r&&Date.now()-g<c)return;const w=f.clientX,E=f.clientY,D=w-d,k=E-u;if(v||Math.abs(D)>n||Math.abs(k)>n){f.preventDefault(),f.stopPropagation();const R=t.getBoundingClientRect(),{left:W,top:M}=R;v||(i?.(d-W,u-M),v=!0),e(D,k,w-W,E-M),d=w,u=E}},S=f=>{if(h.delete(f.pointerId),v){const w=f.clientX,E=f.clientY,D=t.getBoundingClientRect(),{left:k,top:R}=D;s?.(w-k,E-R)}o()},y=f=>{h.delete(f.pointerId),f.relatedTarget&&f.relatedTarget!==document.documentElement||S(f)},x=f=>{v&&(f.stopPropagation(),f.preventDefault())},b=f=>{f.defaultPrevented||h.size>1||v&&f.preventDefault()};document.addEventListener("pointermove",P),document.addEventListener("pointerup",S),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",b,{passive:!1}),document.addEventListener("click",x,{capture:!0}),o=()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",b),setTimeout(()=>{document.removeEventListener("click",x,{capture:!0})},10)}};return t.addEventListener("pointerdown",p),()=>{o(),t.removeEventListener("pointerdown",p),h.clear()}})(this.wrapper,(t,e,i)=>{const s=this.wrapper.getBoundingClientRect().width;this.emit("drag",A(i/s))},t=>{this.isDragging=!0;const e=this.wrapper.getBoundingClientRect().width;this.emit("dragstart",A(t/e))},t=>{this.isDragging=!1;const e=this.wrapper.getBoundingClientRect().width;this.emit("dragend",A(t/e))}),this.subscriptions.push(this.dragUnsubscribe))}initHtml(){const t=document.createElement("div"),e=t.attachShadow({mode:"open"}),i=this.options.cspNonce&&typeof this.options.cspNonce=="string"?this.options.cspNonce.replace(/"/g,""):"";return e.innerHTML=`
|
|
2
|
-
<style${i?` nonce="${i}"`:""}>
|
|
3
|
-
:host {
|
|
4
|
-
user-select: none;
|
|
5
|
-
min-width: 1px;
|
|
6
|
-
}
|
|
7
|
-
:host audio {
|
|
8
|
-
display: block;
|
|
9
|
-
width: 100%;
|
|
10
|
-
}
|
|
11
|
-
:host .scroll {
|
|
12
|
-
overflow-x: auto;
|
|
13
|
-
overflow-y: hidden;
|
|
14
|
-
width: 100%;
|
|
15
|
-
position: relative;
|
|
16
|
-
}
|
|
17
|
-
:host .noScrollbar {
|
|
18
|
-
scrollbar-color: transparent;
|
|
19
|
-
scrollbar-width: none;
|
|
20
|
-
}
|
|
21
|
-
:host .noScrollbar::-webkit-scrollbar {
|
|
22
|
-
display: none;
|
|
23
|
-
-webkit-appearance: none;
|
|
24
|
-
}
|
|
25
|
-
:host .wrapper {
|
|
26
|
-
position: relative;
|
|
27
|
-
overflow: visible;
|
|
28
|
-
z-index: 2;
|
|
29
|
-
}
|
|
30
|
-
:host .canvases {
|
|
31
|
-
min-height: ${this.getHeight(this.options.height,this.options.splitChannels)}px;
|
|
32
|
-
pointer-events: none;
|
|
33
|
-
}
|
|
34
|
-
:host .canvases > div {
|
|
35
|
-
position: relative;
|
|
36
|
-
}
|
|
37
|
-
:host canvas {
|
|
38
|
-
display: block;
|
|
39
|
-
position: absolute;
|
|
40
|
-
top: 0;
|
|
41
|
-
image-rendering: pixelated;
|
|
42
|
-
}
|
|
43
|
-
:host .progress {
|
|
44
|
-
pointer-events: none;
|
|
45
|
-
position: absolute;
|
|
46
|
-
z-index: 2;
|
|
47
|
-
top: 0;
|
|
48
|
-
left: 0;
|
|
49
|
-
width: 0;
|
|
50
|
-
height: 100%;
|
|
51
|
-
overflow: hidden;
|
|
52
|
-
}
|
|
53
|
-
:host .progress > div {
|
|
54
|
-
position: relative;
|
|
55
|
-
}
|
|
56
|
-
:host .cursor {
|
|
57
|
-
pointer-events: none;
|
|
58
|
-
position: absolute;
|
|
59
|
-
z-index: 5;
|
|
60
|
-
top: 0;
|
|
61
|
-
left: 0;
|
|
62
|
-
height: 100%;
|
|
63
|
-
border-radius: 2px;
|
|
64
|
-
}
|
|
65
|
-
</style>
|
|
66
|
-
|
|
67
|
-
<div class="scroll" part="scroll">
|
|
68
|
-
<div class="wrapper" part="wrapper">
|
|
69
|
-
<div class="canvases" part="canvases"></div>
|
|
70
|
-
<div class="progress" part="progress"></div>
|
|
71
|
-
<div class="cursor" part="cursor"></div>
|
|
72
|
-
</div>
|
|
73
|
-
</div>
|
|
74
|
-
`,[t,e]}setOptions(t){if(this.options.container!==t.container){const e=this.parentFromOptionsContainer(t.container);e.appendChild(this.container),this.parent=e}t.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth}getScroll(){return this.scrollContainer.scrollLeft}setScroll(t){this.scrollContainer.scrollLeft=t}setScrollPercentage(t){const{scrollWidth:e}=this.scrollContainer,i=e*t;this.setScroll(i)}destroy(){var t;this.subscriptions.forEach(e=>e()),this.container.remove(),this.resizeObserver&&(this.resizeObserver.disconnect(),this.resizeObserver=null),(t=this.unsubscribeOnScroll)===null||t===void 0||t.forEach(e=>e()),this.unsubscribeOnScroll=[]}createDelay(t=10){let e,i;const s=()=>{e&&(clearTimeout(e),e=void 0),i&&(i(),i=void 0)};return this.timeouts.push(s),()=>new Promise((n,a)=>{s(),i=a,e=setTimeout(()=>{e=void 0,i=void 0,n()},t)})}getHeight(t,e){var i;const s=((i=this.audioData)===null||i===void 0?void 0:i.numberOfChannels)||1;return(function({optionsHeight:n,optionsSplitChannels:a,parentHeight:c,numberOfChannels:h,defaultHeight:r=128}){if(n==null)return r;const o=Number(n);if(!isNaN(o))return o;if(n==="auto"){const p=c||r;return a?.every(m=>!m.overlay)?p/h:p}return r})({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:s,defaultHeight:128})}convertColorValues(t){return(function(e,i){if(!Array.isArray(e))return e||"";if(e.length===0)return"#999";if(e.length<2)return e[0]||"";const s=document.createElement("canvas"),n=s.getContext("2d"),a=s.height*i,c=n.createLinearGradient(0,0,0,a||i),h=1/(e.length-1);return e.forEach((r,o)=>{c.addColorStop(o*h,r)}),c})(t,this.getPixelRatio())}getPixelRatio(){return t=window.devicePixelRatio,Math.max(1,t||1);var t}renderBarWaveform(t,e,i,s){const{width:n,height:a}=i.canvas,{halfHeight:c,barWidth:h,barRadius:r,barIndexScale:o,barSpacing:p}=(function({width:d,height:u,length:v,options:g,pixelRatio:P}){const S=u/2,y=g.barWidth?g.barWidth*P:1,x=g.barGap?g.barGap*P:g.barWidth?y/2:0,b=y+x||1;return{halfHeight:S,barWidth:y,barGap:x,barRadius:g.barRadius||0,barIndexScale:v>0?d/b/v:0,barSpacing:b}})({width:n,height:a,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),m=(function({channelData:d,barIndexScale:u,barSpacing:v,barWidth:g,halfHeight:P,vScale:S,canvasHeight:y,barAlign:x}){const b=d[0]||[],f=d[1]||b,w=b.length,E=[];let D=0,k=0,R=0;for(let W=0;W<=w;W++){const M=Math.round(W*u);if(M>D){const{topHeight:q,totalHeight:z}=K({maxTop:k,maxBottom:R,halfHeight:P,vScale:S}),G=Q({barAlign:x,halfHeight:P,topHeight:q,totalHeight:z,canvasHeight:y});E.push({x:D*v,y:G,width:g,height:z}),D=M,k=0,R=0}const N=Math.abs(b[W]||0),B=Math.abs(f[W]||0);N>k&&(k=N),B>R&&(R=B)}return E})({channelData:t,barIndexScale:o,barSpacing:p,barWidth:h,halfHeight:c,vScale:s,canvasHeight:a,barAlign:e.barAlign});i.beginPath();for(const d of m)r&&"roundRect"in i?i.roundRect(d.x,d.y,d.width,d.height,r):i.rect(d.x,d.y,d.width,d.height);i.fill(),i.closePath()}renderLineWaveform(t,e,i,s){const{width:n,height:a}=i.canvas,c=(function({channelData:h,width:r,height:o,vScale:p}){const m=o/2,d=h[0]||[];return[d,h[1]||d].map((u,v)=>{const g=u.length,P=g?r/g:0,S=m,y=v===0?-1:1,x=[{x:0,y:S}];let b=0,f=0;for(let w=0;w<=g;w++){const E=Math.round(w*P);if(E>b){const k=S+(Math.round(f*m*p)||1)*y;x.push({x:b,y:k}),b=E,f=0}const D=Math.abs(u[w]||0);D>f&&(f=D)}return x.push({x:b,y:S}),x})})({channelData:t,width:n,height:a,vScale:s});i.beginPath();for(const h of c)if(h.length){i.moveTo(h[0].x,h[0].y);for(let r=1;r<h.length;r++){const o=h[r];i.lineTo(o.x,o.y)}}i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction)return void e.renderFunction(t,i);const s=(function({channelData:n,barHeight:a,normalize:c}){var h;const r=a||1;if(!c)return r;const o=n[0];if(!o||o.length===0)return r;let p=0;for(let m=0;m<o.length;m++){const d=(h=o[m])!==null&&h!==void 0?h:0,u=Math.abs(d);u>p&&(p=u)}return p?r/p:r})({channelData:t,barHeight:e.barHeight,normalize:e.normalize});U(e)?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,a,c){const h=this.getPixelRatio(),r=document.createElement("canvas");r.width=Math.round(i*h),r.height=Math.round(s*h),r.style.width=`${i}px`,r.style.height=`${s}px`,r.style.left=`${Math.round(n)}px`,a.appendChild(r);const o=r.getContext("2d");if(e.renderFunction?(o.fillStyle=this.convertColorValues(e.waveColor),e.renderFunction(t,o)):this.renderWaveform(t,e,o),r.width>0&&r.height>0){const p=r.cloneNode(),m=p.getContext("2d");m.drawImage(r,0,0),m.globalCompositeOperation="source-in",m.fillStyle=this.convertColorValues(e.progressColor),m.fillRect(0,0,r.width,r.height),c.appendChild(p)}}renderMultiCanvas(t,e,i,s,n,a){const c=this.getPixelRatio(),{clientWidth:h}=this.scrollContainer,r=i/c,o=(function({clientWidth:u,totalWidth:v,options:g}){return $(Math.min(8e3,u,v),g)})({clientWidth:h,totalWidth:r,options:e});let p={};if(o===0)return;const m=u=>{if(u<0||u>=d||p[u])return;p[u]=!0;const v=u*o;let g=Math.min(r-v,o);if(g=$(g,e),g<=0)return;const P=(function({channelData:S,offset:y,clampedWidth:x,totalWidth:b}){return S.map(f=>{const w=Math.floor(y/b*f.length),E=Math.floor((y+x)/b*f.length);return f.slice(w,E)})})({channelData:t,offset:v,clampedWidth:g,totalWidth:r});this.renderSingleCanvas(P,e,g,s,v,n,a)},d=Math.ceil(r/o);if(!this.isScrollable){for(let u=0;u<d;u++)m(u);return}if(F({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:r,numCanvases:d}).forEach(u=>m(u)),d>1){const u=this.on("scroll",()=>{const{scrollLeft:v}=this.scrollContainer;Object.keys(p).length>10&&(n.innerHTML="",a.innerHTML="",p={}),F({scrollLeft:v,totalWidth:r,numCanvases:d}).forEach(g=>m(g))});this.unsubscribeOnScroll.push(u)}}renderChannel(t,e,i,s){var{overlay:n}=e,a=(function(o,p){var m={};for(var d in o)Object.prototype.hasOwnProperty.call(o,d)&&p.indexOf(d)<0&&(m[d]=o[d]);if(o!=null&&typeof Object.getOwnPropertySymbols=="function"){var u=0;for(d=Object.getOwnPropertySymbols(o);u<d.length;u++)p.indexOf(d[u])<0&&Object.prototype.propertyIsEnumerable.call(o,d[u])&&(m[d[u]]=o[d[u]])}return m})(e,["overlay"]);const c=document.createElement("div"),h=this.getHeight(a.height,a.splitChannels);c.style.height=`${h}px`,n&&s>0&&(c.style.marginTop=`-${h}px`),this.canvasWrapper.style.minHeight=`${h}px`,this.canvasWrapper.appendChild(c);const r=c.cloneNode();this.progressWrapper.appendChild(r),this.renderMultiCanvas(t,a,i,h,c,r)}render(t){return C(this,void 0,void 0,function*(){var e;this.timeouts.forEach(r=>r()),this.timeouts=[],this.canvasWrapper.innerHTML="",this.progressWrapper.innerHTML="",this.options.width!=null&&(this.scrollContainer.style.width=typeof this.options.width=="number"?`${this.options.width}px`:this.options.width);const i=this.getPixelRatio(),s=this.scrollContainer.clientWidth,{scrollWidth:n,isScrollable:a,useParentWidth:c,width:h}=(function({duration:r,minPxPerSec:o=0,parentWidth:p,fillParent:m,pixelRatio:d}){const u=Math.ceil(r*o),v=u>p,g=!!(m&&!v);return{scrollWidth:u,isScrollable:v,useParentWidth:g,width:(g?p:u)*d}})({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:s,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=a,this.wrapper.style.width=c?"100%":`${n}px`,this.scrollContainer.style.overflowX=this.isScrollable?"auto":"hidden",this.scrollContainer.classList.toggle("noScrollbar",!!this.options.hideScrollbar),this.cursor.style.backgroundColor=`${this.options.cursorColor||this.options.progressColor}`,this.cursor.style.width=`${this.options.cursorWidth}px`,this.audioData=t,this.emit("render"),this.options.splitChannels)for(let r=0;r<t.numberOfChannels;r++){const o=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[r]);this.renderChannel([t.getChannelData(r)],o,h,r)}else{const r=[t.getChannelData(0)];t.numberOfChannels>1&&r.push(t.getChannelData(1)),this.renderChannel(r,this.options,h,0)}Promise.resolve().then(()=>this.emit("rendered"))})}reRender(){if(this.unsubscribeOnScroll.forEach(i=>i()),this.unsubscribeOnScroll=[],!this.audioData)return;const{scrollWidth:t}=this.scrollContainer,{right:e}=this.progressWrapper.getBoundingClientRect();if(this.render(this.audioData),this.isScrollable&&t!==this.scrollContainer.scrollWidth){const{right:i}=this.progressWrapper.getBoundingClientRect(),s=(function(n){const a=2*n;return(a<0?Math.floor(a):Math.ceil(a))/2})(i-e);this.scrollContainer.scrollLeft+=s}}zoom(t){this.options.minPxPerSec=t,this.reRender()}scrollIntoView(t,e=!1){const{scrollLeft:i,scrollWidth:s,clientWidth:n}=this.scrollContainer,a=t*s,c=i,h=i+n,r=n/2;if(this.isDragging)a+30>h?this.scrollContainer.scrollLeft+=30:a-30<c&&(this.scrollContainer.scrollLeft-=30);else{(a<c||a>h)&&(this.scrollContainer.scrollLeft=a-(this.options.autoCenter?r:0));const o=a-i-r;e&&this.options.autoCenter&&o>0&&(this.scrollContainer.scrollLeft+=o)}{const o=this.scrollContainer.scrollLeft,{startX:p,endX:m}=j({scrollLeft:o,scrollWidth:s,clientWidth:n});this.emit("scroll",p,m,o,o+n)}}renderProgress(t,e){if(isNaN(t))return;const i=100*t;this.canvasWrapper.style.clipPath=`polygon(${i}% 0%, 100% 0%, 100% 100%, ${i}% 100%)`,this.progressWrapper.style.width=`${i}%`,this.cursor.style.left=`${i}%`,this.cursor.style.transform=this.options.cursorWidth?`translateX(-${t*this.options.cursorWidth}px)`:"",this.isScrollable&&this.options.autoScroll&&this.scrollIntoView(t,e)}exportImage(t,e,i){return C(this,void 0,void 0,function*(){const s=this.canvasWrapper.querySelectorAll("canvas");if(!s.length)throw new Error("No waveform data");if(i==="dataURL"){const n=Array.from(s).map(a=>a.toDataURL(t,e));return Promise.resolve(n)}return Promise.all(Array.from(s).map(n=>new Promise((a,c)=>{n.toBlob(h=>{h?a(h):c(new Error("Could not export image"))},t,e)})))})}}class tt extends T{constructor(){super(...arguments),this.animationFrameId=null,this.isRunning=!1}start(){if(this.isRunning)return;this.isRunning=!0;const t=()=>{this.isRunning&&(this.emit("tick"),this.animationFrameId=requestAnimationFrame(t))};t()}stop(){this.isRunning=!1,this.animationFrameId!==null&&(cancelAnimationFrame(this.animationFrameId),this.animationFrameId=null)}destroy(){this.stop()}}class H extends T{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playedDuration=0,this._muted=!1,this._playbackRate=1,this._duration=void 0,this.buffer=null,this.currentSrc="",this.paused=!0,this.crossOrigin=null,this.seeking=!1,this.autoplay=!1,this.addEventListener=this.on,this.removeEventListener=this.un,this.audioContext=t,this.gainNode=this.audioContext.createGain(),this.gainNode.connect(this.audioContext.destination)}load(){return C(this,void 0,void 0,function*(){})}get src(){return this.currentSrc}set src(t){if(this.currentSrc=t,this._duration=void 0,!t)return this.buffer=null,void this.emit("emptied");fetch(t).then(e=>{if(e.status>=400)throw new Error(`Failed to fetch ${t}: ${e.status} (${e.statusText})`);return e.arrayBuffer()}).then(e=>this.currentSrc!==t?null:this.audioContext.decodeAudioData(e)).then(e=>{this.currentSrc===t&&(this.buffer=e,this.emit("loadedmetadata"),this.emit("canplay"),this.autoplay&&this.play())}).catch(e=>{console.error("WebAudioPlayer load error:",e)})}_play(){if(!this.paused)return;this.paused=!1,this.bufferNode&&(this.bufferNode.onended=null,this.bufferNode.disconnect()),this.bufferNode=this.audioContext.createBufferSource(),this.buffer&&(this.bufferNode.buffer=this.buffer),this.bufferNode.playbackRate.value=this._playbackRate,this.bufferNode.connect(this.gainNode);let t=this.playedDuration*this._playbackRate;(t>=this.duration||t<0)&&(t=0,this.playedDuration=0),this.bufferNode.start(this.audioContext.currentTime,t),this.playStartTime=this.audioContext.currentTime,this.bufferNode.onended=()=>{this.currentTime>=this.duration&&(this.pause(),this.emit("ended"))}}_pause(){var t;this.paused=!0,(t=this.bufferNode)===null||t===void 0||t.stop(),this.playedDuration+=this.audioContext.currentTime-this.playStartTime}play(){return C(this,void 0,void 0,function*(){this.paused&&(this._play(),this.emit("play"))})}pause(){this.paused||(this._pause(),this.emit("pause"))}stopAt(t){const e=t-this.currentTime,i=this.bufferNode;i?.stop(this.audioContext.currentTime+e),i?.addEventListener("ended",()=>{i===this.bufferNode&&(this.bufferNode=null,this.pause())},{once:!0})}setSinkId(t){return C(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){this._playbackRate=t,this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return(this.paused?this.playedDuration:this.playedDuration+(this.audioContext.currentTime-this.playStartTime))*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playedDuration=t/this._playbackRate,e&&this._play(),this.emit("seeking"),this.emit("timeupdate")}get duration(){var t,e;return(t=this._duration)!==null&&t!==void 0?t:((e=this.buffer)===null||e===void 0?void 0:e.duration)||0}set duration(t){this._duration=t}get volume(){return this.gainNode.gain.value}set volume(t){this.gainNode.gain.value=t,this.emit("volumechange")}get muted(){return this._muted}set muted(t){this._muted!==t&&(this._muted=t,this._muted?this.gainNode.disconnect():this.gainNode.connect(this.audioContext.destination))}canPlayType(t){return/^(audio|video)\//.test(t)}getGainNode(){return this.gainNode}getChannelData(){const t=[];if(!this.buffer)return t;const e=this.buffer.numberOfChannels;for(let i=0;i<e;i++)t.push(this.buffer.getChannelData(i));return t}removeAttribute(t){switch(t){case"src":this.src="";break;case"playbackRate":this.playbackRate=0;break;case"currentTime":this.currentTime=0;break;case"duration":this.duration=0;break;case"volume":this.volume=0;break;case"muted":this.muted=!1}}}const et={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class O extends J{static create(t){return new O(t)}constructor(t){const e=t.media||(t.backend==="WebAudio"?new H:void 0);super({media:e,mediaControls:t.mediaControls,autoplay:t.autoplay,playbackRate:t.audioRate}),this.plugins=[],this.decodedData=null,this.stopAtPosition=null,this.subscriptions=[],this.mediaSubscriptions=[],this.abortController=null,this.options=Object.assign({},et,t),this.timer=new tt;const i=e?void 0:this.getMediaElement();this.renderer=new Z(this.options,i),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initPlugins();const s=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:n,duration:a}=this.options;(s||n&&a)&&this.load(s,n,a).catch(c=>{this.emit("error",c instanceof Error?c:new Error(String(c)))})})}updateProgress(t=this.getCurrentTime()){return this.renderer.renderProgress(t/this.getDuration(),this.isPlaying()),t}initTimerEvents(){this.subscriptions.push(this.timer.on("tick",()=>{if(!this.isSeeking()){const t=this.updateProgress();this.emit("timeupdate",t),this.emit("audioprocess",t),this.stopAtPosition!=null&&this.isPlaying()&&t>=this.stopAtPosition&&this.pause()}}))}initPlayerEvents(){this.isPlaying()&&(this.emit("play"),this.timer.start()),this.mediaSubscriptions.push(this.onMediaEvent("timeupdate",()=>{const t=this.updateProgress();this.emit("timeupdate",t)}),this.onMediaEvent("play",()=>{this.emit("play"),this.timer.start()}),this.onMediaEvent("pause",()=>{this.emit("pause"),this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("emptied",()=>{this.timer.stop(),this.stopAtPosition=null}),this.onMediaEvent("ended",()=>{this.emit("timeupdate",this.getDuration()),this.emit("finish"),this.stopAtPosition=null}),this.onMediaEvent("seeking",()=>{this.emit("seeking",this.getCurrentTime())}),this.onMediaEvent("error",()=>{var t;this.emit("error",(t=this.getMediaElement().error)!==null&&t!==void 0?t:new Error("Media error")),this.stopAtPosition=null}))}initRendererEvents(){this.subscriptions.push(this.renderer.on("click",(t,e)=>{this.options.interact&&(this.seekTo(t),this.emit("interaction",t*this.getDuration()),this.emit("click",t,e))}),this.renderer.on("dblclick",(t,e)=>{this.emit("dblclick",t,e)}),this.renderer.on("scroll",(t,e,i,s)=>{const n=this.getDuration();this.emit("scroll",t*n,e*n,i,s)}),this.renderer.on("render",()=>{this.emit("redraw")}),this.renderer.on("rendered",()=>{this.emit("redrawcomplete")}),this.renderer.on("dragstart",t=>{this.emit("dragstart",t)}),this.renderer.on("dragend",t=>{this.emit("dragend",t)}),this.renderer.on("resize",()=>{this.emit("resize")}));{let t;const e=this.renderer.on("drag",i=>{var s;if(!this.options.interact)return;this.renderer.renderProgress(i),clearTimeout(t);let n=0;const a=this.options.dragToSeek;this.isPlaying()?n=0:a===!0?n=200:a&&typeof a=="object"&&(n=(s=a.debounceTime)!==null&&s!==void 0?s:200),t=setTimeout(()=>{this.seekTo(i)},n),this.emit("interaction",i*this.getDuration()),this.emit("drag",i)});this.subscriptions.push(()=>{clearTimeout(t),e()})}}initPlugins(){var t;!((t=this.options.plugins)===null||t===void 0)&&t.length&&this.options.plugins.forEach(e=>{this.registerPlugin(e)})}unsubscribePlayerEvents(){this.mediaSubscriptions.forEach(t=>t()),this.mediaSubscriptions=[]}setOptions(t){this.options=Object.assign({},this.options,t),t.duration&&!t.peaks&&(this.decodedData=L.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=L.createBuffer(t.peaks,t.duration)),this.renderer.setOptions(this.options),t.audioRate&&this.setPlaybackRate(t.audioRate),t.mediaControls!=null&&(this.getMediaElement().controls=t.mediaControls)}registerPlugin(t){if(this.plugins.includes(t))return t;t._init(this),this.plugins.push(t);const e=t.once("destroy",()=>{this.plugins=this.plugins.filter(i=>i!==t),this.subscriptions=this.subscriptions.filter(i=>i!==e)});return this.subscriptions.push(e),t}unregisterPlugin(t){this.plugins=this.plugins.filter(e=>e!==t),t.destroy()}getWrapper(){return this.renderer.getWrapper()}getWidth(){return this.renderer.getWidth()}getScroll(){return this.renderer.getScroll()}setScroll(t){return this.renderer.setScroll(t)}setScrollTime(t){const e=t/this.getDuration();this.renderer.setScrollPercentage(e)}getActivePlugins(){return this.plugins}loadAudio(t,e,i,s){return C(this,void 0,void 0,function*(){var n;if(this.emit("load",t),!this.options.media&&this.isPlaying()&&this.pause(),this.decodedData=null,this.stopAtPosition=null,(n=this.abortController)===null||n===void 0||n.abort(),this.abortController=null,!e&&!i){const c=this.options.fetchParams||{};window.AbortController&&!c.signal&&(this.abortController=new AbortController,c.signal=this.abortController.signal);const h=o=>this.emit("loading",o);e=yield Y.fetchBlob(t,h,c);const r=this.options.blobMimeType;r&&(e=new Blob([e],{type:r}))}this.setSrc(t,e);const a=yield new Promise(c=>{const h=s||this.getDuration();h?c(h):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>c(this.getDuration()),{once:!0}))});if(!t&&!e){const c=this.getMediaElement();c instanceof H&&(c.duration=a)}if(i)this.decodedData=L.createBuffer(i,a||0);else if(e){const c=yield e.arrayBuffer();this.decodedData=yield L.decode(c,this.options.sampleRate)}this.decodedData&&(this.emit("decode",this.getDuration()),this.renderer.render(this.decodedData)),this.emit("ready",this.getDuration())})}load(t,e,i){return C(this,void 0,void 0,function*(){try{return yield this.loadAudio(t,void 0,e,i)}catch(s){throw this.emit("error",s),s}})}loadBlob(t,e,i){return C(this,void 0,void 0,function*(){try{return yield this.loadAudio("",t,e,i)}catch(s){throw this.emit("error",s),s}})}zoom(t){if(!this.decodedData)throw new Error("No audio loaded");this.renderer.zoom(t),this.emit("zoom",t)}getDecodedData(){return this.decodedData}exportPeaks({channels:t=2,maxLength:e=8e3,precision:i=1e4}={}){if(!this.decodedData)throw new Error("The audio has not been decoded yet");const s=Math.min(t,this.decodedData.numberOfChannels),n=[];for(let a=0;a<s;a++){const c=this.decodedData.getChannelData(a),h=[],r=c.length/e;for(let o=0;o<e;o++){const p=c.slice(Math.floor(o*r),Math.ceil((o+1)*r));let m=0;for(let d=0;d<p.length;d++){const u=p[d];Math.abs(u)>Math.abs(m)&&(m=u)}h.push(Math.round(m*i)/i)}n.push(h)}return n}getDuration(){let t=super.getDuration()||0;return t!==0&&t!==1/0||!this.decodedData||(t=this.decodedData.duration),t}toggleInteraction(t){this.options.interact=t}setTime(t){this.stopAtPosition=null,super.setTime(t),this.updateProgress(t),this.emit("timeupdate",t)}seekTo(t){const e=this.getDuration()*t;this.setTime(e)}play(t,e){const i=Object.create(null,{play:{get:()=>super.play}});return C(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const s=yield i.play.call(this);return e!=null&&(this.media instanceof H?this.media.stopAt(e):this.stopAtPosition=e),s})}playPause(){return C(this,void 0,void 0,function*(){return this.isPlaying()?this.pause():this.play()})}stop(){this.pause(),this.setTime(0)}skip(t){this.setTime(this.getCurrentTime()+t)}empty(){this.load("",[[0]],.001)}setMediaElement(t){this.unsubscribePlayerEvents(),super.setMediaElement(t),this.initPlayerEvents()}exportImage(){return C(this,arguments,void 0,function*(t="image/png",e=1,i="dataURL"){return this.renderer.exportImage(t,e,i)})}destroy(){var t;this.emit("destroy"),(t=this.abortController)===null||t===void 0||t.abort(),this.plugins.forEach(e=>e.destroy()),this.subscriptions.forEach(e=>e()),this.unsubscribePlayerEvents(),this.timer.destroy(),this.renderer.destroy(),super.destroy()}}O.BasePlugin=class extends T{constructor(l){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=l}onInit(){}_init(l){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=l,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(l=>l()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},O.dom=V;export{O as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{aE as f,j as c,r as n,m as p,f as h,c as x,L as g,aF as y}from"./index-BvblFOYP.js";const m=n.createContext(null);m.displayName="ElementFullscreenContext";const C=x("div",{target:"elp1w7k0"})(({theme:e,isExpanded:t})=>({width:"100%",height:"100%",...t?{position:"fixed",top:0,left:0,bottom:0,right:0,background:e.colors.bgColor,zIndex:e.zIndices.fullscreenWrapper,padding:e.spacing.md,paddingTop:e.sizes.fullScreenHeaderHeight,overflow:"auto",display:"flex",alignItems:"center",justifyContent:"center"}:{}}),""),v=()=>{const{setFullScreen:e}=n.useContext(g),[t,s]=n.useState(!1),{fullHeight:d,fullWidth:i}=y(),o=n.useCallback(l=>{s(l),e(l)},[e]),r=n.useCallback(()=>{document.body.style.overflow="hidden",o(!0)},[o]),a=n.useCallback(()=>{document.body.style.overflow="unset",o(!1)},[o]),u=n.useCallback(l=>{l.keyCode===27&&t&&a()},[a,t]);return n.useEffect(()=>(document.addEventListener("keydown",u,!1),()=>{document.removeEventListener("keydown",u,!1)}),[u]),n.useMemo(()=>({expanded:t,zoomIn:r,zoomOut:a,fullHeight:d,fullWidth:i}),[t,r,a,d,i])},w=({children:e})=>{const t=p(),{expanded:s,fullHeight:d,fullWidth:i,zoomIn:o,zoomOut:r}=v(),{width:a,elementRef:u}=h(),l=n.useMemo(()=>({width:s?i:a,height:s?d:void 0,expanded:s,expand:o,collapse:r}),[s,d,i,a,o,r]);return c.jsx(m.Provider,{value:l,children:c.jsx(C,{ref:u,isExpanded:s,"data-testid":"stFullScreenFrame",theme:t,children:e})})};function E(e){const t=s=>c.jsx(w,{children:c.jsx(e,{...s})});return t.displayName=`withFullScreenWrapper(${e.displayName||e.name})`,f(t,e)}export{m as d,E as v};
|
|
Binary file
|