tiny-essentials 1.26.4 → 1.27.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/.github/workflows/node.js.yml +1 -1
- package/README.md +0 -1
- package/TinyFork.mjs +7 -7
- package/changelog/1/27/0.md +24 -0
- package/changelog/1/27/1.md +2 -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/TinyClassManager.min.js +1 -1
- package/dist/v1/TinyClipboard.min.js +1 -1
- 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/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/TinyEvents.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/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/TinyMediaPlayer.min.js +1 -0
- package/dist/v1/TinyNeedBar.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyNotifications.min.js +1 -1
- package/dist/v1/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyPromiseQueue.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -0
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySimpleDice.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- 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/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/index.cjs +5 -0
- package/dist/v1/basics/index.d.mts +5 -1
- package/dist/v1/basics/index.mjs +2 -1
- package/dist/v1/basics/mediaContent.cjs +644 -0
- package/dist/v1/basics/mediaContent.d.mts +296 -0
- package/dist/v1/basics/mediaContent.mjs +557 -0
- package/dist/v1/build/TinyMediaPlayer.cjs +7 -0
- package/dist/v1/build/TinyMediaPlayer.d.mts +3 -0
- package/dist/v1/build/TinyMediaPlayer.mjs +2 -0
- package/dist/v1/build/TinyRadioFm.cjs +7 -0
- package/dist/v1/build/TinyRadioFm.d.mts +3 -0
- package/dist/v1/build/TinyRadioFm.mjs +2 -0
- package/dist/v1/index.cjs +9 -0
- package/dist/v1/index.d.mts +7 -1
- package/dist/v1/index.mjs +5 -2
- package/dist/v1/libs/ColorSafeStringify.d.mts +1 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +16 -3
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +7 -3
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +13 -3
- package/dist/v1/libs/TinyArrayComparator.cjs +14 -11
- package/dist/v1/libs/TinyArrayComparator.d.mts +22 -19
- package/dist/v1/libs/TinyArrayComparator.mjs +14 -11
- package/dist/v1/libs/TinyArrayPaginator.cjs +23 -16
- package/dist/v1/libs/TinyArrayPaginator.d.mts +57 -30
- package/dist/v1/libs/TinyArrayPaginator.mjs +22 -16
- package/dist/v1/libs/TinyClassManager/TinyPluginInliner.cjs +265 -0
- package/dist/v1/libs/TinyClassManager/TinyPluginInliner.d.mts +92 -0
- package/dist/v1/libs/TinyClassManager/TinyPluginInliner.mjs +223 -0
- package/dist/v1/libs/TinyClassManager.cjs +52 -22
- package/dist/v1/libs/TinyClassManager.d.mts +26 -16
- package/dist/v1/libs/TinyClassManager.mjs +50 -21
- package/dist/v1/libs/TinyColorValidator.d.mts +16 -16
- package/dist/v1/libs/TinyDragDropDetector.cjs +9 -34
- package/dist/v1/libs/TinyDragDropDetector.d.mts +7 -21
- package/dist/v1/libs/TinyDragDropDetector.mjs +9 -24
- package/dist/v1/libs/TinyDragger.cjs +5 -5
- package/dist/v1/libs/TinyDragger.d.mts +4 -3
- package/dist/v1/libs/TinyDragger.mjs +5 -5
- package/dist/v1/libs/TinyElementObserver.cjs +6 -21
- package/dist/v1/libs/TinyElementObserver.d.mts +6 -15
- package/dist/v1/libs/TinyElementObserver.mjs +6 -20
- package/dist/v1/libs/TinyGamepad.cjs +4 -6
- package/dist/v1/libs/TinyGamepad.d.mts +1 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlIcon.d.mts +1 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlTemplate.d.mts +1 -1
- package/dist/v1/libs/TinyHtml/TinyHtmlTextarea.d.mts +1 -1
- package/dist/v1/libs/TinyHtml/index.d.mts +1 -1
- package/dist/v1/libs/TinyHtml.cjs +72 -98
- package/dist/v1/libs/TinyHtml.d.mts +15 -32
- package/dist/v1/libs/TinyHtml.mjs +53 -77
- package/dist/v1/libs/TinyInventory.d.mts +1 -1
- package/dist/v1/libs/TinyMediaPlayer.cjs +844 -0
- package/dist/v1/libs/TinyMediaPlayer.d.mts +306 -0
- package/dist/v1/libs/TinyMediaPlayer.mjs +755 -0
- package/dist/v1/libs/TinyRadioFm.cjs +1378 -0
- package/dist/v1/libs/TinyRadioFm.d.mts +554 -0
- package/dist/v1/libs/TinyRadioFm.mjs +1137 -0
- package/dist/v1/libs/TinySmartScroller.cjs +39 -26
- package/dist/v1/libs/TinySmartScroller.d.mts +16 -62
- package/dist/v1/libs/TinySmartScroller.mjs +35 -26
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +7 -7
- package/docs/v1/README.md +6 -0
- package/docs/v1/basics/mediaContent.md +131 -0
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +107 -0
- package/docs/v1/libs/TinyDragDropDetector.md +5 -9
- package/docs/v1/libs/TinyElementObserver.md +3 -6
- package/docs/v1/libs/TinyHtml.md +0 -29
- package/docs/v1/libs/TinyMediaPlayer.md +100 -0
- package/docs/v1/libs/TinyRadioFm.md +141 -0
- package/docs/v1/libs/TinySmartScroller.md +3 -3
- package/package.json +40 -22
|
@@ -46,6 +46,7 @@ var TinyEvents = require('./TinyEvents.cjs');
|
|
|
46
46
|
* - Handles media element load events (e.g. `<img>`, `<iframe>`, `<video>`) to prevent sudden scroll jumps
|
|
47
47
|
*
|
|
48
48
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
49
|
+
* @template {Element|Window} HTMLTarget
|
|
49
50
|
*/
|
|
50
51
|
class TinySmartScroller {
|
|
51
52
|
static Utils = { ...collision, TinyHtml };
|
|
@@ -302,6 +303,9 @@ class TinySmartScroller {
|
|
|
302
303
|
#attributeFilter;
|
|
303
304
|
|
|
304
305
|
/** @type {Element} */
|
|
306
|
+
#targetElement;
|
|
307
|
+
|
|
308
|
+
/** @type {HTMLTarget} */
|
|
305
309
|
#target;
|
|
306
310
|
|
|
307
311
|
/** @type {Set<NodeSizesEvent>} */
|
|
@@ -311,7 +315,7 @@ class TinySmartScroller {
|
|
|
311
315
|
* Creates a new instance of TinySmartScroller, attaching scroll and resize observers to manage
|
|
312
316
|
* automatic scroll behaviors, layout shift correction, and visibility tracking.
|
|
313
317
|
*
|
|
314
|
-
* @param {
|
|
318
|
+
* @param {HTMLTarget} target - The scroll container to monitor. Can be an element or `window`.
|
|
315
319
|
* @param {Object} [options={}] - Optional settings to configure scroll behavior.
|
|
316
320
|
* @param {number} [options.extraScrollBoundary=0] - Extra margin in pixels to extend scroll boundary detection.
|
|
317
321
|
* @param {boolean} [options.autoScrollBottom=true] - Whether to auto-scroll to bottom on layout updates.
|
|
@@ -335,7 +339,11 @@ class TinySmartScroller {
|
|
|
335
339
|
} = {},
|
|
336
340
|
) {
|
|
337
341
|
// === target ===
|
|
338
|
-
if (!(
|
|
342
|
+
if (!(
|
|
343
|
+
target instanceof Element ||
|
|
344
|
+
// @ts-ignore
|
|
345
|
+
target === window
|
|
346
|
+
))
|
|
339
347
|
throw new TypeError(
|
|
340
348
|
`TinySmartScroller: 'target' must be a DOM Element or 'window', but got ${typeof target}`,
|
|
341
349
|
);
|
|
@@ -378,7 +386,8 @@ class TinySmartScroller {
|
|
|
378
386
|
);
|
|
379
387
|
|
|
380
388
|
// Start values
|
|
381
|
-
this.#target = target
|
|
389
|
+
this.#target = target;
|
|
390
|
+
this.#targetElement = target instanceof Window ? document.documentElement : target;
|
|
382
391
|
this.#useWindow = target instanceof Window;
|
|
383
392
|
this.#autoScrollBottom = autoScrollBottom;
|
|
384
393
|
this.#observeMutations = observeMutations;
|
|
@@ -396,14 +405,14 @@ class TinySmartScroller {
|
|
|
396
405
|
clearTimeout(timeout);
|
|
397
406
|
timeout = setTimeout(() => this._onScroll(), this.#debounceTime);
|
|
398
407
|
};
|
|
399
|
-
(this.#useWindow ? window : this.#
|
|
408
|
+
(this.#useWindow ? window : this.#targetElement).addEventListener('scroll', this.#handler, {
|
|
400
409
|
passive: true,
|
|
401
410
|
});
|
|
402
411
|
|
|
403
412
|
// Mutations
|
|
404
413
|
if (this.#observeMutations) {
|
|
405
414
|
this._observeMutations();
|
|
406
|
-
this._observeResizes(this.#
|
|
415
|
+
this._observeResizes(this.#targetElement.children);
|
|
407
416
|
}
|
|
408
417
|
|
|
409
418
|
this._scrollDataUpdater();
|
|
@@ -589,11 +598,11 @@ class TinySmartScroller {
|
|
|
589
598
|
*/
|
|
590
599
|
_scrollDataUpdater() {
|
|
591
600
|
const results = new Map();
|
|
592
|
-
this.#
|
|
601
|
+
this.#targetElement.querySelectorAll(this.#querySelector || '*').forEach((target) => {
|
|
593
602
|
const oldIsVisible = this.#newVisibles.get(target) ?? false;
|
|
594
603
|
this.#oldVisibles.set(target, oldIsVisible);
|
|
595
604
|
|
|
596
|
-
const isVisible = TinyHtml.isInContainer(this.#
|
|
605
|
+
const isVisible = TinyHtml.isInContainer(this.#targetElement, target);
|
|
597
606
|
this.#newVisibles.set(target, isVisible);
|
|
598
607
|
|
|
599
608
|
results.set(target, { oldIsVisible, isVisible });
|
|
@@ -608,7 +617,7 @@ class TinySmartScroller {
|
|
|
608
617
|
if (this.#destroyed) return;
|
|
609
618
|
// Get values
|
|
610
619
|
const scrollCache = this._scrollDataUpdater();
|
|
611
|
-
const el = this.#
|
|
620
|
+
const el = this.#targetElement;
|
|
612
621
|
const scrollTop = el.scrollTop;
|
|
613
622
|
const scrollHeight = el.scrollHeight;
|
|
614
623
|
const clientHeight = el.clientHeight;
|
|
@@ -672,13 +681,15 @@ class TinySmartScroller {
|
|
|
672
681
|
throw new TypeError('_fixScroll: targets must be an array of Elements');
|
|
673
682
|
|
|
674
683
|
// Get Scroll data
|
|
675
|
-
const prevScrollHeight = this.#
|
|
676
|
-
const prevScrollTop = this.#
|
|
684
|
+
const prevScrollHeight = this.#targetElement.scrollHeight;
|
|
685
|
+
const prevScrollTop = this.#targetElement.scrollTop;
|
|
677
686
|
const prevBottomOffset =
|
|
678
|
-
this.#
|
|
687
|
+
this.#targetElement.scrollHeight -
|
|
688
|
+
this.#targetElement.scrollTop -
|
|
689
|
+
this.#targetElement.clientHeight;
|
|
679
690
|
|
|
680
691
|
// Get new size
|
|
681
|
-
const newScrollHeight = this.#
|
|
692
|
+
const newScrollHeight = this.#targetElement.scrollHeight;
|
|
682
693
|
const heightDelta = newScrollHeight - prevScrollHeight;
|
|
683
694
|
|
|
684
695
|
/** @type {() => NodeSizes} */
|
|
@@ -726,7 +737,7 @@ class TinySmartScroller {
|
|
|
726
737
|
// Fix scroll size
|
|
727
738
|
if (
|
|
728
739
|
this.#elemOldAmount > 0 &&
|
|
729
|
-
TinyHtml.hasScroll(this.#
|
|
740
|
+
TinyHtml.hasScroll(this.#targetElement).v &&
|
|
730
741
|
this.#autoScrollBottom &&
|
|
731
742
|
this.#preserveScrollOnLayoutShift &&
|
|
732
743
|
!this.#isAtBottom &&
|
|
@@ -734,9 +745,9 @@ class TinySmartScroller {
|
|
|
734
745
|
) {
|
|
735
746
|
const scrollSize = calculateScrollSize();
|
|
736
747
|
// Complete
|
|
737
|
-
this.#
|
|
748
|
+
this.#targetElement.scrollTop = prevScrollTop + heightDelta + scrollSize.height;
|
|
738
749
|
if (scrollSize.width > 0)
|
|
739
|
-
this.#
|
|
750
|
+
this.#targetElement.scrollLeft = this.#targetElement.scrollLeft + scrollSize.width;
|
|
740
751
|
}
|
|
741
752
|
|
|
742
753
|
// Normal stuff
|
|
@@ -745,8 +756,8 @@ class TinySmartScroller {
|
|
|
745
756
|
this.scrollToBottom();
|
|
746
757
|
} else if (!this.#autoScrollBottom && !this.#isAtBottom) {
|
|
747
758
|
calculateScrollSize();
|
|
748
|
-
this.#
|
|
749
|
-
this.#
|
|
759
|
+
this.#targetElement.scrollTop =
|
|
760
|
+
this.#targetElement.scrollHeight - this.#targetElement.clientHeight - prevBottomOffset;
|
|
750
761
|
}
|
|
751
762
|
}
|
|
752
763
|
/**
|
|
@@ -757,7 +768,7 @@ class TinySmartScroller {
|
|
|
757
768
|
if (this.#destroyed) return;
|
|
758
769
|
this._scrollDataUpdater();
|
|
759
770
|
this.#elemOldAmount = this.#elemAmount;
|
|
760
|
-
this.#elemAmount = this.#
|
|
771
|
+
this.#elemAmount = this.#targetElement.childElementCount;
|
|
761
772
|
|
|
762
773
|
mutations.forEach((mutation) => {
|
|
763
774
|
mutation.addedNodes.forEach((node) => {
|
|
@@ -778,7 +789,7 @@ class TinySmartScroller {
|
|
|
778
789
|
});
|
|
779
790
|
|
|
780
791
|
// Install observer
|
|
781
|
-
this.#mutationObserver.observe(this.#
|
|
792
|
+
this.#mutationObserver.observe(this.#targetElement, {
|
|
782
793
|
childList: true,
|
|
783
794
|
subtree: true,
|
|
784
795
|
attributes: true,
|
|
@@ -851,13 +862,15 @@ class TinySmartScroller {
|
|
|
851
862
|
});
|
|
852
863
|
}
|
|
853
864
|
|
|
865
|
+
get target() {
|
|
866
|
+
return this.#target;
|
|
867
|
+
}
|
|
868
|
+
|
|
854
869
|
/**
|
|
855
870
|
* Returns the internal scroll container element being monitored.
|
|
856
|
-
*
|
|
857
|
-
* @returns {Element} The DOM element used as the scroll container target.
|
|
858
871
|
*/
|
|
859
|
-
get
|
|
860
|
-
return this.#
|
|
872
|
+
get targetElement() {
|
|
873
|
+
return this.#targetElement;
|
|
861
874
|
}
|
|
862
875
|
|
|
863
876
|
/**
|
|
@@ -953,14 +966,14 @@ class TinySmartScroller {
|
|
|
953
966
|
* Forces the scroll position to move to the very bottom of the target.
|
|
954
967
|
*/
|
|
955
968
|
scrollToBottom() {
|
|
956
|
-
this.#
|
|
969
|
+
this.#targetElement.scrollTop = this.#targetElement.scrollHeight;
|
|
957
970
|
}
|
|
958
971
|
|
|
959
972
|
/**
|
|
960
973
|
* Forces the scroll position to move to the very top of the target.
|
|
961
974
|
*/
|
|
962
975
|
scrollToTop() {
|
|
963
|
-
this.#
|
|
976
|
+
this.#targetElement.scrollTop = 0;
|
|
964
977
|
}
|
|
965
978
|
|
|
966
979
|
/**
|
|
@@ -1146,7 +1159,7 @@ class TinySmartScroller {
|
|
|
1146
1159
|
}
|
|
1147
1160
|
|
|
1148
1161
|
// Removes scroll listener
|
|
1149
|
-
const target = this.#useWindow ? window : this.#
|
|
1162
|
+
const target = this.#useWindow ? window : this.#targetElement;
|
|
1150
1163
|
if (this.#handler) target.removeEventListener('scroll', this.#handler);
|
|
1151
1164
|
|
|
1152
1165
|
// Clean the WeakMaps
|
|
@@ -65,8 +65,9 @@ export type ScrollListenersFunc = (payload: any) => void;
|
|
|
65
65
|
* - Handles media element load events (e.g. `<img>`, `<iframe>`, `<video>`) to prevent sudden scroll jumps
|
|
66
66
|
*
|
|
67
67
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
68
|
+
* @template {Element|Window} HTMLTarget
|
|
68
69
|
*/
|
|
69
|
-
declare class TinySmartScroller {
|
|
70
|
+
declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
70
71
|
static Utils: {
|
|
71
72
|
TinyHtml: typeof TinyHtml;
|
|
72
73
|
getElsRelativeCenterOffset(rect1: ObjRect, rect2: ObjRect): {
|
|
@@ -88,69 +89,19 @@ declare class TinySmartScroller {
|
|
|
88
89
|
areElsCollTop: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
89
90
|
areElsCollBottom: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
90
91
|
areElsCollLeft: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
91
|
-
areElsCollRight: (
|
|
92
|
-
/**
|
|
93
|
-
* Adds a event listener.
|
|
94
|
-
*
|
|
95
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
96
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
97
|
-
*/
|
|
98
|
-
rect1: ObjRect
|
|
99
|
-
/**
|
|
100
|
-
* Adds a event listener.
|
|
101
|
-
*
|
|
102
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
103
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
104
|
-
*/
|
|
105
|
-
, ////////////////////////////////////////////////////////
|
|
106
|
-
/**
|
|
107
|
-
* Adds a event listener.
|
|
108
|
-
*
|
|
109
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
110
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
111
|
-
*/
|
|
112
|
-
rect2: ObjRect
|
|
113
|
-
/**
|
|
114
|
-
* Adds a event listener.
|
|
115
|
-
*
|
|
116
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
117
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
118
|
-
*/
|
|
119
|
-
) => boolean;
|
|
92
|
+
areElsCollRight: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
120
93
|
areElsCollPerfTop: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
121
94
|
areElsCollPerfBottom: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
122
95
|
areElsCollPerfLeft: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
123
96
|
areElsCollPerfRight: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
124
|
-
areElsColliding: (
|
|
125
|
-
|
|
126
|
-
* Removes a previously registered event listener.
|
|
127
|
-
*
|
|
128
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
129
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
130
|
-
*/
|
|
131
|
-
rect1: ObjRect
|
|
97
|
+
areElsColliding: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
98
|
+
areElsPerfColliding: (rect1: ObjRect, rect2: ObjRect
|
|
132
99
|
/**
|
|
133
|
-
* Removes a
|
|
100
|
+
* Removes all event listeners of a specific type from the element.
|
|
134
101
|
*
|
|
135
|
-
* @param {string|string[]} event - The
|
|
136
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
137
|
-
*/
|
|
138
|
-
, //////////////////////////////////////////////////
|
|
139
|
-
/**
|
|
140
|
-
* Removes a previously registered event listener.
|
|
141
|
-
*
|
|
142
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
143
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
144
|
-
*/
|
|
145
|
-
rect2: ObjRect
|
|
146
|
-
/**
|
|
147
|
-
* Removes a previously registered event listener.
|
|
148
|
-
*
|
|
149
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
150
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
102
|
+
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
151
103
|
*/
|
|
152
104
|
) => boolean;
|
|
153
|
-
areElsPerfColliding: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
154
105
|
getElsColliding: (rect1: ObjRect, rect2: ObjRect) => string | null;
|
|
155
106
|
getElsPerfColliding: (rect1: ObjRect, rect2: ObjRect) => "top" | "bottom" | "left" | "right" | null;
|
|
156
107
|
getElsCollOverlap: (rect1: ObjRect, rect2: ObjRect) => {
|
|
@@ -168,7 +119,11 @@ declare class TinySmartScroller {
|
|
|
168
119
|
dirX: Dirs;
|
|
169
120
|
dirY: Dirs;
|
|
170
121
|
};
|
|
171
|
-
getRectCenter: (
|
|
122
|
+
getRectCenter: (/////////////////////////////
|
|
123
|
+
/** @type {WeakMap<Element, NodeSizes>} */
|
|
124
|
+
rect: ObjRect
|
|
125
|
+
/** @type {WeakMap<Element, NodeSizes>} */
|
|
126
|
+
) => {
|
|
172
127
|
x: number;
|
|
173
128
|
y: number;
|
|
174
129
|
};
|
|
@@ -177,7 +132,7 @@ declare class TinySmartScroller {
|
|
|
177
132
|
* Creates a new instance of TinySmartScroller, attaching scroll and resize observers to manage
|
|
178
133
|
* automatic scroll behaviors, layout shift correction, and visibility tracking.
|
|
179
134
|
*
|
|
180
|
-
* @param {
|
|
135
|
+
* @param {HTMLTarget} target - The scroll container to monitor. Can be an element or `window`.
|
|
181
136
|
* @param {Object} [options={}] - Optional settings to configure scroll behavior.
|
|
182
137
|
* @param {number} [options.extraScrollBoundary=0] - Extra margin in pixels to extend scroll boundary detection.
|
|
183
138
|
* @param {boolean} [options.autoScrollBottom=true] - Whether to auto-scroll to bottom on layout updates.
|
|
@@ -188,7 +143,7 @@ declare class TinySmartScroller {
|
|
|
188
143
|
* @param {string[]|Set<string>|null} [options.attributeFilter=['class', 'style', 'src', 'data-*', 'height', 'width']]
|
|
189
144
|
* - Which attributes to observe for changes.
|
|
190
145
|
*/
|
|
191
|
-
constructor(target:
|
|
146
|
+
constructor(target: HTMLTarget, { extraScrollBoundary, autoScrollBottom, observeMutations, preserveScrollOnLayoutShift, debounceTime, querySelector, attributeFilter, }?: {
|
|
192
147
|
extraScrollBoundary?: number | undefined;
|
|
193
148
|
autoScrollBottom?: boolean | undefined;
|
|
194
149
|
observeMutations?: boolean | undefined;
|
|
@@ -451,12 +406,11 @@ declare class TinySmartScroller {
|
|
|
451
406
|
* @param {NodeListOf<Element>|Element} elements - Target element(s) to listen on.
|
|
452
407
|
*/
|
|
453
408
|
_listenLoadEvents(elements: NodeListOf<Element> | Element): void;
|
|
409
|
+
get target(): HTMLTarget;
|
|
454
410
|
/**
|
|
455
411
|
* Returns the internal scroll container element being monitored.
|
|
456
|
-
*
|
|
457
|
-
* @returns {Element} The DOM element used as the scroll container target.
|
|
458
412
|
*/
|
|
459
|
-
get
|
|
413
|
+
get targetElement(): Element;
|
|
460
414
|
/**
|
|
461
415
|
* Returns the previous size of a given element, or undefined if not tracked.
|
|
462
416
|
*
|
|
@@ -40,6 +40,7 @@ import TinyEvents from './TinyEvents.mjs';
|
|
|
40
40
|
* - Handles media element load events (e.g. `<img>`, `<iframe>`, `<video>`) to prevent sudden scroll jumps
|
|
41
41
|
*
|
|
42
42
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
43
|
+
* @template {Element|Window} HTMLTarget
|
|
43
44
|
*/
|
|
44
45
|
class TinySmartScroller {
|
|
45
46
|
static Utils = { ...TinyCollision, TinyHtml };
|
|
@@ -259,6 +260,8 @@ class TinySmartScroller {
|
|
|
259
260
|
/** @type {Set<string>} */
|
|
260
261
|
#attributeFilter;
|
|
261
262
|
/** @type {Element} */
|
|
263
|
+
#targetElement;
|
|
264
|
+
/** @type {HTMLTarget} */
|
|
262
265
|
#target;
|
|
263
266
|
/** @type {Set<NodeSizesEvent>} */
|
|
264
267
|
#sizeFilter = new Set();
|
|
@@ -266,7 +269,7 @@ class TinySmartScroller {
|
|
|
266
269
|
* Creates a new instance of TinySmartScroller, attaching scroll and resize observers to manage
|
|
267
270
|
* automatic scroll behaviors, layout shift correction, and visibility tracking.
|
|
268
271
|
*
|
|
269
|
-
* @param {
|
|
272
|
+
* @param {HTMLTarget} target - The scroll container to monitor. Can be an element or `window`.
|
|
270
273
|
* @param {Object} [options={}] - Optional settings to configure scroll behavior.
|
|
271
274
|
* @param {number} [options.extraScrollBoundary=0] - Extra margin in pixels to extend scroll boundary detection.
|
|
272
275
|
* @param {boolean} [options.autoScrollBottom=true] - Whether to auto-scroll to bottom on layout updates.
|
|
@@ -279,7 +282,9 @@ class TinySmartScroller {
|
|
|
279
282
|
*/
|
|
280
283
|
constructor(target, { extraScrollBoundary = 0, autoScrollBottom = true, observeMutations = true, preserveScrollOnLayoutShift = true, debounceTime = 100, querySelector = null, attributeFilter = ['class', 'style', 'src', 'data-*', 'height', 'width'], } = {}) {
|
|
281
284
|
// === target ===
|
|
282
|
-
if (!(target instanceof Element ||
|
|
285
|
+
if (!(target instanceof Element ||
|
|
286
|
+
// @ts-ignore
|
|
287
|
+
target === window))
|
|
283
288
|
throw new TypeError(`TinySmartScroller: 'target' must be a DOM Element or 'window', but got ${typeof target}`);
|
|
284
289
|
// === extraScrollBoundary ===
|
|
285
290
|
if (typeof extraScrollBoundary !== 'number' || Number.isNaN(extraScrollBoundary))
|
|
@@ -304,7 +309,8 @@ class TinySmartScroller {
|
|
|
304
309
|
if (!isValidAttrList)
|
|
305
310
|
throw new TypeError(`TinySmartScroller: 'attributeFilter' must be an array, Set, or null. Got ${typeof attributeFilter}`);
|
|
306
311
|
// Start values
|
|
307
|
-
this.#target = target
|
|
312
|
+
this.#target = target;
|
|
313
|
+
this.#targetElement = target instanceof Window ? document.documentElement : target;
|
|
308
314
|
this.#useWindow = target instanceof Window;
|
|
309
315
|
this.#autoScrollBottom = autoScrollBottom;
|
|
310
316
|
this.#observeMutations = observeMutations;
|
|
@@ -321,13 +327,13 @@ class TinySmartScroller {
|
|
|
321
327
|
clearTimeout(timeout);
|
|
322
328
|
timeout = setTimeout(() => this._onScroll(), this.#debounceTime);
|
|
323
329
|
};
|
|
324
|
-
(this.#useWindow ? window : this.#
|
|
330
|
+
(this.#useWindow ? window : this.#targetElement).addEventListener('scroll', this.#handler, {
|
|
325
331
|
passive: true,
|
|
326
332
|
});
|
|
327
333
|
// Mutations
|
|
328
334
|
if (this.#observeMutations) {
|
|
329
335
|
this._observeMutations();
|
|
330
|
-
this._observeResizes(this.#
|
|
336
|
+
this._observeResizes(this.#targetElement.children);
|
|
331
337
|
}
|
|
332
338
|
this._scrollDataUpdater();
|
|
333
339
|
}
|
|
@@ -502,10 +508,10 @@ class TinySmartScroller {
|
|
|
502
508
|
*/
|
|
503
509
|
_scrollDataUpdater() {
|
|
504
510
|
const results = new Map();
|
|
505
|
-
this.#
|
|
511
|
+
this.#targetElement.querySelectorAll(this.#querySelector || '*').forEach((target) => {
|
|
506
512
|
const oldIsVisible = this.#newVisibles.get(target) ?? false;
|
|
507
513
|
this.#oldVisibles.set(target, oldIsVisible);
|
|
508
|
-
const isVisible = TinyHtml.isInContainer(this.#
|
|
514
|
+
const isVisible = TinyHtml.isInContainer(this.#targetElement, target);
|
|
509
515
|
this.#newVisibles.set(target, isVisible);
|
|
510
516
|
results.set(target, { oldIsVisible, isVisible });
|
|
511
517
|
});
|
|
@@ -519,7 +525,7 @@ class TinySmartScroller {
|
|
|
519
525
|
return;
|
|
520
526
|
// Get values
|
|
521
527
|
const scrollCache = this._scrollDataUpdater();
|
|
522
|
-
const el = this.#
|
|
528
|
+
const el = this.#targetElement;
|
|
523
529
|
const scrollTop = el.scrollTop;
|
|
524
530
|
const scrollHeight = el.scrollHeight;
|
|
525
531
|
const clientHeight = el.clientHeight;
|
|
@@ -576,11 +582,13 @@ class TinySmartScroller {
|
|
|
576
582
|
if (!Array.isArray(targets))
|
|
577
583
|
throw new TypeError('_fixScroll: targets must be an array of Elements');
|
|
578
584
|
// Get Scroll data
|
|
579
|
-
const prevScrollHeight = this.#
|
|
580
|
-
const prevScrollTop = this.#
|
|
581
|
-
const prevBottomOffset = this.#
|
|
585
|
+
const prevScrollHeight = this.#targetElement.scrollHeight;
|
|
586
|
+
const prevScrollTop = this.#targetElement.scrollTop;
|
|
587
|
+
const prevBottomOffset = this.#targetElement.scrollHeight -
|
|
588
|
+
this.#targetElement.scrollTop -
|
|
589
|
+
this.#targetElement.clientHeight;
|
|
582
590
|
// Get new size
|
|
583
|
-
const newScrollHeight = this.#
|
|
591
|
+
const newScrollHeight = this.#targetElement.scrollHeight;
|
|
584
592
|
const heightDelta = newScrollHeight - prevScrollHeight;
|
|
585
593
|
/** @type {() => NodeSizes} */
|
|
586
594
|
const calculateScrollSize = () => {
|
|
@@ -618,16 +626,16 @@ class TinySmartScroller {
|
|
|
618
626
|
};
|
|
619
627
|
// Fix scroll size
|
|
620
628
|
if (this.#elemOldAmount > 0 &&
|
|
621
|
-
TinyHtml.hasScroll(this.#
|
|
629
|
+
TinyHtml.hasScroll(this.#targetElement).v &&
|
|
622
630
|
this.#autoScrollBottom &&
|
|
623
631
|
this.#preserveScrollOnLayoutShift &&
|
|
624
632
|
!this.#isAtBottom &&
|
|
625
633
|
!this.#isAtTop) {
|
|
626
634
|
const scrollSize = calculateScrollSize();
|
|
627
635
|
// Complete
|
|
628
|
-
this.#
|
|
636
|
+
this.#targetElement.scrollTop = prevScrollTop + heightDelta + scrollSize.height;
|
|
629
637
|
if (scrollSize.width > 0)
|
|
630
|
-
this.#
|
|
638
|
+
this.#targetElement.scrollLeft = this.#targetElement.scrollLeft + scrollSize.width;
|
|
631
639
|
}
|
|
632
640
|
// Normal stuff
|
|
633
641
|
else if (!this.#scrollPaused && this.#autoScrollBottom) {
|
|
@@ -636,8 +644,8 @@ class TinySmartScroller {
|
|
|
636
644
|
}
|
|
637
645
|
else if (!this.#autoScrollBottom && !this.#isAtBottom) {
|
|
638
646
|
calculateScrollSize();
|
|
639
|
-
this.#
|
|
640
|
-
this.#
|
|
647
|
+
this.#targetElement.scrollTop =
|
|
648
|
+
this.#targetElement.scrollHeight - this.#targetElement.clientHeight - prevBottomOffset;
|
|
641
649
|
}
|
|
642
650
|
}
|
|
643
651
|
/**
|
|
@@ -649,7 +657,7 @@ class TinySmartScroller {
|
|
|
649
657
|
return;
|
|
650
658
|
this._scrollDataUpdater();
|
|
651
659
|
this.#elemOldAmount = this.#elemAmount;
|
|
652
|
-
this.#elemAmount = this.#
|
|
660
|
+
this.#elemAmount = this.#targetElement.childElementCount;
|
|
653
661
|
mutations.forEach((mutation) => {
|
|
654
662
|
mutation.addedNodes.forEach((node) => {
|
|
655
663
|
if (!(node instanceof Element) || node.nodeType !== 1)
|
|
@@ -666,7 +674,7 @@ class TinySmartScroller {
|
|
|
666
674
|
this._fixScroll();
|
|
667
675
|
});
|
|
668
676
|
// Install observer
|
|
669
|
-
this.#mutationObserver.observe(this.#
|
|
677
|
+
this.#mutationObserver.observe(this.#targetElement, {
|
|
670
678
|
childList: true,
|
|
671
679
|
subtree: true,
|
|
672
680
|
attributes: true,
|
|
@@ -733,13 +741,14 @@ class TinySmartScroller {
|
|
|
733
741
|
}
|
|
734
742
|
});
|
|
735
743
|
}
|
|
744
|
+
get target() {
|
|
745
|
+
return this.#target;
|
|
746
|
+
}
|
|
736
747
|
/**
|
|
737
748
|
* Returns the internal scroll container element being monitored.
|
|
738
|
-
*
|
|
739
|
-
* @returns {Element} The DOM element used as the scroll container target.
|
|
740
749
|
*/
|
|
741
|
-
get
|
|
742
|
-
return this.#
|
|
750
|
+
get targetElement() {
|
|
751
|
+
return this.#targetElement;
|
|
743
752
|
}
|
|
744
753
|
/**
|
|
745
754
|
* Returns the previous size of a given element, or undefined if not tracked.
|
|
@@ -825,13 +834,13 @@ class TinySmartScroller {
|
|
|
825
834
|
* Forces the scroll position to move to the very bottom of the target.
|
|
826
835
|
*/
|
|
827
836
|
scrollToBottom() {
|
|
828
|
-
this.#
|
|
837
|
+
this.#targetElement.scrollTop = this.#targetElement.scrollHeight;
|
|
829
838
|
}
|
|
830
839
|
/**
|
|
831
840
|
* Forces the scroll position to move to the very top of the target.
|
|
832
841
|
*/
|
|
833
842
|
scrollToTop() {
|
|
834
|
-
this.#
|
|
843
|
+
this.#targetElement.scrollTop = 0;
|
|
835
844
|
}
|
|
836
845
|
/**
|
|
837
846
|
* Checks if the user is within the defined extra scroll boundary from the bottom.
|
|
@@ -996,7 +1005,7 @@ class TinySmartScroller {
|
|
|
996
1005
|
this.#resizeObserver = null;
|
|
997
1006
|
}
|
|
998
1007
|
// Removes scroll listener
|
|
999
|
-
const target = this.#useWindow ? window : this.#
|
|
1008
|
+
const target = this.#useWindow ? window : this.#targetElement;
|
|
1000
1009
|
if (this.#handler)
|
|
1001
1010
|
target.removeEventListener('scroll', this.#handler);
|
|
1002
1011
|
// Clean the WeakMaps
|
|
@@ -160,23 +160,23 @@ export type MsgGenConfig = {
|
|
|
160
160
|
*/
|
|
161
161
|
declare class UltraRandomMsgGen {
|
|
162
162
|
/** @type {string[]} */
|
|
163
|
-
static
|
|
163
|
+
static #defaultWords: string[];
|
|
164
164
|
/** @type {string[]} */
|
|
165
|
-
static
|
|
165
|
+
static #defaultEmojis: string[];
|
|
166
166
|
/** @type {string[]} */
|
|
167
|
-
static
|
|
167
|
+
static #defaultNouns: string[];
|
|
168
168
|
/** @type {string[]} */
|
|
169
|
-
static
|
|
169
|
+
static #defaultVerbs: string[];
|
|
170
170
|
/** @type {string[]} */
|
|
171
|
-
static
|
|
171
|
+
static #defaultAdjectives: string[];
|
|
172
172
|
/** @type {string[]} */
|
|
173
|
-
static
|
|
173
|
+
static #defaultTemplates: string[];
|
|
174
174
|
/**
|
|
175
175
|
* Utility to validate arrays before setting.
|
|
176
176
|
* @param {any} value
|
|
177
177
|
* @param {string} field
|
|
178
178
|
*/
|
|
179
|
-
static
|
|
179
|
+
static #validateArray(value: any, field: string): void;
|
|
180
180
|
/** @param {string[]} value */
|
|
181
181
|
static set defaultWords(value: string[]);
|
|
182
182
|
/** @returns {string[]} */
|
package/docs/v1/README.md
CHANGED
|
@@ -20,6 +20,7 @@ Here, you can navigate through different sections of the project. Below are the
|
|
|
20
20
|
- 🖼️ **[Html](./basics/html.md)** — Utilities for handling DOM element interactions like collision detection and basic element manipulation.
|
|
21
21
|
- 📺 **[FullScreen](./basics/fullScreen.md)** — A complete fullscreen API manager with detection, event handling, and cross-browser compatibility.
|
|
22
22
|
- 🧱 **[Collision](./basics/collision.md)** — Full-featured rectangle collision detection system with directional analysis, depth calculation, and center offset metrics.
|
|
23
|
+
- 🎵 **[MediaContent](./basics/mediaContent.md)** — A comprehensive media processing module for downloading audio, extracting rich ID3 metadata, and managing image blobs for album art.
|
|
23
24
|
|
|
24
25
|
### 2. **`libs/`**
|
|
25
26
|
- 🗂️ **[TinyPromiseQueue](./libs/TinyPromiseQueue.md)** — A class that allows sequential execution of asynchronous tasks, supporting task delays, cancellation, and queue management.
|
|
@@ -62,7 +63,12 @@ Here, you can navigate through different sections of the project. Below are the
|
|
|
62
63
|
* 🕒 **[TinyAnalogClock](./libs/TinyAnalogClock.md)** — A lightweight analog clock engine for managing time-based rotations, supporting custom offsets, smooth transitions, and easy binding to CSS variables rendering.
|
|
63
64
|
* 🔍 **[TinyArrayComparator](./libs/TinyArrayComparator.md)** — A lightweight, highly optimized JavaScript utility class designed to compare two arrays and efficiently detect which items were **added** or **deleted**.
|
|
64
65
|
* 🧠 **[TinyMamdaniInferenceSystem](./libs/TinyMamdaniInferenceSystem.md)** — A implementation of a Mamdani Inference System, allowing you to model logic using trapezoidal membership functions.
|
|
66
|
+
* ⏯️ **[TinyMediaPlayer](./libs/TinyMediaPlayer.md)** — A universal media player architecture utilizing an adapter pattern to orchestrate multiple platform APIs, featuring robust playlist management, playback controls, and weighted random selection.
|
|
67
|
+
|
|
68
|
+
### 2.1. **`libs/TinyClassManager`**
|
|
69
|
+
|
|
65
70
|
* ⚙️ **[TinyClassManager](./libs/TinyClassManager.md)** — A lightweight, immutable manager designed to linearly compose a base class with multiple modular plugins, featuring automatic dependency verification and duplicate conflict protection.
|
|
71
|
+
* 🛠️ **[TinyPluginInliner](./libs/TinyClassManager/TinyPluginInliner.md)** — A powerful build-time utility that inlines plugin code into a single bundle, automatically rewriting import paths and hoisting dependencies for seamless deployment.
|
|
66
72
|
|
|
67
73
|
### 3. **`fileManager/`**
|
|
68
74
|
* 📁 **[Main](./fileManager/main.md)** — A Node.js file/directory utility module with support for JSON, backups, renaming, size analysis, and more.
|