tiny-essentials 1.28.0 → 1.28.2
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/1.md +23 -0
- package/changelog/1/28/2.md +43 -0
- package/dist/_/numbers.d.mts +91 -16
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyAnalogClock.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyElementObserver.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -1
- package/dist/v1/TinyGamepad.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyI18.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -1
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +57 -9
- package/dist/v1/basics/array.d.mts +28 -12
- package/dist/v1/basics/array.mjs +51 -9
- package/dist/v1/basics/clock.cjs +94 -42
- package/dist/v1/basics/clock.d.mts +22 -22
- package/dist/v1/basics/clock.mjs +91 -54
- package/dist/v1/basics/collision.d.mts +245 -104
- package/dist/v1/basics/deprecated/html.cjs +246 -0
- package/dist/v1/basics/deprecated/html.d.mts +63 -0
- package/dist/v1/basics/deprecated/html.mjs +190 -0
- package/dist/v1/basics/extendObjType/Buffer.d.mts +1 -1
- package/dist/v1/basics/fullScreen.d.mts +47 -7
- package/dist/v1/basics/html.cjs +149 -130
- package/dist/v1/basics/html.d.mts +69 -113
- package/dist/v1/basics/html.mjs +113 -105
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +11 -65
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/mediaContent.cjs +116 -32
- package/dist/v1/basics/mediaContent.d.mts +143 -159
- package/dist/v1/basics/mediaContent.mjs +105 -33
- package/dist/v1/basics/objChecker.cjs +7 -5
- package/dist/v1/basics/objChecker.d.mts +5 -4
- package/dist/v1/basics/objChecker.mjs +6 -6
- package/dist/v1/basics/objFilter.cjs +71 -14
- package/dist/v1/basics/objFilter.d.mts +16 -19
- package/dist/v1/basics/objFilter.mjs +63 -14
- package/dist/v1/basics/simpleMath.cjs +81 -25
- package/dist/v1/basics/simpleMath.d.mts +22 -22
- package/dist/v1/basics/simpleMath.mjs +70 -27
- package/dist/v1/basics/text.cjs +76 -31
- package/dist/v1/basics/text.d.mts +64 -14
- package/dist/v1/basics/text.mjs +62 -31
- 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 +4 -0
- package/dist/v1/index.d.mts +54 -137
- package/dist/v1/index.mjs +4 -3
- package/dist/v1/libs/ColorSafeStringify.d.mts +3 -12
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +64 -116
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +15 -19
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
- package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
- package/dist/v1/libs/TinyAnalogClock.d.mts +12 -9
- package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
- 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.cjs +2 -0
- package/dist/v1/libs/TinyClipboard.d.mts +12 -5
- package/dist/v1/libs/TinyClipboard.mjs +2 -0
- package/dist/v1/libs/TinyColorConverter.cjs +1 -0
- package/dist/v1/libs/TinyColorConverter.d.mts +10 -32
- package/dist/v1/libs/TinyColorConverter.mjs +1 -0
- package/dist/v1/libs/TinyColorValidator.d.mts +145 -184
- package/dist/v1/libs/TinyCookieConsent.d.mts +17 -17
- package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
- package/dist/v1/libs/TinyDayNightCycle.d.mts +87 -117
- package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
- package/dist/v1/libs/TinyDomReadyManager.d.mts +8 -16
- package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +32 -26
- package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
- package/dist/v1/libs/TinyDragger.cjs +46 -19
- package/dist/v1/libs/TinyDragger.d.mts +82 -81
- package/dist/v1/libs/TinyDragger.mjs +45 -18
- package/dist/v1/libs/TinyElementObserver.cjs +39 -0
- package/dist/v1/libs/TinyElementObserver.d.mts +28 -25
- package/dist/v1/libs/TinyElementObserver.mjs +36 -0
- package/dist/v1/libs/TinyGamepad.cjs +131 -2
- package/dist/v1/libs/TinyGamepad.d.mts +50 -122
- package/dist/v1/libs/TinyGamepad.mjs +129 -2
- 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 +4 -5
- package/dist/v1/libs/TinyHtml.d.mts +1503 -1731
- package/dist/v1/libs/TinyHtml.mjs +5 -6
- package/dist/v1/libs/TinyI18.cjs +61 -0
- package/dist/v1/libs/TinyI18.d.mts +34 -58
- package/dist/v1/libs/TinyI18.mjs +55 -0
- package/dist/v1/libs/TinyIframeEvents.cjs +19 -2
- package/dist/v1/libs/TinyIframeEvents.d.mts +29 -38
- package/dist/v1/libs/TinyIframeEvents.mjs +19 -2
- 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.cjs +48 -0
- package/dist/v1/libs/TinyLocalStorage.d.mts +11 -30
- package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
- package/dist/v1/libs/TinyMamdaniInferenceSystem.d.mts +37 -23
- package/dist/v1/libs/TinyMediaPlayer.cjs +77 -3
- package/dist/v1/libs/TinyMediaPlayer.d.mts +109 -106
- package/dist/v1/libs/TinyMediaPlayer.mjs +71 -3
- package/dist/v1/libs/TinyNeedBar.d.mts +25 -37
- package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
- package/dist/v1/libs/TinyNewWinEvents.d.mts +32 -29
- package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
- package/dist/v1/libs/TinyNotifications.d.mts +6 -6
- package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +15 -15
- package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
- package/dist/v1/libs/TinyPromiseQueue.d.mts +11 -11
- package/dist/v1/libs/TinyRadioFm.cjs +70 -12
- package/dist/v1/libs/TinyRadioFm.d.mts +45 -80
- package/dist/v1/libs/TinyRadioFm.mjs +64 -12
- package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
- package/dist/v1/libs/TinyRateLimiter.d.mts +29 -36
- package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
- package/dist/v1/libs/TinySimpleDice.d.mts +17 -36
- package/dist/v1/libs/TinySmartScroller.cjs +52 -3
- package/dist/v1/libs/TinySmartScroller.d.mts +62 -70
- package/dist/v1/libs/TinySmartScroller.mjs +51 -5
- package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
- package/dist/v1/libs/TinyTextDiffer.d.mts +11 -13
- package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
- package/dist/v1/libs/TinyTextRangeEditor.d.mts +8 -8
- package/dist/v1/libs/TinyTextarea.cjs +19 -0
- package/dist/v1/libs/TinyTextarea.d.mts +34 -28
- package/dist/v1/libs/TinyTextarea.mjs +17 -0
- package/dist/v1/libs/TinyTimeout.cjs +11 -1
- package/dist/v1/libs/TinyTimeout.d.mts +14 -14
- package/dist/v1/libs/TinyTimeout.mjs +9 -1
- package/dist/v1/libs/TinyToastNotify.cjs +36 -1
- package/dist/v1/libs/TinyToastNotify.d.mts +15 -17
- package/dist/v1/libs/TinyToastNotify.mjs +32 -1
- package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +38 -8
- package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +52 -78
- package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
- package/dist/v1/libs/utils.cjs +21 -0
- package/dist/v1/libs/utils.d.mts +6 -0
- package/dist/v1/libs/utils.mjs +16 -0
- package/docs/v1/README.md +1 -0
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/basics/deprecated/html.md +17 -0
- package/docs/v1/basics/fullScreen.md +1 -1
- package/docs/v1/basics/html.md +12 -26
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +1 -1
- package/docs/v1/basics/text.md +2 -2
- package/docs/v1/fileManager/main.md +1 -1
- package/docs/v1/libs/ColorSafeStringify.md +1 -1
- package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
- package/docs/v1/libs/TinyAnalogClock.md +1 -1
- package/docs/v1/libs/TinyArrayComparator.md +1 -1
- package/docs/v1/libs/TinyArrayPaginator.md +1 -1
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
- package/docs/v1/libs/TinyClassManager.md +1 -1
- package/docs/v1/libs/TinyClipboard.md +1 -1
- package/docs/v1/libs/TinyCookieConsent.md +1 -1
- package/docs/v1/libs/TinyDomReadyManager.md +1 -1
- package/docs/v1/libs/TinyDragDropDetector.md +1 -1
- package/docs/v1/libs/TinyDragger.md +1 -1
- package/docs/v1/libs/TinyElementObserver.md +1 -1
- package/docs/v1/libs/TinyHtml.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +2 -2
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyNewWinEvents.md +2 -2
- package/docs/v1/libs/TinyNotifications.md +1 -1
- package/docs/v1/libs/TinyPromiseQueue.md +2 -2
- package/docs/v1/libs/TinyTextDiffer.md +1 -1
- package/docs/v1/libs/TinyTextarea.md +1 -1
- package/package.json +11 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { diffArrayList } from '../basics/array.mjs';
|
|
2
|
-
import {
|
|
2
|
+
import { diffObjList } from '../basics/text.mjs';
|
|
3
3
|
import * as TinyCollision from '../basics/collision.mjs';
|
|
4
4
|
import TinyElementObserver from './TinyElementObserver.mjs';
|
|
5
5
|
// TITLE: Introduction
|
|
@@ -333,7 +333,6 @@ class TinyHtml {
|
|
|
333
333
|
* Enables or disables debug output.
|
|
334
334
|
* @param {boolean} value True to enable debug output; false to disable.
|
|
335
335
|
* @throws {TypeError} Thrown if the provided value is not a boolean.
|
|
336
|
-
* @returns {void}
|
|
337
336
|
*/
|
|
338
337
|
static set elemDebug(value) {
|
|
339
338
|
if (typeof value !== 'boolean')
|
|
@@ -432,7 +431,7 @@ class TinyHtml {
|
|
|
432
431
|
const newVal = mutation.target.getAttribute('style') || '';
|
|
433
432
|
const oldStyles = TinyHtml.parseStyle(oldVal);
|
|
434
433
|
const newStyles = TinyHtml.parseStyle(newVal);
|
|
435
|
-
const changes =
|
|
434
|
+
const changes = diffObjList(oldStyles, newStyles);
|
|
436
435
|
if (Object.keys(changes.added).length ||
|
|
437
436
|
Object.keys(changes.removed).length ||
|
|
438
437
|
Object.keys(changes.modified).length) {
|
|
@@ -511,7 +510,7 @@ class TinyHtml {
|
|
|
511
510
|
*
|
|
512
511
|
* @param {string} url - The URL of the HTML file.
|
|
513
512
|
* @param {RequestInit} [ops] - Optional fetch configuration (e.g., method, headers, cache, etc).
|
|
514
|
-
*
|
|
513
|
+
* Returns the promise that resolves with the TinyHtml instances.
|
|
515
514
|
*/
|
|
516
515
|
static async fetchHtmlTinyElems(url, ops) {
|
|
517
516
|
const nodes = await TinyHtml.fetchHtmlNodes(url, ops);
|
|
@@ -1437,7 +1436,7 @@ class TinyHtml {
|
|
|
1437
1436
|
* of the input form.
|
|
1438
1437
|
*
|
|
1439
1438
|
* @param {TinyElement|Text|(TinyElement|Text)[]} elems - A single element or an array of elements (DOM or TinyHtml).
|
|
1440
|
-
*
|
|
1439
|
+
* Returns the array of TinyHtml instances corresponding to the input elements.
|
|
1441
1440
|
*/
|
|
1442
1441
|
static toTinyElm(elems) {
|
|
1443
1442
|
/** @param {(TinyElement|Text)[]} item */
|
|
@@ -3706,7 +3705,7 @@ class TinyHtml {
|
|
|
3706
3705
|
// TITLE: Animate DOM (cssExpand)
|
|
3707
3706
|
/**
|
|
3708
3707
|
* CSS expansion shorthand used by genStyleFx to include margin/padding values.
|
|
3709
|
-
* @
|
|
3708
|
+
* @type {['Top', 'Right', 'Bottom', 'Left']}
|
|
3710
3709
|
*/
|
|
3711
3710
|
static #cssExpand = ['Top', 'Right', 'Bottom', 'Left'];
|
|
3712
3711
|
// TITLE: Animate DOM (styleEffects)
|
package/dist/v1/libs/TinyI18.cjs
CHANGED
|
@@ -3,6 +3,9 @@
|
|
|
3
3
|
var promises = require('fs/promises');
|
|
4
4
|
var fs = require('fs');
|
|
5
5
|
var path = require('path');
|
|
6
|
+
var utils = require('./utils.cjs');
|
|
7
|
+
|
|
8
|
+
const checkDestroy = utils.createCheckDestroyed('TinyI18');
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* Supported operating modes for TinyI18.
|
|
@@ -168,6 +171,21 @@ class TinyI18 {
|
|
|
168
171
|
await promises.writeFile(output, JSON.stringify(merged, null, spaces), 'utf-8');
|
|
169
172
|
}
|
|
170
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Tracks whether the instance has been destroyed.
|
|
176
|
+
* @type {boolean}
|
|
177
|
+
*/
|
|
178
|
+
#destroyed = false;
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Gets the current destruction status of the instance.
|
|
182
|
+
*
|
|
183
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
184
|
+
*/
|
|
185
|
+
get destroyed() {
|
|
186
|
+
return this.#destroyed;
|
|
187
|
+
}
|
|
188
|
+
|
|
171
189
|
/** @type {ModeTypes} */
|
|
172
190
|
#mode;
|
|
173
191
|
/** @type {LocaleCode} */
|
|
@@ -197,6 +215,7 @@ class TinyI18 {
|
|
|
197
215
|
* @returns {LocaleCode|null}
|
|
198
216
|
*/
|
|
199
217
|
get currentLocale() {
|
|
218
|
+
checkDestroy(this.#destroyed);
|
|
200
219
|
return this.#currentLocale;
|
|
201
220
|
}
|
|
202
221
|
|
|
@@ -206,6 +225,7 @@ class TinyI18 {
|
|
|
206
225
|
* @type {LocaleCode}
|
|
207
226
|
*/
|
|
208
227
|
get defaultLocale() {
|
|
228
|
+
checkDestroy(this.#destroyed);
|
|
209
229
|
return this.#defaultLocale;
|
|
210
230
|
}
|
|
211
231
|
|
|
@@ -216,6 +236,7 @@ class TinyI18 {
|
|
|
216
236
|
* @type {ModeTypes}
|
|
217
237
|
*/
|
|
218
238
|
get mode() {
|
|
239
|
+
checkDestroy(this.#destroyed);
|
|
219
240
|
return this.#mode;
|
|
220
241
|
}
|
|
221
242
|
|
|
@@ -226,6 +247,7 @@ class TinyI18 {
|
|
|
226
247
|
* @type {boolean}
|
|
227
248
|
*/
|
|
228
249
|
get strict() {
|
|
250
|
+
checkDestroy(this.#destroyed);
|
|
229
251
|
return this.#strict;
|
|
230
252
|
}
|
|
231
253
|
|
|
@@ -236,6 +258,7 @@ class TinyI18 {
|
|
|
236
258
|
* @type {string|null}
|
|
237
259
|
*/
|
|
238
260
|
get basePath() {
|
|
261
|
+
checkDestroy(this.#destroyed);
|
|
239
262
|
return this.#basePath;
|
|
240
263
|
}
|
|
241
264
|
|
|
@@ -244,6 +267,7 @@ class TinyI18 {
|
|
|
244
267
|
* @returns {StatLocale[]}
|
|
245
268
|
*/
|
|
246
269
|
get stats() {
|
|
270
|
+
checkDestroy(this.#destroyed);
|
|
247
271
|
const locales = [];
|
|
248
272
|
for (const loc of this.#stringTables.keys()) locales.push(this.getStatsForLocale(loc));
|
|
249
273
|
return locales;
|
|
@@ -255,6 +279,7 @@ class TinyI18 {
|
|
|
255
279
|
* @returns {Record<string, Dict>}
|
|
256
280
|
*/
|
|
257
281
|
get stringTables() {
|
|
282
|
+
checkDestroy(this.#destroyed);
|
|
258
283
|
/** @type {Record<string, Dict>} */
|
|
259
284
|
const obj = {};
|
|
260
285
|
for (const [locale, dict] of this.#stringTables.entries()) {
|
|
@@ -269,6 +294,7 @@ class TinyI18 {
|
|
|
269
294
|
* @returns {Record<string, PatternEntry[]>}
|
|
270
295
|
*/
|
|
271
296
|
get patternTables() {
|
|
297
|
+
checkDestroy(this.#destroyed);
|
|
272
298
|
/** @type {Record<string, PatternEntry[]>} */
|
|
273
299
|
const obj = {};
|
|
274
300
|
for (const [locale, arr] of this.#patternTables.entries()) {
|
|
@@ -287,6 +313,7 @@ class TinyI18 {
|
|
|
287
313
|
* @returns {Record<string, HelperCallback>}
|
|
288
314
|
*/
|
|
289
315
|
get helpers() {
|
|
316
|
+
checkDestroy(this.#destroyed);
|
|
290
317
|
/** @type {Record<string, HelperCallback>} */
|
|
291
318
|
const obj = {};
|
|
292
319
|
for (const [name, fn] of this.#helpers.entries()) {
|
|
@@ -301,6 +328,7 @@ class TinyI18 {
|
|
|
301
328
|
* @returns {Record<string, RegExp>}
|
|
302
329
|
*/
|
|
303
330
|
get regexCache() {
|
|
331
|
+
checkDestroy(this.#destroyed);
|
|
304
332
|
/** @type {Record<string, RegExp>} */
|
|
305
333
|
const obj = {};
|
|
306
334
|
for (const [key, re] of this.#regexCache.entries()) {
|
|
@@ -765,6 +793,7 @@ class TinyI18 {
|
|
|
765
793
|
* management is always controlled via the API instead of direct access.
|
|
766
794
|
*/
|
|
767
795
|
clearRegexCache() {
|
|
796
|
+
checkDestroy(this.#destroyed);
|
|
768
797
|
this.#regexCache.clear();
|
|
769
798
|
}
|
|
770
799
|
|
|
@@ -774,6 +803,7 @@ class TinyI18 {
|
|
|
774
803
|
* @param {HelperCallback} fn
|
|
775
804
|
*/
|
|
776
805
|
registerHelper(name, fn) {
|
|
806
|
+
checkDestroy(this.#destroyed);
|
|
777
807
|
if (typeof name !== 'string' || !name)
|
|
778
808
|
throw new TypeError('registerHelper: "name" must be non-empty string');
|
|
779
809
|
if (typeof fn !== 'function') throw new TypeError('registerHelper: "fn" must be a function');
|
|
@@ -789,6 +819,7 @@ class TinyI18 {
|
|
|
789
819
|
* @returns {boolean} `true` if the helper was removed, `false` if it was not found.
|
|
790
820
|
*/
|
|
791
821
|
unregisterHelper(name) {
|
|
822
|
+
checkDestroy(this.#destroyed);
|
|
792
823
|
if (typeof name !== 'string' || !name)
|
|
793
824
|
throw new TypeError('unregisterHelper: "name" must be non-empty string');
|
|
794
825
|
return this.#helpers.delete(name);
|
|
@@ -800,6 +831,7 @@ class TinyI18 {
|
|
|
800
831
|
* @param {Dict} data
|
|
801
832
|
*/
|
|
802
833
|
loadLocaleLocal(locale, data) {
|
|
834
|
+
checkDestroy(this.#destroyed);
|
|
803
835
|
if (this.#mode !== 'local')
|
|
804
836
|
throw new TypeError('loadLocaleLocal is only available in "local" mode');
|
|
805
837
|
this.#ingestLocale(locale, data);
|
|
@@ -811,6 +843,7 @@ class TinyI18 {
|
|
|
811
843
|
* @param {LocaleCode|null} locale - null -> keep only default
|
|
812
844
|
*/
|
|
813
845
|
async setLocale(locale) {
|
|
846
|
+
checkDestroy(this.#destroyed);
|
|
814
847
|
if (locale !== null && (typeof locale !== 'string' || !locale))
|
|
815
848
|
throw new TypeError('setLocale: "locale" must be string or null');
|
|
816
849
|
|
|
@@ -856,6 +889,7 @@ class TinyI18 {
|
|
|
856
889
|
* @returns {any}
|
|
857
890
|
*/
|
|
858
891
|
get(key, params = undefined, options = undefined) {
|
|
892
|
+
checkDestroy(this.#destroyed);
|
|
859
893
|
if (typeof key !== 'string' || !key)
|
|
860
894
|
throw new TypeError('get: "key" must be a non-empty string');
|
|
861
895
|
|
|
@@ -891,6 +925,7 @@ class TinyI18 {
|
|
|
891
925
|
* @returns {any}
|
|
892
926
|
*/
|
|
893
927
|
resolveByPattern(key, options) {
|
|
928
|
+
checkDestroy(this.#destroyed);
|
|
894
929
|
if (typeof key !== 'string' || !key)
|
|
895
930
|
throw new TypeError('get: "key" must be a non-empty string');
|
|
896
931
|
const { locale: forceLocale } = options || {};
|
|
@@ -908,6 +943,7 @@ class TinyI18 {
|
|
|
908
943
|
* Selected locale becomes null.
|
|
909
944
|
*/
|
|
910
945
|
resetToDefaultOnly() {
|
|
946
|
+
checkDestroy(this.#destroyed);
|
|
911
947
|
if (this.#mode === 'file') {
|
|
912
948
|
for (const loc of Array.from(this.#stringTables.keys())) {
|
|
913
949
|
if (loc !== this.#defaultLocale) {
|
|
@@ -925,6 +961,7 @@ class TinyI18 {
|
|
|
925
961
|
* @throws {Error} If the locale is not registered.
|
|
926
962
|
*/
|
|
927
963
|
getStatsForLocale(locale) {
|
|
964
|
+
checkDestroy(this.#destroyed);
|
|
928
965
|
if (typeof locale !== 'string' || !locale)
|
|
929
966
|
throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');
|
|
930
967
|
if (!this.#stringTables.has(locale))
|
|
@@ -941,6 +978,30 @@ class TinyI18 {
|
|
|
941
978
|
isCurrent: locale === this.#currentLocale,
|
|
942
979
|
};
|
|
943
980
|
}
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Destroys the TinyI18 instance, clearing all internal maps and references
|
|
984
|
+
* to free up memory. Once destroyed, the instance cannot be reused.
|
|
985
|
+
*
|
|
986
|
+
* @throws {Error} If the instance has already been destroyed.
|
|
987
|
+
* @returns {void}
|
|
988
|
+
*/
|
|
989
|
+
destroy() {
|
|
990
|
+
if (this.#destroyed) return;
|
|
991
|
+
|
|
992
|
+
// Clear all internal maps to release memory
|
|
993
|
+
this.#stringTables.clear();
|
|
994
|
+
this.#patternTables.clear();
|
|
995
|
+
this.#helpers.clear();
|
|
996
|
+
this.#regexCache.clear();
|
|
997
|
+
|
|
998
|
+
// Reset locale and path configurations
|
|
999
|
+
this.#currentLocale = null;
|
|
1000
|
+
this.#basePath = null;
|
|
1001
|
+
|
|
1002
|
+
// Mark the instance as destroyed
|
|
1003
|
+
this.#destroyed = true;
|
|
1004
|
+
}
|
|
944
1005
|
}
|
|
945
1006
|
|
|
946
1007
|
module.exports = TinyI18;
|
|
@@ -1,34 +1,11 @@
|
|
|
1
|
-
export default TinyI18;
|
|
2
|
-
/**
|
|
3
|
-
* Supported operating modes for TinyI18.
|
|
4
|
-
* - `"local"` → All translations are managed entirely in memory (browser + Node.js).
|
|
5
|
-
* - `"file"` → Translations are loaded from JSON files on disk (Node.js only).
|
|
6
|
-
*/
|
|
7
1
|
export type ModeTypes = "local" | "file";
|
|
8
|
-
/**
|
|
9
|
-
* Dictionary of translation keys mapped to values.
|
|
10
|
-
*/
|
|
11
2
|
export type Dict = Record<string, any>;
|
|
12
|
-
/**
|
|
13
|
-
* `$pattern` - Regex string (will be compiled into RegExp).
|
|
14
|
-
*
|
|
15
|
-
* `$fn` - Helper function name associated with this entry.
|
|
16
|
-
*
|
|
17
|
-
* `[key]` - Additional key-value pairs for interpolation or extra metadata.
|
|
18
|
-
*/
|
|
19
3
|
export type FileValue = {
|
|
20
4
|
$pattern: string;
|
|
21
5
|
$fn: string;
|
|
22
6
|
[key: string]: string;
|
|
23
7
|
};
|
|
24
|
-
/**
|
|
25
|
-
* Represents a valid locale code string.
|
|
26
|
-
* Example: "en", "pt-BR", "fr".
|
|
27
|
-
*/
|
|
28
8
|
export type LocaleCode = string;
|
|
29
|
-
/**
|
|
30
|
-
* Represents a single regex-based translation entry.
|
|
31
|
-
*/
|
|
32
9
|
export type PatternEntry = {
|
|
33
10
|
/**
|
|
34
11
|
* - Compiled regular expression used for matching.
|
|
@@ -47,7 +24,7 @@ export type FileModeEntryJSON = {
|
|
|
47
24
|
/**
|
|
48
25
|
* - regex as string e.g. "^user\\.(\\d+)$"
|
|
49
26
|
*/
|
|
50
|
-
$pattern?: string
|
|
27
|
+
$pattern?: string;
|
|
51
28
|
/**
|
|
52
29
|
* - string or { $fn: string, args?: any }
|
|
53
30
|
*/
|
|
@@ -63,25 +40,22 @@ export type TinyI18Options = {
|
|
|
63
40
|
/**
|
|
64
41
|
* - Required in file mode. Directory with <locale>.json
|
|
65
42
|
*/
|
|
66
|
-
basePath?: string
|
|
43
|
+
basePath?: string;
|
|
67
44
|
/**
|
|
68
45
|
* - Optional initial map { locale: dict } for local mode
|
|
69
46
|
*/
|
|
70
|
-
localResources?: Dict
|
|
47
|
+
localResources?: Dict;
|
|
71
48
|
/**
|
|
72
49
|
* - If true, throws on missing keys; else returns key
|
|
73
50
|
*/
|
|
74
|
-
strict?: boolean
|
|
51
|
+
strict?: boolean;
|
|
75
52
|
};
|
|
76
53
|
export type ResolveOptions = {
|
|
77
54
|
/**
|
|
78
55
|
* - force resolve using a specific locale first
|
|
79
56
|
*/
|
|
80
|
-
locale?:
|
|
57
|
+
locale?: LocaleCode;
|
|
81
58
|
};
|
|
82
|
-
/**
|
|
83
|
-
* Represents statistics for a specific locale.
|
|
84
|
-
*/
|
|
85
59
|
export type StatLocale = {
|
|
86
60
|
/**
|
|
87
61
|
* - The locale code (e.g., "en", "pt-BR").
|
|
@@ -104,30 +78,17 @@ export type StatLocale = {
|
|
|
104
78
|
*/
|
|
105
79
|
isCurrent: boolean;
|
|
106
80
|
};
|
|
107
|
-
|
|
108
|
-
* Read-only view of registered helpers, exposed to function-based entries.
|
|
109
|
-
*
|
|
110
|
-
* Provides safe access to:
|
|
111
|
-
* - check if a helper exists by name
|
|
112
|
-
* - call a helper by name, passing arguments
|
|
113
|
-
*/
|
|
114
|
-
export type HelpersReadonly<T extends unknown, R extends unknown> = {
|
|
81
|
+
export type HelpersReadonly<T extends any, R extends any> = {
|
|
115
82
|
/**
|
|
116
83
|
* - Check if a helper with given name is registered.
|
|
117
84
|
*/
|
|
118
|
-
has?: (
|
|
85
|
+
has?: (name: string) => boolean;
|
|
119
86
|
/**
|
|
120
87
|
* -
|
|
121
88
|
* Invoke a helper by name with an argument and optional extras.
|
|
122
89
|
*/
|
|
123
|
-
call?: (
|
|
90
|
+
call?: (name: string, arg: T, extras?: HelpersReadonly<T, R>) => R;
|
|
124
91
|
};
|
|
125
|
-
/**
|
|
126
|
-
* A helper callback function used in translations.
|
|
127
|
-
*
|
|
128
|
-
* - Receives user-supplied parameters and a read-only facade for calling other helpers.
|
|
129
|
-
* - Must return a string (e.g. processed, interpolated, or formatted output).
|
|
130
|
-
*/
|
|
131
92
|
export type HelperCallback = (params: Dict, helpers: HelpersReadonly<any, any>) => string;
|
|
132
93
|
/**
|
|
133
94
|
* Supported operating modes for TinyI18.
|
|
@@ -241,6 +202,7 @@ export type HelperCallback = (params: Dict, helpers: HelpersReadonly<any, any>)
|
|
|
241
202
|
* - Safe: no dynamic code eval from files; functions in file mode are referenced by name ("$fn").
|
|
242
203
|
*/
|
|
243
204
|
declare class TinyI18 {
|
|
205
|
+
#private;
|
|
244
206
|
/**
|
|
245
207
|
* Merges multiple JSON locale files into a single file for TinyI18 usage.
|
|
246
208
|
* @param {Object} options
|
|
@@ -253,20 +215,14 @@ declare class TinyI18 {
|
|
|
253
215
|
static mergeLocaleFiles({ files, output, spaces }: {
|
|
254
216
|
files: string[];
|
|
255
217
|
output: string;
|
|
256
|
-
spaces?: number
|
|
218
|
+
spaces?: number;
|
|
257
219
|
}): Promise<void>;
|
|
258
220
|
/**
|
|
259
|
-
*
|
|
221
|
+
* Gets the current destruction status of the instance.
|
|
260
222
|
*
|
|
261
|
-
*
|
|
262
|
-
* - "local": loads translations directly from provided objects.
|
|
263
|
-
* - "file": loads translations from JSON files on demand.
|
|
264
|
-
*
|
|
265
|
-
* Ensures the default locale is always initialized. In "file" mode, `basePath` is required.
|
|
266
|
-
*
|
|
267
|
-
* @param {TinyI18Options} options - Configuration options for the instance.
|
|
223
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
268
224
|
*/
|
|
269
|
-
|
|
225
|
+
get destroyed(): boolean;
|
|
270
226
|
/**
|
|
271
227
|
* Gets the currently selected locale, or null if only default is active.
|
|
272
228
|
* @returns {LocaleCode|null}
|
|
@@ -328,6 +284,18 @@ declare class TinyI18 {
|
|
|
328
284
|
* @returns {Record<string, RegExp>}
|
|
329
285
|
*/
|
|
330
286
|
get regexCache(): Record<string, RegExp>;
|
|
287
|
+
/**
|
|
288
|
+
* Creates a new TinyI18 instance for managing localized strings and patterns.
|
|
289
|
+
*
|
|
290
|
+
* Supports two modes:
|
|
291
|
+
* - "local": loads translations directly from provided objects.
|
|
292
|
+
* - "file": loads translations from JSON files on demand.
|
|
293
|
+
*
|
|
294
|
+
* Ensures the default locale is always initialized. In "file" mode, `basePath` is required.
|
|
295
|
+
*
|
|
296
|
+
* @param {TinyI18Options} options - Configuration options for the instance.
|
|
297
|
+
*/
|
|
298
|
+
constructor(options: TinyI18Options);
|
|
331
299
|
/**
|
|
332
300
|
* Clears the internal regex cache.
|
|
333
301
|
*
|
|
@@ -413,6 +381,14 @@ declare class TinyI18 {
|
|
|
413
381
|
* @throws {Error} If the locale is not registered.
|
|
414
382
|
*/
|
|
415
383
|
getStatsForLocale(locale: LocaleCode): StatLocale;
|
|
416
|
-
|
|
384
|
+
/**
|
|
385
|
+
* Destroys the TinyI18 instance, clearing all internal maps and references
|
|
386
|
+
* to free up memory. Once destroyed, the instance cannot be reused.
|
|
387
|
+
*
|
|
388
|
+
* @throws {Error} If the instance has already been destroyed.
|
|
389
|
+
* @returns {void}
|
|
390
|
+
*/
|
|
391
|
+
destroy(): void;
|
|
417
392
|
}
|
|
393
|
+
export default TinyI18;
|
|
418
394
|
//# sourceMappingURL=TinyI18.d.mts.map
|
package/dist/v1/libs/TinyI18.mjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { readFile, writeFile } from 'fs/promises';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import { join as pathJoin } from 'path';
|
|
4
|
+
import { createCheckDestroyed } from './utils.mjs';
|
|
5
|
+
const checkDestroy = createCheckDestroyed('TinyI18');
|
|
4
6
|
/**
|
|
5
7
|
* Supported operating modes for TinyI18.
|
|
6
8
|
* - `"local"` → All translations are managed entirely in memory (browser + Node.js).
|
|
@@ -148,6 +150,19 @@ class TinyI18 {
|
|
|
148
150
|
}
|
|
149
151
|
await writeFile(output, JSON.stringify(merged, null, spaces), 'utf-8');
|
|
150
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* Tracks whether the instance has been destroyed.
|
|
155
|
+
* @type {boolean}
|
|
156
|
+
*/
|
|
157
|
+
#destroyed = false;
|
|
158
|
+
/**
|
|
159
|
+
* Gets the current destruction status of the instance.
|
|
160
|
+
*
|
|
161
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
162
|
+
*/
|
|
163
|
+
get destroyed() {
|
|
164
|
+
return this.#destroyed;
|
|
165
|
+
}
|
|
151
166
|
/** @type {ModeTypes} */
|
|
152
167
|
#mode;
|
|
153
168
|
/** @type {LocaleCode} */
|
|
@@ -172,6 +187,7 @@ class TinyI18 {
|
|
|
172
187
|
* @returns {LocaleCode|null}
|
|
173
188
|
*/
|
|
174
189
|
get currentLocale() {
|
|
190
|
+
checkDestroy(this.#destroyed);
|
|
175
191
|
return this.#currentLocale;
|
|
176
192
|
}
|
|
177
193
|
/**
|
|
@@ -180,6 +196,7 @@ class TinyI18 {
|
|
|
180
196
|
* @type {LocaleCode}
|
|
181
197
|
*/
|
|
182
198
|
get defaultLocale() {
|
|
199
|
+
checkDestroy(this.#destroyed);
|
|
183
200
|
return this.#defaultLocale;
|
|
184
201
|
}
|
|
185
202
|
/**
|
|
@@ -189,6 +206,7 @@ class TinyI18 {
|
|
|
189
206
|
* @type {ModeTypes}
|
|
190
207
|
*/
|
|
191
208
|
get mode() {
|
|
209
|
+
checkDestroy(this.#destroyed);
|
|
192
210
|
return this.#mode;
|
|
193
211
|
}
|
|
194
212
|
/**
|
|
@@ -198,6 +216,7 @@ class TinyI18 {
|
|
|
198
216
|
* @type {boolean}
|
|
199
217
|
*/
|
|
200
218
|
get strict() {
|
|
219
|
+
checkDestroy(this.#destroyed);
|
|
201
220
|
return this.#strict;
|
|
202
221
|
}
|
|
203
222
|
/**
|
|
@@ -207,6 +226,7 @@ class TinyI18 {
|
|
|
207
226
|
* @type {string|null}
|
|
208
227
|
*/
|
|
209
228
|
get basePath() {
|
|
229
|
+
checkDestroy(this.#destroyed);
|
|
210
230
|
return this.#basePath;
|
|
211
231
|
}
|
|
212
232
|
/**
|
|
@@ -214,6 +234,7 @@ class TinyI18 {
|
|
|
214
234
|
* @returns {StatLocale[]}
|
|
215
235
|
*/
|
|
216
236
|
get stats() {
|
|
237
|
+
checkDestroy(this.#destroyed);
|
|
217
238
|
const locales = [];
|
|
218
239
|
for (const loc of this.#stringTables.keys())
|
|
219
240
|
locales.push(this.getStatsForLocale(loc));
|
|
@@ -225,6 +246,7 @@ class TinyI18 {
|
|
|
225
246
|
* @returns {Record<string, Dict>}
|
|
226
247
|
*/
|
|
227
248
|
get stringTables() {
|
|
249
|
+
checkDestroy(this.#destroyed);
|
|
228
250
|
/** @type {Record<string, Dict>} */
|
|
229
251
|
const obj = {};
|
|
230
252
|
for (const [locale, dict] of this.#stringTables.entries()) {
|
|
@@ -238,6 +260,7 @@ class TinyI18 {
|
|
|
238
260
|
* @returns {Record<string, PatternEntry[]>}
|
|
239
261
|
*/
|
|
240
262
|
get patternTables() {
|
|
263
|
+
checkDestroy(this.#destroyed);
|
|
241
264
|
/** @type {Record<string, PatternEntry[]>} */
|
|
242
265
|
const obj = {};
|
|
243
266
|
for (const [locale, arr] of this.#patternTables.entries()) {
|
|
@@ -255,6 +278,7 @@ class TinyI18 {
|
|
|
255
278
|
* @returns {Record<string, HelperCallback>}
|
|
256
279
|
*/
|
|
257
280
|
get helpers() {
|
|
281
|
+
checkDestroy(this.#destroyed);
|
|
258
282
|
/** @type {Record<string, HelperCallback>} */
|
|
259
283
|
const obj = {};
|
|
260
284
|
for (const [name, fn] of this.#helpers.entries()) {
|
|
@@ -268,6 +292,7 @@ class TinyI18 {
|
|
|
268
292
|
* @returns {Record<string, RegExp>}
|
|
269
293
|
*/
|
|
270
294
|
get regexCache() {
|
|
295
|
+
checkDestroy(this.#destroyed);
|
|
271
296
|
/** @type {Record<string, RegExp>} */
|
|
272
297
|
const obj = {};
|
|
273
298
|
for (const [key, re] of this.#regexCache.entries()) {
|
|
@@ -707,6 +732,7 @@ class TinyI18 {
|
|
|
707
732
|
* management is always controlled via the API instead of direct access.
|
|
708
733
|
*/
|
|
709
734
|
clearRegexCache() {
|
|
735
|
+
checkDestroy(this.#destroyed);
|
|
710
736
|
this.#regexCache.clear();
|
|
711
737
|
}
|
|
712
738
|
/**
|
|
@@ -715,6 +741,7 @@ class TinyI18 {
|
|
|
715
741
|
* @param {HelperCallback} fn
|
|
716
742
|
*/
|
|
717
743
|
registerHelper(name, fn) {
|
|
744
|
+
checkDestroy(this.#destroyed);
|
|
718
745
|
if (typeof name !== 'string' || !name)
|
|
719
746
|
throw new TypeError('registerHelper: "name" must be non-empty string');
|
|
720
747
|
if (typeof fn !== 'function')
|
|
@@ -730,6 +757,7 @@ class TinyI18 {
|
|
|
730
757
|
* @returns {boolean} `true` if the helper was removed, `false` if it was not found.
|
|
731
758
|
*/
|
|
732
759
|
unregisterHelper(name) {
|
|
760
|
+
checkDestroy(this.#destroyed);
|
|
733
761
|
if (typeof name !== 'string' || !name)
|
|
734
762
|
throw new TypeError('unregisterHelper: "name" must be non-empty string');
|
|
735
763
|
return this.#helpers.delete(name);
|
|
@@ -740,6 +768,7 @@ class TinyI18 {
|
|
|
740
768
|
* @param {Dict} data
|
|
741
769
|
*/
|
|
742
770
|
loadLocaleLocal(locale, data) {
|
|
771
|
+
checkDestroy(this.#destroyed);
|
|
743
772
|
if (this.#mode !== 'local')
|
|
744
773
|
throw new TypeError('loadLocaleLocal is only available in "local" mode');
|
|
745
774
|
this.#ingestLocale(locale, data);
|
|
@@ -750,6 +779,7 @@ class TinyI18 {
|
|
|
750
779
|
* @param {LocaleCode|null} locale - null -> keep only default
|
|
751
780
|
*/
|
|
752
781
|
async setLocale(locale) {
|
|
782
|
+
checkDestroy(this.#destroyed);
|
|
753
783
|
if (locale !== null && (typeof locale !== 'string' || !locale))
|
|
754
784
|
throw new TypeError('setLocale: "locale" must be string or null');
|
|
755
785
|
const prev = this.#currentLocale;
|
|
@@ -791,6 +821,7 @@ class TinyI18 {
|
|
|
791
821
|
* @returns {any}
|
|
792
822
|
*/
|
|
793
823
|
get(key, params = undefined, options = undefined) {
|
|
824
|
+
checkDestroy(this.#destroyed);
|
|
794
825
|
if (typeof key !== 'string' || !key)
|
|
795
826
|
throw new TypeError('get: "key" must be a non-empty string');
|
|
796
827
|
const { locale: forceLocale } = options || {};
|
|
@@ -822,6 +853,7 @@ class TinyI18 {
|
|
|
822
853
|
* @returns {any}
|
|
823
854
|
*/
|
|
824
855
|
resolveByPattern(key, options) {
|
|
856
|
+
checkDestroy(this.#destroyed);
|
|
825
857
|
if (typeof key !== 'string' || !key)
|
|
826
858
|
throw new TypeError('get: "key" must be a non-empty string');
|
|
827
859
|
const { locale: forceLocale } = options || {};
|
|
@@ -839,6 +871,7 @@ class TinyI18 {
|
|
|
839
871
|
* Selected locale becomes null.
|
|
840
872
|
*/
|
|
841
873
|
resetToDefaultOnly() {
|
|
874
|
+
checkDestroy(this.#destroyed);
|
|
842
875
|
if (this.#mode === 'file') {
|
|
843
876
|
for (const loc of Array.from(this.#stringTables.keys())) {
|
|
844
877
|
if (loc !== this.#defaultLocale) {
|
|
@@ -855,6 +888,7 @@ class TinyI18 {
|
|
|
855
888
|
* @throws {Error} If the locale is not registered.
|
|
856
889
|
*/
|
|
857
890
|
getStatsForLocale(locale) {
|
|
891
|
+
checkDestroy(this.#destroyed);
|
|
858
892
|
if (typeof locale !== 'string' || !locale)
|
|
859
893
|
throw new TypeError('getStatsForLocale: "locale" must be a non-empty string');
|
|
860
894
|
if (!this.#stringTables.has(locale))
|
|
@@ -869,5 +903,26 @@ class TinyI18 {
|
|
|
869
903
|
isCurrent: locale === this.#currentLocale,
|
|
870
904
|
};
|
|
871
905
|
}
|
|
906
|
+
/**
|
|
907
|
+
* Destroys the TinyI18 instance, clearing all internal maps and references
|
|
908
|
+
* to free up memory. Once destroyed, the instance cannot be reused.
|
|
909
|
+
*
|
|
910
|
+
* @throws {Error} If the instance has already been destroyed.
|
|
911
|
+
* @returns {void}
|
|
912
|
+
*/
|
|
913
|
+
destroy() {
|
|
914
|
+
if (this.#destroyed)
|
|
915
|
+
return;
|
|
916
|
+
// Clear all internal maps to release memory
|
|
917
|
+
this.#stringTables.clear();
|
|
918
|
+
this.#patternTables.clear();
|
|
919
|
+
this.#helpers.clear();
|
|
920
|
+
this.#regexCache.clear();
|
|
921
|
+
// Reset locale and path configurations
|
|
922
|
+
this.#currentLocale = null;
|
|
923
|
+
this.#basePath = null;
|
|
924
|
+
// Mark the instance as destroyed
|
|
925
|
+
this.#destroyed = true;
|
|
926
|
+
}
|
|
872
927
|
}
|
|
873
928
|
export default TinyI18;
|