tiny-essentials 1.28.1 → 1.28.3
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/1/28/2.md +43 -0
- package/changelog/1/28/3.md +9 -0
- package/dist/_/numbers.d.mts +91 -16
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/basics/array.d.mts +14 -14
- package/dist/v1/basics/clock.cjs +15 -15
- package/dist/v1/basics/clock.d.mts +21 -21
- package/dist/v1/basics/clock.mjs +15 -15
- package/dist/v1/basics/collision.d.mts +245 -104
- package/dist/v1/basics/deprecated/html.d.mts +33 -33
- package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
- package/dist/v1/basics/fullScreen.d.mts +47 -7
- package/dist/v1/basics/html.d.mts +52 -61
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +11 -67
- package/dist/v1/basics/index.mjs +2 -2
- package/dist/v1/basics/mediaContent.cjs +65 -23
- package/dist/v1/basics/mediaContent.d.mts +144 -73
- package/dist/v1/basics/mediaContent.mjs +65 -23
- package/dist/v1/basics/objChecker.d.mts +2 -2
- package/dist/v1/basics/objFilter.cjs +50 -16
- package/dist/v1/basics/objFilter.d.mts +34 -13
- package/dist/v1/basics/objFilter.mjs +48 -16
- package/dist/v1/basics/simpleMath.d.mts +21 -21
- package/dist/v1/basics/text.d.mts +34 -46
- package/dist/v1/build/ColorSafeStringify.d.mts +1 -1
- package/dist/v1/build/TinyAdvancedRaffle.d.mts +1 -1
- package/dist/v1/build/TinyAfterScrollWatcher.d.mts +1 -1
- package/dist/v1/build/TinyAnalogClock.d.mts +1 -1
- package/dist/v1/build/TinyArrayComparator.d.mts +1 -1
- package/dist/v1/build/TinyArrayPaginator.d.mts +1 -1
- package/dist/v1/build/TinyClassManager.d.mts +1 -1
- package/dist/v1/build/TinyClipboard.d.mts +1 -1
- package/dist/v1/build/TinyColorConverter.d.mts +1 -1
- package/dist/v1/build/TinyColorValidator.d.mts +1 -1
- package/dist/v1/build/TinyCookieConsent.d.mts +1 -1
- package/dist/v1/build/TinyDayNightCycle.d.mts +1 -1
- package/dist/v1/build/TinyDomReadyManager.d.mts +1 -1
- package/dist/v1/build/TinyDragDropDetector.d.mts +1 -1
- package/dist/v1/build/TinyDragger.d.mts +1 -1
- package/dist/v1/build/TinyElementObserver.d.mts +1 -1
- package/dist/v1/build/TinyGamepad.d.mts +1 -1
- package/dist/v1/build/TinyHtml.d.mts +1 -1
- package/dist/v1/build/TinyI18.d.mts +1 -1
- package/dist/v1/build/TinyIframeEvents.d.mts +1 -1
- package/dist/v1/build/TinyInventory.d.mts +1 -1
- package/dist/v1/build/TinyInventoryTrader.d.mts +1 -1
- package/dist/v1/build/TinyLevelUp.d.mts +1 -1
- package/dist/v1/build/TinyLoadingScreen.d.mts +1 -1
- package/dist/v1/build/TinyLocalStorage.d.mts +1 -1
- package/dist/v1/build/TinyMediaPlayer.d.mts +1 -1
- package/dist/v1/build/TinyNeedBar.d.mts +1 -1
- package/dist/v1/build/TinyNewWinEvents.d.mts +1 -1
- package/dist/v1/build/TinyNotifications.d.mts +1 -1
- package/dist/v1/build/TinyNotifyCenter.d.mts +1 -1
- package/dist/v1/build/TinyPromiseQueue.d.mts +1 -1
- package/dist/v1/build/TinyRadioFm.d.mts +1 -1
- package/dist/v1/build/TinyRateLimiter.d.mts +1 -1
- package/dist/v1/build/TinySimpleDice.d.mts +1 -1
- package/dist/v1/build/TinySmartScroller.d.mts +1 -1
- package/dist/v1/build/TinyTextDiffer.d.mts +1 -1
- package/dist/v1/build/TinyTextRangeEditor.d.mts +1 -1
- package/dist/v1/build/TinyTextarea.d.mts +1 -1
- package/dist/v1/build/TinyTimeout.d.mts +1 -1
- package/dist/v1/build/TinyToastNotify.d.mts +1 -1
- package/dist/v1/build/TinyUploadClicker.d.mts +1 -1
- package/dist/v1/build/UltraRandomMsgGen.d.mts +1 -1
- package/dist/v1/fileManager/asyncFuncs.d.mts +13 -13
- package/dist/v1/fileManager/index.d.mts +3 -29
- package/dist/v1/fileManager/normalFuncs.d.mts +22 -22
- package/dist/v1/index.cjs +2 -0
- package/dist/v1/index.d.mts +53 -139
- package/dist/v1/index.mjs +2 -2
- package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +60 -103
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +11 -18
- package/dist/v1/libs/TinyAnalogClock.d.mts +8 -11
- package/dist/v1/libs/TinyArrayComparator.d.mts +14 -20
- package/dist/v1/libs/TinyArrayPaginator.d.mts +22 -26
- package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +8 -8
- package/dist/v1/libs/TinyClassManager.cjs +5 -7
- package/dist/v1/libs/TinyClassManager.d.mts +16 -16
- package/dist/v1/libs/TinyClassManager.mjs +5 -6
- package/dist/v1/libs/TinyClipboard.d.mts +8 -3
- package/dist/v1/libs/TinyColorConverter.d.mts +8 -31
- package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
- package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
- package/dist/v1/libs/TinyDayNightCycle.d.mts +85 -110
- package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
- package/dist/v1/libs/TinyDragDropDetector.d.mts +30 -30
- package/dist/v1/libs/TinyDragger.d.mts +82 -81
- package/dist/v1/libs/TinyElementObserver.d.mts +25 -28
- package/dist/v1/libs/TinyGamepad.cjs +0 -1
- package/dist/v1/libs/TinyGamepad.d.mts +50 -122
- package/dist/v1/libs/TinyGamepad.mjs +0 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.cjs +2 -25
- package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.d.mts +19 -25
- package/dist/v1/libs/TinyHtml/TinyHtmlAnchor.mjs +3 -27
- package/dist/v1/libs/TinyHtml/TinyHtmlButton.cjs +2 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlButton.d.mts +55 -55
- package/dist/v1/libs/TinyHtml/TinyHtmlButton.mjs +2 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlCanvas.d.mts +6 -6
- package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.cjs +8 -4
- package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.d.mts +19 -21
- package/dist/v1/libs/TinyHtml/TinyHtmlDatalist.mjs +7 -4
- package/dist/v1/libs/TinyHtml/TinyHtmlEmbed.d.mts +8 -8
- package/dist/v1/libs/TinyHtml/TinyHtmlForm.d.mts +18 -18
- package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +5 -6
- package/dist/v1/libs/TinyHtml/TinyHtmlIframe.d.mts +19 -19
- package/dist/v1/libs/TinyHtml/TinyHtmlImage.cjs +0 -28
- package/dist/v1/libs/TinyHtml/TinyHtmlImage.d.mts +22 -28
- package/dist/v1/libs/TinyHtml/TinyHtmlImage.mjs +1 -27
- package/dist/v1/libs/TinyHtml/TinyHtmlInput.d.mts +11 -11
- package/dist/v1/libs/TinyHtml/TinyHtmlLink.d.mts +23 -23
- package/dist/v1/libs/TinyHtml/TinyHtmlMedia.d.mts +26 -26
- package/dist/v1/libs/TinyHtml/TinyHtmlScript.cjs +4 -30
- package/dist/v1/libs/TinyHtml/TinyHtmlScript.d.mts +20 -26
- package/dist/v1/libs/TinyHtml/TinyHtmlScript.mjs +5 -32
- package/dist/v1/libs/TinyHtml/TinyHtmlSelect.d.mts +19 -19
- package/dist/v1/libs/TinyHtml/TinyHtmlStyle.d.mts +8 -8
- package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +26 -28
- package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.cjs +14 -15
- package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +32 -32
- package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.mjs +15 -15
- package/dist/v1/libs/TinyHtml/index.d.mts +102 -45
- package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.cjs +11 -9
- package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.d.mts +21 -21
- package/dist/v1/libs/TinyHtml/input/TinyHtmlColorInput.mjs +11 -9
- package/dist/v1/libs/TinyHtml/input/TinyHtmlFileInput.d.mts +11 -11
- package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.cjs +4 -4
- package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.d.mts +17 -13
- package/dist/v1/libs/TinyHtml/input/TinyHtmlHiddenInput.mjs +4 -4
- package/dist/v1/libs/TinyHtml/input/TinyHtmlImageInput.d.mts +21 -21
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.cjs +5 -4
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlButtonInput.mjs +5 -4
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.cjs +4 -3
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.d.mts +10 -10
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlResetInput.mjs +4 -3
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.cjs +4 -3
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.d.mts +19 -19
- package/dist/v1/libs/TinyHtml/input/button/TinyHtmlSubmitInput.mjs +4 -3
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.cjs +5 -4
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.d.mts +11 -11
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlCheckboxInput.mjs +5 -4
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.cjs +4 -3
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.d.mts +15 -11
- package/dist/v1/libs/TinyHtml/input/check/TinyHtmlRadioInput.mjs +4 -3
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.cjs +49 -21
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.d.mts +34 -20
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateInput.mjs +45 -20
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.cjs +1 -1
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlDateTimeInput.mjs +1 -1
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.cjs +1 -1
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlMonthInput.mjs +1 -1
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.cjs +48 -25
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.d.mts +27 -21
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlTimeInput.mjs +40 -27
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.cjs +1 -1
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/date/TinyHtmlWeekInput.mjs +1 -1
- package/dist/v1/libs/TinyHtml/input/number/TinyHtmlNumberInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/number/TinyHtmlRangeInput.d.mts +14 -14
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlEmailInput.d.mts +25 -21
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlPasswordInput.d.mts +18 -18
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlSearchInput.d.mts +33 -29
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTelInput.d.mts +22 -22
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlTextInput.d.mts +18 -18
- package/dist/v1/libs/TinyHtml/input/text/TinyHtmlUrlInput.d.mts +31 -27
- package/dist/v1/libs/TinyHtml/media/TinyHtmlAudio.d.mts +35 -11
- package/dist/v1/libs/TinyHtml/media/TinyHtmlObject.d.mts +10 -10
- package/dist/v1/libs/TinyHtml/media/TinyHtmlSource.d.mts +12 -12
- package/dist/v1/libs/TinyHtml/media/TinyHtmlVideo.d.mts +35 -27
- package/dist/v1/libs/TinyHtml.cjs +3 -4
- package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
- package/dist/v1/libs/TinyHtml.mjs +3 -4
- package/dist/v1/libs/TinyI18.d.mts +23 -61
- package/dist/v1/libs/TinyIframeEvents.cjs +1 -1
- package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
- package/dist/v1/libs/TinyIframeEvents.mjs +1 -1
- package/dist/v1/libs/TinyInventory.d.mts +78 -141
- package/dist/v1/libs/TinyInventoryTrader.d.mts +19 -22
- package/dist/v1/libs/TinyLevelUp.d.mts +10 -13
- package/dist/v1/libs/TinyLoadingScreen.d.mts +21 -31
- package/dist/v1/libs/TinyLocalStorage.d.mts +11 -36
- package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
- package/dist/v1/libs/TinyMediaPlayer.cjs +5 -3
- package/dist/v1/libs/TinyMediaPlayer.d.mts +102 -109
- package/dist/v1/libs/TinyMediaPlayer.mjs +5 -3
- package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
- package/dist/v1/libs/TinyNewWinEvents.d.mts +29 -32
- package/dist/v1/libs/TinyNotifications.d.mts +6 -6
- package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -21
- package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
- package/dist/v1/libs/TinyRadioFm.cjs +32 -12
- package/dist/v1/libs/TinyRadioFm.d.mts +44 -80
- package/dist/v1/libs/TinyRadioFm.mjs +29 -12
- package/dist/v1/libs/TinyRateLimiter.d.mts +26 -39
- package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
- package/dist/v1/libs/TinySmartScroller.d.mts +50 -60
- package/dist/v1/libs/TinyTextDiffer.d.mts +11 -14
- package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
- package/dist/v1/libs/TinyTextarea.d.mts +31 -31
- package/dist/v1/libs/TinyTimeout.d.mts +14 -14
- package/dist/v1/libs/TinyToastNotify.cjs +1 -1
- package/dist/v1/libs/TinyToastNotify.d.mts +15 -23
- package/dist/v1/libs/TinyToastNotify.mjs +1 -1
- package/dist/v1/libs/TinyUploadClicker.d.mts +38 -14
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +44 -84
- package/dist/v1/libs/utils.d.mts +5 -1
- package/docs/v1/basics/deprecated/objFilter.md +14 -0
- package/docs/v1/basics/objFilter.md +31 -17
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={7(t){var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}f(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&f(t,"error",e,{once:!0})}(t,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function l(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,r,n){var i,o,s,u;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(t))>0&&s.length>i&&!s.warned){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=t,h.type=e,h.count=s.length,u=h,console&&console.warn&&console.warn(u)}return t}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function d(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):p(i,i.length)}function y(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function p(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function f(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function i(o){n.once&&t.removeEventListener(e,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[t];if(void 0===l)return!1;if("function"==typeof l)n(l,this,e);else{var u=l.length,h=p(l,u);for(r=0;r<u;++r)n(h[r],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,c(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,c(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,s;if(a(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return d(this,t,!0)},o.prototype.rawListeners=function(t){return d(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):y.call(t,e)},o.prototype.listenerCount=y,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function r(n){const i=e[n];if(void 0!==i)return i.exports;const o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{if(Array.isArray(e))for(var n=0;n<e.length;){var i=e[n++],o=e[n++];r.o(t,i)?0===o&&n++:0===o?Object.defineProperty(t,i,{enumerable:!0,value:e[n++]}):Object.defineProperty(t,i,{enumerable:!0,get:o})}else for(var i in e)r.o(e,i)&&!r.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let n={};r.d(n,{TinyMediaPlayer:()=>g});var i=r(7);const o=(t,e)=>{if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},a=(t,e)=>{if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},l=new Map;class u extends Error{constructor(t,e,r){if(o(t,"message"),o(e,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=r}}const h=async t=>{o(t,"str");const e=(new TextEncoder).encode(t),r=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(r)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},c=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);o(e,"format");const r=t=>{const e=URL.createObjectURL(t),r=l.get(e);return l.set(e,"number"==typeof r?r+1:1),e};if(t instanceof Uint8Array)return r(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const n=t.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let t=0;t<i.length;t++)o[t]=i.charCodeAt(t);return r(new Blob([o],{type:e}))}return"string"==typeof t?t:""},d=(t,e)=>{if(a(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const r=t=>e&&void 0===t,n=t=>r(t)||"string"==typeof t||null===t,i=(t,e)=>!!r(t)||!(!Array.isArray(t)||!t.every(e));if(!n(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(o=t.year,!r(o)&&"number"!=typeof o&&null!==o)throw new TypeError('Invalid metadata: "year" must be a number or null.');var o;if(!i(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const s=(t,e)=>{if(!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};s(t.disk,"disk"),s(t.track,"track")},y=t=>d(t,!1),p=t=>{if(t)throw new Error("This TinyMediaPlayer instance has been destroyed and can no longer be used.")};class f{constructor(){if(new.target===f)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(t){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(t){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(t){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(t){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class m extends i.EventEmitter{static BaseMediaAdapter=f;static#t="Unknown Artist";static get unknownArtist(){return m.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");m.#t=t}static async parseContent(t,e,r,n,i){return(async(t,e={},r={},n=t=>new Promise((t,e)=>e(new TypeError("parseFile library not found."))),i={},l="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(e,"defaultMetadata"),a(r,"metadata"),s(n,"parseFile"),a(i,"callbacks"),i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let y,p="";const f=(e,r)=>{i.onProgress&&i.onProgress({event:r,status:"loading",stage:e,url:p||(t instanceof HTMLMediaElement?t.src:"unknown")})},m=(e,r)=>{i.onError&&i.onError({error:e,url:p||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof t?(p=t,y=new Audio(p)):(y=t,p=y.src);try{await new Promise((t,e)=>{const r=t=>f("DOWNLOADING",t),n=()=>{o(),t(void 0)},i=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{y.removeEventListener("progress",r),y.removeEventListener("loadedmetadata",n),y.removeEventListener("error",i)};y.addEventListener("progress",r),y.addEventListener("loadedmetadata",n),y.addEventListener("error",i),y.readyState>=1&&(o(),t(void 0))}),f("METADATA_LOADED")}catch(t){throw new u(t instanceof Error?t.message:"UNKNOWN ERROR",p,"METADATA")}const a={id:r.id||await h(p),duration:Math.floor(1e3*y.duration),url:p,weight:r.weight??1};let g={};f("EXTRACTING_ID3");try{g=await(async(t,e)=>{o(t,"url"),s(e,"parseFile");try{const r=await fetch(t);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await e(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=i.common;return(t=>{d(t,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(t=>({...t,data:c(t.data,t.format)}))??[]}}catch(t){throw t}})(p,n)}catch(t){m(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${p}. Falling back to filename.`)}const w=t=>{try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},v={...a,...e,...g,...r,title:g.title||r.title||w(p),artist:g.artist||r.artist||("string"==typeof l?l:String(l()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:p}),v}catch(t){if(t instanceof u)throw t;{const e=new u(t instanceof Error?t.message:"UNKNOWN ERROR",p,"INITIALIZING");throw m(e,"INITIALIZING"),e}}})(t,e,r,n,i,m.#t)}#e=!1;get destroyed(){return this.#e}#r=new Map;#n=[];#i=-1;#o="NONE";#s=!1;#a=!1;#l=1;#u;#h;constructor(t={}){super(),this.#u=Boolean(t.persistVolume),this.#h="string"==typeof t.volumeStorageKey?t.volumeStorageKey:"tiny_media_player_volume",this.#u&&this.#c()}#c(){try{if("undefined"!=typeof window&&window.localStorage){const t=window.localStorage.getItem(this.#h);if(null!==t){const e=parseFloat(t);!isNaN(e)&&e>=0&&e<=1&&(this.#l=e)}}}catch(t){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",t)}}#d(){try{this.#u&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#h,this.#l.toString())}catch(t){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",t)}}_getWeightedRandomIndex(){if(0===this.#n.length)return-1;if(1===this.#n.length)return 0;let t=0;for(let e=0;e<this.#n.length;e++){if(e===this.#i)continue;const r=this.#n[e];t+="number"==typeof r.weight&&r.weight>0?r.weight:1}let e=Math.random()*t;for(let t=0;t<this.#n.length;t++){if(t===this.#i)continue;const r=this.#n[t],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(e<n)return t;e-=n}return this.#i===this.#n.length-1?0:this.#n.length-1}get playlist(){return p(this.#e),[...this.#n]}set playlist(t){if(p(this.#e),!Array.isArray(t))throw new TypeError("Playlist must be an array of MediaContent objects.");t.forEach(t=>y(t));const e=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#y()}catch(t){}this.#n=t,this.emit("playlistUpdate",this.playlist),0===this.#n.length?this.#i=-1:(this.#i>=this.#n.length||-1===this.#i)&&(this.#i=0),this.emit("trackChange",this.#i),e&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(t){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",t)}})()}get currentIndex(){return p(this.#e),this.#i}set currentIndex(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Current index must be a number.");if(t<-1||t>=this.#n.length&&this.#n.length>0)throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);if(this.#i===t)return;const e=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#y()}catch(t){}this.#i=t,this.emit("trackChange",this.#i),e&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(t){console.warn("[TinyMediaPlayer] Background transition error on index update:",t)}})()}get loopMode(){return p(this.#e),this.#o}set loopMode(t){p(this.#e);const e=["NONE","TRACK","PLAYLIST"];if(!e.includes(t))throw new TypeError(`Loop mode must be one of: ${e.join(", ")}.`);this.#o=t,this.emit("loopModeChange",this.#o)}get isRandom(){return p(this.#e),this.#s}set isRandom(t){if(p(this.#e),"boolean"!=typeof t)throw new TypeError("Random mode state must be a boolean.");this.#s=t,this.emit("randomModeChange",this.#s)}get isPlaying(){return p(this.#e),this.#a}get volume(){return p(this.#e),this.#l}set volume(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Volume must be a number.");if(t<0||t>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#l=t,this.#d(),this.emit("volumeChange",this.#l),-1!==this.#i&&this.#n.length>0)try{const t=this.#y();t&&t.setVolume(this.#l)}catch(t){}}get persistVolume(){return p(this.#e),this.#u}set persistVolume(t){if(p(this.#e),"boolean"!=typeof t)throw new TypeError("Persist volume parameter must be a boolean.");this.#u=t,t&&this.#d()}get volumeStorageKey(){return p(this.#e),this.#h}set volumeStorageKey(t){if(p(this.#e),"string"!=typeof t)throw new TypeError("Volume storage key must be a string.");if(""===t.trim())throw new TypeError("Volume storage key cannot be an empty string.");const e=this.#h;this.#h=t;try{this.#u&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(e),this.#d())}catch(t){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",t)}}registerAdapter(t,e){if(p(this.#e),"string"!=typeof t)throw new TypeError("Adapter ID must be a string.");if(!(e instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#r.set(t,e)}#y(){if(-1===this.#i||0===this.#n.length)return null;const t=this.#n[this.#i];for(const e of this.#r.values())if(e.canHandle(t))return e;throw new Error(`No compatible adapter found for content ID: ${t.id}.`)}addTrack(t){if(p(this.#e),!t||"object"!=typeof t||"string"!=typeof t.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const e={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...t};y(e);const r=this.#n.push(e);return-1===this.#i&&(this.#i=0,this.emit("trackChange",this.#i)),this.emit("playlistUpdate",this.playlist),r}existsTrack(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Index must be a number.");return t>=0&&t<this.#n.length}getTrack(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Index must be a number.");if(!this.existsTrack(t))throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);return this.#n[t]}async removeTrack(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Index must be a number.");if(!this.existsTrack(t))throw new RangeError(`Index ${t} is out of bounds for the current playlist.`);t===this.#i?(await this.stop(),this.#n.splice(t,1),0===this.#n.length?this.#i=-1:this.#i>=this.#n.length&&(this.#i=0),this.emit("trackChange",this.#i)):(this.#n.splice(t,1),t<this.#i&&(this.#i-=1,this.emit("trackChange",this.#i))),this.emit("playlistUpdate",this.playlist)}searchTrack(t){if(p(this.#e),"string"!=typeof t&&"function"!=typeof t)throw new TypeError("Search query must be a string or a boolean evaluation function.");const e=[];for(let r=0;r<this.#n.length;r++){const n=this.#n[r];let i=!1;if("function"==typeof t)i=Boolean(t(n));else{const e=t.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(e),o=n.artist&&n.artist.toLowerCase().includes(e),s=n.album&&n.album.toLowerCase().includes(e);i=Boolean(r||o||s)}i&&e.push({track:n,index:r})}return e}async clearPlaylist(){p(this.#e),await this.stop(),this.#n=[],this.#i=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#i)}async play(){p(this.#e);const t=this.#y();t&&(t.setVolume(this.#l),await t.play(this.#n[this.#i]),this.#a=!0,this.emit("play",this.#i))}async pause(){p(this.#e);const t=this.#y();t&&(await t.pause(),this.#a=!1,this.emit("pause",this.#i))}async stop(){p(this.#e);const t=this.#y();t&&(await t.stop(),this.#a=!1,this.emit("stop",this.#i))}async next(){if(p(this.#e),0!==this.#n.length)if(await this.stop(),"TRACK"!==this.#o){if(this.#s)this.#i=this._getWeightedRandomIndex();else{let t=this.#i+1;if(t>=this.#n.length){if("PLAYLIST"!==this.#o)return;t=0}this.#i=t}this.emit("trackChange",this.#i),await this.play()}else await this.play()}async prev(){if(p(this.#e),0!==this.#n.length){if(await this.stop(),this.#s)this.#i=this._getWeightedRandomIndex();else{let t=this.#i-1;if(t<0){if("PLAYLIST"!==this.#o)return;t=this.#n.length-1}this.#i=t}this.emit("trackChange",this.#i),await this.play()}}async seek(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Seek time must be a number in milliseconds.");if(t<0)throw new RangeError("Seek time cannot be negative.");const e=this.#y();e&&(await e.seek(t),this.emit("seek",t))}async step(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Step amount must be a number in milliseconds.");const e=this.#y();if(!e)return;let r=e.getCurrentTime()+t;r<0&&(r=0),await this.seek(r)}async destroy(){if(!this.#e){try{this.#a&&await this.stop()}catch(t){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",t)}this.#n=[],this.#i=-1,this.#a=!1,this.#r.clear(),this.removeAllListeners(),this.#e=!0}}}const g=m;window.TinyMediaPlayer=n.TinyMediaPlayer})();
|
|
1
|
+
(()=>{"use strict";var e={7(e){var t,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(e,t,r){return Function.prototype.apply.call(e,t,r)};t=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:function(e){return Object.getOwnPropertyNames(e)};var i=Number.isNaN||function(e){return e!=e};function o(){o.init.call(this)}e.exports=o,e.exports.once=function(e,t){return new Promise(function(r,n){function i(r){e.removeListener(t,o),n(r)}function o(){"function"==typeof e.removeListener&&e.removeListener("error",i),r([].slice.call(arguments))}f(e,t,o,{once:!0}),"error"!==t&&function(e,t){"function"==typeof e.on&&f(e,"error",t,{once:!0})}(e,i)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(e){if("function"!=typeof e)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}function l(e){return void 0===e._maxListeners?o.defaultMaxListeners:e._maxListeners}function u(e,t,r,n){var i,o,s,u;if(a(r),void 0===(o=e._events)?(o=e._events=Object.create(null),e._eventsCount=0):(void 0!==o.newListener&&(e.emit("newListener",t,r.listener?r.listener:r),o=e._events),s=o[t]),void 0===s)s=o[t]=r,++e._eventsCount;else if("function"==typeof s?s=o[t]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=l(e))>0&&s.length>i&&!s.warned){s.warned=!0;var h=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");h.name="MaxListenersExceededWarning",h.emitter=e,h.type=t,h.count=s.length,u=h,console&&console.warn&&console.warn(u)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function c(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function d(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}(i):y(i,i.length)}function p(e){var t=this._events;if(void 0!==t){var r=t[e];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function y(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function f(e,t,r,n){if("function"==typeof e.on)n.once?e.once(t,r):e.on(t,r);else{if("function"!=typeof e.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e);e.addEventListener(t,function i(o){n.once&&e.removeEventListener(t,i),r(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");s=e}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(e){if("number"!=typeof e||e<0||i(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this},o.prototype.getMaxListeners=function(){return l(this)},o.prototype.emit=function(e){for(var t=[],r=1;r<arguments.length;r++)t.push(arguments[r]);var i="error"===e,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(t.length>0&&(s=t[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var l=o[e];if(void 0===l)return!1;if("function"==typeof l)n(l,this,t);else{var u=l.length,h=y(l,u);for(r=0;r<u;++r)n(h[r],this,t)}return!0},o.prototype.addListener=function(e,t){return u(this,e,t,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(e,t){return u(this,e,t,!0)},o.prototype.once=function(e,t){return a(t),this.on(e,c(this,e,t)),this},o.prototype.prependOnceListener=function(e,t){return a(t),this.prependListener(e,c(this,e,t)),this},o.prototype.removeListener=function(e,t){var r,n,i,o,s;if(a(t),void 0===(n=this._events))return this;if(void 0===(r=n[e]))return this;if(r===t||r.listener===t)0===--this._eventsCount?this._events=Object.create(null):(delete n[e],n.removeListener&&this.emit("removeListener",e,r.listener||t));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===t||r[o].listener===t){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}(r,i),1===r.length&&(n[e]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",e,s||t)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(e){var t,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[e]&&(0===--this._eventsCount?this._events=Object.create(null):delete r[e]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(t=r[e]))this.removeListener(e,t);else if(void 0!==t)for(n=t.length-1;n>=0;n--)this.removeListener(e,t[n]);return this},o.prototype.listeners=function(e){return d(this,e,!0)},o.prototype.rawListeners=function(e){return d(this,e,!1)},o.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):p.call(e,t)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?t(this._events):[]}}};const t={};function r(n){const i=t[n];if(void 0!==i)return i.exports;const o=t[n]={exports:{}};return e[n](o,o.exports,r),o.exports}r.d=(e,t)=>{if(Array.isArray(t))for(var n=0;n<t.length;){var i=t[n++],o=t[n++];r.o(e,i)?0===o&&n++:0===o?Object.defineProperty(e,i,{enumerable:!0,value:t[n++]}):Object.defineProperty(e,i,{enumerable:!0,get:o})}else for(var i in t)r.o(t,i)&&!r.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let n={};r.d(n,{TinyMediaPlayer:()=>w});var i=r(7);const o=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof e)throw new TypeError(`Expected "${t}" to be a string, but received ${typeof e}.`)},s=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof e)throw new TypeError(`Expected "${t}" to be a function, but received ${typeof e}.`)},a=(e,t)=>{if("string"!=typeof t)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof e||null===e||Array.isArray(e))throw new TypeError(`Expected "${t}" to be a plain object, but received ${null===e?"null":Array.isArray(e)?"array":typeof e}.`)},l=new Map;class u extends Error{constructor(e,t,r){if(o(e,"message"),o(t,"url"),"string"!=typeof r)throw new TypeError(`Expected "stage" to be a string, but received ${typeof r}.`);super(e),this.name="MediaLoadingError",this.url=t,this.stage=r}}const h=async e=>{o(e,"str");const t=(new TextEncoder).encode(e),r=await crypto.subtle.digest("SHA-1",t);return Array.from(new Uint8Array(r)).map(e=>e.toString(16).padStart(2,"0")).join("").substring(0,8)},c=(e,t="image/jpeg")=>{if(!(e instanceof Uint8Array)&&"string"!=typeof e)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof e}.`);o(t,"format");const r=e=>{const t=URL.createObjectURL(e),r=l.get(t);return l.set(t,"number"==typeof r?r+1:1),t};if(e instanceof Uint8Array)return r(new Blob([e],{type:t}));if("string"==typeof e&&e.startsWith("data:")){const n=e.split(",")[1],i=atob(n),o=new Uint8Array(i.length);for(let e=0;e<i.length;e++)o[e]=i.charCodeAt(e);return r(new Blob([o],{type:t}))}return"string"==typeof e?e:""},d=(e,t)=>{if(a(e,"common"),"boolean"!=typeof t)throw new TypeError('Expected "isPartial" to be a boolean.');const r=e=>t&&void 0===e,n=e=>r(e)||"string"==typeof e||null===e,i=(e,t)=>(s(t,"valueValidator"),!!r(e)||!(!Array.isArray(e)||!e.every(t)));if(!n(e.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!n(e.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!n(e.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!n(e.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(l=e.year,!r(l)&&"number"!=typeof l&&null!==l)throw new TypeError('Invalid metadata: "year" must be a number or null.');var l;if(!i(e.albumartists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!i(e.genre,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!i(e.label,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!i(e.composer,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!i(e.artists,e=>"string"==typeof e))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!i(e.picture,e=>e&&"object"==typeof e&&(void 0===e.description||"string"==typeof e.description)&&(void 0===e.name||"string"==typeof e.name)&&(void 0===e.type||"string"==typeof e.type)&&"string"==typeof e.format&&(e.data instanceof Uint8Array||"string"==typeof e.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(e,t)=>{if(o(e,"name"),!r(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};u("disk",e.disk),u("track",e.track)},p=e=>(a(e,"common"),d(e,!1)),y=e=>{if(e)throw new Error("This TinyMediaPlayer instance has been destroyed and can no longer be used.")};class f{constructor(){if(new.target===f)throw new Error("BaseMediaAdapter is an abstract class and cannot be instantiated directly.")}canHandle(e){throw new Error('Method "canHandle" must be implemented by the subclass.')}async play(e){throw new Error('Method "play" must be implemented by the subclass.')}async pause(){throw new Error('Method "pause" must be implemented by the subclass.')}async stop(){throw new Error('Method "stop" must be implemented by the subclass.')}async seek(e){throw new Error('Method "seek" must be implemented by the subclass.')}getCurrentTime(){throw new Error('Method "getCurrentTime" must be implemented by the subclass.')}setVolume(e){throw new Error('Method "setVolume" must be implemented by the subclass.')}}class m extends i.EventEmitter{static BaseMediaAdapter=f;static#e="Unknown Artist";static get unknownArtist(){return m.#e}static set unknownArtist(e){if("string"!=typeof e&&"function"!=typeof e)throw new TypeError("unknownArtist must have an string or function.");m.#e=e}static async parseContent(e,t,r,n,i){return(async(e,t={},r={},n=e=>{if(!(e instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((e,t)=>t(new TypeError("parseFile library not found.")))},i={},l="null")=>{if("string"!=typeof e&&!(e instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(t,"defaultMetadata"),a(r,"metadata"),s(n,"parseFile"),a(i,"callbacks"),i.onProgress&&"function"!=typeof i.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(i.onError&&"function"!=typeof i.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof l&&"function"!=typeof l)throw new TypeError("unknownArtist must be a string or a function returning a string.");let p,y="";const f=(t,r)=>{if(o(t,"stage"),void 0!==r&&!(r instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');i.onProgress&&i.onProgress({event:r,status:"loading",stage:t,url:y||(e instanceof HTMLMediaElement?e.src:"unknown")})},m=(t,r)=>{if(!(t instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(r,"stage"),i.onError&&i.onError({error:t,url:y||(e instanceof HTMLMediaElement?e.src:"unknown"),stage:r})};try{f("INITIALIZING"),"string"==typeof e?(y=e,p=new Audio(y)):(p=e,y=p.src);try{await new Promise((e,t)=>{const r=e=>f("DOWNLOADING",e),n=()=>{o(),e(void 0)},i=e=>{o(),t(new Error(`HTMLMediaElement failed to load: ${e.message||"Unknown error"}`))},o=()=>{p.removeEventListener("progress",r),p.removeEventListener("loadedmetadata",n),p.removeEventListener("error",i)};p.addEventListener("progress",r),p.addEventListener("loadedmetadata",n),p.addEventListener("error",i),p.readyState>=1&&(o(),e(void 0))}),f("METADATA_LOADED")}catch(e){throw new u(e instanceof Error?e.message:"UNKNOWN ERROR",y,"METADATA")}const w={id:r.id||await h(y),duration:Math.floor(1e3*p.duration),url:y,weight:r.weight??1};let g={};f("EXTRACTING_ID3");try{g=await(async(e,t)=>{o(e,"url"),s(t,"parseFile");try{const r=await fetch(e);if(!r.ok)throw new Error(`Failed to fetch audio file: ${r.status} ${r.statusText}`);const n=await r.blob(),i=await t(n);if(!i||"object"!=typeof i.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=i.common;return(e=>{a(e,"common"),d(e,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(e=>({...e,data:c(e.data,e.format)}))??[]}}catch(e){throw e}})(y,n)}catch(e){m(e instanceof Error?e:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${y}. Falling back to filename.`)}const v=e=>{o(e,"url");try{return(e.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},b={...w,...t,...g,...r,title:g.title||r.title||v(y),artist:g.artist||r.artist||("string"==typeof l?l:String(l()))};return i.onProgress&&i.onProgress({status:"success",stage:"COMPLETE",url:y}),b}catch(e){if(e instanceof u)throw e;{const t=new u(e instanceof Error?e.message:"UNKNOWN ERROR",y,"INITIALIZING");throw m(t,"INITIALIZING"),t}}})(e,t,r,n,i,m.#e)}#t=!1;get destroyed(){return this.#t}#r=new Map;#n=[];#i=-1;#o="NONE";#s=!1;#a=!1;#l=1;#u;#h;constructor(e={}){super(),this.#u=Boolean(e.persistVolume),this.#h="string"==typeof e.volumeStorageKey?e.volumeStorageKey:"tiny_media_player_volume",this.#u&&this.#c()}#c(){try{if("undefined"!=typeof window&&window.localStorage){const e=window.localStorage.getItem(this.#h);if(null!==e){const t=parseFloat(e);!isNaN(t)&&t>=0&&t<=1&&(this.#l=t)}}}catch(e){console.warn("[TinyMediaPlayer] Failed to read volume from localStorage.",e)}}#d(){try{this.#u&&"undefined"!=typeof window&&window.localStorage&&window.localStorage.setItem(this.#h,this.#l.toString())}catch(e){console.warn("[TinyMediaPlayer] Failed to save volume to localStorage.",e)}}_getWeightedRandomIndex(){if(0===this.#n.length)return-1;if(1===this.#n.length)return 0;let e=0;for(let t=0;t<this.#n.length;t++){if(t===this.#i)continue;const r=this.#n[t];e+="number"==typeof r.weight&&r.weight>0?r.weight:1}let t=Math.random()*e;for(let e=0;e<this.#n.length;e++){if(e===this.#i)continue;const r=this.#n[e],n="number"==typeof r.weight&&r.weight>0?r.weight:1;if(t<n)return e;t-=n}return this.#i===this.#n.length-1?0:this.#n.length-1}get playlist(){return y(this.#t),[...this.#n]}set playlist(e){if(y(this.#t),!Array.isArray(e))throw new TypeError("Playlist must be an array of MediaContent objects.");e.forEach(e=>p(e));const t=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#p()}catch(e){}this.#n=e,this.emit("playlistUpdate",this.playlist),0===this.#n.length?this.#i=-1:(this.#i>=this.#n.length||-1===this.#i)&&(this.#i=0),this.emit("trackChange",this.#i),t&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on playlist update:",e)}})()}get currentIndex(){return y(this.#t),this.#i}set currentIndex(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Current index must be a number.");if(e<-1||e>=this.#n.length&&this.#n.length>0)throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);if(this.#i===e)return;const t=this.#a;let r=null;if(-1!==this.#i&&this.#n.length>0)try{r=this.#p()}catch(e){}this.#i=e,this.emit("trackChange",this.#i),t&&(async()=>{try{r&&await r.stop(),-1!==this.#i&&await this.play()}catch(e){console.warn("[TinyMediaPlayer] Background transition error on index update:",e)}})()}get loopMode(){return y(this.#t),this.#o}set loopMode(e){y(this.#t);const t=["NONE","TRACK","PLAYLIST"];if(!t.includes(e))throw new TypeError(`Loop mode must be one of: ${t.join(", ")}.`);this.#o=e,this.emit("loopModeChange",this.#o)}get isRandom(){return y(this.#t),this.#s}set isRandom(e){if(y(this.#t),"boolean"!=typeof e)throw new TypeError("Random mode state must be a boolean.");this.#s=e,this.emit("randomModeChange",this.#s)}get isPlaying(){return y(this.#t),this.#a}get volume(){return y(this.#t),this.#l}set volume(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Volume must be a number.");if(e<0||e>1)throw new RangeError("Volume must be tightly constrained between 0.0 and 1.0.");if(this.#l=e,this.#d(),this.emit("volumeChange",this.#l),-1!==this.#i&&this.#n.length>0)try{const e=this.#p();e&&e.setVolume(this.#l)}catch(e){}}get persistVolume(){return y(this.#t),this.#u}set persistVolume(e){if(y(this.#t),"boolean"!=typeof e)throw new TypeError("Persist volume parameter must be a boolean.");this.#u=e,e&&this.#d()}get volumeStorageKey(){return y(this.#t),this.#h}set volumeStorageKey(e){if(y(this.#t),"string"!=typeof e)throw new TypeError("Volume storage key must be a string.");if(""===e.trim())throw new TypeError("Volume storage key cannot be an empty string.");const t=this.#h;this.#h=e;try{this.#u&&"undefined"!=typeof window&&window.localStorage&&(window.localStorage.removeItem(t),this.#d())}catch(e){console.warn("[TinyMediaPlayer] Failed to migrate volume storage key.",e)}}registerAdapter(e,t){if(y(this.#t),"string"!=typeof e)throw new TypeError("Adapter ID must be a string.");if(!(t instanceof f))throw new TypeError("Adapter must be an instance of BaseMediaAdapter.");this.#r.set(e,t)}#p(){if(-1===this.#i||0===this.#n.length)return null;const e=this.#n[this.#i];for(const t of this.#r.values())if(t.canHandle(e))return t;throw new Error(`No compatible adapter found for content ID: ${e.id}.`)}addTrack(e){if(y(this.#t),!e||"object"!=typeof e||"string"!=typeof e.url)throw new TypeError("Track content must be a valid MediaContent object containing a URL.");const t={id:"",title:"",artist:"",url:"",duration:0,weight:1,title:null,album:null,albumartist:null,albumartists:[],genre:[],label:[],composer:[],year:null,artist:null,artists:[],disk:{no:null,of:null},track:{no:null,of:null},picture:[],...e};p(t);const r=this.#n.push(t);return-1===this.#i&&(this.#i=0,this.emit("trackChange",this.#i)),this.emit("playlistUpdate",this.playlist),r}existsTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");return e>=0&&e<this.#n.length}getTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);return this.#n[e]}async removeTrack(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Index must be a number.");if(!this.existsTrack(e))throw new RangeError(`Index ${e} is out of bounds for the current playlist.`);e===this.#i?(await this.stop(),this.#n.splice(e,1),0===this.#n.length?this.#i=-1:this.#i>=this.#n.length&&(this.#i=0),this.emit("trackChange",this.#i)):(this.#n.splice(e,1),e<this.#i&&(this.#i-=1,this.emit("trackChange",this.#i))),this.emit("playlistUpdate",this.playlist)}searchTrack(e){if(y(this.#t),"string"!=typeof e&&"function"!=typeof e)throw new TypeError("Search query must be a string or a boolean evaluation function.");const t=[];for(let r=0;r<this.#n.length;r++){const n=this.#n[r];let i=!1;if("function"==typeof e)i=Boolean(e(n));else{const t=e.toLowerCase(),r=n.title&&n.title.toLowerCase().includes(t),o=n.artist&&n.artist.toLowerCase().includes(t),s=n.album&&n.album.toLowerCase().includes(t);i=Boolean(r||o||s)}i&&t.push({track:n,index:r})}return t}async clearPlaylist(){y(this.#t),await this.stop(),this.#n=[],this.#i=-1,this.emit("playlistUpdate",this.playlist),this.emit("trackChange",this.#i)}async play(){y(this.#t);const e=this.#p();e&&(e.setVolume(this.#l),await e.play(this.#n[this.#i]),this.#a=!0,this.emit("play",this.#i))}async pause(){y(this.#t);const e=this.#p();e&&(await e.pause(),this.#a=!1,this.emit("pause",this.#i))}async stop(){y(this.#t);const e=this.#p();e&&(await e.stop(),this.#a=!1,this.emit("stop",this.#i))}async next(){if(y(this.#t),0!==this.#n.length)if(await this.stop(),"TRACK"!==this.#o){if(this.#s)this.#i=this._getWeightedRandomIndex();else{let e=this.#i+1;if(e>=this.#n.length){if("PLAYLIST"!==this.#o)return;e=0}this.#i=e}this.emit("trackChange",this.#i),await this.play()}else await this.play()}async prev(){if(y(this.#t),0!==this.#n.length){if(await this.stop(),this.#s)this.#i=this._getWeightedRandomIndex();else{let e=this.#i-1;if(e<0){if("PLAYLIST"!==this.#o)return;e=this.#n.length-1}this.#i=e}this.emit("trackChange",this.#i),await this.play()}}async seek(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Seek time must be a number in milliseconds.");if(e<0)throw new RangeError("Seek time cannot be negative.");const t=this.#p();t&&(await t.seek(e),this.emit("seek",e))}async step(e){if(y(this.#t),"number"!=typeof e)throw new TypeError("Step amount must be a number in milliseconds.");const t=this.#p();if(!t)return;let r=t.getCurrentTime()+e;r<0&&(r=0),await this.seek(r)}async destroy(){if(!this.#t){try{this.#a&&await this.stop()}catch(e){console.warn("[TinyMediaPlayer] Non-fatal error during playback termination:",e)}this.#n=[],this.#i=-1,this.#a=!1,this.#r.clear(),this.removeAllListeners(),this.#t=!0}}}const w=m;window.TinyMediaPlayer=n.TinyMediaPlayer})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var t={7(t){var e,i="object"==typeof Reflect?Reflect:null,r=i&&"function"==typeof i.apply?i.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};e=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(i,r){function n(i){t.removeListener(e,o),r(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),i([].slice.call(arguments))}p(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&p(t,"error",e,{once:!0})}(t,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,i,r){var n,o,s,u;if(a(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=c(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=l.bind(r);return n.listener=i,r.wrapFn=n,n}function h(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):m(n,n.length)}function f(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}function p(t,e,i,r){if("function"==typeof t.on)r.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(o){r.once&&t.removeEventListener(e,n),i(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var u=c.length,l=m(c,u);for(i=0;i<u;++i)r(l[i],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var i,r,n,o,s;if(a(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,o=Object.keys(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function i(r){const n=e[r];if(void 0!==n)return n.exports;const o=e[r]={exports:{}};return t[r](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var n=e[r++],o=e[r++];i.o(t,n)?0===o&&r++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};i.d(r,{TinyRadioFm:()=>v});var n=i(7);const o=(t,e)=>{if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},a=(t,e)=>{if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},c=new Map;class u extends Error{constructor(t,e,i){if(o(t,"message"),o(e,"url"),"string"!=typeof i)throw new TypeError(`Expected "stage" to be a string, but received ${typeof i}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const l=async t=>{o(t,"str");const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},d=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);o(e,"format");const i=t=>{const e=URL.createObjectURL(t),i=c.get(e);return c.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const r=t.split(",")[1],n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},h=async t=>{if(o(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const r=new FileReader;r.onloadend=()=>t(String(r.result)),r.onerror=e,r.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},f=t=>{a(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=c.get(t.data)??0;e>1?c.set(t.data,e-1):c.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},m=async(t,e)=>{o(t,"url"),s(e,"parseFile");try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const r=await i.blob(),n=await e(r);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const o=n.common;return(t=>{((t,e)=>{if(a(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const i=t=>e&&void 0===t,r=t=>i(t)||"string"==typeof t||null===t,n=(t,e)=>!!i(t)||!(!Array.isArray(t)||!t.every(e));if(!r(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!r(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!r(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!r(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(o=t.year,!i(o)&&"number"!=typeof o&&null!==o)throw new TypeError('Invalid metadata: "year" must be a number or null.');var o;if(!n(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const s=(t,e)=>{if(!i(t)){if(null==t)throw new TypeError(`Invalid metadata: "${e}" is required.`);if("object"!=typeof t)throw new TypeError(`Invalid metadata: "${e}" must be an object or null.`);if("number"!=typeof t.no&&null!==t.no)throw new TypeError(`Invalid metadata: "${e}.no" must be a number or null.`);if("number"!=typeof t.of&&null!==t.of)throw new TypeError(`Invalid metadata: "${e}.of" must be a number or null.`)}};s(t.disk,"disk"),s(t.track,"track")})(t,!0)})(o),{title:o?.title??null,album:o?.album??null,albumartist:o?.albumartist??null,albumartists:o?.albumartists??[],genre:o?.genre??[],label:o?.label??[],composer:o?.composer??[],year:o?.year??null,artist:o?.artist??null,artists:o?.artists??[],disk:o?.disk?{no:o.disk.no,of:o.disk.of}:{no:null,of:null},track:o?.track?{no:o.track.no,of:o.track.of}:{no:null,of:null},picture:o?.picture?.map(t=>({...t,data:d(t.data,t.format)}))??[]}}catch(t){throw t}},p=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class y extends n.EventEmitter{static async parseContent(t,e,i,r,n){return(async(t,e={},i={},r=t=>new Promise((t,e)=>e(new TypeError("parseFile library not found."))),n={},o="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(e,"defaultMetadata"),a(i,"metadata"),s(r,"parseFile"),a(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof o&&"function"!=typeof o)throw new TypeError("unknownArtist must be a string or a function returning a string.");let c,d="";const h=(e,i)=>{n.onProgress&&n.onProgress({event:i,status:"loading",stage:e,url:d||(t instanceof HTMLMediaElement?t.src:"unknown")})},f=(e,i)=>{n.onError&&n.onError({error:e,url:d||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{h("INITIALIZING"),"string"==typeof t?(d=t,c=new Audio(d)):(c=t,d=c.src);try{await new Promise((t,e)=>{const i=t=>h("DOWNLOADING",t),r=()=>{o(),t(void 0)},n=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{c.removeEventListener("progress",i),c.removeEventListener("loadedmetadata",r),c.removeEventListener("error",n)};c.addEventListener("progress",i),c.addEventListener("loadedmetadata",r),c.addEventListener("error",n),c.readyState>=1&&(o(),t(void 0))}),h("METADATA_LOADED")}catch(t){throw new u(t instanceof Error?t.message:"UNKNOWN ERROR",d,"METADATA")}const s={id:i.id||await l(d),duration:Math.floor(1e3*c.duration),url:d,weight:i.weight??1};let a={};h("EXTRACTING_ID3");try{a=await m(d,r)}catch(t){f(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${d}. Falling back to filename.`)}const p=t=>{try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},y={...s,...e,...a,...i,title:a.title||i.title||p(d),artist:a.artist||i.artist||("string"==typeof o?o:String(o()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:d}),y}catch(t){if(t instanceof u)throw t;{const e=new u(t instanceof Error?t.message:"UNKNOWN ERROR",d,"INITIALIZING");throw f(e,"INITIALIZING"),e}}})(t,e,i,r,n,y.#t)}static#t="Unknown Artist";static get unknownArtist(){return y.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");y.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return p(this.#e),this.#i.length+this.#r.length}get musicSize(){return p(this.#e),this.#i.length}get voiceSize(){return p(this.#e),this.#r.length}get customPosSize(){return p(this.#e),this.#n.length}get tasksSize(){return p(this.#e),this.#o.length}get cycleCacheSize(){return p(this.#e),this.#s.size}#i=[];get musicList(){return p(this.#e),structuredClone(this.#i)}#r=[];get voiceList(){return p(this.#e),structuredClone(this.#r)}#n=[];get customPositions(){return p(this.#e),structuredClone(this.#n)}#o=[];get scheduledTasks(){return p(this.#e),structuredClone(this.#o)}get allList(){return p(this.#e),[...this.musicList,...this.voiceList]}#a=0;get seed(){return p(this.#e),this.#a}set seed(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#a=t,this.#s.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return p(this.#e),this.#c}#s=new Map;#u={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return p(this.#e),structuredClone(this.#u)}set config(t){p(this.#e),this.#l(t),this.#u=structuredClone(t),this.#s.clear(),this.emit("configChanged",{config:this.config})}#l(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#u.voiceMin,r=t.voiceMax??this.#u.voiceMax;if(r<i)throw new RangeError(`Logical error: voiceMax (${r}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#a=e,t?this.#d(t):this.#c=Date.now()}add(t,e,i=!0){if(p(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#i.push(e),this.#s.clear()):"voice"===t?(this.#r.push(e),this.#s.clear()):"custom"===t&&this.#h(e,i),this.#f(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,r,n=!0){if(p(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof r)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(n){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:r};this.#o.push(s),this.#f(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(p(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#i.filter(e=>e.id===t).forEach(t=>f(t)),this.#r.filter(e=>e.id===t).forEach(t=>f(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>f(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#i=this.#i.filter(e),this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(f(e.payload),!1):e.payload!==t),this.#s.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){p(this.#e),this.#l(t);const e={...this.#u,...t};this.#l(e),this.#u=e,this.#s.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){p(this.#e);const t=Date.now();return this.#f(t),this.#m(t,t)}queryTimeline(t,e=10){if(p(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#u.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#u.queryLimit}.`);const i=new y(JSON.parse(this._exportState())),r=[];let n=t;for(let o=0;o<e;o++){i.#f(n);const e=i.#p(n,t);if(!e)break;r.push(e),n=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:r.length}),r}searchCustomPositions(){return p(this.#e),this.#f(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>({...t,data:await h(t.data)})))),e}))}_exportState(){return JSON.stringify({music:this.#i,voice:this.#r,custom:this.#n,tasks:this.#o,seed:this.#a,anchorDate:this.#c,config:this.#u})}async exportState(){p(this.#e);const t=await this._processListForExport(this.#i),e=await this._processListForExport(this.#r),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),r=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:r,seed:this.#a,anchorDate:this.#c,config:this.#u})}importState(t){let e;if(p(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#d(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#y(t,e,i,r=0){if(0===t.length)return[];if("random"!==i)return[...t];const n=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;n.length>0;){let t=n;-1!==r&&null!==a&&c>r&&(t=n.filter(t=>t.id!==a),0===t.length&&(t=n));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=n.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=n.findIndex(t=>l&&t.id===l.id)),s.push(l),n.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#v(t){const e=this.#a+t,i=this._prng(10*e),r=this.#y(this.#i,e+1,this.#u.mode,this.#u.musicMaxConsecutive),n=this.#y(this.#r,e+2,this.#u.voiceMode,this.#u.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<r.length;t++){const e=r[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#u.silenceDuration,this.#u.voiceAfterMusic&&n.length>0){const t=this.#u.voiceMax-this.#u.voiceMin+1,e=Math.floor(i()*t)+this.#u.voiceMin;for(let t=0;t<e;t++){const t=n[a%n.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#u.silenceDuration}}}return{items:o,duration:s}}#g(t){if(0===this.#i.length)return null;let e=this.#c,i=0;for(;;){if(i>this.#u.queryLimit)throw new Error("Safety limit hit during cycle location.");let r=this.#s.get(i);if(r||(r=this.#v(i),this.#s.set(i,r)),0===r.duration)return null;if(t>=e&&t<e+r.duration)return{block:r,startTimestamp:e,loopIndex:i};e+=r.duration,i++}}#p(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let r=null;if(i){const t=Math.max(e,i.intendedTimestamp);r=this.#w(i.content,i.intendedTimestamp,t,!0)}const n=this.#b(t,e);return n||r?n?r?r.absoluteStart<=n.absoluteStart?r:(r.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=r.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-e),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:r:null}#b(t,e){let i=this.#g(t);if(!i)return null;const{block:r,startTimestamp:n}=i,o=t-n;let s,a=r.items.find(t=>t.cycleEnd>o);if(a)s=n+a.cycleStart;else{if(i=this.#g(n+r.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#w(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#w(i.content,i.intendedTimestamp,e,!0);const r=this.#g(t);if(!r)return null;const{block:n,startTimestamp:o}=r,s=t-o,a=n.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#w(a,o+a.cycleStart,e,!1):null}#w(t,e,i,r){const n=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:n,remainingTime:t.duration-n,progress:Math.min(1,n/t.duration),isCustom:r}}#h(t,e){let i=t.timestamp||Date.now();const r=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const n=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(n.some(t=>i<t.intendedTimestamp+t.content.duration&&i+r>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of n)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#u.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=r){let t=null;if(i>=e.start&&i+r<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-r),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#f(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let r=!1;i.forEach(t=>{f(t.content),this.#a+=t.content.id.length,r=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#i:this.#r;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i);if(-1!==r){const[t]=e.splice(r,1);f(t)}}else if("move"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i.id);if(-1!==r){const[t]=e.splice(r,1);e.splice(i.newIndex,0,t)}}this.#c=t.timestamp,this.#a+=1,r=!0,this.emit("taskExecuted",structuredClone(t))}),r&&this.#s.clear()}#d(t){this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>({...t,data:d(t.data,t.format)}))),e});this.#i=e(t.music),this.#r=e(t.voice),this.#a=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#u={...this.#u,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)})),this.#i=[],this.#r=[],this.#n=[],this.#o=[],this.#s.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const v=y;window.TinyRadioFm=r.TinyRadioFm})();
|
|
1
|
+
(()=>{"use strict";var t={7(t){var e,i="object"==typeof Reflect?Reflect:null,r=i&&"function"==typeof i.apply?i.apply:function(t,e,i){return Function.prototype.apply.call(t,e,i)};e=i&&"function"==typeof i.ownKeys?i.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var n=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise(function(i,r){function n(i){t.removeListener(e,o),r(i)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",n),i([].slice.call(arguments))}p(t,e,o,{once:!0}),"error"!==e&&function(t,e){"function"==typeof t.on&&p(t,"error",e,{once:!0})}(t,n)})},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function c(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function u(t,e,i,r){var n,o,s,u;if(a(i),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,i.listener?i.listener:i),o=t._events),s=o[e]),void 0===s)s=o[e]=i,++t._eventsCount;else if("function"==typeof s?s=o[e]=r?[i,s]:[s,i]:r?s.unshift(i):s.push(i),(n=c(t))>0&&s.length>n&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,u=l,console&&console.warn&&console.warn(u)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(t,e,i){var r={fired:!1,wrapFn:void 0,target:t,type:e,listener:i},n=l.bind(r);return n.listener=i,r.wrapFn=n,n}function h(t,e,i){var r=t._events;if(void 0===r)return[];var n=r[e];return void 0===n?[]:"function"==typeof n?i?[n.listener||n]:[n]:i?function(t){for(var e=new Array(t.length),i=0;i<e.length;++i)e[i]=t[i].listener||t[i];return e}(n):m(n,n.length)}function f(t){var e=this._events;if(void 0!==e){var i=e[t];if("function"==typeof i)return 1;if(void 0!==i)return i.length}return 0}function m(t,e){for(var i=new Array(e),r=0;r<e;++r)i[r]=t[r];return i}function p(t,e,i,r){if("function"==typeof t.on)r.once?t.once(e,i):t.on(e,i);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,function n(o){r.once&&t.removeEventListener(e,n),i(o)})}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||n(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return c(this)},o.prototype.emit=function(t){for(var e=[],i=1;i<arguments.length;i++)e.push(arguments[i]);var n="error"===t,o=this._events;if(void 0!==o)n=n&&void 0===o.error;else if(!n)return!1;if(n){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var c=o[t];if(void 0===c)return!1;if("function"==typeof c)r(c,this,e);else{var u=c.length,l=m(c,u);for(i=0;i<u;++i)r(l[i],this,e)}return!0},o.prototype.addListener=function(t,e){return u(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return u(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,d(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,d(this,t,e)),this},o.prototype.removeListener=function(t,e){var i,r,n,o,s;if(a(e),void 0===(r=this._events))return this;if(void 0===(i=r[t]))return this;if(i===e||i.listener===e)0===--this._eventsCount?this._events=Object.create(null):(delete r[t],r.removeListener&&this.emit("removeListener",t,i.listener||e));else if("function"!=typeof i){for(n=-1,o=i.length-1;o>=0;o--)if(i[o]===e||i[o].listener===e){s=i[o].listener,n=o;break}if(n<0)return this;0===n?i.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(i,n),1===i.length&&(r[t]=i[0]),void 0!==r.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,i,r;if(void 0===(i=this._events))return this;if(void 0===i.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==i[t]&&(0===--this._eventsCount?this._events=Object.create(null):delete i[t]),this;if(0===arguments.length){var n,o=Object.keys(i);for(r=0;r<o.length;++r)"removeListener"!==(n=o[r])&&this.removeAllListeners(n);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=i[t]))this.removeListener(t,e);else if(void 0!==e)for(r=e.length-1;r>=0;r--)this.removeListener(t,e[r]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):f.call(t,e)},o.prototype.listenerCount=f,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}}};const e={};function i(r){const n=e[r];if(void 0!==n)return n.exports;const o=e[r]={exports:{}};return t[r](o,o.exports,i),o.exports}i.d=(t,e)=>{if(Array.isArray(e))for(var r=0;r<e.length;){var n=e[r++],o=e[r++];i.o(t,n)?0===o&&r++:0===o?Object.defineProperty(t,n,{enumerable:!0,value:e[r++]}):Object.defineProperty(t,n,{enumerable:!0,get:o})}else for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let r={};i.d(r,{TinyRadioFm:()=>v});var n=i(7);const o=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("string"!=typeof t)throw new TypeError(`Expected "${e}" to be a string, but received ${typeof t}.`)},s=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("function"!=typeof t)throw new TypeError(`Expected "${e}" to be a function, but received ${typeof t}.`)},a=(t,e)=>{if("string"!=typeof e)throw new TypeError('Expected "name" to be a string.');if("object"!=typeof t||null===t||Array.isArray(t))throw new TypeError(`Expected "${e}" to be a plain object, but received ${null===t?"null":Array.isArray(t)?"array":typeof t}.`)},c=new Map;class u extends Error{constructor(t,e,i){if(o(t,"message"),o(e,"url"),"string"!=typeof i)throw new TypeError(`Expected "stage" to be a string, but received ${typeof i}.`);super(t),this.name="MediaLoadingError",this.url=e,this.stage=i}}const l=async t=>{o(t,"str");const e=(new TextEncoder).encode(t),i=await crypto.subtle.digest("SHA-1",e);return Array.from(new Uint8Array(i)).map(t=>t.toString(16).padStart(2,"0")).join("").substring(0,8)},d=(t,e="image/jpeg")=>{if(!(t instanceof Uint8Array)&&"string"!=typeof t)throw new TypeError(`Expected "data" to be an instance of Uint8Array or a string, but received ${typeof t}.`);o(e,"format");const i=t=>{const e=URL.createObjectURL(t),i=c.get(e);return c.set(e,"number"==typeof i?i+1:1),e};if(t instanceof Uint8Array)return i(new Blob([t],{type:e}));if("string"==typeof t&&t.startsWith("data:")){const r=t.split(",")[1],n=atob(r),o=new Uint8Array(n.length);for(let t=0;t<n.length;t++)o[t]=n.charCodeAt(t);return i(new Blob([o],{type:e}))}return"string"==typeof t?t:""},h=async t=>{if(o(t,"url"),!t.startsWith("blob:"))return t;try{const e=await fetch(t),i=await e.blob();return await new Promise((t,e)=>{const r=new FileReader;r.onloadend=()=>t(String(r.result)),r.onerror=e,r.readAsDataURL(i)})}catch(e){return console.warn(`[TinyAudioUtils] Failed to convert Blob URL to Base64 on export: ${t}`,e),t}},f=t=>{a(t,"content"),t&&Array.isArray(t.picture)&&t.picture.forEach(t=>{if("string"==typeof t.data&&t.data.startsWith("blob:")){const e=c.get(t.data)??0;e>1?c.set(t.data,e-1):c.delete(t.data),e<=1&&URL.revokeObjectURL(t.data)}})},m=async(t,e)=>{o(t,"url"),s(e,"parseFile");try{const i=await fetch(t);if(!i.ok)throw new Error(`Failed to fetch audio file: ${i.status} ${i.statusText}`);const r=await i.blob(),n=await e(r);if(!n||"object"!=typeof n.common)throw new TypeError('Invalid metadata: "common" property is missing or not an object.');const c=n.common;return(t=>{a(t,"common"),((t,e)=>{if(a(t,"common"),"boolean"!=typeof e)throw new TypeError('Expected "isPartial" to be a boolean.');const i=t=>e&&void 0===t,r=t=>i(t)||"string"==typeof t||null===t,n=(t,e)=>(s(e,"valueValidator"),!!i(t)||!(!Array.isArray(t)||!t.every(e)));if(!r(t.title))throw new TypeError('Invalid metadata: "title" must be a string or null.');if(!r(t.album))throw new TypeError('Invalid metadata: "album" must be a string or null.');if(!r(t.albumartist))throw new TypeError('Invalid metadata: "albumartist" must be a string or null.');if(!r(t.artist))throw new TypeError('Invalid metadata: "artist" must be a string or null.');if(c=t.year,!i(c)&&"number"!=typeof c&&null!==c)throw new TypeError('Invalid metadata: "year" must be a number or null.');var c;if(!n(t.albumartists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "albumartists" must be an array of string.');if(!n(t.genre,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "genre" must be an array of string.');if(!n(t.label,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "label" must be an array of string.');if(!n(t.composer,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "composer" must be an array of string.');if(!n(t.artists,t=>"string"==typeof t))throw new TypeError('Invalid metadata: "artists" must be an array of string.');if(!n(t.picture,t=>t&&"object"==typeof t&&(void 0===t.description||"string"==typeof t.description)&&(void 0===t.name||"string"==typeof t.name)&&(void 0===t.type||"string"==typeof t.type)&&"string"==typeof t.format&&(t.data instanceof Uint8Array||"string"==typeof t.data)))throw new TypeError('Invalid metadata: "picture" must be an array of pictures.');const u=(t,e)=>{if(o(t,"name"),!i(e)){if(null==e)throw new TypeError(`Invalid metadata: "${t}" is required.`);if("object"!=typeof e)throw new TypeError(`Invalid metadata: "${t}" must be an object or null.`);if("number"!=typeof e.no&&null!==e.no)throw new TypeError(`Invalid metadata: "${t}.no" must be a number or null.`);if("number"!=typeof e.of&&null!==e.of)throw new TypeError(`Invalid metadata: "${t}.of" must be a number or null.`)}};u("disk",t.disk),u("track",t.track)})(t,!0)})(c),{title:c?.title??null,album:c?.album??null,albumartist:c?.albumartist??null,albumartists:c?.albumartists??[],genre:c?.genre??[],label:c?.label??[],composer:c?.composer??[],year:c?.year??null,artist:c?.artist??null,artists:c?.artists??[],disk:c?.disk?{no:c.disk.no,of:c.disk.of}:{no:null,of:null},track:c?.track?{no:c.track.no,of:c.track.of}:{no:null,of:null},picture:c?.picture?.map(t=>({...t,data:d(t.data,t.format)}))??[]}}catch(t){throw t}},p=t=>{if(t)throw new Error("This TinyRadioFm instance has been destroyed and can no longer be used.")};class y extends n.EventEmitter{static async parseContent(t,e,i,r,n){return(async(t,e={},i={},r=t=>{if(!(t instanceof Blob))throw new TypeError('Expected "data" to be a Blob.');return new Promise((t,e)=>e(new TypeError("parseFile library not found.")))},n={},c="null")=>{if("string"!=typeof t&&!(t instanceof HTMLMediaElement))throw new TypeError("Source must be a string or an HTMLMediaElement.");if(a(e,"defaultMetadata"),a(i,"metadata"),s(r,"parseFile"),a(n,"callbacks"),n.onProgress&&"function"!=typeof n.onProgress)throw new TypeError("callbacks.onProgress must be a function.");if(n.onError&&"function"!=typeof n.onError)throw new TypeError("callbacks.onError must be a function.");if("string"!=typeof c&&"function"!=typeof c)throw new TypeError("unknownArtist must be a string or a function returning a string.");let d,h="";const f=(e,i)=>{if(o(e,"stage"),void 0!==i&&!(i instanceof Event))throw new TypeError('Expected "event" to be an Event or undefined.');n.onProgress&&n.onProgress({event:i,status:"loading",stage:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown")})},p=(e,i)=>{if(!(e instanceof Error))throw new TypeError('Expected "error" to be an Error.');o(i,"stage"),n.onError&&n.onError({error:e,url:h||(t instanceof HTMLMediaElement?t.src:"unknown"),stage:i})};try{f("INITIALIZING"),"string"==typeof t?(h=t,d=new Audio(h)):(d=t,h=d.src);try{await new Promise((t,e)=>{const i=t=>f("DOWNLOADING",t),r=()=>{o(),t(void 0)},n=t=>{o(),e(new Error(`HTMLMediaElement failed to load: ${t.message||"Unknown error"}`))},o=()=>{d.removeEventListener("progress",i),d.removeEventListener("loadedmetadata",r),d.removeEventListener("error",n)};d.addEventListener("progress",i),d.addEventListener("loadedmetadata",r),d.addEventListener("error",n),d.readyState>=1&&(o(),t(void 0))}),f("METADATA_LOADED")}catch(t){throw new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"METADATA")}const s={id:i.id||await l(h),duration:Math.floor(1e3*d.duration),url:h,weight:i.weight??1};let a={};f("EXTRACTING_ID3");try{a=await m(h,r)}catch(t){p(t instanceof Error?t:new Error("Unknown Error"),"ID3"),console.warn(`[TinyAudioUtils] ID3 extraction failed for ${h}. Falling back to filename.`)}const y=t=>{o(t,"url");try{return(t.split(/[?#]/)[0].split("/").pop()??"").replace(/\.[^/.]+$/,"")||"Unknown Track"}catch{return"Unknown Track"}},v={...s,...e,...a,...i,title:a.title||i.title||y(h),artist:a.artist||i.artist||("string"==typeof c?c:String(c()))};return n.onProgress&&n.onProgress({status:"success",stage:"COMPLETE",url:h}),v}catch(t){if(t instanceof u)throw t;{const e=new u(t instanceof Error?t.message:"UNKNOWN ERROR",h,"INITIALIZING");throw p(e,"INITIALIZING"),e}}})(t,e,i,r,n,y.#t)}static#t="Unknown Artist";static get unknownArtist(){return y.#t}static set unknownArtist(t){if("string"!=typeof t&&"function"!=typeof t)throw new TypeError("unknownArtist must have an string or function.");y.#t=t}#e=!1;get destroyed(){return this.#e}get size(){return p(this.#e),this.#i.length+this.#r.length}get musicSize(){return p(this.#e),this.#i.length}get voiceSize(){return p(this.#e),this.#r.length}get customPosSize(){return p(this.#e),this.#n.length}get tasksSize(){return p(this.#e),this.#o.length}get cycleCacheSize(){return p(this.#e),this.#s.size}#i=[];get musicList(){return p(this.#e),structuredClone(this.#i)}#r=[];get voiceList(){return p(this.#e),structuredClone(this.#r)}#n=[];get customPositions(){return p(this.#e),structuredClone(this.#n)}#o=[];get scheduledTasks(){return p(this.#e),structuredClone(this.#o)}get allList(){return p(this.#e),[...this.musicList,...this.voiceList]}#a=0;get seed(){return p(this.#e),this.#a}set seed(t){if(p(this.#e),"number"!=typeof t)throw new TypeError("Seed must be a number.");this.#a=t,this.#s.clear(),this.emit("seedChanged",{seed:t})}#c=Date.now();get anchorDate(){return p(this.#e),this.#c}#s=new Map;#u={mode:"playlist",voiceMode:"playlist",silenceDuration:0,queryLimit:1e5,voiceAfterMusic:!0,voiceMin:0,voiceMax:1,musicMaxConsecutive:0,voiceMaxConsecutive:0};get config(){return p(this.#e),structuredClone(this.#u)}set config(t){p(this.#e),this.#l(t),this.#u=structuredClone(t),this.#s.clear(),this.emit("configChanged",{config:this.config})}#l(t){if("object"!=typeof t||null===t)throw new TypeError("Configuration must be a valid object.");const e=["playlist","random"];if(void 0!==t.mode&&!e.includes(t.mode))throw new TypeError(`Invalid mode: "${t.mode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.voiceMode&&!e.includes(t.voiceMode))throw new TypeError(`Invalid voiceMode: "${t.voiceMode}". Must be one of: ${e.join(", ")}.`);if(void 0!==t.silenceDuration&&("number"!=typeof t.silenceDuration||t.silenceDuration<0))throw new TypeError("silenceDuration must be a non-negative number.");if(void 0!==t.queryLimit&&("number"!=typeof t.queryLimit||t.queryLimit<=0))throw new TypeError("queryLimit must be a positive number.");if(void 0!==t.voiceAfterMusic&&"boolean"!=typeof t.voiceAfterMusic)throw new TypeError("voiceAfterMusic must be a boolean.");if(void 0!==t.voiceMin&&("number"!=typeof t.voiceMin||t.voiceMin<0))throw new TypeError("voiceMin must be a non-negative number.");if(void 0!==t.voiceMax&&("number"!=typeof t.voiceMax||t.voiceMax<0))throw new TypeError("voiceMax must be a non-negative number.");if(void 0!==t.musicMaxConsecutive&&("number"!=typeof t.musicMaxConsecutive||t.musicMaxConsecutive<-1))throw new TypeError("musicMaxConsecutive must be a number >= -1.");if(void 0!==t.voiceMaxConsecutive&&("number"!=typeof t.voiceMaxConsecutive||t.voiceMaxConsecutive<-1))throw new TypeError("voiceMaxConsecutive must be a number >= -1.");const i=t.voiceMin??this.#u.voiceMin,r=t.voiceMax??this.#u.voiceMax;if(r<i)throw new RangeError(`Logical error: voiceMax (${r}) cannot be less than voiceMin (${i}).`)}constructor(t=null,e=0){if(super(),null!==t&&"object"!=typeof t)throw new TypeError("initialData must be an object or null.");if("number"!=typeof e)throw new TypeError("seed must be a number.");this.#a=e,t?this.#d(t):this.#c=Date.now()}add(t,e,i=!0){if(p(this.#e),!["music","voice","custom"].includes(t))throw new TypeError('Type must be "music", "voice", or "custom".');if(!e||"string"!=typeof e.id||"number"!=typeof e.duration)throw new TypeError("Content must have a string ID and a valid numerical duration in milliseconds.");if("boolean"!=typeof i)throw new TypeError("smartQueue must be a boolean.");"music"===t?(this.#i.push(e),this.#s.clear()):"voice"===t?(this.#r.push(e),this.#s.clear()):"custom"===t&&this.#h(e,i),this.#f(Date.now()),this.emit("contentAdded",{type:t,data:structuredClone(e)})}scheduleTask(t,e,i,r,n=!0){if(p(this.#e),"number"!=typeof t||isNaN(t))throw new TypeError("timestamp must be a valid number.");if(!["add","remove","move"].includes(e))throw new TypeError('action must be "add", "remove", or "move".');if(!["music","voice"].includes(i))throw new TypeError('type must be "music" or "voice".');if("boolean"!=typeof n)throw new TypeError("smartQueue must be a boolean.");if("add"===e){if("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.duration)throw new TypeError('Payload for "add" must be a MediaContent object (id: string, duration: number).')}else if("remove"===e){if("string"!=typeof r)throw new TypeError('Payload for "remove" must be a string (the content ID).')}else if("move"===e&&("object"!=typeof r||null===r||"string"!=typeof r.id||"number"!=typeof r.newIndex))throw new TypeError('Payload for "move" must be a ScheduledMovePayload (id: string, newIndex: number).');let o=t;if(n){const e=this.#m(t,t);e&&(o=e.absoluteEnd)}const s={timestamp:o,action:e,type:i,payload:r};this.#o.push(s),this.#f(Date.now()),this.emit("taskScheduled",structuredClone(s))}remove(t){if(p(this.#e),"string"!=typeof t)throw new TypeError("id must be a string.");this.#i.filter(e=>e.id===t).forEach(t=>f(t)),this.#r.filter(e=>e.id===t).forEach(t=>f(t)),this.#n.filter(e=>e.content?.id===t).forEach(t=>f(t.content));const e=e=>e.id!==t&&e.content?.id!==t;this.#i=this.#i.filter(e),this.#r=this.#r.filter(e),this.#n=this.#n.filter(e),this.#o=this.#o.filter(e=>"add"===e.action&&"object"==typeof e.payload&&null!==e.payload&&"id"in e.payload?e.payload.id!==t||(f(e.payload),!1):e.payload!==t),this.#s.clear(),this.emit("contentRemoved",{id:t})}setConfig(t){p(this.#e),this.#l(t);const e={...this.#u,...t};this.#l(e),this.#u=e,this.#s.clear(),this.emit("configChanged",{config:this.config})}getCurrentEvent(){p(this.#e);const t=Date.now();return this.#f(t),this.#m(t,t)}queryTimeline(t,e=10){if(p(this.#e),"number"!=typeof e||isNaN(e))throw new TypeError("Invalid query limit value. Ensure it is a number.");if(e>this.#u.queryLimit||e<=0)throw new RangeError(`Invalid query limit. Ensure it is > 0 and <= ${this.#u.queryLimit}.`);const i=new y(JSON.parse(this._exportState())),r=[];let n=t;for(let o=0;o<e;o++){i.#f(n);const e=i.#p(n,t);if(!e)break;r.push(e),n=e.absoluteEnd}return i.destroy(!1),this.emit("timelineQueried",{targetDate:t,limit:e,resultCount:r.length}),r}searchCustomPositions(){return p(this.#e),this.#f(Date.now()),[...this.#n]}async _processListForExport(t){return Promise.all(t.map(async t=>{const e=structuredClone(t);return e.picture&&Array.isArray(e.picture)&&(e.picture=await Promise.all(e.picture.map(async t=>"string"==typeof t.data&&t.data.startsWith("blob:")?{...t,data:await h(t.data)}:t))),e}))}_exportState(){return JSON.stringify({music:this.#i,voice:this.#r,custom:this.#n,tasks:this.#o,seed:this.#a,anchorDate:this.#c,config:this.#u})}async exportState(){p(this.#e);const t=await this._processListForExport(this.#i),e=await this._processListForExport(this.#r),i=await Promise.all(this.#n.map(async t=>{const e=await this._processListForExport([t.content]);return{...t,content:e[0]}})),r=await Promise.all(this.#o.map(async t=>{if("add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload){const e=await this._processListForExport([t.payload]);return{...t,payload:e[0]}}return t}));return JSON.stringify({music:t,voice:e,custom:i,tasks:r,seed:this.#a,anchorDate:this.#c,config:this.#u})}importState(t){let e;if(p(this.#e),"string"==typeof t)try{e=JSON.parse(t)}catch{throw new TypeError("Provided string is not valid JSON.")}else{if("object"!=typeof t||null===t)throw new TypeError("Import data must be a valid JSON string or an object.");e=t}this.#d(e),this.emit("stateImported",{data:structuredClone(e)})}_prng(t){return function(){let e=t+=1831565813;return e=Math.imul(e^e>>>15,1|e),e^=e+Math.imul(e^e>>>7,61|e),((e^e>>>14)>>>0)/4294967296}}#y(t,e,i,r=0){if(0===t.length)return[];if("random"!==i)return[...t];const n=t.map(t=>({...t,weight:t.weight??1})),o=this._prng(e),s=[];let a=null,c=0;for(;n.length>0;){let t=n;-1!==r&&null!==a&&c>r&&(t=n.filter(t=>t.id!==a),0===t.length&&(t=n));const e=t.reduce((t,e)=>t+e.weight,0);if(e<=0){s.push(...t);break}const i=o()*e;let u=0,l=null,d=-1;for(let e=0;e<t.length;e++)if(u+=t[e].weight,i<=u){l=t[e],d=n.findIndex(t=>l&&t.id===l.id);break}l&&-1!==d||(l=t[0],d=n.findIndex(t=>l&&t.id===l.id)),s.push(l),n.splice(d,1),l.id===a?c++:(a=l.id,c=1)}return s}#v(t){const e=this.#a+t,i=this._prng(10*e),r=this.#y(this.#i,e+1,this.#u.mode,this.#u.musicMaxConsecutive),n=this.#y(this.#r,e+2,this.#u.voiceMode,this.#u.voiceMaxConsecutive),o=[];let s=0,a=0;for(let t=0;t<r.length;t++){const e=r[t];if(o.push({...e,cycleStart:s,cycleEnd:s+e.duration}),s+=e.duration+this.#u.silenceDuration,this.#u.voiceAfterMusic&&n.length>0){const t=this.#u.voiceMax-this.#u.voiceMin+1,e=Math.floor(i()*t)+this.#u.voiceMin;for(let t=0;t<e;t++){const t=n[a%n.length];a++,o.push({...t,cycleStart:s,cycleEnd:s+t.duration}),s+=t.duration+this.#u.silenceDuration}}}return{items:o,duration:s}}#g(t){if(0===this.#i.length)return null;let e=this.#c,i=0;for(;;){if(i>this.#u.queryLimit)throw new Error("Safety limit hit during cycle location.");let r=this.#s.get(i);if(r||(r=this.#v(i),this.#s.set(i,r)),0===r.duration)return null;if(t>=e&&t<e+r.duration)return{block:r,startTimestamp:e,loopIndex:i};e+=r.duration,i++}}#p(t,e){const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t).sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp)[0];let r=null;if(i){const t=Math.max(e,i.intendedTimestamp);r=this.#w(i.content,i.intendedTimestamp,t,!0)}const n=this.#b(t,e);return n||r?n?r?r.absoluteStart<=n.absoluteStart?r:(r.absoluteStart<n.absoluteEnd&&(n.absoluteEnd=r.absoluteStart,n.duration=n.absoluteEnd-n.absoluteStart,n.remainingTime=Math.max(0,n.absoluteEnd-e),n.progress=Math.min(1,n.elapsedTime/n.duration)),n):n:r:null}#b(t,e){let i=this.#g(t);if(!i)return null;const{block:r,startTimestamp:n}=i,o=t-n;let s,a=r.items.find(t=>t.cycleEnd>o);if(a)s=n+a.cycleStart;else{if(i=this.#g(n+r.duration),!i||0===i.block.items.length)return null;a=i.block.items[0],s=i.startTimestamp+a.cycleStart}const c=Math.max(e,s);return this.#w(a,s,c,!1)}#m(t,e){const i=this.#n.find(e=>t>=e.intendedTimestamp&&t<e.intendedTimestamp+e.content.duration);if(i)return this.#w(i.content,i.intendedTimestamp,e,!0);const r=this.#g(t);if(!r)return null;const{block:n,startTimestamp:o}=r,s=t-o,a=n.items.find(t=>s>=t.cycleStart&&s<t.cycleEnd);return a?this.#w(a,o+a.cycleStart,e,!1):null}#w(t,e,i,r){const n=i-e;return{id:t.id,title:t.title,artist:t.artist,duration:t.duration,url:t.url,absoluteStart:e,absoluteEnd:e+t.duration,elapsedTime:n,remainingTime:t.duration-n,progress:Math.min(1,n/t.duration),isCustom:r}}#h(t,e){let i=t.timestamp||Date.now();const r=t.duration;if(e){const t=this.#m(i,i);t&&(i=t.absoluteEnd)}const n=[...this.#n].sort((t,e)=>t.intendedTimestamp-e.intendedTimestamp);let o=i;if(n.some(t=>i<t.intendedTimestamp+t.content.duration&&i+r>t.intendedTimestamp)){const t=[];let e=Date.now();for(const i of n)i.intendedTimestamp>e&&t.push({start:e,end:i.intendedTimestamp}),e=Math.max(e,i.intendedTimestamp+i.content.duration+this.#u.silenceDuration);t.push({start:e,end:1/0});let s=1/0;for(const e of t)if(e.end-e.start>=r){let t=null;if(i>=e.start&&i+r<=e.end?t=i:i<e.start?t=e.start:i>e.end&&(t=e.end-r),null!==t){const e=Math.abs(i-t);e<s&&(s=e,o=t)}}}this.#n.push({content:t,intendedTimestamp:o,originalTimestamp:t.timestamp||Date.now()})}#f(t){const e=this.#o.filter(e=>e.timestamp<=t);this.#o=this.#o.filter(e=>e.timestamp>t);const i=this.#n.filter(e=>e.intendedTimestamp+e.content.duration<=t);this.#n=this.#n.filter(e=>e.intendedTimestamp+e.content.duration>t);let r=!1;i.forEach(t=>{f(t.content),this.#a+=t.content.id.length,r=!0,this.emit("customPositionExpired",{contentId:t.content.id})}),e.length>0&&e.sort((t,e)=>t.timestamp-e.timestamp).forEach(t=>{const e="music"===t.type?this.#i:this.#r;if("add"===t.action)e.push(t.payload);else if("remove"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i);if(-1!==r){const[t]=e.splice(r,1);f(t)}}else if("move"===t.action){const i=t.payload,r=e.findIndex(t=>t.id===i.id);if(-1!==r){const[t]=e.splice(r,1);e.splice(i.newIndex,0,t)}}this.#c=t.timestamp,this.#a+=1,r=!0,this.emit("taskExecuted",structuredClone(t))}),r&&this.#s.clear()}#d(t){this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)});const e=t=>t.map(t=>{const e={...t};return e.picture&&Array.isArray(e.picture)&&(e.picture=e.picture.map(t=>{const e="string"==typeof t.data&&t.data.startsWith("data:"),i=t.data instanceof Uint8Array;return e||i?{...t,data:d(t.data,t.format)}:t})),e});this.#i=e(t.music),this.#r=e(t.voice),this.#a=t.seed||0,this.#c=t.anchorDate||Date.now(),this.#u={...this.#u,...t.config||{}},this.#n=t.custom.map(t=>({...t,content:e([t.content])[0]})),this.#o=t.tasks.map(t=>"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload?{...t,payload:e([t.payload])[0]}:t)}destroy(t=!0){this.#e||(t&&(this.#i.forEach(t=>f(t)),this.#r.forEach(t=>f(t)),this.#n.forEach(t=>f(t.content)),this.#o.forEach(t=>{"add"===t.action&&t.payload&&"object"==typeof t.payload&&"title"in t.payload&&f(t.payload)})),this.#i=[],this.#r=[],this.#n=[],this.#o=[],this.#s.clear(),this.emit("destroyed",{timestamp:Date.now()}),this.removeAllListeners(),this.#e=!0)}}const v=y;window.TinyRadioFm=r.TinyRadioFm})();
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* @param {T} items - The array to shuffle.
|
|
9
9
|
* @returns {T} The same array instance, now shuffled in place.
|
|
10
10
|
*/
|
|
11
|
-
export function shuffleArray<T extends any[]>(items: T): T;
|
|
11
|
+
export declare function shuffleArray<T extends any[]>(items: T): T;
|
|
12
12
|
/**
|
|
13
13
|
* Generates an array with repeated phases according to counts.
|
|
14
14
|
*
|
|
@@ -17,7 +17,17 @@ export function shuffleArray<T extends any[]>(items: T): T;
|
|
|
17
17
|
* @param {number[]} counts - Array of integers specifying how many times to repeat each phase, e.g., [4,5,5,4].
|
|
18
18
|
* @returns {BlockValue[]} - Flattened array containing phases repeated according to counts, concatenated in order.
|
|
19
19
|
*/
|
|
20
|
-
export function multiplyArrayBlocks<BlockValue extends
|
|
20
|
+
export declare function multiplyArrayBlocks<BlockValue extends any>(phases: BlockValue[], counts: number[]): BlockValue[];
|
|
21
|
+
export type DiffArrayListData<T> = {
|
|
22
|
+
/**
|
|
23
|
+
* - Items that only exist in the new array.
|
|
24
|
+
*/
|
|
25
|
+
added: T[];
|
|
26
|
+
/**
|
|
27
|
+
* - Items that only existed in the old array.
|
|
28
|
+
*/
|
|
29
|
+
removed: T[];
|
|
30
|
+
};
|
|
21
31
|
/**
|
|
22
32
|
* @template T
|
|
23
33
|
* @typedef {Object} DiffArrayListData
|
|
@@ -31,7 +41,7 @@ export function multiplyArrayBlocks<BlockValue extends unknown>(phases: BlockVal
|
|
|
31
41
|
* @param {T[]} newItems - The new array for comparison.
|
|
32
42
|
* @returns {DiffArrayListData<T>} An object containing arrays of added and removed items.
|
|
33
43
|
*/
|
|
34
|
-
export function diffArrayList<T>(oldItems: T[], newItems: T[]): DiffArrayListData<T>;
|
|
44
|
+
export declare function diffArrayList<T>(oldItems: T[], newItems: T[]): DiffArrayListData<T>;
|
|
35
45
|
/**
|
|
36
46
|
* Generates a comparator function to sort an array of objects by a given key.
|
|
37
47
|
*
|
|
@@ -47,15 +57,5 @@ export function diffArrayList<T>(oldItems: T[], newItems: T[]): DiffArrayListDat
|
|
|
47
57
|
* const arr = [{ pos: 2 }, { pos: 1 }, { pos: 3 }];
|
|
48
58
|
* arr.sort(arraySortPositions('pos', true)); // Descending: [{pos: 3}, {pos: 2}, {pos: 1}]
|
|
49
59
|
*/
|
|
50
|
-
export function arraySortPositions(item?: string | null, isReverse?: boolean): (a: any, b: any) => number;
|
|
51
|
-
export type DiffArrayListData<T> = {
|
|
52
|
-
/**
|
|
53
|
-
* - Items that only exist in the new array.
|
|
54
|
-
*/
|
|
55
|
-
added: T[];
|
|
56
|
-
/**
|
|
57
|
-
* - Items that only existed in the old array.
|
|
58
|
-
*/
|
|
59
|
-
removed: T[];
|
|
60
|
-
};
|
|
60
|
+
export declare function arraySortPositions(item?: string | null, isReverse?: boolean): (a: any, b: any) => number;
|
|
61
61
|
//# sourceMappingURL=array.d.mts.map
|
package/dist/v1/basics/clock.cjs
CHANGED
|
@@ -81,13 +81,13 @@ function formatCustomTimer(totalSeconds, level = 'seconds', format = '{time}') {
|
|
|
81
81
|
|
|
82
82
|
/**
|
|
83
83
|
* @type {{
|
|
84
|
-
* years: number
|
|
85
|
-
* months: number
|
|
86
|
-
* days: number
|
|
87
|
-
* hours: number
|
|
88
|
-
* minutes: number
|
|
89
|
-
* seconds: number
|
|
90
|
-
* total: number
|
|
84
|
+
* years: number,
|
|
85
|
+
* months: number,
|
|
86
|
+
* days: number,
|
|
87
|
+
* hours: number,
|
|
88
|
+
* minutes: number,
|
|
89
|
+
* seconds: number,
|
|
90
|
+
* total: number
|
|
91
91
|
* }}
|
|
92
92
|
*/
|
|
93
93
|
const parts = {
|
|
@@ -245,14 +245,14 @@ function formatDayTimer(seconds) {
|
|
|
245
245
|
* @param {number} totalMs - The total duration in milliseconds.
|
|
246
246
|
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
247
247
|
* @returns {{
|
|
248
|
-
* years: number
|
|
249
|
-
* months: number
|
|
250
|
-
* days: number
|
|
251
|
-
* hours: number
|
|
252
|
-
* minutes: number
|
|
253
|
-
* seconds: number
|
|
254
|
-
* milliseconds: number
|
|
255
|
-
* total: number
|
|
248
|
+
* years: number,
|
|
249
|
+
* months: number,
|
|
250
|
+
* days: number,
|
|
251
|
+
* hours: number,
|
|
252
|
+
* minutes: number,
|
|
253
|
+
* seconds: number,
|
|
254
|
+
* milliseconds: number,
|
|
255
|
+
* total: number
|
|
256
256
|
* }}
|
|
257
257
|
*/
|
|
258
258
|
function breakdownDuration(totalMs, level = 'milliseconds') {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {Date|null} [now=null] - The current time as a Date object. Defaults to the current date and time if not provided.
|
|
7
7
|
* @returns {number|null} The calculated duration in the specified unit, or `null` if `timeData` is not provided.
|
|
8
8
|
*/
|
|
9
|
-
export function getTimeDuration(timeData?: Date, durationType?:
|
|
9
|
+
export declare function getTimeDuration(timeData?: Date, durationType?: 'asMilliseconds' | 'asSeconds' | 'asMinutes' | 'asHours' | 'asDays', now?: Date | null): number | null;
|
|
10
10
|
/**
|
|
11
11
|
* Formats a custom timer string based on total seconds and a detail level.
|
|
12
12
|
* Includes proper reallocation of lower units into higher ones, ensuring consistent hierarchy.
|
|
@@ -16,7 +16,7 @@ export function getTimeDuration(timeData?: Date, durationType?: "asMilliseconds"
|
|
|
16
16
|
* @param {string} [format='{time}'] - Output template with placeholders like {years}, {months}, {days}, {hours}, {minutes}, {seconds}, {time}, {total}.
|
|
17
17
|
* @returns {string} The formatted timer string.
|
|
18
18
|
*/
|
|
19
|
-
export function formatCustomTimer(totalSeconds: number, level?:
|
|
19
|
+
export declare function formatCustomTimer(totalSeconds: number, level?: 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years', format?: string): string;
|
|
20
20
|
/**
|
|
21
21
|
* Formats a duration (in seconds) into a timer string showing only hours, minutes, and seconds.
|
|
22
22
|
*
|
|
@@ -25,7 +25,7 @@ export function formatCustomTimer(totalSeconds: number, level?: "seconds" | "min
|
|
|
25
25
|
* @param {number} seconds - The total number of seconds to format.
|
|
26
26
|
* @returns {string} The formatted timer string in "HH:MM:SS" format.
|
|
27
27
|
*/
|
|
28
|
-
export function formatTimer(seconds: number): string;
|
|
28
|
+
export declare function formatTimer(seconds: number): string;
|
|
29
29
|
/**
|
|
30
30
|
* Formats a duration (in seconds) into a timer string including days, hours, minutes, and seconds.
|
|
31
31
|
*
|
|
@@ -34,31 +34,31 @@ export function formatTimer(seconds: number): string;
|
|
|
34
34
|
* @param {number} seconds - The total number of seconds to format.
|
|
35
35
|
* @returns {string} The formatted timer string in "Xd HH:MM:SS" format.
|
|
36
36
|
*/
|
|
37
|
-
export function formatDayTimer(seconds: number): string;
|
|
37
|
+
export declare function formatDayTimer(seconds: number): string;
|
|
38
38
|
/**
|
|
39
39
|
* Breaks down a duration in milliseconds into its time components.
|
|
40
40
|
*
|
|
41
41
|
* @param {number} totalMs - The total duration in milliseconds.
|
|
42
42
|
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
43
43
|
* @returns {{
|
|
44
|
-
* years: number
|
|
45
|
-
* months: number
|
|
46
|
-
* days: number
|
|
47
|
-
* hours: number
|
|
48
|
-
* minutes: number
|
|
49
|
-
* seconds: number
|
|
50
|
-
* milliseconds: number
|
|
51
|
-
* total: number
|
|
44
|
+
* years: number,
|
|
45
|
+
* months: number,
|
|
46
|
+
* days: number,
|
|
47
|
+
* hours: number,
|
|
48
|
+
* minutes: number,
|
|
49
|
+
* seconds: number,
|
|
50
|
+
* milliseconds: number,
|
|
51
|
+
* total: number
|
|
52
52
|
* }}
|
|
53
53
|
*/
|
|
54
|
-
export function breakdownDuration(totalMs: number, level?:
|
|
55
|
-
years: number
|
|
56
|
-
months: number
|
|
57
|
-
days: number
|
|
58
|
-
hours: number
|
|
59
|
-
minutes: number
|
|
60
|
-
seconds: number
|
|
61
|
-
milliseconds: number
|
|
62
|
-
total: number
|
|
54
|
+
export declare function breakdownDuration(totalMs: number, level?: 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years'): {
|
|
55
|
+
years: number;
|
|
56
|
+
months: number;
|
|
57
|
+
days: number;
|
|
58
|
+
hours: number;
|
|
59
|
+
minutes: number;
|
|
60
|
+
seconds: number;
|
|
61
|
+
milliseconds: number;
|
|
62
|
+
total: number;
|
|
63
63
|
};
|
|
64
64
|
//# sourceMappingURL=clock.d.mts.map
|
package/dist/v1/basics/clock.mjs
CHANGED
|
@@ -73,13 +73,13 @@ export function formatCustomTimer(totalSeconds, level = 'seconds', format = '{ti
|
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* @type {{
|
|
76
|
-
* years: number
|
|
77
|
-
* months: number
|
|
78
|
-
* days: number
|
|
79
|
-
* hours: number
|
|
80
|
-
* minutes: number
|
|
81
|
-
* seconds: number
|
|
82
|
-
* total: number
|
|
76
|
+
* years: number,
|
|
77
|
+
* months: number,
|
|
78
|
+
* days: number,
|
|
79
|
+
* hours: number,
|
|
80
|
+
* minutes: number,
|
|
81
|
+
* seconds: number,
|
|
82
|
+
* total: number
|
|
83
83
|
* }}
|
|
84
84
|
*/
|
|
85
85
|
const parts = {
|
|
@@ -202,14 +202,14 @@ export function formatDayTimer(seconds) {
|
|
|
202
202
|
* @param {number} totalMs - The total duration in milliseconds.
|
|
203
203
|
* @param {'milliseconds'|'seconds'|'minutes'|'hours'|'days'|'months'|'years'} [level='milliseconds'] - The highest level to calculate and display.
|
|
204
204
|
* @returns {{
|
|
205
|
-
* years: number
|
|
206
|
-
* months: number
|
|
207
|
-
* days: number
|
|
208
|
-
* hours: number
|
|
209
|
-
* minutes: number
|
|
210
|
-
* seconds: number
|
|
211
|
-
* milliseconds: number
|
|
212
|
-
* total: number
|
|
205
|
+
* years: number,
|
|
206
|
+
* months: number,
|
|
207
|
+
* days: number,
|
|
208
|
+
* hours: number,
|
|
209
|
+
* minutes: number,
|
|
210
|
+
* seconds: number,
|
|
211
|
+
* milliseconds: number,
|
|
212
|
+
* total: number
|
|
213
213
|
* }}
|
|
214
214
|
*/
|
|
215
215
|
export function breakdownDuration(totalMs, level = 'milliseconds') {
|