@stlite/desktop 0.98.1 → 0.99.1
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 +36 -36
- package/build/assets/ArrowVegaLiteChart-B-Kd_jPH-Biiko0Ef.js +1 -0
- package/build/assets/Audio-B5gtg70U-Bh9tGjUY.js +1 -0
- package/build/assets/AudioInput-CgFzLi-y-C8cmY_cr.js +1 -0
- package/build/assets/{index-CKw_lXVb-3dsfAMaj.js → Balloons-CqQICrNd-BGoQrXhe.js} +2 -2
- package/build/assets/BidiComponent-CkI6DfPr-CbrqDKKX.js +2 -0
- package/build/assets/Button-BOmzB5Yb-Bpnf-WZl.js +1 -0
- package/build/assets/ButtonGroup-C5sVTynN-DPa0Tx1x.js +2 -0
- package/build/assets/CameraInput-C1f0GN0n-Bo12mEPo.js +1 -0
- package/build/assets/ChatInput-ClqoaQw2-PqG4grVV.js +1 -0
- package/build/assets/Checkbox-ClzElazy-D-AYf8eH.js +1 -0
- package/build/assets/{index-BXKF9Na4-e8_T7zol.js → ColorPicker-mCkrAGPa-CtUHNwYp.js} +3 -3
- package/build/assets/ComponentInstance-B_1vn-IY-BM9ElpU6.js +11 -0
- package/build/assets/DataFrame-CXPcdw96-Crfv7wfu.js +198 -0
- package/build/assets/DateInput-DzaFFasw-CiMjvLKg.js +1 -0
- package/build/assets/DateTimeInput-WmD8vSCU-K1wv6LRy.js +1 -0
- package/build/assets/{index-Dxtfs80M-s0TmhiEk.js → DeckGlJsonChart-CDmFrnUQ-CKLXTmyf.js} +217 -215
- package/build/assets/{index-D52Jf8Ey-SgTlRv8T.js → DownloadButton-g54AS0W2-qOKvF9wp.js} +1 -1
- package/build/assets/{ErrorOutline.esm-DV80JhHP-XkDmlp3T.js → ErrorOutline.esm-B1NqpuZN-D4cKYVYX.js} +1 -1
- package/build/assets/Feedback-DTXGrEzp-Dd_SGEH7.js +1 -0
- package/build/assets/{FileDownload.esm-Bg0DSX1Z-tYB-VhDd.js → FileDownload.esm-B_usFfyI-DvbGAuNe.js} +1 -1
- package/build/assets/FileUploader-CzCdIxed-CWWB6xZB.js +1 -0
- package/build/assets/FormSubmitContent-CstMuKlS-CwJlipqn.js +1 -0
- package/build/assets/{index-DuuHtz-x-Caurorud.js → GraphVizChart-nJ8rg3sZ-B_FsOCth.js} +2 -2
- package/build/assets/{index-B0C1EJi--C9vASPz3.js → Html-CkFoh4ns-BXVZGZ2C.js} +1 -1
- package/build/assets/IFrame-BklekJPV-_sg-kw0j.js +49 -0
- package/build/assets/ImageList-l3ue-eW1-CIwYKSdj.js +1 -0
- package/build/assets/{InputInstructions-GG_DznKT-BTS6NlIa.js → InputInstructions-C3LBp4_M-BIHPK8ho.js} +1 -1
- package/build/assets/Json-DmaVI2eK-CplwjZhb.js +2 -0
- package/build/assets/LinkButton-D87rEwzB-C31w_f7c.js +1 -0
- package/build/assets/MenuButton-DCWYT9Sm-Cjs_mH64.js +1 -0
- package/build/assets/Metric-B85kD6qx-D6Bt_A2_.js +1 -0
- package/build/assets/Multiselect-Dj9HMUjc-C1tpZV37.js +1 -0
- package/build/assets/NumberInput-Bz1Z4Olo-HwfUQwvD.js +1 -0
- package/build/assets/PageLink-DxIPOlCu-CAX1QvMp.js +1 -0
- package/build/assets/{Particles-ByFZ9kUC-B_aeMYcp.js → Particles-CgV8FzZe-CZFoM1Ot.js} +1 -1
- package/build/assets/{index-DlNfwH7j-Ciae2OLh.js → PlotlyChart-DApJXgoh-msWOSLU2.js} +105 -105
- package/build/assets/{index-CzaX93h_-B-_1QLd4.js → Progress-DXRywIcj-D00Siwwp.js} +1 -1
- package/build/assets/{ProgressBar-uLtuFXoi-C547ZD3U.js → ProgressBar-By08lmvS-BN2oE7g_.js} +2 -2
- package/build/assets/{index-C2tfS9CH-BRrFBwHT.js → Radio-DZEQy4hT-Cx0uGU2K.js} +3 -3
- package/build/assets/Selectbox-BywNaXj9-EovVNC_I.js +1 -0
- package/build/assets/Slider-sLEYxDUG-Bby7yVsF.js +2 -0
- package/build/assets/{index-DnMeTGk7-X2HPuQXI.js → Snow-MxXLnUX_-CCUTgEUd.js} +2 -2
- package/build/assets/{index-CxYiRuXO-CRK1FQiS.js → Spinner-D-YJYPV5-qoM-yuRL.js} +1 -1
- package/build/assets/{StreamlitSyntaxHighlighter-0BOUSobY-CgsoE1gN.js → StreamlitSyntaxHighlighter-y_BJ441X-Do55UoZC.js} +1 -1
- package/build/assets/Table-ah-SFAz4-BuzfN8wv.js +1 -0
- package/build/assets/{TableChart.esm-CoMoidiP-DrT_rrb0.js → TableChart.esm-x67iDGlj-hZSJidLi.js} +1 -1
- package/build/assets/TextArea-COwbG28l-yfu63ssv.js +1 -0
- package/build/assets/TextInput-CPqz-18c-DPGxqoCs.js +1 -0
- package/build/assets/TimeInput-BQ-fP8Yi-FMCqKedu.js +3 -0
- package/build/assets/{index-CrKJRmJv-Bg5NDALn.js → Toast-CGUHIZQI-39x9j5Rs.js} +1 -1
- package/build/assets/Video-CWomx7KF-nGUBPGaY.js +1 -0
- package/build/assets/{WidgetLabel-CoLw86qs-CNbX-e3H.js → WidgetLabel-DUaobbKW-DD-xWyXR.js} +1 -1
- package/build/assets/WidgetLabelHelpIcon-Dk_Qm9_8-CtMOr4fX.js +1 -0
- package/build/assets/WidgetLabelHelpIconInline-CkTH9muE-i_BwkvTR.js +1 -0
- package/build/assets/{_baseAssignValue-DQhmkaDt-Bl1quFU6.js → _baseAssignValue-DbpQ8D1L-D2c_-zPN.js} +1 -1
- package/build/assets/b1c37dc02f43b345-BK8hQpFn.woff2 +0 -0
- package/build/assets/{base-input-BdLA32iO-A9B9vy_-.js → base-input-CUlWnT-V-BhBQbzWk.js} +2 -2
- package/build/assets/{checkbox-DFREjf9t-Bj1xZr4O.js → checkbox-CEu7IJmq-3LmskyhR.js} +2 -2
- package/build/assets/{constants-Dj7RTpUo-BGkidDJo.js → constants-BFZIinC9-BhIl5GAK.js} +2 -2
- package/build/assets/{createDownloadLinkElement-DdPyJxB4-BwUogbJk.js → createDownloadLinkElement-CO9Q-pa0-BNUtAwjF.js} +1 -1
- package/build/assets/{createSuper-BZpABwIl-CzqIX_hj.js → createSuper-CPupKoXU-C5x8b8jJ.js} +1 -1
- package/build/assets/data-grid-overlay-editor-D7_bQukB-DqAp5wnt.js +1 -0
- package/build/assets/{downloader-DcCTL3Wz-BV_PV8FK.js → downloader-CZ7qD7NY-DGAnDDXL.js} +1 -1
- package/build/assets/{embed-DsUNNyuf-iklb31Eb.js → embed-Dc8baQ26-DAsqJZrc.js} +4 -4
- package/build/assets/{es6--XPcqeHG-CHWR2W_o.js → es6-BxevHr5y-DDD2E1qH.js} +2 -2
- package/build/assets/{formatNumber-C0_e-CAH-GlcLbdL6.js → formatNumber-DxMjoq14-D-XVTuz9.js} +1 -1
- package/build/assets/iconPosition-9UgvX_TD-BzkVt95G.js +1 -0
- package/build/assets/iframeResizer.contentWindow-CCqu70r3-2dQhJjwY.js +1 -0
- package/build/assets/{index-D8-_3_8b-1KPkAAUR.js → index-BV2WTlzI-BDu7x5w-.js} +1 -1
- package/build/assets/{index-rCmWIVzf.css → index-Bdx5V1kE.css} +1 -1
- package/build/assets/index-BoaYS_fk-BOYhDwkq.js +1 -0
- package/build/assets/{index-D84Izf2I-C_zQnNB2.js → index-CDNzkMOW-Ci5P-rfD.js} +1 -1
- package/build/assets/{index-DuHJMwJD-Bsr8Y8w7.js → index-CJ4tMOMA-DwN410du.js} +1 -1
- package/build/assets/{index-DXEnufEK-CPeh905k.js → index-Co96_X1M-Dl06Rnsd.js} +1 -1
- package/build/assets/index-DJf52eor.js +192 -0
- package/build/assets/{input-vJKt6Tqs-D1h27UxA.js → input-HUYzfsf9-BxmLV7Ek.js} +1 -1
- package/build/assets/{memory-B3L1Fctl-Cn5y4VWL.js → memory-C-LDMFc2-DmYLyk9H.js} +1 -1
- package/build/assets/{moment-CU6QKNej-DcQX_LE0.js → moment-C29_LcvN-BY3oO1nk.js} +1 -1
- package/build/assets/number-overlay-editor-BQXyYsVn-Dh7S4LVs.js +9 -0
- package/build/assets/{numbro-CBbENDeu-C6X7Pww4.js → numbro-CDdPhOTG-s-4vlRUZ.js} +1 -1
- package/build/assets/{pandasStylerUtils-GHHHScPD-CTKMoUtV.js → pandasStylerUtils-BVB-ECxE-CDURxvwo.js} +1 -1
- package/build/assets/{possibleConstructorReturn-E3G46ZYb-Lz9Rlt8w.js → possibleConstructorReturn-YeRoNy63-B2FGD3ja.js} +1 -1
- package/build/assets/reactJsonViewCompat-CeSrJm8p-le930912.js +13 -0
- package/build/assets/resolveDefaultExport-Cy5TTESD-D1yDGtVx.js +1 -0
- package/build/assets/{sandbox-ChAzL-i--BIq4nttm.js → sandbox-DbnteG5V-yqy_7sO8.js} +1 -1
- package/build/assets/select-haj_e3M_-P2nevO2w.js +11 -0
- package/build/assets/{sprintfjs-BB1ejNgh-D_XlFCD8.js → sprintfjs-DwuHM96D-Dbm-A0ro.js} +1 -1
- package/build/assets/stateful-menu-DhWFcRsJ-hkmyKt6q.js +4 -0
- package/build/assets/{styled-components-UJ_u5XUO-B68esmwJ.js → styled-components-BwoIjXty-eQCTyKeV.js} +1 -1
- package/build/assets/{styled-components-BF-9yHWP-Fq0Myn8O.js → styled-components-CRl5ROSi-CaifWlLZ.js} +1 -1
- package/build/assets/{styled-components-BPyosp2h-CHa8nolL.js → styled-components-CggDa8xh-DRn7YfuV.js} +1 -1
- package/build/assets/{threshold-eWsxmMyL-jpRnj60B.js → threshold-C_rop_uq-CSTNJaOo.js} +1 -1
- package/build/assets/timepicker-t1TdfIJG-CM4-XB8w.js +4 -0
- package/build/assets/{timer-DAAwtI0i-CB52lra-.js → timer-CuhnLtz1-DD8qTMUW.js} +1 -1
- package/build/assets/{toConsumableArray-fI4JT57_-CqtYDc1p.js → toConsumableArray-DtFGUM3A-BLxO6YGd.js} +1 -1
- package/build/assets/useBasicWidgetState-Bd8NTj87-Cqs9ZQAV.js +1 -0
- package/build/assets/{useIntlLocale-CYWMTZ3s-Bfz8l4j_.js → useIntlLocale-CXWYgGQX-B2q3sAu2.js} +9 -9
- package/build/assets/useSelectCommon-O2yZsfjb-6cuQoolB.js +1 -0
- package/build/assets/{useTextInputAutoExpand-DKFPNBDa-Cb0YY3m0.js → useTextInputAutoExpand-BTuNAk3V-5wcrsLsu.js} +2 -2
- package/build/assets/useUpdateUiValue-B574r2my-B36XHNQq.js +1 -0
- package/build/assets/useWaveformController-EemjKAv5-CT3VAgB8.js +1 -0
- package/build/assets/utils-DNbZWtPr-BHo82ec1.js +5 -0
- package/build/assets/{value-DwxUZIyI-CNuykc50.js → value-FXychKGJ-DfnNAqu8.js} +1 -1
- package/build/assets/wavesurfer.esm-BdCEnQA2-Cb5Yveqj.js +74 -0
- package/build/assets/withCalculatedWidth-CswVJ4Re-BeXEmgBt.js +1 -0
- package/build/assets/withFullScreenWrapper-CKo__VbV-B1HqecCF.js +1 -0
- package/build/assets/worker-DSGzx9v2-CeEZF0Hz.js +773 -0
- package/build/index.html +2 -2
- package/package.json +7 -7
- package/wheels/streamlit-1.56.0-cp313-none-any.whl +0 -0
- package/build/assets/9897c61aa169e10d-BSbTZIlv.woff2 +0 -0
- package/build/assets/FileHelper-6E1AHofU-qrMXF9BJ.js +0 -5
- package/build/assets/FormClearHelper-CbmTijuR-BhfBTvx4.js +0 -1
- package/build/assets/WidgetLabelHelpIcon-DGQ_r-QQ-BpBcjxpA.js +0 -1
- package/build/assets/WidgetLabelHelpIconInline-CBvJmNo2-CLxNkiVd.js +0 -1
- package/build/assets/data-grid-overlay-editor-QHhShSfm-3TuDDPoi.js +0 -1
- package/build/assets/iconPosition-DC20xXN5-Dq1FtUtw.js +0 -1
- package/build/assets/iframeResizer.contentWindow-CK2JqAeV-DqbaJEzN.js +0 -1
- package/build/assets/index-9BL32MjC-d0WHvbzb.js +0 -1
- package/build/assets/index-B4B1qPeD-B4iZ3Hle.js +0 -1
- package/build/assets/index-B5UL-R7r-CWJT9KeA.js +0 -1
- package/build/assets/index-BGnBFvx7-CovA4PPU.js +0 -1
- package/build/assets/index-BLF4SOe9-BATezQGi.js +0 -1
- package/build/assets/index-BVqn7psP-DOIOIfGO.js +0 -1
- package/build/assets/index-BWq44yej-BLlqoxJR.js +0 -2
- package/build/assets/index-BYY96E5j-Bp1H9cgU.js +0 -1
- package/build/assets/index-BZJBZSAA-DFqiOZai.js +0 -2
- package/build/assets/index-BjrlCNX2-LTYqrHHV.js +0 -1
- package/build/assets/index-BmK3aM70-BtZtyb9b.js +0 -2
- package/build/assets/index-BuOHAFyU-CgkpNrjG.js +0 -1
- package/build/assets/index-BwVivyUp-BMVGZ9_Q.js +0 -1
- package/build/assets/index-CDQEgcT1-DtNnQE5Q.js +0 -3
- package/build/assets/index-CSHbNsrd-CaeMETbK.js +0 -1
- package/build/assets/index-CStypS2h-ZcgczjKg.js +0 -1
- package/build/assets/index-CTUrfAxj--v8quZkn.js +0 -2
- package/build/assets/index-CYGEb27Q-2USI782v.js +0 -1
- package/build/assets/index-CZIHO3Hi-CIp8gy8I.js +0 -1
- package/build/assets/index-Cqst7YJT-C9v2_kdG.js +0 -1
- package/build/assets/index-DCNthJH_-DBm0ode_.js +0 -1
- package/build/assets/index-DKp3_2FO-qvF0epur.js +0 -1
- package/build/assets/index-Dd99Pbav-BGjrs667.js +0 -1
- package/build/assets/index-DegoUuPm.js +0 -171
- package/build/assets/index-DpazIH3n-D6BMkmZF.js +0 -1
- package/build/assets/index-LfSwL_C3-BhFtSxQv.js +0 -1
- package/build/assets/index-SfqmeEwF-Dq9F6PRu.js +0 -1
- package/build/assets/index-Zh4mTo6Q-BW_atvXh.js +0 -1
- package/build/assets/index-dDzvj0X4-DcwcRJ2U.js +0 -1
- package/build/assets/index-ebIdPrk5-uPj-BdYi.js +0 -1
- package/build/assets/index-glyZT6vh-DgW3Iulb.js +0 -11
- package/build/assets/index-hpzROwMA-mo9c0M0y.js +0 -1
- package/build/assets/index-t2JVnYeR-CxNAko6c.js +0 -198
- package/build/assets/main-B1Ej7gwo-CcTKNe5S.js +0 -13
- package/build/assets/number-overlay-editor-DJYV-edd-B_O-Ktcq.js +0 -9
- package/build/assets/select-Pj-68ff--fhVXPkd8.js +0 -14
- package/build/assets/timepicker-BJ4MpQyD-d8465QWp.js +0 -4
- package/build/assets/uniqueId-DvP0IaTe-DffbsNAr.js +0 -1
- package/build/assets/useBasicWidgetState-JbPrIror-Bu87DmaN.js +0 -1
- package/build/assets/useSelectCommon-DTdQ2TWs-DMezB-1T.js +0 -1
- package/build/assets/useUpdateUiValue-DMih0kWV-BWZ6Saew.js +0 -1
- package/build/assets/useWaveformController-BeUcMXLl-DLfXFMqt.js +0 -1
- package/build/assets/wavesurfer.esm-idh1jvYE-D4Wwdy60.js +0 -74
- package/build/assets/withCalculatedWidth-Du6RrD8E-CIxv0z4S.js +0 -1
- package/build/assets/withFullScreenWrapper-uh7txjJc-CYEgnXN4.js +0 -1
- package/build/assets/worker-DAN7Os1o-BP8Vk1l7.js +0 -106
- package/wheels/streamlit-1.55.0-cp313-none-any.whl +0 -0
- /package/build/assets/{index-BWXbSx5b-3ZGL6YOx.js → index-BKiUojFK-3ZGL6YOx.js} +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function x(c,t,e,i){return new(e||(e=Promise))(function(s,n){function a(r){try{l(i.next(r))}catch(h){n(h)}}function o(r){try{l(i.throw(r))}catch(h){n(h)}}function l(r){var h;r.done?s(r.value):(h=r.value,h instanceof e?h:new e(function(p){p(h)})).then(a,o)}l((i=i.apply(c,t||[])).next())})}class H{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 N={decode:function(c,t){return x(this,void 0,void 0,function*(){const e=new AudioContext({sampleRate:t});try{return yield e.decodeAudioData(c)}finally{e.close()}})},createBuffer:function(c,t){if(!c||c.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 c[0]=="number"&&(c=[c]),!c[0]||c[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 o=0;o<n;o++){const l=Math.abs(s[o]);l>a&&(a=l)}for(const o of i)for(let l=0;l<n;l++)o[l]/=a}})(c);const e=c.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 G(c,t){const e=t.xmlns?document.createElementNS(t.xmlns,c):document.createElement(c);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(G(n,a));else i==="style"?Object.assign(e.style,s):i==="textContent"?e.textContent=s:e.setAttribute(i,s.toString());return e}function j(c,t,e){const i=G(c,t||{});return e?.appendChild(i),i}var K=Object.freeze({__proto__:null,createElement:j,default:j});const Q={fetchBlob:function(c,t,e){return x(this,void 0,void 0,function*(){const i=yield fetch(c,e);if(i.status>=400)throw new Error(`Failed to fetch ${c}: ${i.status} (${i.statusText})`);return(function(s,n){x(this,void 0,void 0,function*(){if(!s.body||!s.headers)return;const a=s.body.getReader(),o=Number(s.headers.get("Content-Length"))||0;let l=0;const r=h=>{l+=h?.length||0;const p=Math.round(l/o*100);n(p)};try{for(;;){const h=yield a.read();if(h.done)break;r(h.value)}}catch(h){console.warn("Progress tracking error:",h)}})})(i.clone(),t),i.blob()})}};function C(c){let t=c;const e=new Set;return{get value(){return t},set(i){Object.is(t,i)||(t=i,e.forEach(s=>s(t)))},update(i){this.set(i(t))},subscribe:i=>(e.add(i),()=>e.delete(i))}}function A(c,t){const e=C(c());return t.forEach(i=>i.subscribe(()=>{const s=c();Object.is(e.value,s)||e.set(s)})),{get value(){return e.value},subscribe:i=>e.subscribe(i)}}function _(c,t){let e;const i=()=>{e&&(e(),e=void 0),e=c()},s=t.map(n=>n.subscribe(i));return i(),()=>{e&&(e(),e=void 0),s.forEach(n=>n())}}class tt extends H{get isPlayingSignal(){return this._isPlaying}get currentTimeSignal(){return this._currentTime}get durationSignal(){return this._duration}get volumeSignal(){return this._volume}get mutedSignal(){return this._muted}get playbackRateSignal(){return this._playbackRate}get seekingSignal(){return this._seeking}constructor(t){super(),this.isExternalMedia=!1,this.reactiveMediaEventCleanups=[],t.media?(this.media=t.media,this.isExternalMedia=!0):this.media=document.createElement("audio"),this._isPlaying=C(!1),this._currentTime=C(0),this._duration=C(0),this._volume=C(this.media.volume),this._muted=C(this.media.muted),this._playbackRate=C(this.media.playbackRate||1),this._seeking=C(!1),this.setupReactiveMediaEvents(),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})}setupReactiveMediaEvents(){this.reactiveMediaEventCleanups.push(this.onMediaEvent("play",()=>{this._isPlaying.set(!0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("pause",()=>{this._isPlaying.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ended",()=>{this._isPlaying.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("timeupdate",()=>{this._currentTime.set(this.media.currentTime)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("durationchange",()=>{this._duration.set(this.media.duration||0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("loadedmetadata",()=>{this._duration.set(this.media.duration||0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeking",()=>{this._seeking.set(!0)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("seeked",()=>{this._seeking.set(!1)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("volumechange",()=>{this._volume.set(this.media.volume),this._muted.set(this.media.muted)})),this.reactiveMediaEventCleanups.push(this.onMediaEvent("ratechange",()=>{this._playbackRate.set(this.media.playbackRate)}))}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.reactiveMediaEventCleanups.forEach(t=>t()),this.reactiveMediaEventCleanups=[],this.isExternalMedia||(this.media.pause(),this.revokeSrc(),this.media.removeAttribute("src"),this.media.load(),this.media.remove())}setMediaElement(t){this.reactiveMediaEventCleanups.forEach(e=>e()),this.reactiveMediaEventCleanups=[],this.media=t,this.setupReactiveMediaEvents()}play(){return x(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 et({maxTop:c,maxBottom:t,halfHeight:e,vScale:i,barMinHeight:s=0,barAlign:n}){let a=Math.round(c*e*i),o=a+Math.round(t*e*i)||1;return o<s&&(o=s,n||(a=o/2)),{topHeight:a,totalHeight:o}}function it({barAlign:c,halfHeight:t,topHeight:e,totalHeight:i,canvasHeight:s}){return c==="top"?0:c==="bottom"?s-i:t-e}function X(c,t,e){const i=t-c.left,s=e-c.top;return[i/c.width,s/c.height]}function U(c){return!!(c.barWidth||c.barGap||c.barAlign)}function V(c,t){if(!U(t))return c;const e=t.barWidth||.5,i=e+(t.barGap||e/2);return i===0?c:Math.floor(c/i)*i}function q({scrollLeft:c,totalWidth:t,numCanvases:e}){if(t===0)return[0];const i=c/t,s=Math.floor(i*e);return[s-1,s,s+1]}function Y(c){const t=c._cleanup;typeof t=="function"&&t()}function st(c){const t=C({scrollLeft:c.scrollLeft,scrollWidth:c.scrollWidth,clientWidth:c.clientWidth}),e=A(()=>(function(n){const{scrollLeft:a,scrollWidth:o,clientWidth:l}=n;if(o===0)return{startX:0,endX:1};const r=a/o,h=(a+l)/o;return{startX:Math.max(0,Math.min(1,r)),endX:Math.max(0,Math.min(1,h))}})(t.value),[t]),i=A(()=>(function(n){return{left:n.scrollLeft,right:n.scrollLeft+n.clientWidth}})(t.value),[t]),s=()=>{t.set({scrollLeft:c.scrollLeft,scrollWidth:c.scrollWidth,clientWidth:c.clientWidth})};return c.addEventListener("scroll",s,{passive:!0}),{scrollData:t,percentages:e,bounds:i,cleanup:()=>{c.removeEventListener("scroll",s),Y(t)}}}class nt extends H{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.dragStream=null,this.scrollStream=null,this.containerInlinePadding=0,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"),this.calculateInlinePadding(),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(){this.wrapper.addEventListener("click",e=>{const i=this.wrapper.getBoundingClientRect(),[s,n]=X(i,e.clientX,e.clientY);this.emit("click",s,n)}),this.wrapper.addEventListener("dblclick",e=>{const i=this.wrapper.getBoundingClientRect(),[s,n]=X(i,e.clientX,e.clientY);this.emit("dblclick",s,n)}),this.options.dragToSeek!==!0&&typeof this.options.dragToSeek!="object"||this.initDrag(),this.scrollStream=st(this.scrollContainer);const t=_(()=>{const{startX:e,endX:i}=this.scrollStream.percentages.value,{left:s,right:n}=this.scrollStream.bounds.value;this.emit("scroll",e,i,s,n)},[this.scrollStream.percentages,this.scrollStream.bounds]);if(this.subscriptions.push(t),typeof ResizeObserver=="function"){const e=this.createDelay(100);this.resizeObserver=new ResizeObserver(()=>{e().then(()=>this.onContainerResize()).catch(()=>{})}),this.resizeObserver.observe(this.scrollContainer)}}onContainerResize(){const t=this.parent.clientWidth;this.calculateInlinePadding(),t===this.lastContainerWidth&&this.options.height!=="auto"||(this.lastContainerWidth=t,this.reRender(),this.emit("resize"))}initDrag(){if(this.dragStream)return;this.dragStream=(function(e,i={}){const{threshold:s=3,mouseButton:n=0,touchDelay:a=100}=i,o=C(null),l=new Map,r=matchMedia("(pointer: coarse)").matches;let h=()=>{};const p=d=>{if(d.button!==n||(l.set(d.pointerId,d),l.size>1))return;let m=d.clientX,u=d.clientY,g=!1;const v=Date.now(),P=e.getBoundingClientRect(),{left:E,top:k}=P,w=b=>{if(b.defaultPrevented||l.size>1||r&&Date.now()-v<a)return;const R=b.clientX,D=b.clientY,W=R-m,L=D-u;(g||Math.abs(W)>s||Math.abs(L)>s)&&(b.preventDefault(),b.stopPropagation(),g||(o.set({type:"start",x:m-E,y:u-k}),g=!0),o.set({type:"move",x:R-E,y:D-k,deltaX:W,deltaY:L}),m=R,u=D)},S=b=>{if(l.delete(b.pointerId),g){const R=b.clientX,D=b.clientY;o.set({type:"end",x:R-E,y:D-k})}h()},y=b=>{l.delete(b.pointerId),b.relatedTarget&&b.relatedTarget!==document.documentElement||S(b)},M=b=>{g&&(b.stopPropagation(),b.preventDefault())},T=b=>{b.defaultPrevented||l.size>1||g&&b.preventDefault()};document.addEventListener("pointermove",w),document.addEventListener("pointerup",S),document.addEventListener("pointerout",y),document.addEventListener("pointercancel",y),document.addEventListener("touchmove",T,{passive:!1}),document.addEventListener("click",M,{capture:!0}),h=()=>{document.removeEventListener("pointermove",w),document.removeEventListener("pointerup",S),document.removeEventListener("pointerout",y),document.removeEventListener("pointercancel",y),document.removeEventListener("touchmove",T),setTimeout(()=>{document.removeEventListener("click",M,{capture:!0})},10)}};return e.addEventListener("pointerdown",p),{signal:o,cleanup:()=>{h(),e.removeEventListener("pointerdown",p),l.clear(),Y(o)}}})(this.wrapper);const t=_(()=>{const e=this.dragStream.signal.value;if(!e)return;const i=this.wrapper.getBoundingClientRect().width,s=(n=e.x/i)<0?0:n>1?1:n;var n;e.type==="start"?(this.isDragging=!0,this.emit("dragstart",s)):e.type==="move"?this.emit("drag",s):e.type==="end"&&(this.isDragging=!1,this.emit("dragend",s))},[this.dragStream.signal]);this.subscriptions.push(t)}calculateInlinePadding(){const{paddingLeft:t,paddingRight:e}=getComputedStyle(this.scrollContainer),i=parseFloat(t)+parseFloat(e);this.containerInlinePadding=Number.isNaN(i)?0:i}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){var e;if(this.options.container!==t.container){const i=this.parentFromOptionsContainer(t.container);i.appendChild(this.container),this.parent=i}t.dragToSeek===!0||typeof this.options.dragToSeek=="object"?this.initDrag():((e=this.dragStream)===null||e===void 0||e.cleanup(),this.dragStream=null),this.options=t,this.reRender()}getWrapper(){return this.wrapper}getWidth(){return this.scrollContainer.clientWidth-this.containerInlinePadding}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=[],this.dragStream&&(this.dragStream.cleanup(),this.dragStream=null),this.scrollStream&&(this.scrollStream.cleanup(),this.scrollStream=null)}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:o,numberOfChannels:l,defaultHeight:r=128}){if(n==null)return r;const h=Number(n);if(!isNaN(h))return h;if(n==="auto"){const p=o||r;return a?.every(d=>!d.overlay)?p/l:p}return r})({optionsHeight:t,optionsSplitChannels:e,parentHeight:this.parent.clientHeight,numberOfChannels:s,defaultHeight:128})}convertColorValues(t,e){return(function(i,s,n){if(!Array.isArray(i))return i||"";if(i.length===0)return"#999";if(i.length<2)return i[0]||"";const a=document.createElement("canvas"),o=a.getContext("2d"),l=n??a.height*s,r=o.createLinearGradient(0,0,0,l||s),h=1/(i.length-1);return i.forEach((p,d)=>{r.addColorStop(d*h,p)}),r})(t,this.getPixelRatio(),e?.canvas.height)}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:o,barWidth:l,barRadius:r,barIndexScale:h,barSpacing:p,barMinHeight:d}=(function({width:u,height:g,length:v,options:P,pixelRatio:E}){const k=g/2,w=P.barWidth?P.barWidth*E:1,S=P.barGap?P.barGap*E:P.barWidth?w/2:0,y=w+S||1;return{halfHeight:k,barWidth:w,barGap:S,barRadius:P.barRadius||0,barMinHeight:P.barMinHeight?P.barMinHeight*E:0,barIndexScale:v>0?u/y/v:0,barSpacing:y}})({width:n,height:a,length:(t[0]||[]).length,options:e,pixelRatio:this.getPixelRatio()}),m=(function({channelData:u,barIndexScale:g,barSpacing:v,barWidth:P,halfHeight:E,vScale:k,canvasHeight:w,barAlign:S,barMinHeight:y}){const M=u[0]||[],T=u[1]||M,b=M.length,R=[];let D=0,W=0,L=0;for(let f=0;f<=b;f++){const O=Math.round(f*g);if(O>D){const{topHeight:Z,totalHeight:F}=et({maxTop:W,maxBottom:L,halfHeight:E,vScale:k,barMinHeight:y,barAlign:S}),J=it({barAlign:S,halfHeight:E,topHeight:Z,totalHeight:F,canvasHeight:w});R.push({x:D*v,y:J,width:P,height:F}),D=O,W=0,L=0}const B=Math.abs(M[f]||0),$=Math.abs(T[f]||0);B>W&&(W=B),$>L&&(L=$)}return R})({channelData:t,barIndexScale:h,barSpacing:p,barWidth:l,halfHeight:o,vScale:s,canvasHeight:a,barAlign:e.barAlign,barMinHeight:d});i.beginPath();for(const u of m)r&&"roundRect"in i?i.roundRect(u.x,u.y,u.width,u.height,r):i.rect(u.x,u.y,u.width,u.height);i.fill(),i.closePath()}renderLineWaveform(t,e,i,s){const{width:n,height:a}=i.canvas,o=(function({channelData:l,width:r,height:h,vScale:p}){const d=h/2,m=l[0]||[];return[m,l[1]||m].map((u,g)=>{const v=u.length,P=v?r/v:0,E=d,k=g===0?-1:1,w=[{x:0,y:E}];let S=0,y=0;for(let M=0;M<=v;M++){const T=Math.round(M*P);if(T>S){const R=E+(Math.round(y*d*p)||1)*k;w.push({x:S,y:R}),S=T,y=0}const b=Math.abs(u[M]||0);b>y&&(y=b)}return w.push({x:S,y:E}),w})})({channelData:t,width:n,height:a,vScale:s});i.beginPath();for(const l of o)if(l.length){i.moveTo(l[0].x,l[0].y);for(let r=1;r<l.length;r++){const h=l[r];i.lineTo(h.x,h.y)}}i.fill(),i.closePath()}renderWaveform(t,e,i){if(i.fillStyle=this.convertColorValues(e.waveColor,i),e.renderFunction)return void e.renderFunction(t,i);const s=(function({channelData:n,barHeight:a,normalize:o,maxPeak:l}){var r;const h=a||1;if(!o)return h;const p=n[0];if(!p||p.length===0)return h;let d=l??0;if(!l)for(let m=0;m<p.length;m++){const u=(r=p[m])!==null&&r!==void 0?r:0,g=Math.abs(u);g>d&&(d=g)}return d?h/d:h})({channelData:t,barHeight:e.barHeight,normalize:e.normalize,maxPeak:e.maxPeak});U(e)?this.renderBarWaveform(t,e,i,s):this.renderLineWaveform(t,e,i,s)}renderSingleCanvas(t,e,i,s,n,a,o){const l=this.getPixelRatio(),r=document.createElement("canvas");r.width=Math.round(i*l),r.height=Math.round(s*l),r.style.width=`${i}px`,r.style.height=`${s}px`,r.style.left=`${Math.round(n)}px`,a.appendChild(r);const h=r.getContext("2d");if(e.renderFunction?(h.fillStyle=this.convertColorValues(e.waveColor,h),e.renderFunction(t,h)):this.renderWaveform(t,e,h),r.width>0&&r.height>0){const p=r.cloneNode(),d=p.getContext("2d");d.drawImage(r,0,0),d.globalCompositeOperation="source-in",d.fillStyle=this.convertColorValues(e.progressColor,d),d.fillRect(0,0,r.width,r.height),o.appendChild(p)}}renderMultiCanvas(t,e,i,s,n,a){const o=this.getPixelRatio(),{clientWidth:l}=this.scrollContainer,r=i/o,h=(function({clientWidth:u,totalWidth:g,options:v}){return V(Math.min(8e3,u,g),v)})({clientWidth:l,totalWidth:r,options:e});let p={};if(h===0)return;const d=u=>{if(u<0||u>=m||p[u])return;p[u]=!0;const g=u*h;let v=Math.min(r-g,h);if(v=V(v,e),v<=0)return;const P=(function({channelData:E,offset:k,clampedWidth:w,totalWidth:S}){return E.map(y=>{const M=Math.floor(k/S*y.length),T=Math.floor((k+w)/S*y.length);return y.slice(M,T)})})({channelData:t,offset:g,clampedWidth:v,totalWidth:r});this.renderSingleCanvas(P,e,v,s,g,n,a)},m=Math.ceil(r/h);if(!this.isScrollable){for(let u=0;u<m;u++)d(u);return}if(q({scrollLeft:this.scrollContainer.scrollLeft,totalWidth:r,numCanvases:m}).forEach(u=>d(u)),m>1){const u=this.on("scroll",()=>{const{scrollLeft:g}=this.scrollContainer;Object.keys(p).length>10&&(n.innerHTML="",a.innerHTML="",p={}),q({scrollLeft:g,totalWidth:r,numCanvases:m}).forEach(v=>d(v))});this.unsubscribeOnScroll.push(u)}}renderChannel(t,e,i,s){var{overlay:n}=e,a=(function(h,p){var d={};for(var m in h)Object.prototype.hasOwnProperty.call(h,m)&&p.indexOf(m)<0&&(d[m]=h[m]);if(h!=null&&typeof Object.getOwnPropertySymbols=="function"){var u=0;for(m=Object.getOwnPropertySymbols(h);u<m.length;u++)p.indexOf(m[u])<0&&Object.prototype.propertyIsEnumerable.call(h,m[u])&&(d[m[u]]=h[m[u]])}return d})(e,["overlay"]);const o=document.createElement("div"),l=this.getHeight(a.height,a.splitChannels);o.style.height=`${l}px`,n&&s>0&&(o.style.marginTop=`-${l}px`),this.canvasWrapper.style.minHeight=`${l}px`,this.canvasWrapper.appendChild(o);const r=o.cloneNode();this.progressWrapper.appendChild(r),this.renderMultiCanvas(t,a,i,l,o,r)}render(t){return x(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-this.containerInlinePadding,{scrollWidth:n,isScrollable:a,useParentWidth:o,width:l}=(function({duration:r,minPxPerSec:h=0,parentWidth:p,fillParent:d,pixelRatio:m}){const u=Math.ceil(r*h),g=u>p,v=!!(d&&!g);return{scrollWidth:u,isScrollable:g,useParentWidth:v,width:(v?p:u)*m}})({duration:t.duration,minPxPerSec:this.options.minPxPerSec||0,parentWidth:s,fillParent:this.options.fillParent,pixelRatio:i});if(this.isScrollable=a,this.wrapper.style.width=o?"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 h=Object.assign(Object.assign({},this.options),(e=this.options.splitChannels)===null||e===void 0?void 0:e[r]);this.renderChannel([t.getChannelData(r)],h,l,r)}else{const r=[t.getChannelData(0)];t.numberOfChannels>1&&r.push(t.getChannelData(1)),this.renderChannel(r,this.options,l,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&&this.scrollContainer.scrollLeft)this.scrollContainer.scrollLeft=0;else if(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){var i;const{scrollLeft:s,scrollWidth:n,clientWidth:a}=this.scrollContainer,o=t*n,l=s,r=s+a,h=a/2;if(this.isDragging)o+30>r?this.scrollContainer.scrollLeft+=30:o-30<l&&(this.scrollContainer.scrollLeft-=30);else{(o<l||o>r)&&(this.scrollContainer.scrollLeft=o-(this.options.autoCenter?h:0));const p=o-s-h;if(e&&this.options.autoCenter&&p>0){const d=(i=this.audioData)===null||i===void 0?void 0:i.duration;if(d===void 0||d<=0)return void(this.scrollContainer.scrollLeft+=p);const m=n/d;this.scrollContainer.scrollLeft+=m<=600?Math.min(p,10):p}}}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.audioData&&this.audioData.duration>0&&this.scrollIntoView(t,e)}exportImage(t,e,i){return x(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,o)=>{n.toBlob(l=>{l?a(l):o(new Error("Could not export image"))},t,e)})))})}}class rt extends H{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 z extends H{constructor(t=new AudioContext){super(),this.bufferNode=null,this.playStartTime=0,this.playbackPosition=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 x(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.playbackPosition;(t>=this.duration||t<0)&&(t=0,this.playbackPosition=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.playbackPosition+=(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}play(){return x(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 x(this,void 0,void 0,function*(){return this.audioContext.setSinkId(t)})}get playbackRate(){return this._playbackRate}set playbackRate(t){const e=!this.paused;e&&this._pause(),this._playbackRate=t,e&&this._play(),this.bufferNode&&(this.bufferNode.playbackRate.value=t)}get currentTime(){return this.paused?this.playbackPosition:this.playbackPosition+(this.audioContext.currentTime-this.playStartTime)*this._playbackRate}set currentTime(t){const e=!this.paused;e&&this._pause(),this.playbackPosition=t,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 at={waveColor:"#999",progressColor:"#555",cursorWidth:1,minPxPerSec:0,fillParent:!0,interact:!0,dragToSeek:!1,autoScroll:!0,autoCenter:!0,sampleRate:8e3};class I extends tt{static create(t){return new I(t)}getState(){return this.wavesurferState}getRenderer(){return this.renderer}constructor(t){const e=t.media||(t.backend==="WebAudio"?new z: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.reactiveCleanups=[],this.options=Object.assign({},at,t);const{state:i,actions:s}=(function(o){var l,r,h,p,d,m;const u=(l=o?.currentTime)!==null&&l!==void 0?l:C(0),g=(r=o?.duration)!==null&&r!==void 0?r:C(0),v=(h=o?.isPlaying)!==null&&h!==void 0?h:C(!1),P=(p=o?.isSeeking)!==null&&p!==void 0?p:C(!1),E=(d=o?.volume)!==null&&d!==void 0?d:C(1),k=(m=o?.playbackRate)!==null&&m!==void 0?m:C(1),w=C(null),S=C(null),y=C(""),M=C(0),T=C(0),b=A(()=>!v.value,[v]),R=A(()=>w.value!==null,[w]),D=A(()=>R.value&&g.value>0,[R,g]),W=A(()=>u.value,[u]),L=A(()=>g.value>0?u.value/g.value:0,[u,g]);return{state:{currentTime:u,duration:g,isPlaying:v,isPaused:b,isSeeking:P,volume:E,playbackRate:k,audioBuffer:w,peaks:S,url:y,zoom:M,scrollPosition:T,canPlay:R,isReady:D,progress:W,progressPercent:L},actions:{setCurrentTime:f=>{const O=Math.max(0,Math.min(g.value||1/0,f));u.set(O)},setDuration:f=>{g.set(Math.max(0,f))},setPlaying:f=>{v.set(f)},setSeeking:f=>{P.set(f)},setVolume:f=>{const O=Math.max(0,Math.min(1,f));E.set(O)},setPlaybackRate:f=>{const O=Math.max(.1,Math.min(16,f));k.set(O)},setAudioBuffer:f=>{w.set(f),f&&g.set(f.duration)},setPeaks:f=>{S.set(f)},setUrl:f=>{y.set(f)},setZoom:f=>{M.set(Math.max(0,f))},setScrollPosition:f=>{T.set(Math.max(0,f))}}}})({isPlaying:this.isPlayingSignal,currentTime:this.currentTimeSignal,duration:this.durationSignal,volume:this.volumeSignal,playbackRate:this.playbackRateSignal,isSeeking:this.seekingSignal});this.wavesurferState=i,this.wavesurferActions=s,this.timer=new rt;const n=e?void 0:this.getMediaElement();this.renderer=new nt(this.options,n),this.initPlayerEvents(),this.initRendererEvents(),this.initTimerEvents(),this.initReactiveState(),this.initPlugins();const a=this.options.url||this.getSrc()||"";Promise.resolve().then(()=>{this.emit("init");const{peaks:o,duration:l}=this.options;(a||o&&l)&&this.load(a,o,l).catch(r=>{this.emit("error",r instanceof Error?r:new Error(String(r)))})})}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()}}))}initReactiveState(){this.reactiveCleanups.push((function(t,e){const i=[];i.push(_(()=>{const a=t.isPlaying.value;e.emit(a?"play":"pause")},[t.isPlaying])),i.push(_(()=>{const a=t.currentTime.value;e.emit("timeupdate",a),t.isPlaying.value&&e.emit("audioprocess",a)},[t.currentTime,t.isPlaying])),i.push(_(()=>{t.isSeeking.value&&e.emit("seeking",t.currentTime.value)},[t.isSeeking,t.currentTime]));let s=!1;i.push(_(()=>{t.isReady.value&&!s&&(s=!0,e.emit("ready",t.duration.value))},[t.isReady,t.duration]));let n=!1;return i.push(_(()=>{const a=t.isPlaying.value,o=t.currentTime.value,l=t.duration.value,r=l>0&&o>=l;n&&!a&&r&&e.emit("finish"),n=a&&r},[t.isPlaying,t.currentTime,t.duration])),i.push(_(()=>{const a=t.zoom.value;a>0&&e.emit("zoom",a)},[t.zoom])),()=>{i.forEach(a=>a())}})(this.wavesurferState,{emit:this.emit.bind(this)}))}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=N.createBuffer(this.exportPeaks(),t.duration)),t.peaks&&t.duration&&(this.decodedData=N.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 x(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 o=this.options.fetchParams||{};window.AbortController&&!o.signal&&(this.abortController=new AbortController,o.signal=this.abortController.signal);const l=h=>this.emit("loading",h);e=yield Q.fetchBlob(t,l,o);const r=this.options.blobMimeType;r&&(e=new Blob([e],{type:r}))}this.setSrc(t,e);const a=yield new Promise(o=>{const l=s||this.getDuration();l?o(l):this.mediaSubscriptions.push(this.onMediaEvent("loadedmetadata",()=>o(this.getDuration()),{once:!0}))});if(!t&&!e){const o=this.getMediaElement();o instanceof z&&(o.duration=a)}if(i)this.decodedData=N.createBuffer(i,a||0);else if(e){const o=yield e.arrayBuffer();this.decodedData=yield N.decode(o,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 x(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 x(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 o=this.decodedData.getChannelData(a),l=[],r=o.length/e;for(let h=0;h<e;h++){const p=o.slice(Math.floor(h*r),Math.ceil((h+1)*r));let d=0;for(let m=0;m<p.length;m++){const u=p[m];Math.abs(u)>Math.abs(d)&&(d=u)}l.push(Math.round(d*i)/i)}n.push(l)}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 x(this,void 0,void 0,function*(){t!=null&&this.setTime(t);const s=yield i.play.call(this);return e!=null&&(this.media instanceof z?this.media.stopAt(e):this.stopAtPosition=e),s})}playPause(){return x(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 x(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.reactiveCleanups.forEach(e=>e()),this.reactiveCleanups=[],this.timer.destroy(),this.renderer.destroy(),super.destroy()}}I.BasePlugin=class extends H{constructor(c){super(),this.subscriptions=[],this.isDestroyed=!1,this.options=c}onInit(){}_init(c){this.isDestroyed&&(this.subscriptions=[],this.isDestroyed=!1),this.wavesurfer=c,this.onInit()}destroy(){this.emit("destroy"),this.subscriptions.forEach(c=>c()),this.subscriptions=[],this.isDestroyed=!0,this.wavesurfer=void 0}},I.dom=K;export{I as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cw as o,G as c,j as t,ap as r}from"./index-DJf52eor.js";const l=s=>{const e=a=>{const{width:i,elementRef:n}=c();return t.jsx(r,{ref:n,children:t.jsx(s,{...a,width:i})})};return e.displayName=`withCalculatedWidth(${s.displayName||s.name})`,o(e,s)};export{l as o};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{cw as p,r as n,j as c,N as h,G as f,cx as x,cy as g,x as y}from"./index-DJf52eor.js";const m=n.createContext(null);m.displayName="ElementFullscreenContext";const w=y("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"}:{}}),""),C=()=>{const{setFullScreen:e}=n.useContext(x),[t,s]=n.useState(!1),{fullHeight:d,fullWidth:i}=g(),l=n.useCallback(a=>{s(a),e(a)},[e]),r=n.useCallback(()=>{document.body.style.overflow="hidden",l(!0)},[l]),o=n.useCallback(()=>{document.body.style.overflow="unset",l(!1)},[l]),u=n.useCallback(a=>{a.keyCode===27&&t&&o()},[o,t]);return n.useEffect(()=>(document.addEventListener("keydown",u,!1),()=>{document.removeEventListener("keydown",u,!1)}),[u]),n.useMemo(()=>({expanded:t,zoomIn:r,zoomOut:o,fullHeight:d,fullWidth:i}),[t,r,o,d,i])},v=({children:e})=>{const t=h(),{expanded:s,fullHeight:d,fullWidth:i,zoomIn:l,zoomOut:r}=C(),{width:o,elementRef:u}=f(),a=n.useMemo(()=>({width:s?i:o,height:s?d:void 0,expanded:s,expand:l,collapse:r}),[s,d,i,o,l,r]);return c.jsx(m.Provider,{value:a,children:c.jsx(w,{ref:u,isExpanded:s,"data-testid":"stFullScreenFrame",theme:t,children:e})})};function k(e){const t=s=>c.jsx(v,{children:c.jsx(e,{...s})});return t.displayName=`withFullScreenWrapper(${e.displayName||e.name})`,p(t,e)}export{m as G,k as N};
|