tiny-essentials 1.28.19 → 1.29.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/changelog/1/28/19.md +24 -0
- package/changelog/1/29/0.md +58 -0
- package/changelog/1/29/1.md +11 -0
- package/dist/v1/ColorSafeStringify.min.js +1 -1
- 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/TinyArrayComparator.min.js +1 -1
- package/dist/v1/TinyArrayPaginator.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -1
- package/dist/v1/TinyBrowserMonitor.min.js +1 -0
- package/dist/v1/TinyClassManager.min.js +1 -1
- package/dist/v1/TinyClipboard.min.js +1 -1
- package/dist/v1/TinyCloner.min.js +1 -0
- package/dist/v1/TinyColorConverter.min.js +1 -1
- package/dist/v1/TinyColorValidator.min.js +1 -1
- package/dist/v1/TinyCookieConsent.min.js +1 -1
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDebugger.min.js +1 -1
- package/dist/v1/TinyDomReadyManager.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/TinyHtmlTagRegexBuilder.min.js +1 -0
- package/dist/v1/TinyHttpResponseRegistry.min.js +1 -0
- package/dist/v1/TinyI18.min.js +1 -1
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyInventory.min.js +1 -1
- package/dist/v1/TinyInventoryTrader.min.js +1 -1
- package/dist/v1/TinyLevelUp.min.js +1 -1
- package/dist/v1/TinyLoadingScreen.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMaInSys.min.js +1 -1
- package/dist/v1/TinyMapCache.min.js +1 -0
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNeedBar.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotificationAdapter.min.js +1 -0
- package/dist/v1/TinyNotifications.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyOPFSFileSystem.min.js +1 -0
- package/dist/v1/TinyPasswordValidator.min.js +1 -0
- package/dist/v1/TinyPluginPackage.min.js +1 -0
- package/dist/v1/TinyPromiseQueue.min.js +1 -1
- package/dist/v1/TinyPushManager.min.js +1 -0
- package/dist/v1/TinyPushPayload.min.js +1 -0
- package/dist/v1/TinyPushRouter.min.js +1 -0
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinyRegexEs.min.js +1 -0
- package/dist/v1/TinyRouter.min.js +1 -0
- package/dist/v1/TinyServiceWorker.min.js +1 -0
- package/dist/v1/TinyServiceWorkerEngine.min.js +1 -0
- package/dist/v1/TinySetMapPackage.min.js +1 -0
- package/dist/v1/TinySimpleDice.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyStorageBucketFileSystem.min.js +1 -0
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextRangeEditor.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyThrottledApi.min.js +1 -0
- 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/TinyUriParser.min.js +1 -0
- package/dist/v1/TinyVersion.min.js +1 -0
- package/dist/v1/TinyWebWorker.min.js +1 -0
- package/dist/v1/TinyWebWorkerEngine.min.js +1 -0
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +2 -2
- package/dist/v1/basics/array.d.mts +2 -0
- package/dist/v1/basics/array.d.mts.map +1 -1
- package/dist/v1/basics/array.mjs +2 -1
- package/dist/v1/basics/browserDetector.cjs +37 -12
- package/dist/v1/basics/browserDetector.d.mts +8 -0
- package/dist/v1/basics/browserDetector.d.mts.map +1 -1
- package/dist/v1/basics/browserDetector.mjs +32 -13
- package/dist/v1/basics/crypto.cjs +23 -0
- package/dist/v1/basics/crypto.d.mts +10 -0
- package/dist/v1/basics/crypto.d.mts.map +1 -0
- package/dist/v1/basics/crypto.mjs +18 -0
- package/dist/v1/basics/html.cjs +0 -3
- package/dist/v1/basics/html.d.mts.map +1 -1
- package/dist/v1/basics/html.mjs +0 -2
- package/dist/v1/basics/index.cjs +8 -1
- package/dist/v1/basics/index.d.mts +6 -5
- package/dist/v1/basics/index.d.mts.map +1 -1
- package/dist/v1/basics/index.mjs +6 -5
- package/dist/v1/basics/objChecker.cjs +88 -0
- package/dist/v1/basics/objChecker.d.mts +26 -0
- package/dist/v1/basics/objChecker.d.mts.map +1 -1
- package/dist/v1/basics/objChecker.mjs +74 -0
- package/dist/v1/basics/objFilter.cjs +234 -93
- package/dist/v1/basics/objFilter.d.mts +96 -22
- package/dist/v1/basics/objFilter.d.mts.map +1 -1
- package/dist/v1/basics/objFilter.mjs +216 -92
- package/dist/v1/basics/promiseUtils.cjs +48 -12
- package/dist/v1/basics/promiseUtils.d.mts +45 -12
- package/dist/v1/basics/promiseUtils.d.mts.map +1 -1
- package/dist/v1/basics/promiseUtils.mjs +47 -12
- package/dist/v1/basics/text.cjs +0 -12
- package/dist/v1/basics/text.d.mts +0 -10
- package/dist/v1/basics/text.d.mts.map +1 -1
- package/dist/v1/basics/text.mjs +0 -10
- package/dist/v1/index.cjs +88 -3
- package/dist/v1/index.d.mts +31 -6
- package/dist/v1/index.d.mts.map +1 -1
- package/dist/v1/index.mjs +32 -7
- package/dist/v1/jsdoc/EventEmitter.cjs +4 -0
- package/dist/v1/jsdoc/EventEmitter.d.mts +33 -0
- package/dist/v1/jsdoc/EventEmitter.d.mts.map +1 -0
- package/dist/v1/jsdoc/EventEmitter.mjs +18 -0
- package/dist/v1/libs/array/TinyArrayComparator.cjs +240 -25
- package/dist/v1/libs/array/TinyArrayComparator.d.mts +130 -22
- package/dist/v1/libs/array/TinyArrayComparator.d.mts.map +1 -1
- package/dist/v1/libs/array/TinyArrayComparator.mjs +210 -24
- package/dist/v1/libs/fs/constants.cjs +74 -0
- package/dist/v1/libs/fs/constants.d.mts +22 -0
- package/dist/v1/libs/fs/constants.d.mts.map +1 -0
- package/dist/v1/libs/fs/constants.mjs +53 -0
- package/dist/v1/libs/fs/encoding.cjs +118 -0
- package/dist/v1/libs/fs/encoding.d.mts +50 -0
- package/dist/v1/libs/fs/encoding.d.mts.map +1 -0
- package/dist/v1/libs/fs/encoding.mjs +102 -0
- package/dist/v1/libs/fs/error.cjs +188 -0
- package/dist/v1/libs/fs/error.d.mts +105 -0
- package/dist/v1/libs/fs/error.d.mts.map +1 -0
- package/dist/v1/libs/fs/error.mjs +158 -0
- package/dist/v1/libs/fs/handle.cjs +121 -0
- package/dist/v1/libs/fs/handle.d.mts +56 -0
- package/dist/v1/libs/fs/handle.d.mts.map +1 -0
- package/dist/v1/libs/fs/handle.mjs +100 -0
- package/dist/v1/libs/fs/index.cjs +700 -0
- package/dist/v1/libs/fs/index.d.mts +377 -0
- package/dist/v1/libs/fs/index.d.mts.map +1 -0
- package/dist/v1/libs/fs/index.mjs +630 -0
- package/dist/v1/libs/fs/path.cjs +234 -0
- package/dist/v1/libs/fs/path.d.mts +176 -0
- package/dist/v1/libs/fs/path.d.mts.map +1 -0
- package/dist/v1/libs/fs/path.mjs +197 -0
- package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.cjs +202 -0
- package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts +121 -0
- package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.d.mts.map +1 -0
- package/dist/v1/libs/fs/plugins/OPFS/StorageBucket.mjs +172 -0
- package/dist/v1/libs/fs/plugins/OPFS/index.cjs +334 -0
- package/dist/v1/libs/fs/plugins/OPFS/index.d.mts +98 -0
- package/dist/v1/libs/fs/plugins/OPFS/index.d.mts.map +1 -0
- package/dist/v1/libs/fs/plugins/OPFS/index.mjs +300 -0
- package/dist/v1/libs/fs/stats.cjs +245 -0
- package/dist/v1/libs/fs/stats.d.mts +226 -0
- package/dist/v1/libs/fs/stats.d.mts.map +1 -0
- package/dist/v1/libs/fs/stats.mjs +197 -0
- package/dist/v1/libs/html/events/TinyIframeEvents.cjs +10 -1
- package/dist/v1/libs/html/events/TinyIframeEvents.d.mts +9 -2
- package/dist/v1/libs/html/events/TinyIframeEvents.d.mts.map +1 -1
- package/dist/v1/libs/html/events/TinyIframeEvents.mjs +8 -1
- package/dist/v1/libs/html/events/TinyNewWinEvents.cjs +14 -3
- package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts +21 -5
- package/dist/v1/libs/html/events/TinyNewWinEvents.d.mts.map +1 -1
- package/dist/v1/libs/html/events/TinyNewWinEvents.mjs +12 -3
- package/dist/v1/libs/html/scroll/TinySmartScroller.cjs +13 -1
- package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts +29 -2
- package/dist/v1/libs/html/scroll/TinySmartScroller.d.mts.map +1 -1
- package/dist/v1/libs/html/scroll/TinySmartScroller.mjs +11 -1
- package/dist/v1/libs/math/TinyAdvancedRaffle.cjs +13 -1
- package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts +32 -2
- package/dist/v1/libs/math/TinyAdvancedRaffle.d.mts.map +1 -1
- package/dist/v1/libs/math/TinyAdvancedRaffle.mjs +11 -1
- package/dist/v1/libs/math/TinyTimeout.cjs +0 -14
- package/dist/v1/libs/math/TinyTimeout.d.mts +0 -11
- package/dist/v1/libs/math/TinyTimeout.d.mts.map +1 -1
- package/dist/v1/libs/math/TinyTimeout.mjs +0 -13
- package/dist/v1/libs/media/TinyMediaPlayer/index.cjs +25 -1
- package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts +35 -2
- package/dist/v1/libs/media/TinyMediaPlayer/index.d.mts.map +1 -1
- package/dist/v1/libs/media/TinyMediaPlayer/index.mjs +23 -1
- package/dist/v1/libs/media/TinyMediaPlayer.cjs +2 -2
- package/dist/v1/libs/media/TinyMediaPlayer.d.mts +2 -2
- package/dist/v1/libs/media/TinyMediaPlayer.d.mts.map +1 -1
- package/dist/v1/libs/media/TinyMediaPlayer.mjs +2 -2
- package/dist/v1/libs/media/TinyRadioFm.cjs +19 -1
- package/dist/v1/libs/media/TinyRadioFm.d.mts +78 -2
- package/dist/v1/libs/media/TinyRadioFm.d.mts.map +1 -1
- package/dist/v1/libs/media/TinyRadioFm.mjs +17 -1
- package/dist/v1/libs/plugin/TinyPlugin.cjs +1630 -0
- package/dist/v1/libs/plugin/TinyPlugin.d.mts +753 -0
- package/dist/v1/libs/plugin/TinyPlugin.d.mts.map +1 -0
- package/dist/v1/libs/plugin/TinyPlugin.mjs +1376 -0
- package/dist/v1/libs/plugin/TinyVersion.cjs +204 -0
- package/dist/v1/libs/plugin/TinyVersion.d.mts +70 -0
- package/dist/v1/libs/plugin/TinyVersion.d.mts.map +1 -0
- package/dist/v1/libs/plugin/TinyVersion.mjs +179 -0
- package/dist/v1/libs/router/TinyRouter.cjs +661 -0
- package/dist/v1/libs/router/TinyRouter.d.mts +320 -0
- package/dist/v1/libs/router/TinyRouter.d.mts.map +1 -0
- package/dist/v1/libs/router/TinyRouter.mjs +572 -0
- package/dist/v1/libs/storage/TinyLocalStorage.cjs +20 -1
- package/dist/v1/libs/storage/TinyLocalStorage.d.mts +64 -2
- package/dist/v1/libs/storage/TinyLocalStorage.d.mts.map +1 -1
- package/dist/v1/libs/storage/TinyLocalStorage.mjs +18 -1
- package/dist/v1/libs/storage/TinyMapCache.cjs +373 -0
- package/dist/v1/libs/storage/TinyMapCache.d.mts +274 -0
- package/dist/v1/libs/storage/TinyMapCache.d.mts.map +1 -0
- package/dist/v1/libs/storage/TinyMapCache.mjs +333 -0
- package/dist/v1/libs/storage/TinySetMapDatabase.cjs +1167 -0
- package/dist/v1/libs/storage/TinySetMapDatabase.d.mts +603 -0
- package/dist/v1/libs/storage/TinySetMapDatabase.d.mts.map +1 -0
- package/dist/v1/libs/storage/TinySetMapDatabase.mjs +1059 -0
- package/dist/v1/libs/sw/browser/TinyNotificationAdapter.cjs +126 -0
- package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts +132 -0
- package/dist/v1/libs/sw/browser/TinyNotificationAdapter.d.mts.map +1 -0
- package/dist/v1/libs/sw/browser/TinyNotificationAdapter.mjs +109 -0
- package/dist/v1/libs/sw/browser/TinyPushManager.cjs +310 -0
- package/dist/v1/libs/sw/browser/TinyPushManager.d.mts +168 -0
- package/dist/v1/libs/sw/browser/TinyPushManager.d.mts.map +1 -0
- package/dist/v1/libs/sw/browser/TinyPushManager.mjs +264 -0
- package/dist/v1/libs/sw/browser/TinyServiceWorker.cjs +1060 -0
- package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts +348 -0
- package/dist/v1/libs/sw/browser/TinyServiceWorker.d.mts.map +1 -0
- package/dist/v1/libs/sw/browser/TinyServiceWorker.mjs +933 -0
- package/dist/v1/libs/sw/browser/plugins/TabManager.cjs +315 -0
- package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts +178 -0
- package/dist/v1/libs/sw/browser/plugins/TabManager.d.mts.map +1 -0
- package/dist/v1/libs/sw/browser/plugins/TabManager.mjs +274 -0
- package/dist/v1/libs/sw/browser/utils.cjs +28 -0
- package/dist/v1/libs/sw/browser/utils.d.mts +8 -0
- package/dist/v1/libs/sw/browser/utils.d.mts.map +1 -0
- package/dist/v1/libs/sw/browser/utils.mjs +21 -0
- package/dist/v1/libs/sw/service/TinyPushRouter.cjs +222 -0
- package/dist/v1/libs/sw/service/TinyPushRouter.d.mts +138 -0
- package/dist/v1/libs/sw/service/TinyPushRouter.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/TinyPushRouter.mjs +201 -0
- package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.cjs +3016 -0
- package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts +993 -0
- package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/TinyServiceWorkerEngine.mjs +2558 -0
- package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.cjs +88 -0
- package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts +32 -0
- package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/plugins/GlobBypassPlugin.mjs +69 -0
- package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.cjs +112 -0
- package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts +31 -0
- package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/plugins/GlobCachePlugin.mjs +91 -0
- package/dist/v1/libs/sw/service/plugins/Ping.cjs +32 -0
- package/dist/v1/libs/sw/service/plugins/Ping.d.mts +9 -0
- package/dist/v1/libs/sw/service/plugins/Ping.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/plugins/Ping.mjs +25 -0
- package/dist/v1/libs/sw/service/plugins/TabManager.cjs +457 -0
- package/dist/v1/libs/sw/service/plugins/TabManager.d.mts +91 -0
- package/dist/v1/libs/sw/service/plugins/TabManager.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/plugins/TabManager.mjs +372 -0
- package/dist/v1/libs/sw/service/plugins/ViteFileDetector.cjs +180 -0
- package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts +28 -0
- package/dist/v1/libs/sw/service/plugins/ViteFileDetector.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/plugins/ViteFileDetector.mjs +148 -0
- package/dist/v1/libs/sw/service/shared/TinyPushPayload.cjs +199 -0
- package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts +80 -0
- package/dist/v1/libs/sw/service/shared/TinyPushPayload.d.mts.map +1 -0
- package/dist/v1/libs/sw/service/shared/TinyPushPayload.mjs +174 -0
- package/dist/v1/libs/sw/utils.cjs +57 -0
- package/dist/v1/libs/sw/utils.d.mts +173 -0
- package/dist/v1/libs/sw/utils.d.mts.map +1 -0
- package/dist/v1/libs/sw/utils.mjs +50 -0
- package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.cjs +57 -0
- package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts +39 -0
- package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.d.mts.map +1 -0
- package/dist/v1/libs/text/TinyI18/Browser-NON-DOM.mjs +48 -0
- package/dist/v1/libs/text/TinyI18/Browser.cjs +64 -0
- package/dist/v1/libs/text/TinyI18/Browser.d.mts +47 -0
- package/dist/v1/libs/text/TinyI18/Browser.d.mts.map +1 -0
- package/dist/v1/libs/text/TinyI18/Browser.mjs +57 -0
- package/dist/v1/libs/text/TinyI18/Node.cjs +49 -0
- package/dist/v1/libs/text/TinyI18/Node.d.mts +38 -0
- package/dist/v1/libs/text/TinyI18/Node.d.mts.map +1 -0
- package/dist/v1/libs/text/TinyI18/Node.mjs +43 -0
- package/dist/v1/libs/text/TinyI18/browser-utils.cjs +17 -0
- package/dist/v1/libs/text/TinyI18/browser-utils.d.mts +8 -0
- package/dist/v1/libs/text/TinyI18/browser-utils.d.mts.map +1 -0
- package/dist/v1/libs/text/TinyI18/browser-utils.mjs +13 -0
- package/dist/v1/libs/text/{TinyI18.cjs → TinyI18/index.cjs} +205 -104
- package/dist/v1/libs/text/{TinyI18.d.mts → TinyI18/index.d.mts} +141 -92
- package/dist/v1/libs/text/TinyI18/index.d.mts.map +1 -0
- package/dist/v1/libs/text/{TinyI18.mjs → TinyI18/index.mjs} +195 -101
- package/dist/v1/libs/tools/TinyBrowserMonitor.cjs +1088 -0
- package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts +621 -0
- package/dist/v1/libs/tools/TinyBrowserMonitor.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyBrowserMonitor.mjs +940 -0
- package/dist/v1/libs/tools/TinyDebugger.cjs +180 -19
- package/dist/v1/libs/tools/TinyDebugger.d.mts +220 -24
- package/dist/v1/libs/tools/TinyDebugger.d.mts.map +1 -1
- package/dist/v1/libs/tools/TinyDebugger.mjs +161 -19
- package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.cjs +256 -0
- package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts +125 -0
- package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHtmlTagRegexBuilder.mjs +223 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.cjs +23 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts +17 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser-NON-DOM.mjs +19 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.cjs +23 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts +17 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Browser.mjs +19 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.cjs +390 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts +9 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/EmptyRequestCodes.mjs +387 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.cjs +2 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts +27 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/JsDoc.mjs +12 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/LICENSE +53 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.cjs +405 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts +34 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/MozillaRequestCodes/index.mjs +342 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.cjs +23 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts +17 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/Node.mjs +19 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.cjs +327 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts +9 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/RequestCodes.mjs +324 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.cjs +268 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts +107 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyHttpResponseRegistry/index.mjs +238 -0
- package/dist/v1/libs/tools/TinyPasswordValidator.cjs +491 -0
- package/dist/v1/libs/tools/TinyPasswordValidator.d.mts +246 -0
- package/dist/v1/libs/tools/TinyPasswordValidator.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyPasswordValidator.mjs +434 -0
- package/dist/v1/libs/tools/TinyPkgExportValidator.cjs +48 -0
- package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts +14 -0
- package/dist/v1/libs/tools/TinyPkgExportValidator.d.mts.map +1 -1
- package/dist/v1/libs/tools/TinyPkgExportValidator.mjs +44 -0
- package/dist/v1/libs/tools/TinySiteMap.cjs +1029 -0
- package/dist/v1/libs/tools/TinySiteMap.d.mts +429 -0
- package/dist/v1/libs/tools/TinySiteMap.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinySiteMap.mjs +910 -0
- package/dist/v1/libs/tools/TinySiteMapStream.cjs +121 -0
- package/dist/v1/libs/tools/TinySiteMapStream.d.mts +51 -0
- package/dist/v1/libs/tools/TinySiteMapStream.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinySiteMapStream.mjs +85 -0
- package/dist/v1/libs/tools/TinyURLSecurityVerifier.cjs +444 -0
- package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts +217 -0
- package/dist/v1/libs/tools/TinyURLSecurityVerifier.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyURLSecurityVerifier.mjs +394 -0
- package/dist/v1/libs/tools/TinyUriParser/BlueSky.cjs +613 -0
- package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts +152 -0
- package/dist/v1/libs/tools/TinyUriParser/BlueSky.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyUriParser/BlueSky.mjs +527 -0
- package/dist/v1/libs/tools/TinyUriParser/Discord.cjs +1119 -0
- package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts +306 -0
- package/dist/v1/libs/tools/TinyUriParser/Discord.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyUriParser/Discord.mjs +968 -0
- package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.cjs +469 -0
- package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts +80 -0
- package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyUriParser/MatrixProtocol.mjs +379 -0
- package/dist/v1/libs/tools/TinyUriParser.cjs +217 -0
- package/dist/v1/libs/tools/TinyUriParser.d.mts +109 -0
- package/dist/v1/libs/tools/TinyUriParser.d.mts.map +1 -0
- package/dist/v1/libs/tools/TinyUriParser.mjs +183 -0
- package/dist/v1/libs/utils/TinyCloner.cjs +466 -0
- package/dist/v1/libs/utils/TinyCloner.d.mts +221 -0
- package/dist/v1/libs/utils/TinyCloner.d.mts.map +1 -0
- package/dist/v1/libs/utils/TinyCloner.mjs +416 -0
- package/dist/v1/libs/utils/TinyPromiseQueue.cjs +1 -1
- package/dist/v1/libs/utils/TinyPromiseQueue.d.mts +2 -2
- package/dist/v1/libs/utils/TinyPromiseQueue.d.mts.map +1 -1
- package/dist/v1/libs/utils/TinyPromiseQueue.mjs +1 -1
- package/dist/v1/libs/utils/TinyThrottledApi.cjs +333 -0
- package/dist/v1/libs/utils/TinyThrottledApi.d.mts +163 -0
- package/dist/v1/libs/utils/TinyThrottledApi.d.mts.map +1 -0
- package/dist/v1/libs/utils/TinyThrottledApi.mjs +294 -0
- package/dist/v1/libs/worker/browser/TinyWebWorker.cjs +342 -0
- package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts +97 -0
- package/dist/v1/libs/worker/browser/TinyWebWorker.d.mts.map +1 -0
- package/dist/v1/libs/worker/browser/TinyWebWorker.mjs +305 -0
- package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.cjs +346 -0
- package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts +127 -0
- package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.d.mts.map +1 -0
- package/dist/v1/libs/worker/engine/TinyWebWorkerEngine.mjs +304 -0
- package/dist/v1/regexp/Email.cjs +185 -0
- package/dist/v1/regexp/Email.d.mts +73 -0
- package/dist/v1/regexp/Email.d.mts.map +1 -0
- package/dist/v1/regexp/Email.mjs +153 -0
- package/dist/v1/regexp/Glob.cjs +293 -0
- package/dist/v1/regexp/Glob.d.mts +45 -0
- package/dist/v1/regexp/Glob.d.mts.map +1 -0
- package/dist/v1/regexp/Glob.mjs +260 -0
- package/dist/v1/regexp/Ipv4.cjs +57 -0
- package/dist/v1/regexp/Ipv4.d.mts +29 -0
- package/dist/v1/regexp/Ipv4.d.mts.map +1 -0
- package/dist/v1/regexp/Ipv4.mjs +45 -0
- package/dist/v1/regexp/Ipv6.cjs +67 -0
- package/dist/v1/regexp/Ipv6.d.mts +29 -0
- package/dist/v1/regexp/Ipv6.d.mts.map +1 -0
- package/dist/v1/regexp/Ipv6.mjs +54 -0
- package/dist/v1/regexp/SegmentExtractor.cjs +145 -0
- package/dist/v1/regexp/SegmentExtractor.d.mts +91 -0
- package/dist/v1/regexp/SegmentExtractor.d.mts.map +1 -0
- package/dist/v1/regexp/SegmentExtractor.mjs +116 -0
- package/dist/v1/regexp/UrlDetector.cjs +125 -0
- package/dist/v1/regexp/UrlDetector.d.mts +67 -0
- package/dist/v1/regexp/UrlDetector.d.mts.map +1 -0
- package/dist/v1/regexp/UrlDetector.mjs +102 -0
- package/dist/v1/regexp/Username/index.cjs +233 -0
- package/dist/v1/regexp/Username/index.d.mts +77 -0
- package/dist/v1/regexp/Username/index.d.mts.map +1 -0
- package/dist/v1/regexp/Username/index.mjs +199 -0
- package/dist/v1/regexp/Username/jsDoc.cjs +2 -0
- package/dist/v1/regexp/Username/jsDoc.d.mts +57 -0
- package/dist/v1/regexp/Username/jsDoc.d.mts.map +1 -0
- package/dist/v1/regexp/Username/jsDoc.mjs +18 -0
- package/dist/v1/regexp/Username/templates/BlueSky.cjs +56 -0
- package/dist/v1/regexp/Username/templates/BlueSky.d.mts +35 -0
- package/dist/v1/regexp/Username/templates/BlueSky.d.mts.map +1 -0
- package/dist/v1/regexp/Username/templates/BlueSky.mjs +52 -0
- package/dist/v1/regexp/Username/templates/Discord.cjs +505 -0
- package/dist/v1/regexp/Username/templates/Discord.d.mts +209 -0
- package/dist/v1/regexp/Username/templates/Discord.d.mts.map +1 -0
- package/dist/v1/regexp/Username/templates/Discord.mjs +458 -0
- package/dist/v1/regexp/Username/templates/MatrixProtocol.cjs +143 -0
- package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts +70 -0
- package/dist/v1/regexp/Username/templates/MatrixProtocol.d.mts.map +1 -0
- package/dist/v1/regexp/Username/templates/MatrixProtocol.mjs +128 -0
- package/dist/v1/regexp/Username/templates/deprecated/Discord.cjs +24 -0
- package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts +17 -0
- package/dist/v1/regexp/Username/templates/deprecated/Discord.d.mts.map +1 -0
- package/dist/v1/regexp/Username/templates/deprecated/Discord.mjs +20 -0
- package/dist/v1/regexp/Username/templates/index.cjs +11 -0
- package/dist/v1/regexp/Username/templates/index.d.mts +5 -0
- package/dist/v1/regexp/Username/templates/index.d.mts.map +1 -0
- package/dist/v1/regexp/Username/templates/index.mjs +4 -0
- package/dist/v1/regexp/index.cjs +41 -0
- package/dist/v1/regexp/index.d.mts +9 -0
- package/dist/v1/regexp/index.d.mts.map +1 -0
- package/dist/v1/regexp/index.mjs +8 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.cjs +64 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts +11 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.d.mts.map +1 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Browser.mjs +51 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.cjs +66 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts +11 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.d.mts.map +1 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/FileInput.mjs +51 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.cjs +39 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts +11 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.d.mts.map +1 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Node.mjs +28 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.cjs +494 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts +142 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.d.mts.map +1 -0
- package/dist/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters/Template.mjs +445 -0
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.cjs +30 -4
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts +5 -2
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.d.mts.map +1 -1
- package/dist/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.mjs +29 -5
- package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.cjs +135 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts +83 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.d.mts.map +1 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Browser/index.mjs +120 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.cjs +127 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts +95 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.d.mts.map +1 -0
- package/dist/v1/webTemplates/media/MediaValidator/v1/Node/index.mjs +109 -0
- package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.cjs +83 -0
- package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts +46 -0
- package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.d.mts.map +1 -0
- package/dist/v1/webTemplates/multiformats/14.0/IPFSHasher/index.mjs +71 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.cjs +493 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts +67 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.d.mts.map +1 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.mjs +399 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.cjs +35 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts +6 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.d.mts.map +1 -0
- package/dist/v1/webTemplates/vite/7.3/plugins/githubUtils.mjs +29 -0
- package/docs/info/RegExp.md +74 -0
- package/docs/v1/Exports.md +101 -0
- package/docs/v1/README.md +113 -15
- package/docs/v1/basics/asyncReplace.md +2 -0
- package/docs/v1/basics/browserDetector.md +28 -11
- package/docs/v1/basics/crypto.md +85 -0
- package/docs/v1/basics/deprecated/html.md +2 -0
- package/docs/v1/basics/deprecated/objFilter.md +2 -0
- package/docs/v1/basics/html.md +2 -0
- package/docs/v1/basics/objChecker.md +55 -0
- package/docs/v1/basics/objFilter.md +57 -86
- package/docs/v1/basics/promiseUtils.md +12 -3
- package/docs/v1/basics/text.md +0 -1
- package/docs/v1/libs/array/TinyArrayComparator.md +50 -39
- package/docs/v1/libs/fs/TinyFS.md +752 -0
- package/docs/v1/libs/fs/TinyOPFSFileSystem.md +495 -0
- package/docs/v1/libs/fs/TinyStorageBucketFileSystem.md +407 -0
- package/docs/v1/libs/plugin/TinyPlugin.md +441 -0
- package/docs/v1/libs/plugin/TinyVersion.md +145 -0
- package/docs/v1/libs/router/TinyRouter.md +216 -0
- package/docs/v1/libs/storage/TinyMapCache.md +219 -0
- package/docs/v1/libs/storage/TinySetMapDatabase.md +478 -0
- package/docs/v1/libs/sw/browser/TinyNotificationAdapter.md +280 -0
- package/docs/v1/libs/sw/browser/TinyPushManager.md +782 -0
- package/docs/v1/libs/sw/browser/TinyServiceWorker.md +365 -0
- package/docs/v1/libs/sw/browser/plugins/TabManager.md +133 -0
- package/docs/v1/libs/sw/service/TinyPushRouter.md +314 -0
- package/docs/v1/libs/sw/service/TinyServiceWorkerEngine.md +748 -0
- package/docs/v1/libs/sw/service/plugins/GlobBypassPlugin.md +229 -0
- package/docs/v1/libs/sw/service/plugins/GlobCachePlugin.md +91 -0
- package/docs/v1/libs/sw/service/plugins/Ping.md +36 -0
- package/docs/v1/libs/sw/service/plugins/TabManager.md +64 -0
- package/docs/v1/libs/sw/service/plugins/ViteFileDetector.md +92 -0
- package/docs/v1/libs/sw/service/shared/TinyPushPayload.md +316 -0
- package/docs/v1/libs/text/TinyI18.md +80 -56
- package/docs/v1/libs/tools/TinyBrowserMonitor.md +170 -0
- package/docs/v1/libs/tools/TinyDebugger.md +117 -1
- package/docs/v1/libs/tools/TinyHtmlTagRegexBuilder.md +141 -0
- package/docs/v1/libs/tools/TinyHttpResponseRegistry.md +129 -0
- package/docs/v1/libs/tools/TinyPasswordValidator.md +153 -0
- package/docs/v1/libs/tools/TinyPkgExportValidator.md +45 -1
- package/docs/v1/libs/tools/TinySiteMap.md +134 -0
- package/docs/v1/libs/tools/TinySiteMapStream.md +97 -0
- package/docs/v1/libs/tools/TinyURLSecurityVerifier.md +146 -0
- package/docs/v1/libs/tools/TinyUriParser/Discord.md +374 -0
- package/docs/v1/libs/tools/TinyUriParser/MatrixProtocol.md +54 -0
- package/docs/v1/libs/tools/TinyUriParser.md +128 -0
- package/docs/v1/libs/utils/TinyCloner.md +126 -0
- package/docs/v1/libs/utils/TinyPromiseQueue.md +1 -1
- package/docs/v1/libs/utils/TinyThrottledApi.md +219 -0
- package/docs/v1/libs/worker/browser/TinyWebWorker.md +331 -0
- package/docs/v1/libs/worker/engine/TinyWebWorkerEngine.md +137 -0
- package/docs/v1/regexp/Email.md +127 -0
- package/docs/v1/regexp/Glob.md +155 -0
- package/docs/v1/regexp/IPv4.md +103 -0
- package/docs/v1/regexp/IPv6.md +122 -0
- package/docs/v1/regexp/SegmentExtractor.md +120 -0
- package/docs/v1/regexp/UrlDetector.md +117 -0
- package/docs/v1/regexp/Username/Base.md +131 -0
- package/docs/v1/regexp/Username/Discord.md +267 -0
- package/docs/v1/regexp/Username/MatrixProtocol.md +131 -0
- package/docs/v1/webTemplates/ag-psd/31.0/ProcessSolidFilters.md +565 -0
- package/docs/v1/webTemplates/bootstrap/5.3/html/BootstrapDialogs.md +19 -7
- package/docs/v1/webTemplates/media/MediaValidator/v1/Browser.md +123 -0
- package/docs/v1/webTemplates/media/MediaValidator/v1/Node.md +136 -0
- package/docs/v1/webTemplates/multiformats/14.0/IPFSHasher.md +310 -0
- package/docs/v1/webTemplates/vite/7.3/plugins/TinyVitePwaPlugin.md +131 -0
- package/docs/v1/webTemplates/vite/7.3/plugins/githubUtils.md +50 -0
- package/package.json +340 -22
- package/types/EventEmitter.d.ts +48 -0
- package/dist/v1/libs/text/TinyI18.d.mts.map +0 -1
|
@@ -0,0 +1,910 @@
|
|
|
1
|
+
import TinyURLSecurityVerifier from './TinyURLSecurityVerifier.mjs';
|
|
2
|
+
/**
|
|
3
|
+
* @typedef {Object} SitemapNamespace
|
|
4
|
+
* @property {'xmlns'|'attribute'} [type] - Defines if it's a namespace declaration or a raw root attribute. Defaults to 'xmlns'.
|
|
5
|
+
* @property {string} [prefix] - The namespace prefix (e.g., 'example'). Used only if type is 'xmlns'.
|
|
6
|
+
* @property {string} [name] - The exact attribute name (e.g., 'xsi:schemaLocation'). Required if type is 'attribute'.
|
|
7
|
+
* @property {string} [uri] - The namespace URI. Used if type is 'xmlns'.
|
|
8
|
+
* @property {string} [value] - The attribute value. Used if type is 'attribute' (acts as an alias to 'uri' for flexibility).
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {(instance: TinySiteMap) => SitemapNamespace[]} NamespaceStrategy
|
|
12
|
+
* A function that receives the TinySiteMap instance and returns an array of namespaces.
|
|
13
|
+
*/
|
|
14
|
+
/**
|
|
15
|
+
* A map where keys are the XML tag names and values are the tag contents.
|
|
16
|
+
* @typedef {Object} CustomTagMap
|
|
17
|
+
* @property {string} [tag] - The tag name (key in the object, e.g., 'example:tag').
|
|
18
|
+
* @property {string} [value] - The content of the tag (value in the object).
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* @typedef {Object} SitemapEntry
|
|
22
|
+
* @property {string} loc - The absolute URL of the page (or relative path).
|
|
23
|
+
* @property {string} [lastmod] - The last modified date in ISO 8601 format (e.g., '2023-10-27T10:00:00Z').
|
|
24
|
+
* @property {'always'|'hourly'|'daily'|'weekly'|'monthly'|'yearly'|'never'} [changefreq] - Frequency of change.
|
|
25
|
+
* @property {number} [priority] - Importance of the URL (0.0 to 1.0).
|
|
26
|
+
* @property {CustomTagMap} [customTags] - Custom XML tags to include in this entry.
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {Object} SitemapIndexEntry
|
|
30
|
+
* @property {string} loc - The absolute URL of the sitemap file.
|
|
31
|
+
* @property {string} [lastmod] - The last modified date in ISO 8601 format.
|
|
32
|
+
*/
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {Object} SitemapConfig
|
|
35
|
+
* @property {string} [xslUrl] - URL to XSL stylesheet.
|
|
36
|
+
* @property {boolean} [xslUrlPathnameOnly=true]
|
|
37
|
+
* @property {boolean} [lastmodDateOnly] - Format lastmod as date only (YYYY-MM-DD).
|
|
38
|
+
* @property {'normal'|'index'} [type] - The type of sitemap to generate. Defaults to 'normal'.
|
|
39
|
+
* @property {string} baseUrl - The base URL of the website.
|
|
40
|
+
* @property {SitemapNamespace[]} [namespaces] - Initial manual namespaces or root attributes.
|
|
41
|
+
* @property {NamespaceStrategy} [namespaceStrategy] - Dynamic logic to provide namespaces.
|
|
42
|
+
* @property {SitemapEntry[] | SitemapIndexEntry[]} entries - Array of entries.
|
|
43
|
+
*/
|
|
44
|
+
/**
|
|
45
|
+
* A service to manage and generate secure XML sitemaps or sitemap indexes.
|
|
46
|
+
* This class handles URL resolution, root attributes management, and XML escaping to prevent injection.
|
|
47
|
+
*/
|
|
48
|
+
class TinySiteMap {
|
|
49
|
+
/** The security verifier used to validate URLs. @type {TinyURLSecurityVerifier} */
|
|
50
|
+
#urlVerifier = new TinyURLSecurityVerifier();
|
|
51
|
+
/** @type {URL} The base URL used for resolving relative paths. */
|
|
52
|
+
#baseUrl;
|
|
53
|
+
/** @type {(SitemapEntry|SitemapIndexEntry)[]} The internal list of validated entries. */
|
|
54
|
+
#entries = [];
|
|
55
|
+
/** @type {SitemapNamespace[]} The list of manually added namespaces/attributes. */
|
|
56
|
+
#namespaces = [];
|
|
57
|
+
/** @type {NamespaceStrategy | null} The dynamic strategy for generating namespaces. */
|
|
58
|
+
#namespaceStrategy = null;
|
|
59
|
+
/** @type {'normal'|'index'} The mode of the generator. */
|
|
60
|
+
#type;
|
|
61
|
+
/** @type {number} The maximum allowed length for a resolved URL. */
|
|
62
|
+
#maxResolvedUrlSize = 2048;
|
|
63
|
+
/** @type {boolean} Determines if the 'lastmod' field is formatted as a simple date (YYYY-MM-DD) instead of full ISO 8601. */
|
|
64
|
+
#lastmodDateOnly = false;
|
|
65
|
+
/** @type {URL|null} The URL of the XSL stylesheet used to style the XML output in web browsers. */
|
|
66
|
+
#xslUrl = null;
|
|
67
|
+
/** @type {boolean} */
|
|
68
|
+
#xslUrlPathnameOnly = true;
|
|
69
|
+
/**
|
|
70
|
+
* Official limit established by sitemaps.org
|
|
71
|
+
* @type {number}
|
|
72
|
+
*/
|
|
73
|
+
static #MAX_URLS = 50000;
|
|
74
|
+
/**
|
|
75
|
+
* Gets the maximum number of URLs allowed in a single sitemap.
|
|
76
|
+
* @returns {number}
|
|
77
|
+
*/
|
|
78
|
+
static get maxUrls() {
|
|
79
|
+
return TinySiteMap.#MAX_URLS;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Sets the maximum number of URLs allowed in a single sitemap.
|
|
83
|
+
* @param {number} value
|
|
84
|
+
* @throws {TypeError} If the value is not a number.
|
|
85
|
+
*/
|
|
86
|
+
static set maxUrls(value) {
|
|
87
|
+
if (typeof value !== 'number' || Number.isNaN(value)) {
|
|
88
|
+
throw new TypeError('entry.priority must be a number.');
|
|
89
|
+
}
|
|
90
|
+
TinySiteMap.#MAX_URLS = value;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* @type {RegExp} Regex to validate XML Names/Prefixes.
|
|
94
|
+
* From package "sitemap.js" by Eugene Kalinin.
|
|
95
|
+
* @reference https://github.com/ekalinin/sitemap.js/blob/1a782cf41e0d391299029c9e00c8bfa8cdaad212/lib/sitemap-xml.ts
|
|
96
|
+
*/
|
|
97
|
+
static #xmlNameRegex = /^[a-zA-Z_:][\w:.-]*$/;
|
|
98
|
+
/**
|
|
99
|
+
* @type {RegExp} Regex to validate XML Names/Prefixes.
|
|
100
|
+
*
|
|
101
|
+
* From package "sitemap.js" by Eugene Kalinin.
|
|
102
|
+
* @reference https://github.com/ekalinin/sitemap.js/blob/1a782cf41e0d391299029c9e00c8bfa8cdaad212/lib/sitemap-xml.ts
|
|
103
|
+
*
|
|
104
|
+
*/
|
|
105
|
+
static get xmlNameRegex() {
|
|
106
|
+
return new RegExp(TinySiteMap.#xmlNameRegex.source, TinySiteMap.#xmlNameRegex.flags);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* A static map storing predefined XML namespace identifiers and their corresponding URIs.
|
|
110
|
+
* @type {Map<string, string>}
|
|
111
|
+
*/
|
|
112
|
+
static #attrValues = new Map([
|
|
113
|
+
['ROOT', 'http://www.sitemaps.org/schemas/sitemap/0.9'],
|
|
114
|
+
['exampleSchema', 'http://www.example.com/schemas/example_schema'],
|
|
115
|
+
['news', 'http://www.google.com/schemas/sitemap-news/0.9'],
|
|
116
|
+
['xhtml', 'http://www.google.com/schemas/sitemap-news/0.9'],
|
|
117
|
+
['image', 'http://www.google.com/schemas/sitemap-news/0.9'],
|
|
118
|
+
['video', 'http://www.google.com/schemas/sitemap-news/0.9'],
|
|
119
|
+
['xsi', 'http://www.w3.org/2001/XMLSchema-instance'],
|
|
120
|
+
[
|
|
121
|
+
'schemaLocation:normal',
|
|
122
|
+
'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd',
|
|
123
|
+
],
|
|
124
|
+
[
|
|
125
|
+
'schemaLocation:index',
|
|
126
|
+
'http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd',
|
|
127
|
+
],
|
|
128
|
+
]);
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves the URI for a specific namespace ID.
|
|
131
|
+
* @param {string} id - The namespace identifier.
|
|
132
|
+
* @returns {string|undefined} The namespace URI or undefined if not found.
|
|
133
|
+
*/
|
|
134
|
+
static getAttrVal(id) {
|
|
135
|
+
return TinySiteMap.#attrValues.get(id);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Sets or updates a namespace URI for a specific ID.
|
|
139
|
+
* @param {string} id - The namespace identifier.
|
|
140
|
+
* @param {string} value - The namespace URI.
|
|
141
|
+
* @throws {TypeError} If the ID or value are not strings.
|
|
142
|
+
*/
|
|
143
|
+
static setAttrVal(id, value) {
|
|
144
|
+
if (typeof id !== 'string')
|
|
145
|
+
throw new TypeError('Namespace ID must be a string.');
|
|
146
|
+
if (typeof value !== 'string')
|
|
147
|
+
throw new TypeError('Namespace URI must be a string.');
|
|
148
|
+
TinySiteMap.#attrValues.set(id, value);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Checks if a namespace ID exists.
|
|
152
|
+
* @param {string} id - The namespace identifier.
|
|
153
|
+
* @returns {boolean} True if it exists, false otherwise.
|
|
154
|
+
*/
|
|
155
|
+
static hasAttrVal(id) {
|
|
156
|
+
return TinySiteMap.#attrValues.has(id);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Gets all namespaces as a plain object.
|
|
160
|
+
* @returns {Record<string, string>} A map of IDs to URIs.
|
|
161
|
+
*/
|
|
162
|
+
static get attrValues() {
|
|
163
|
+
return Object.fromEntries(TinySiteMap.#attrValues);
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Replaces all current namespaces with a new set.
|
|
167
|
+
* @param {Record<string, string>} obj - The new namespace mapping.
|
|
168
|
+
* @throws {TypeError} If the input is not a valid object or contains non-string values.
|
|
169
|
+
*/
|
|
170
|
+
static set attrValues(obj) {
|
|
171
|
+
if (typeof obj !== 'object' || obj === null || Array.isArray(obj)) {
|
|
172
|
+
throw new TypeError('attrValues must be a non-null object.');
|
|
173
|
+
}
|
|
174
|
+
const attrValues = TinySiteMap.#attrValues;
|
|
175
|
+
try {
|
|
176
|
+
// Validate all values are strings before applying to ensure atomicity
|
|
177
|
+
TinySiteMap.#attrValues = new Map();
|
|
178
|
+
for (const [key, value] of Object.entries(obj)) {
|
|
179
|
+
TinySiteMap.setAttrVal(key, value);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
catch (err) {
|
|
183
|
+
TinySiteMap.#attrValues = attrValues;
|
|
184
|
+
throw err;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Gets the total number of registered namespaces.
|
|
189
|
+
* @returns {number} The count of namespaces.
|
|
190
|
+
*/
|
|
191
|
+
static get attrValuesSize() {
|
|
192
|
+
return TinySiteMap.#attrValues.size;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Clears all registered namespaces in the static attribute map.
|
|
196
|
+
* Note: This affects all instances of TinySiteMap globally.
|
|
197
|
+
*/
|
|
198
|
+
static clearAttrValues() {
|
|
199
|
+
TinySiteMap.#attrValues.clear();
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Initializes a new instance of the TinySiteMap class with the provided configuration.
|
|
203
|
+
* @param {SitemapConfig} config - The configuration object.
|
|
204
|
+
* @throws {TypeError} If the configuration is invalid.
|
|
205
|
+
*/
|
|
206
|
+
constructor(config) {
|
|
207
|
+
this.#validateConfig(config);
|
|
208
|
+
this.#type = config.type ?? 'normal';
|
|
209
|
+
this.#baseUrl = new URL(config.baseUrl);
|
|
210
|
+
this.xslUrlPathnameOnly = config.xslUrlPathnameOnly ?? true;
|
|
211
|
+
this.#xslUrl = config.xslUrl
|
|
212
|
+
? this.#xslUrlPathnameOnly
|
|
213
|
+
? new URL(config.xslUrl, this.#baseUrl.origin)
|
|
214
|
+
: new URL(config.xslUrl)
|
|
215
|
+
: null;
|
|
216
|
+
this.lastmodDateOnly = config.lastmodDateOnly ?? false;
|
|
217
|
+
this.namespaces = config.namespaces ?? [];
|
|
218
|
+
this.namespaceStrategy = config.namespaceStrategy ?? TinySiteMap.simpleStrategy;
|
|
219
|
+
if (config.entries && config.entries.length > 0) {
|
|
220
|
+
for (const entry of config.entries) {
|
|
221
|
+
this.addEntry(entry);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Validates a single namespace object for correct structure and XML naming compliance.
|
|
227
|
+
* @param {SitemapNamespace} ns
|
|
228
|
+
* @param {RegExp} regex
|
|
229
|
+
* @throws {TypeError}
|
|
230
|
+
*/
|
|
231
|
+
#validateNamespace(ns, regex = TinySiteMap.#xmlNameRegex) {
|
|
232
|
+
if (typeof ns !== 'object' || ns === null)
|
|
233
|
+
throw new TypeError('Namespace or Attribute must be a non-null object.');
|
|
234
|
+
const type = ns.type ?? 'xmlns';
|
|
235
|
+
if (!['xmlns', 'attribute'].includes(type))
|
|
236
|
+
throw new TypeError('Type must be either "xmlns" or "attribute".');
|
|
237
|
+
const val = ns.value ?? ns.uri;
|
|
238
|
+
if (typeof val !== 'string')
|
|
239
|
+
throw new TypeError('Namespace URI or Attribute value must be a string.');
|
|
240
|
+
if (type === 'xmlns') {
|
|
241
|
+
if (ns.prefix !== undefined && typeof ns.prefix !== 'string')
|
|
242
|
+
throw new TypeError('Namespace prefix must be a string.');
|
|
243
|
+
if (ns.prefix && !regex.test(ns.prefix))
|
|
244
|
+
throw new TypeError(`Invalid namespace prefix: "${ns.prefix}".`);
|
|
245
|
+
}
|
|
246
|
+
else if (type === 'attribute') {
|
|
247
|
+
if (typeof ns.name !== 'string')
|
|
248
|
+
throw new TypeError('Attribute name must be a string when type is "attribute".');
|
|
249
|
+
if (!regex.test(ns.name))
|
|
250
|
+
throw new TypeError(`Invalid attribute name: "${ns.name}".`);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Validates a collection of namespace objects.
|
|
255
|
+
* @param {SitemapNamespace[]} namespaces
|
|
256
|
+
* @throws {TypeError}
|
|
257
|
+
*/
|
|
258
|
+
#validateNamespaceSet(namespaces) {
|
|
259
|
+
if (!Array.isArray(namespaces))
|
|
260
|
+
throw new TypeError('namespaces must be an array.');
|
|
261
|
+
for (const ns of namespaces)
|
|
262
|
+
this.#validateNamespace(ns);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Escapes special XML characters to prevent XML injection.
|
|
266
|
+
* @param {string} str - The raw string to be escaped.
|
|
267
|
+
* @param {boolean} isOtag
|
|
268
|
+
* @reference https://github.com/ekalinin/sitemap.js/blob/1a782cf41e0d391299029c9e00c8bfa8cdaad212/lib/sitemap-xml.ts
|
|
269
|
+
* @returns {string} The escaped string with characters like <, >, &, ", and ' replaced by entities.
|
|
270
|
+
*/
|
|
271
|
+
static #escapeXml(str, isOtag) {
|
|
272
|
+
const amp = /&/g;
|
|
273
|
+
const lt = /</g;
|
|
274
|
+
const gt = />/g;
|
|
275
|
+
const apos = /'/g;
|
|
276
|
+
const quot = /"/g;
|
|
277
|
+
let result = str;
|
|
278
|
+
result = result.replace(amp, '&').replace(lt, '<').replace(gt, '>');
|
|
279
|
+
if (isOtag) {
|
|
280
|
+
result = result.replace(apos, ''').replace(quot, '"');
|
|
281
|
+
}
|
|
282
|
+
return result.replace(/[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u0084\u0086-\u009F\uD800-\uDFFF\p{NChar}]/gu, '');
|
|
283
|
+
}
|
|
284
|
+
/**
|
|
285
|
+
* Escapes special XML characters to prevent XML injection.
|
|
286
|
+
* @param {string} str - The raw string to be escaped.
|
|
287
|
+
* @param {boolean} isOtag
|
|
288
|
+
* @reference https://github.com/ekalinin/sitemap.js/blob/1a782cf41e0d391299029c9e00c8bfa8cdaad212/lib/sitemap-xml.ts
|
|
289
|
+
* @returns {string} The escaped string with characters like <, >, &, ", and ' replaced by entities.
|
|
290
|
+
*/
|
|
291
|
+
static escapeXml(str, isOtag) {
|
|
292
|
+
return this.#escapeXml(str, isOtag);
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Validates the initial configuration object.
|
|
296
|
+
* @param {SitemapConfig} config - The configuration to validate.
|
|
297
|
+
* @throws {TypeError} If config is not an object, baseUrl is invalid, type is unsupported, or namespaces are malformed.
|
|
298
|
+
*/
|
|
299
|
+
#validateConfig(config) {
|
|
300
|
+
if (typeof config !== 'object' || config === null) {
|
|
301
|
+
throw new TypeError('Configuration must be a non-null object.');
|
|
302
|
+
}
|
|
303
|
+
if (typeof config.baseUrl !== 'string') {
|
|
304
|
+
throw new TypeError('config.baseUrl must be a string.');
|
|
305
|
+
}
|
|
306
|
+
try {
|
|
307
|
+
new URL(config.baseUrl);
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
throw new TypeError('config.baseUrl must be a valid absolute URL.');
|
|
311
|
+
}
|
|
312
|
+
if (config.type && !['normal', 'index'].includes(config.type)) {
|
|
313
|
+
throw new TypeError('config.type must be either "normal" or "index".');
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Resolves relative URLs, validates all fields, and returns a new normalized object.
|
|
318
|
+
* @param {SitemapEntry | SitemapIndexEntry} entry - The entry object to process.
|
|
319
|
+
* @param {URL} baseUrl
|
|
320
|
+
* @param {'normal'|'index'} type
|
|
321
|
+
* @param {number} maxUrlSize
|
|
322
|
+
* @param {RegExp} regex
|
|
323
|
+
* @param {TinyURLSecurityVerifier} urlVerifier
|
|
324
|
+
* @returns {SitemapEntry | SitemapIndexEntry} A new, normalized, and validated entry object.
|
|
325
|
+
* @throws {TypeError} If the entry is invalid, if loc is not a string, if origin doesn't match, or if field values are invalid.
|
|
326
|
+
* @throws {RangeError} If the resolved URL exceeds maxResolvedUrlSize or if priority is outside [0.0, 1.0].
|
|
327
|
+
*/
|
|
328
|
+
static #resolveAndValidate(entry, baseUrl, type, maxUrlSize, regex, urlVerifier) {
|
|
329
|
+
if (typeof entry !== 'object' || entry === null)
|
|
330
|
+
throw new TypeError('Entry must be a non-null object.');
|
|
331
|
+
// Validate loc: Must be string, must be valid URL, must match base origin
|
|
332
|
+
if (typeof entry.loc !== 'string')
|
|
333
|
+
throw new TypeError('entry.loc must be a string.');
|
|
334
|
+
// Automatically handle relative paths using the baseUrl
|
|
335
|
+
const resolvedUrl = new URL(entry.loc, baseUrl);
|
|
336
|
+
// Security: Ensure the resolved URL belongs to the same origin
|
|
337
|
+
if (resolvedUrl.origin !== baseUrl.origin) {
|
|
338
|
+
throw new TypeError(`entry.loc "${entry.loc}" must belong to the same origin as ${baseUrl.origin}`);
|
|
339
|
+
}
|
|
340
|
+
if (resolvedUrl.href.length >= maxUrlSize) {
|
|
341
|
+
throw new RangeError(`entry.loc must be less than ${maxUrlSize} characters.`);
|
|
342
|
+
}
|
|
343
|
+
if (urlVerifier.isDangerous(resolvedUrl)) {
|
|
344
|
+
throw new Error('');
|
|
345
|
+
}
|
|
346
|
+
/** @type {SitemapEntry} */
|
|
347
|
+
const normalizedEntry = { ...entry, loc: resolvedUrl.href };
|
|
348
|
+
// Validate lastmod (Shared by both types)
|
|
349
|
+
if (normalizedEntry.lastmod && typeof normalizedEntry.lastmod === 'string') {
|
|
350
|
+
if (Number.isNaN(Date.parse(normalizedEntry.lastmod))) {
|
|
351
|
+
throw new TypeError(`entry.lastmod "${normalizedEntry.lastmod}" is an invalid date.`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
// Type-specific validation
|
|
355
|
+
if (type === 'normal') {
|
|
356
|
+
// Validate changefreq
|
|
357
|
+
const validFreqs = ['always', 'hourly', 'daily', 'weekly', 'monthly', 'yearly', 'never'];
|
|
358
|
+
if (normalizedEntry.changefreq && !validFreqs.includes(normalizedEntry.changefreq)) {
|
|
359
|
+
throw new TypeError(`entry.changefreq must be one of: ${validFreqs.join(', ')}`);
|
|
360
|
+
}
|
|
361
|
+
// Validate priority
|
|
362
|
+
if (normalizedEntry.priority !== undefined) {
|
|
363
|
+
if (typeof normalizedEntry.priority !== 'number' ||
|
|
364
|
+
Number.isNaN(normalizedEntry.priority)) {
|
|
365
|
+
throw new TypeError('entry.priority must be a number.');
|
|
366
|
+
}
|
|
367
|
+
if (normalizedEntry.priority < 0 || normalizedEntry.priority > 1) {
|
|
368
|
+
throw new RangeError('entry.priority must be between 0.0 and 1.0.');
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
// Validate customTags
|
|
372
|
+
if (normalizedEntry.customTags) {
|
|
373
|
+
// Validation for customTags
|
|
374
|
+
if (typeof normalizedEntry.customTags !== 'object' || normalizedEntry.customTags === null) {
|
|
375
|
+
throw new TypeError('entry.customTags must be an object.');
|
|
376
|
+
}
|
|
377
|
+
for (const [tag, value] of Object.entries(normalizedEntry.customTags)) {
|
|
378
|
+
// SECURITY: Validate that the tag name is a valid XML QName to prevent injection
|
|
379
|
+
if (!regex.test(tag))
|
|
380
|
+
throw new TypeError(`Invalid custom tag name: "${tag}".`);
|
|
381
|
+
// Validate content
|
|
382
|
+
if (typeof value !== 'string')
|
|
383
|
+
throw new TypeError(`The content for custom tag "${tag}" must be a string.`);
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
else if (type === 'index') {
|
|
388
|
+
// Strict mode for 'index': forbid properties that don't belong to <sitemap>
|
|
389
|
+
if (normalizedEntry.changefreq || normalizedEntry.priority || normalizedEntry.customTags) {
|
|
390
|
+
throw new TypeError('Sitemap Index entries cannot contain changefreq, priority, or customTags.');
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
return normalizedEntry;
|
|
394
|
+
}
|
|
395
|
+
/**
|
|
396
|
+
* Resolves relative URLs, validates all fields, and returns a new normalized object.
|
|
397
|
+
* @param {SitemapEntry | SitemapIndexEntry} entry - The entry object to process.
|
|
398
|
+
* @param {URL} baseUrl
|
|
399
|
+
* @param {'normal'|'index'} type
|
|
400
|
+
* @param {number} maxUrlSize
|
|
401
|
+
* @param {RegExp} regex
|
|
402
|
+
* @param {TinyURLSecurityVerifier} urlVerifier
|
|
403
|
+
* @returns {SitemapEntry | SitemapIndexEntry} A new, normalized, and validated entry object.
|
|
404
|
+
* @throws {TypeError} If the entry is invalid, if loc is not a string, if origin doesn't match, or if field values are invalid.
|
|
405
|
+
* @throws {RangeError} If the resolved URL exceeds maxResolvedUrlSize or if priority is outside [0.0, 1.0].
|
|
406
|
+
*/
|
|
407
|
+
static resolveAndValidate(entry, baseUrl, type, maxUrlSize, regex, urlVerifier) {
|
|
408
|
+
return TinySiteMap.#resolveAndValidate(entry, baseUrl, type, maxUrlSize, regex, urlVerifier);
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* Resolves relative URLs, validates all fields, and returns a new normalized object.
|
|
412
|
+
* @param {SitemapEntry | SitemapIndexEntry} entry - The entry object to process.
|
|
413
|
+
* @returns {SitemapEntry | SitemapIndexEntry} A new, normalized, and validated entry object.
|
|
414
|
+
* @throws {TypeError} If the entry is invalid, if loc is not a string, if origin doesn't match, or if field values are invalid.
|
|
415
|
+
* @throws {RangeError} If the resolved URL exceeds maxResolvedUrlSize or if priority is outside [0.0, 1.0].
|
|
416
|
+
*/
|
|
417
|
+
#rav(entry) {
|
|
418
|
+
return TinySiteMap.#resolveAndValidate(entry, this.#baseUrl, this.#type, this.#maxResolvedUrlSize, TinySiteMap.#xmlNameRegex, this.#urlVerifier);
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* Adds a namespace to the sitemap, preventing duplicate prefixes or attribute names.
|
|
422
|
+
* @param {SitemapNamespace} ns - The namespace to add.
|
|
423
|
+
* @throws {TypeError} If the namespace format is invalid.
|
|
424
|
+
*/
|
|
425
|
+
addNamespace(ns) {
|
|
426
|
+
this.#validateNamespace(ns);
|
|
427
|
+
const newType = ns.type ?? 'xmlns';
|
|
428
|
+
// Prevent duplicate attributes or prefixes
|
|
429
|
+
const exists = this.#namespaces.some((existing) => {
|
|
430
|
+
const existingType = existing.type ?? 'xmlns';
|
|
431
|
+
if (existingType !== newType)
|
|
432
|
+
return false;
|
|
433
|
+
if (newType === 'attribute') {
|
|
434
|
+
return existing.name === ns.name;
|
|
435
|
+
}
|
|
436
|
+
return existing.prefix === ns.prefix;
|
|
437
|
+
});
|
|
438
|
+
if (exists) {
|
|
439
|
+
const identifier = newType === 'attribute' ? ns.name : ns.prefix || 'ROOT';
|
|
440
|
+
throw new Error(`Root declaration with identifier "${identifier}" already exists.`);
|
|
441
|
+
}
|
|
442
|
+
this.#namespaces.push(ns);
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* Removes a namespace from the sitemap list by its identifier (prefix or name).
|
|
446
|
+
* @param {string} identifier - The identifier to remove.
|
|
447
|
+
*/
|
|
448
|
+
removeNamespace(identifier) {
|
|
449
|
+
this.#namespaces = this.#namespaces.filter((ns) => {
|
|
450
|
+
const type = ns.type ?? 'xmlns';
|
|
451
|
+
if (type === 'attribute')
|
|
452
|
+
return ns.name !== identifier;
|
|
453
|
+
return ns.prefix !== identifier;
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
/**
|
|
457
|
+
* Clears all manually added namespaces.
|
|
458
|
+
*/
|
|
459
|
+
clearNamespaces() {
|
|
460
|
+
this.#namespaces = [];
|
|
461
|
+
}
|
|
462
|
+
/**
|
|
463
|
+
* Adds a new entry to the sitemap.
|
|
464
|
+
* @param {SitemapEntry | SitemapIndexEntry} entry - The entry to add.
|
|
465
|
+
* @param {number} [index] - The optional index at which to insert the entry.
|
|
466
|
+
* @returns {number} The new length of the entries array.
|
|
467
|
+
*/
|
|
468
|
+
addEntry(entry, index) {
|
|
469
|
+
if (this.#entries.length >= TinySiteMap.#MAX_URLS) {
|
|
470
|
+
throw new RangeError(`Sitemaps cannot exceed ${TinySiteMap.#MAX_URLS} entries.`);
|
|
471
|
+
}
|
|
472
|
+
const validated = this.#rav(entry);
|
|
473
|
+
const newSize = this.#entries.push(validated);
|
|
474
|
+
if (typeof index !== 'undefined')
|
|
475
|
+
this.moveEntry(newSize - 1, index);
|
|
476
|
+
return newSize;
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Removes an entry from the sitemap by its index.
|
|
480
|
+
* @param {number} index - The index of the entry to remove.
|
|
481
|
+
* @returns {boolean} True if an element was removed, false otherwise.
|
|
482
|
+
* @throws {RangeError} If the index is out of bounds.
|
|
483
|
+
*/
|
|
484
|
+
removeEntry(index) {
|
|
485
|
+
if (index < 0 || index >= this.#entries.length) {
|
|
486
|
+
throw new RangeError('Index out of bounds.');
|
|
487
|
+
}
|
|
488
|
+
const oldSize = this.#entries.length;
|
|
489
|
+
this.#entries.splice(index, 1);
|
|
490
|
+
return oldSize !== this.#entries.length;
|
|
491
|
+
}
|
|
492
|
+
/**
|
|
493
|
+
* Updates an existing entry with new data.
|
|
494
|
+
* @param {number} index - The index of the entry to update.
|
|
495
|
+
* @param {Partial<SitemapEntry | SitemapIndexEntry>} entryData - The partial data to merge into the existing entry.
|
|
496
|
+
* @throws {RangeError} If the index is out of bounds.
|
|
497
|
+
*/
|
|
498
|
+
updateEntry(index, entryData) {
|
|
499
|
+
if (index < 0 || index >= this.#entries.length) {
|
|
500
|
+
throw new RangeError('Index out of bounds.');
|
|
501
|
+
}
|
|
502
|
+
// Merge current data with new data to allow partial updates
|
|
503
|
+
const updatedData = { ...this.#entries[index], ...entryData };
|
|
504
|
+
// Re-validate the entire merged object
|
|
505
|
+
this.#entries[index] = this.#rav(updatedData);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Changes the position of an entry within the list.
|
|
509
|
+
* @param {number} fromIndex - The index of the entry to move.
|
|
510
|
+
* @param {number} toIndex - The index to move the entry to.
|
|
511
|
+
* @throws {RangeError} If either index is out of bounds.
|
|
512
|
+
*/
|
|
513
|
+
moveEntry(fromIndex, toIndex) {
|
|
514
|
+
if (fromIndex < 0 ||
|
|
515
|
+
fromIndex >= this.#entries.length ||
|
|
516
|
+
toIndex < 0 ||
|
|
517
|
+
toIndex >= this.#entries.length) {
|
|
518
|
+
throw new RangeError('Index out of bounds.');
|
|
519
|
+
}
|
|
520
|
+
const [movedItem] = this.#entries.splice(fromIndex, 1);
|
|
521
|
+
this.#entries.splice(toIndex, 0, movedItem);
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Clears all manually added entries.
|
|
525
|
+
*/
|
|
526
|
+
clearEntries() {
|
|
527
|
+
this.#entries = [];
|
|
528
|
+
}
|
|
529
|
+
/**
|
|
530
|
+
* Gets the URL security verifier.
|
|
531
|
+
* @returns {TinyURLSecurityVerifier}
|
|
532
|
+
*/
|
|
533
|
+
get urlVerifier() {
|
|
534
|
+
return this.#urlVerifier;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Sets a dynamic strategy to provide namespaces based on the instance state.
|
|
538
|
+
* @param {NamespaceStrategy} strategy - The strategy function.
|
|
539
|
+
* @throws {TypeError} If the strategy is not a function.
|
|
540
|
+
*/
|
|
541
|
+
set namespaceStrategy(strategy) {
|
|
542
|
+
if (typeof strategy !== 'function') {
|
|
543
|
+
throw new TypeError('namespaceStrategy must be a function.');
|
|
544
|
+
}
|
|
545
|
+
this.#namespaceStrategy = strategy;
|
|
546
|
+
}
|
|
547
|
+
/**
|
|
548
|
+
* Returns a copy of the manually added namespaces.
|
|
549
|
+
* @returns {SitemapNamespace[]}
|
|
550
|
+
*/
|
|
551
|
+
get namespaces() {
|
|
552
|
+
return this.#namespaces.map((i) => ({ ...i }));
|
|
553
|
+
}
|
|
554
|
+
/**
|
|
555
|
+
* Sets the manual namespaces for the sitemap.
|
|
556
|
+
* @param {SitemapNamespace[]} nss - The array of namespaces to set.
|
|
557
|
+
* @throws {TypeError} If the namespaces array is invalid.
|
|
558
|
+
*/
|
|
559
|
+
set namespaces(nss) {
|
|
560
|
+
if (!Array.isArray(nss))
|
|
561
|
+
throw new TypeError('namespaces must be an array.');
|
|
562
|
+
const oldNamespaces = this.#namespaces;
|
|
563
|
+
try {
|
|
564
|
+
this.#namespaces = [];
|
|
565
|
+
for (const ns of nss)
|
|
566
|
+
this.addNamespace(ns);
|
|
567
|
+
}
|
|
568
|
+
catch (err) {
|
|
569
|
+
this.#namespaces = oldNamespaces;
|
|
570
|
+
throw err;
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
/**
|
|
574
|
+
* Gets the sitemap type.
|
|
575
|
+
* @returns {'normal'|'index'} The type of sitemap.
|
|
576
|
+
*/
|
|
577
|
+
get type() {
|
|
578
|
+
return this.#type;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Gets the base URL.
|
|
582
|
+
* @returns {URL} The copy of the base URL instance.
|
|
583
|
+
*/
|
|
584
|
+
get baseUrl() {
|
|
585
|
+
return new URL(this.#baseUrl.href);
|
|
586
|
+
}
|
|
587
|
+
/**
|
|
588
|
+
* Gets a shallow copy of the current entries.
|
|
589
|
+
* @returns {SitemapEntry[] | SitemapIndexEntry[]} A copy of the entries array.
|
|
590
|
+
*/
|
|
591
|
+
get entries() {
|
|
592
|
+
return this.#entries.map((/** @type {SitemapEntry} */ e) => ({
|
|
593
|
+
...e,
|
|
594
|
+
...(e.customTags ? { customTags: { ...e.customTags } } : {}),
|
|
595
|
+
}));
|
|
596
|
+
}
|
|
597
|
+
/**
|
|
598
|
+
* Sets the sitemap entries, validating each one via the addEntry method.
|
|
599
|
+
* @param {SitemapEntry[] | SitemapIndexEntry[]} entries - The entries to set.
|
|
600
|
+
* @throws {TypeError} If the entries is not an array.
|
|
601
|
+
*/
|
|
602
|
+
set entries(entries) {
|
|
603
|
+
if (!Array.isArray(entries))
|
|
604
|
+
throw new TypeError('entries must be an array.');
|
|
605
|
+
const oldEntries = this.#entries;
|
|
606
|
+
try {
|
|
607
|
+
this.#entries = [];
|
|
608
|
+
for (const entry of entries)
|
|
609
|
+
this.addEntry(entry);
|
|
610
|
+
}
|
|
611
|
+
catch (err) {
|
|
612
|
+
this.#entries = oldEntries;
|
|
613
|
+
throw err;
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
/**
|
|
617
|
+
* Gets the maximum allowed URL size.
|
|
618
|
+
* @returns {number} The current maximum size.
|
|
619
|
+
*/
|
|
620
|
+
get maxResolvedUrlSize() {
|
|
621
|
+
return this.#maxResolvedUrlSize;
|
|
622
|
+
}
|
|
623
|
+
/**
|
|
624
|
+
* Sets the maximum allowed URL size.
|
|
625
|
+
* @param {number} value - The new maximum size.
|
|
626
|
+
* @throws {TypeError} If the provided value is not a non-negative number.
|
|
627
|
+
*/
|
|
628
|
+
set maxResolvedUrlSize(value) {
|
|
629
|
+
if (typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value) || value < 0) {
|
|
630
|
+
throw new TypeError('maxResolvedUrlSize must be a non-negative number.');
|
|
631
|
+
}
|
|
632
|
+
this.#maxResolvedUrlSize = value;
|
|
633
|
+
}
|
|
634
|
+
/**
|
|
635
|
+
* Gets the current configuration state for 'lastmod' date formatting.
|
|
636
|
+
* @returns {boolean} True if date-only formatting is enabled, false otherwise.
|
|
637
|
+
*/
|
|
638
|
+
get lastmodDateOnly() {
|
|
639
|
+
return this.#lastmodDateOnly;
|
|
640
|
+
}
|
|
641
|
+
/**
|
|
642
|
+
* Sets whether the 'lastmod' field should be formatted as a simple date (YYYY-MM-DD) instead of full ISO 8601.
|
|
643
|
+
* @param {boolean} value - True to use YYYY-MM-DD format, false to use full ISO 8601.
|
|
644
|
+
* @throws {TypeError} If the provided value is not a boolean.
|
|
645
|
+
*/
|
|
646
|
+
set lastmodDateOnly(value) {
|
|
647
|
+
if (typeof value !== 'boolean') {
|
|
648
|
+
throw new TypeError('lastmodDateOnly must be a boolean.');
|
|
649
|
+
}
|
|
650
|
+
this.#lastmodDateOnly = value;
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Gets the URL of the XSL stylesheet used to style the XML output.
|
|
654
|
+
* @returns {string|null} The XSL stylesheet URL or null.
|
|
655
|
+
*/
|
|
656
|
+
get xslUrl() {
|
|
657
|
+
return this.#xslUrlPathnameOnly
|
|
658
|
+
? (this.#xslUrl?.pathname ?? null)
|
|
659
|
+
: (this.#xslUrl?.href ?? null);
|
|
660
|
+
}
|
|
661
|
+
/**
|
|
662
|
+
* Sets the URL of the XSL stylesheet used to style the XML output.
|
|
663
|
+
* @param {string|null} value - The URL of the XSL stylesheet used to style the XML output.
|
|
664
|
+
* @throws {TypeError} If the value is not a string or null.
|
|
665
|
+
*/
|
|
666
|
+
set xslUrl(value) {
|
|
667
|
+
if (value !== null && typeof value !== 'string') {
|
|
668
|
+
throw new TypeError('xslUrl must be a string or null.');
|
|
669
|
+
}
|
|
670
|
+
this.#xslUrl = value
|
|
671
|
+
? this.#xslUrlPathnameOnly
|
|
672
|
+
? new URL(value, this.#baseUrl.origin)
|
|
673
|
+
: new URL(value)
|
|
674
|
+
: null;
|
|
675
|
+
}
|
|
676
|
+
/**
|
|
677
|
+
* Gets whether the XSL URL is treated as a pathname only.
|
|
678
|
+
* @returns {boolean}
|
|
679
|
+
*/
|
|
680
|
+
get xslUrlPathnameOnly() {
|
|
681
|
+
return this.#xslUrlPathnameOnly;
|
|
682
|
+
}
|
|
683
|
+
/**
|
|
684
|
+
* Sets whether the XSL URL is treated as a pathname only.
|
|
685
|
+
* @param {boolean} value - Sets whether the XSL URL is treated as a pathname only.
|
|
686
|
+
* @throws {TypeError} If the value is not a boolean.
|
|
687
|
+
*/
|
|
688
|
+
set xslUrlPathnameOnly(value) {
|
|
689
|
+
if (value !== null && typeof value !== 'boolean') {
|
|
690
|
+
throw new TypeError('xslUrlPathnameOnly must be a boolean or null.');
|
|
691
|
+
}
|
|
692
|
+
this.#xslUrlPathnameOnly = value;
|
|
693
|
+
}
|
|
694
|
+
/**
|
|
695
|
+
* Gets the total number of entries in the sitemap.
|
|
696
|
+
* @returns {number}
|
|
697
|
+
*/
|
|
698
|
+
get entriesSize() {
|
|
699
|
+
return this.#entries.length;
|
|
700
|
+
}
|
|
701
|
+
/**
|
|
702
|
+
* Gets the total number of namespaces in the sitemap.
|
|
703
|
+
* @returns {number}
|
|
704
|
+
*/
|
|
705
|
+
get namespacesSize() {
|
|
706
|
+
return this.#namespaces.length;
|
|
707
|
+
}
|
|
708
|
+
/**
|
|
709
|
+
* Resets the instance by clearing all entries and namespaces.
|
|
710
|
+
*/
|
|
711
|
+
clearAll() {
|
|
712
|
+
this.clearEntries();
|
|
713
|
+
this.clearNamespaces();
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Generates the XML header.
|
|
717
|
+
* @param {SitemapNamespace[]} namespaces
|
|
718
|
+
* @param {string} [xslUrl]
|
|
719
|
+
* @param {'normal'|'index'} [type]
|
|
720
|
+
* @returns {string}
|
|
721
|
+
*/
|
|
722
|
+
static #generateHeader(namespaces, xslUrl, type) {
|
|
723
|
+
let header = '';
|
|
724
|
+
if (xslUrl) {
|
|
725
|
+
header += `<?xml-stylesheet type="text/xsl" href="${TinySiteMap.#escapeXml(xslUrl, true)}"?>\n`;
|
|
726
|
+
}
|
|
727
|
+
let rootAttributes = '';
|
|
728
|
+
for (const ns of namespaces) {
|
|
729
|
+
const nsType = ns.type ?? 'xmlns';
|
|
730
|
+
const val = ns.value ?? ns.uri ?? '';
|
|
731
|
+
// Handles the schemaLocation properly as an attribute, not an xmlns prefix
|
|
732
|
+
if (nsType === 'attribute') {
|
|
733
|
+
rootAttributes += ` ${ns.name}="${TinySiteMap.#escapeXml(val, true)}"`;
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
const prefixPart = ns.prefix ? `:${ns.prefix}` : '';
|
|
737
|
+
rootAttributes += ` xmlns${prefixPart}="${TinySiteMap.#escapeXml(val, true)}"`;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
header +=
|
|
741
|
+
type === 'index' ? `<sitemapindex${rootAttributes}>\n` : `<urlset${rootAttributes}>\n`;
|
|
742
|
+
return header;
|
|
743
|
+
}
|
|
744
|
+
/**
|
|
745
|
+
* Generates the XML fragment for a single entry.
|
|
746
|
+
* @param {SitemapEntry} entry
|
|
747
|
+
* @param {'normal'|'index'} type
|
|
748
|
+
* @param {boolean} [lastmodDateOnly=false]
|
|
749
|
+
* @returns {string}
|
|
750
|
+
*/
|
|
751
|
+
static #generateEntry(entry, type, lastmodDateOnly = false) {
|
|
752
|
+
let lastmodStr = '';
|
|
753
|
+
if (entry.lastmod) {
|
|
754
|
+
const dateObj = new Date(entry.lastmod);
|
|
755
|
+
lastmodStr = TinySiteMap.#escapeXml(lastmodDateOnly ? dateObj.toISOString().split('T')[0] : dateObj.toISOString(), false);
|
|
756
|
+
}
|
|
757
|
+
// All dynamic content is passed through #escapeXml to prevent XML Injection
|
|
758
|
+
if (type === 'index') {
|
|
759
|
+
return ` <sitemap>\n <loc>${TinySiteMap.#escapeXml(entry.loc, false)}</loc>\n${lastmodStr ? ` <lastmod>${lastmodStr}</lastmod>\n` : ''} </sitemap>\n`;
|
|
760
|
+
}
|
|
761
|
+
let xml = ` <url>\n <loc>${TinySiteMap.#escapeXml(entry.loc, false)}</loc>\n`;
|
|
762
|
+
if (lastmodStr)
|
|
763
|
+
xml += ` <lastmod>${lastmodStr}</lastmod>\n`;
|
|
764
|
+
if (entry.changefreq)
|
|
765
|
+
xml += ` <changefreq>${TinySiteMap.#escapeXml(entry.changefreq, false)}</changefreq>\n`;
|
|
766
|
+
if (entry.priority !== undefined)
|
|
767
|
+
xml += ` <priority>${entry.priority.toFixed(1)}</priority>\n`;
|
|
768
|
+
// Render custom tags
|
|
769
|
+
if (entry.customTags) {
|
|
770
|
+
for (const [tag, value] of Object.entries(entry.customTags)) {
|
|
771
|
+
xml += ` <${TinySiteMap.#escapeXml(tag, true)}>${TinySiteMap.#escapeXml(value, false)}</${tag}>\n`;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
xml += ` </url>\n`;
|
|
775
|
+
return xml;
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Generates the XML footer.
|
|
779
|
+
* @param {'normal'|'index'} type
|
|
780
|
+
* @returns {string}
|
|
781
|
+
*/
|
|
782
|
+
static #generateFooter(type) {
|
|
783
|
+
return type === 'index' ? '</sitemapindex>' : '</urlset>';
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* Generates the XML header.
|
|
787
|
+
* @param {SitemapNamespace[]} namespaces
|
|
788
|
+
* @param {string} [xslUrl]
|
|
789
|
+
* @param {'normal'|'index'} [type]
|
|
790
|
+
* @returns {string}
|
|
791
|
+
*/
|
|
792
|
+
static _generateHeader(namespaces, xslUrl, type) {
|
|
793
|
+
return TinySiteMap.#generateHeader(namespaces, xslUrl, type);
|
|
794
|
+
}
|
|
795
|
+
/**
|
|
796
|
+
* Generates the XML fragment for a single entry.
|
|
797
|
+
* @param {SitemapEntry} entry
|
|
798
|
+
* @param {'normal'|'index'} type
|
|
799
|
+
* @param {boolean} [lastmodDateOnly=false]
|
|
800
|
+
* @returns {string}
|
|
801
|
+
*/
|
|
802
|
+
static _generateEntry(entry, type, lastmodDateOnly = false) {
|
|
803
|
+
return TinySiteMap.#generateEntry(entry, type, lastmodDateOnly);
|
|
804
|
+
}
|
|
805
|
+
/**
|
|
806
|
+
* Generates the XML footer.
|
|
807
|
+
* @param {'normal'|'index'} type
|
|
808
|
+
* @returns {string}
|
|
809
|
+
*/
|
|
810
|
+
static _generateFooter(type) {
|
|
811
|
+
return TinySiteMap.#generateFooter(type);
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Generates the sitemap or sitemap index as a valid XML string.
|
|
815
|
+
* @returns {string} The generated XML content.
|
|
816
|
+
*/
|
|
817
|
+
generateXml() {
|
|
818
|
+
// 1. Collect all namespaces (Manual + Dynamic Strategy)
|
|
819
|
+
const dynamicNamespaces = this.#namespaceStrategy ? this.#namespaceStrategy(this) : [];
|
|
820
|
+
// 2. SECURITY: Validate all collected namespaces before rendering
|
|
821
|
+
this.#validateNamespaceSet(dynamicNamespaces);
|
|
822
|
+
const allNamespaces = [...dynamicNamespaces, ...this.#namespaces];
|
|
823
|
+
const xmlChunks = [`<?xml version="1.0" encoding="UTF-8"?>\n`];
|
|
824
|
+
// 3. Add header (Stylesheet + Root Tag)
|
|
825
|
+
xmlChunks.push(TinySiteMap.#generateHeader(allNamespaces, this.#xslUrl ? this.#xslUrl.href : undefined, this.#type));
|
|
826
|
+
// 4. Add entries
|
|
827
|
+
for (const entry of this.#entries) {
|
|
828
|
+
xmlChunks.push(TinySiteMap.#generateEntry(entry, this.#type, this.#lastmodDateOnly));
|
|
829
|
+
}
|
|
830
|
+
// 5. Add o footer
|
|
831
|
+
xmlChunks.push(TinySiteMap.#generateFooter(this.#type));
|
|
832
|
+
return xmlChunks.join('');
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Returns a namespace strategy that includes standard Google sitemaps namespaces (news, xhtml, image, and video).
|
|
836
|
+
*
|
|
837
|
+
* The function name is a fun reference to name of Eugene Kalinin. This strategy is inspired in the original "sitemap.js" package.
|
|
838
|
+
* @reference https://github.com/ekalinin/sitemap.js/blob/1a782cf41e0d391299029c9e00c8bfa8cdaad212/lib/sitemap-stream.ts
|
|
839
|
+
* @type {NamespaceStrategy}
|
|
840
|
+
*/
|
|
841
|
+
static kaliStrategy() {
|
|
842
|
+
/** @type {SitemapNamespace[]} */
|
|
843
|
+
const namespaces = [];
|
|
844
|
+
namespaces.push({ type: 'xmlns', uri: TinySiteMap.#attrValues.get('ROOT') ?? '' });
|
|
845
|
+
namespaces.push({
|
|
846
|
+
type: 'xmlns',
|
|
847
|
+
uri: TinySiteMap.#attrValues.get('news') ?? '',
|
|
848
|
+
prefix: 'news',
|
|
849
|
+
});
|
|
850
|
+
namespaces.push({
|
|
851
|
+
type: 'xmlns',
|
|
852
|
+
uri: TinySiteMap.#attrValues.get('xhtml') ?? '',
|
|
853
|
+
prefix: 'xhtml',
|
|
854
|
+
});
|
|
855
|
+
namespaces.push({
|
|
856
|
+
type: 'xmlns',
|
|
857
|
+
uri: TinySiteMap.#attrValues.get('image') ?? '',
|
|
858
|
+
prefix: 'image',
|
|
859
|
+
});
|
|
860
|
+
namespaces.push({
|
|
861
|
+
type: 'xmlns',
|
|
862
|
+
uri: TinySiteMap.#attrValues.get('video') ?? '',
|
|
863
|
+
prefix: 'video',
|
|
864
|
+
});
|
|
865
|
+
return namespaces;
|
|
866
|
+
}
|
|
867
|
+
/**
|
|
868
|
+
* Returns a basic namespace strategy that only includes the default XML sitemap ROOT namespace.
|
|
869
|
+
* @type {NamespaceStrategy}
|
|
870
|
+
*/
|
|
871
|
+
static simpleStrategy() {
|
|
872
|
+
return [{ type: 'xmlns', uri: TinySiteMap.#attrValues.get('ROOT') ?? '' }];
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Returns a comprehensive namespace strategy that includes the ROOT, XSI, and schemaLocation namespaces,
|
|
876
|
+
* and conditionally includes custom namespaces based on the sitemap instance state.
|
|
877
|
+
* @reference https://www.sitemaps.org/protocol.html
|
|
878
|
+
* @type {NamespaceStrategy}
|
|
879
|
+
*/
|
|
880
|
+
static protocolStrategy(instance) {
|
|
881
|
+
/** @type {SitemapNamespace[]} */
|
|
882
|
+
const namespaces = [];
|
|
883
|
+
// Default xmlns
|
|
884
|
+
namespaces.push({ type: 'xmlns', uri: TinySiteMap.#attrValues.get('ROOT') ?? '' });
|
|
885
|
+
// xmlns:xsi
|
|
886
|
+
namespaces.push({
|
|
887
|
+
type: 'xmlns',
|
|
888
|
+
prefix: 'xsi',
|
|
889
|
+
uri: TinySiteMap.#attrValues.get('xsi') ?? '',
|
|
890
|
+
});
|
|
891
|
+
// Schema Location
|
|
892
|
+
const schemaUri = instance.type === 'normal'
|
|
893
|
+
? (TinySiteMap.#attrValues.get('schemaLocation:normal') ?? '')
|
|
894
|
+
: (TinySiteMap.#attrValues.get('schemaLocation:index') ?? '');
|
|
895
|
+
namespaces.push({ type: 'attribute', name: 'xsi:schemaLocation', value: schemaUri });
|
|
896
|
+
// Custom Tags logic (original insertNamespaces behavior)
|
|
897
|
+
if (instance.type === 'normal') {
|
|
898
|
+
const hasCustomTags = instance.entries.some((/** @type {SitemapEntry} */ e) => e.customTags && Object.keys(e.customTags).length > 0);
|
|
899
|
+
if (hasCustomTags) {
|
|
900
|
+
namespaces.push({
|
|
901
|
+
type: 'xmlns',
|
|
902
|
+
prefix: 'example',
|
|
903
|
+
uri: TinySiteMap.#attrValues.get('exampleSchema') ?? '',
|
|
904
|
+
});
|
|
905
|
+
}
|
|
906
|
+
}
|
|
907
|
+
return namespaces;
|
|
908
|
+
}
|
|
909
|
+
}
|
|
910
|
+
export default TinySiteMap;
|