tiny-essentials 1.27.1 → 1.28.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.
Files changed (188) hide show
  1. package/README.md +1 -0
  2. package/changelog/1/28/0.md +16 -0
  3. package/changelog/1/28/1.md +23 -0
  4. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  5. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  6. package/dist/v1/TinyAnalogClock.min.js +1 -1
  7. package/dist/v1/TinyBasicsEs.min.js +1 -2
  8. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  9. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  10. package/dist/v1/TinyDragger.min.js +1 -1
  11. package/dist/v1/TinyElementObserver.min.js +1 -1
  12. package/dist/v1/TinyEssentials.min.js +1 -2
  13. package/dist/v1/TinyGamepad.min.js +1 -1
  14. package/dist/v1/TinyHtml.min.js +1 -1
  15. package/dist/v1/TinyI18.min.js +1 -1
  16. package/dist/v1/TinyIframeEvents.min.js +1 -1
  17. package/dist/v1/TinyLocalStorage.min.js +1 -1
  18. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  19. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  20. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  21. package/dist/v1/TinyRadioFm.min.js +1 -1
  22. package/dist/v1/TinyRateLimiter.min.js +1 -1
  23. package/dist/v1/TinySmartScroller.min.js +1 -1
  24. package/dist/v1/TinyTextDiffer.min.js +1 -1
  25. package/dist/v1/TinyTextarea.min.js +1 -1
  26. package/dist/v1/TinyTimeout.min.js +1 -1
  27. package/dist/v1/TinyToastNotify.min.js +1 -1
  28. package/dist/v1/TinyUploadClicker.min.js +1 -2
  29. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  30. package/dist/v1/basics/array.cjs +57 -9
  31. package/dist/v1/basics/array.d.mts +27 -11
  32. package/dist/v1/basics/array.mjs +51 -9
  33. package/dist/v1/basics/clock.cjs +94 -42
  34. package/dist/v1/basics/clock.d.mts +10 -10
  35. package/dist/v1/basics/clock.mjs +91 -54
  36. package/dist/v1/basics/deprecated/html.cjs +246 -0
  37. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  38. package/dist/v1/basics/deprecated/html.mjs +190 -0
  39. package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
  40. package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
  41. package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
  42. package/dist/v1/basics/html.cjs +149 -130
  43. package/dist/v1/basics/html.d.mts +26 -61
  44. package/dist/v1/basics/html.mjs +113 -105
  45. package/dist/v1/basics/index.cjs +2 -0
  46. package/dist/v1/basics/index.d.mts +3 -1
  47. package/dist/v1/basics/index.mjs +3 -3
  48. package/dist/v1/basics/mediaContent.cjs +51 -9
  49. package/dist/v1/basics/mediaContent.d.mts +0 -87
  50. package/dist/v1/basics/mediaContent.mjs +40 -10
  51. package/dist/v1/basics/objChecker.cjs +7 -5
  52. package/dist/v1/basics/objChecker.d.mts +3 -2
  53. package/dist/v1/basics/objChecker.mjs +6 -6
  54. package/dist/v1/basics/objFilter.cjs +40 -18
  55. package/dist/v1/basics/objFilter.d.mts +6 -6
  56. package/dist/v1/basics/objFilter.mjs +32 -17
  57. package/dist/v1/basics/simpleMath.cjs +81 -25
  58. package/dist/v1/basics/simpleMath.d.mts +2 -2
  59. package/dist/v1/basics/simpleMath.mjs +70 -27
  60. package/dist/v1/basics/text.cjs +76 -31
  61. package/dist/v1/basics/text.d.mts +69 -7
  62. package/dist/v1/basics/text.mjs +62 -31
  63. package/dist/v1/index.cjs +4 -2
  64. package/dist/v1/index.d.mts +4 -2
  65. package/dist/v1/index.mjs +4 -4
  66. package/dist/v1/libs/TinyAdvancedRaffle.cjs +71 -255
  67. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +6 -134
  68. package/dist/v1/libs/TinyAdvancedRaffle.mjs +69 -228
  69. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  70. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
  71. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  72. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  73. package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
  74. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  75. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  76. package/dist/v1/libs/TinyClipboard.d.mts +4 -2
  77. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  78. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  79. package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
  80. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  81. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  82. package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
  83. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  84. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  85. package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
  86. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  87. package/dist/v1/libs/TinyDragger.cjs +46 -19
  88. package/dist/v1/libs/TinyDragger.mjs +45 -18
  89. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  90. package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
  91. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  92. package/dist/v1/libs/TinyGamepad.cjs +131 -1
  93. package/dist/v1/libs/TinyGamepad.mjs +129 -1
  94. package/dist/v1/libs/TinyHtml.cjs +1 -1
  95. package/dist/v1/libs/TinyHtml.mjs +2 -2
  96. package/dist/v1/libs/TinyI18.cjs +61 -0
  97. package/dist/v1/libs/TinyI18.d.mts +14 -0
  98. package/dist/v1/libs/TinyI18.mjs +55 -0
  99. package/dist/v1/libs/TinyIframeEvents.cjs +26 -196
  100. package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
  101. package/dist/v1/libs/TinyIframeEvents.mjs +26 -171
  102. package/dist/v1/libs/TinyLocalStorage.cjs +53 -205
  103. package/dist/v1/libs/TinyLocalStorage.d.mts +6 -127
  104. package/dist/v1/libs/TinyLocalStorage.mjs +50 -178
  105. package/dist/v1/libs/TinyMediaPlayer.cjs +74 -2
  106. package/dist/v1/libs/TinyMediaPlayer.d.mts +12 -2
  107. package/dist/v1/libs/TinyMediaPlayer.mjs +68 -2
  108. package/dist/v1/libs/TinyNewWinEvents.cjs +39 -197
  109. package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -119
  110. package/dist/v1/libs/TinyNewWinEvents.mjs +36 -172
  111. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  112. package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
  113. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  114. package/dist/v1/libs/TinyRadioFm.cjs +40 -3
  115. package/dist/v1/libs/TinyRadioFm.d.mts +3 -3
  116. package/dist/v1/libs/TinyRadioFm.mjs +37 -3
  117. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  118. package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
  119. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  120. package/dist/v1/libs/TinySmartScroller.cjs +56 -205
  121. package/dist/v1/libs/TinySmartScroller.d.mts +19 -152
  122. package/dist/v1/libs/TinySmartScroller.mjs +55 -181
  123. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  124. package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
  125. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  126. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  127. package/dist/v1/libs/TinyTextarea.d.mts +6 -0
  128. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  129. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  130. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  131. package/dist/v1/libs/TinyToastNotify.cjs +35 -0
  132. package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
  133. package/dist/v1/libs/TinyToastNotify.mjs +31 -0
  134. package/dist/v1/libs/TinyUploadClicker.cjs +20 -0
  135. package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
  136. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  137. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  138. package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
  139. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  140. package/dist/v1/libs/utils.cjs +21 -0
  141. package/dist/v1/libs/utils.d.mts +2 -0
  142. package/dist/v1/libs/utils.mjs +16 -0
  143. package/docs/v1/Exports.md +0 -1
  144. package/docs/v1/README.md +1 -1
  145. package/docs/v1/basics/array.md +2 -2
  146. package/docs/v1/basics/deprecated/html.md +17 -0
  147. package/docs/v1/basics/fullScreen.md +1 -1
  148. package/docs/v1/basics/html.md +12 -26
  149. package/docs/v1/basics/mediaContent.md +1 -1
  150. package/docs/v1/basics/objChecker.md +1 -1
  151. package/docs/v1/basics/objFilter.md +1 -1
  152. package/docs/v1/basics/text.md +2 -2
  153. package/docs/v1/fileManager/main.md +1 -1
  154. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  155. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  156. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  157. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  158. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  159. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  160. package/docs/v1/libs/TinyClassManager.md +1 -1
  161. package/docs/v1/libs/TinyClipboard.md +1 -1
  162. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  163. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  164. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  165. package/docs/v1/libs/TinyDragger.md +1 -1
  166. package/docs/v1/libs/TinyElementObserver.md +1 -1
  167. package/docs/v1/libs/TinyHtml.md +1 -1
  168. package/docs/v1/libs/TinyIframeEvents.md +10 -10
  169. package/docs/v1/libs/TinyLevelUp.md +1 -1
  170. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  171. package/docs/v1/libs/TinyLocalStorage.md +3 -3
  172. package/docs/v1/libs/TinyNewWinEvents.md +10 -11
  173. package/docs/v1/libs/TinyNotifications.md +1 -1
  174. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  175. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  176. package/docs/v1/libs/TinyTextarea.md +1 -1
  177. package/package.json +15 -5
  178. package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
  179. package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
  180. package/dist/v1/TinyEvents.min.js +0 -1
  181. package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
  182. package/dist/v1/build/TinyEvents.cjs +0 -7
  183. package/dist/v1/build/TinyEvents.d.mts +0 -3
  184. package/dist/v1/build/TinyEvents.mjs +0 -2
  185. package/dist/v1/libs/TinyEvents.cjs +0 -395
  186. package/dist/v1/libs/TinyEvents.d.mts +0 -164
  187. package/dist/v1/libs/TinyEvents.mjs +0 -360
  188. package/docs/v1/libs/TinyEvents.md +0 -187
@@ -1,8 +1,11 @@
1
1
  'use strict';
2
2
 
3
+ var events = require('events');
3
4
  var TinyHtml = require('./TinyHtml.cjs');
4
5
  var collision = require('../basics/collision.cjs');
5
- var TinyEvents = require('./TinyEvents.cjs');
6
+ var utils = require('./utils.cjs');
7
+
8
+ const checkDestroy = utils.createCheckDestroyed('TinySmartScroller');
6
9
 
7
10
  /**
8
11
  * Represents the dimensions of a DOM element.
@@ -48,208 +51,9 @@ var TinyEvents = require('./TinyEvents.cjs');
48
51
  * This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
49
52
  * @template {Element|Window} HTMLTarget
50
53
  */
51
- class TinySmartScroller {
54
+ class TinySmartScroller extends events.EventEmitter {
52
55
  static Utils = { ...collision, TinyHtml };
53
56
 
54
- #events = new TinyEvents();
55
-
56
- /**
57
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
58
- *
59
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
60
- */
61
- setThrowOnMaxListeners(shouldThrow) {
62
- return this.#events.setThrowOnMaxListeners(shouldThrow);
63
- }
64
-
65
- /**
66
- * Checks whether an error will be thrown when the max listener limit is exceeded.
67
- *
68
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
69
- */
70
- getThrowOnMaxListeners() {
71
- return this.#events.getThrowOnMaxListeners();
72
- }
73
-
74
- /////////////////////////////////////////////////////////////
75
-
76
- /**
77
- * Adds a listener to the beginning of the listeners array for the specified event.
78
- *
79
- * @param {string|string[]} event - Event name.
80
- * @param {ScrollListenersFunc} handler - The callback function.
81
- */
82
- prependListener(event, handler) {
83
- return this.#events.prependListener(event, handler);
84
- }
85
-
86
- /**
87
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
88
- *
89
- * @param {string|string[]} event - Event name.
90
- * @param {ScrollListenersFunc} handler - The callback function.
91
- * @returns {ScrollListenersFunc[]} - The wrapped handler used internally.
92
- */
93
- prependListenerOnce(event, handler) {
94
- return this.#events.prependListenerOnce(event, handler);
95
- }
96
-
97
- //////////////////////////////////////////////////////////////////////
98
-
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
- appendListener(event, handler) {
106
- return this.#events.appendListener(event, handler);
107
- }
108
-
109
- /**
110
- * Registers an event listener that runs only once, then is removed.
111
- *
112
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
113
- * @param {ScrollListenersFunc} handler - The callback function to run on event.
114
- * @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
115
- */
116
- appendListenerOnce(event, handler) {
117
- return this.#events.appendListenerOnce(event, handler);
118
- }
119
-
120
- /**
121
- * Adds a event listener.
122
- *
123
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
124
- * @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
125
- */
126
- on(event, handler) {
127
- return this.#events.on(event, handler);
128
- }
129
-
130
- /**
131
- * Registers an event listener that runs only once, then is removed.
132
- *
133
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
134
- * @param {ScrollListenersFunc} handler - The callback function to run on event.
135
- * @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
136
- */
137
- once(event, handler) {
138
- return this.#events.once(event, handler);
139
- }
140
-
141
- ////////////////////////////////////////////////////////////////////
142
-
143
- /**
144
- * Removes a previously registered event listener.
145
- *
146
- * @param {string|string[]} event - The name of the event to remove the handler from.
147
- * @param {ScrollListenersFunc} handler - The specific callback function to remove.
148
- */
149
- off(event, handler) {
150
- return this.#events.off(event, handler);
151
- }
152
-
153
- /**
154
- * Removes all event listeners of a specific type from the element.
155
- *
156
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
157
- */
158
- offAll(event) {
159
- return this.#events.offAll(event);
160
- }
161
-
162
- /**
163
- * Removes all event listeners of all types from the element.
164
- */
165
- offAllTypes() {
166
- return this.#events.offAllTypes();
167
- }
168
-
169
- ////////////////////////////////////////////////////////////
170
-
171
- /**
172
- * Returns the number of listeners for a given event.
173
- *
174
- * @param {string} event - The name of the event.
175
- * @returns {number} Number of listeners for the event.
176
- */
177
- listenerCount(event) {
178
- return this.#events.listenerCount(event);
179
- }
180
-
181
- /**
182
- * Returns a copy of the array of listeners for the specified event.
183
- *
184
- * @param {string} event - The name of the event.
185
- * @returns {ScrollListenersFunc[]} Array of listener functions.
186
- */
187
- listeners(event) {
188
- return this.#events.listeners(event);
189
- }
190
-
191
- /**
192
- * Returns a copy of the array of listeners for the specified event.
193
- *
194
- * @param {string} event - The name of the event.
195
- * @returns {ScrollListenersFunc[]} Array of listener functions.
196
- */
197
- onceListeners(event) {
198
- return this.#events.onceListeners(event);
199
- }
200
-
201
- /**
202
- * Returns a copy of the internal listeners array for the specified event,
203
- * including wrapper functions like those used by `.once()`.
204
- * @param {string | symbol} event - The event name.
205
- * @returns {ScrollListenersFunc[]} An array of raw listener functions.
206
- */
207
- allListeners(event) {
208
- return this.#events.allListeners(event);
209
- }
210
-
211
- /**
212
- * Returns an array of event names for which there are registered listeners.
213
- *
214
- * @returns {string[]} Array of registered event names.
215
- */
216
- eventNames() {
217
- return this.#events.eventNames();
218
- }
219
-
220
- //////////////////////////////////////////////////////
221
-
222
- /**
223
- * Emits an event, triggering all registered handlers for that event.
224
- *
225
- * @param {string} event - The event name to emit.
226
- * @param {...any} payload - Optional data to pass to each handler.
227
- * @returns {boolean[]} True if any listeners were called, false otherwise.
228
- */
229
- emit(event, ...payload) {
230
- return this.#events.emit(event, ...payload);
231
- }
232
-
233
- /**
234
- * Sets the maximum number of listeners per event before a warning is shown.
235
- *
236
- * @param {number} n - The maximum number of listeners.
237
- */
238
- setMaxListeners(n) {
239
- return this.#events.setMaxListeners(n);
240
- }
241
-
242
- /**
243
- * Gets the maximum number of listeners allowed per event.
244
- *
245
- * @returns {number} The maximum number of listeners.
246
- */
247
- getMaxListeners() {
248
- return this.#events.getMaxListeners();
249
- }
250
-
251
- ///////////////////////////////////////////////////
252
-
253
57
  /** @type {WeakMap<Element, NodeSizes>} */
254
58
  #oldSizes = new WeakMap();
255
59
  /** @type {WeakMap<Element, NodeSizes>} */
@@ -338,6 +142,7 @@ class TinySmartScroller {
338
142
  attributeFilter = ['class', 'style', 'src', 'data-*', 'height', 'width'],
339
143
  } = {},
340
144
  ) {
145
+ super();
341
146
  // === target ===
342
147
  if (!(
343
148
  target instanceof Element ||
@@ -425,6 +230,7 @@ class TinySmartScroller {
425
230
  * @returns {NodeSizesEvent} A function that compares previous and current height, returning height delta.
426
231
  */
427
232
  getSimpleOnHeight(filter = []) {
233
+ checkDestroy(this.#destroyed);
428
234
  if (!Array.isArray(filter))
429
235
  throw new TypeError('getSimpleOnHeight(filter): filter must be an array of tag names');
430
236
  return (elem, sizes, amounts) => {
@@ -444,6 +250,7 @@ class TinySmartScroller {
444
250
  * @returns {NodeSizesEvent} The added size difference callback.
445
251
  */
446
252
  addSimpleOnHeight(filter) {
253
+ checkDestroy(this.#destroyed);
447
254
  if (!Array.isArray(filter))
448
255
  throw new TypeError('addSimpleOnHeight(filter): filter must be an array of tag names');
449
256
  const result = this.getSimpleOnHeight(filter);
@@ -457,6 +264,7 @@ class TinySmartScroller {
457
264
  * @returns {string[]} Array of tag names.
458
265
  */
459
266
  getLoadTags() {
267
+ checkDestroy(this.#destroyed);
460
268
  return Array.from(this.#loadTags);
461
269
  }
462
270
 
@@ -466,6 +274,7 @@ class TinySmartScroller {
466
274
  * @param {string} tag - The tag name to add (e.g., 'IMG').
467
275
  */
468
276
  addLoadTag(tag) {
277
+ checkDestroy(this.#destroyed);
469
278
  if (typeof tag !== 'string') throw new TypeError('addLoadTag(tag): tag must be a string');
470
279
  this.#loadTags.add(tag.toUpperCase());
471
280
  }
@@ -476,6 +285,7 @@ class TinySmartScroller {
476
285
  * @param {string} tag - The tag name to remove.
477
286
  */
478
287
  removeLoadTag(tag) {
288
+ checkDestroy(this.#destroyed);
479
289
  if (typeof tag !== 'string') throw new TypeError('removeLoadTag(tag): tag must be a string');
480
290
  this.#loadTags.delete(tag.toUpperCase());
481
291
  }
@@ -487,6 +297,7 @@ class TinySmartScroller {
487
297
  * @returns {boolean} True if the tag is being tracked.
488
298
  */
489
299
  hasLoadTag(tag) {
300
+ checkDestroy(this.#destroyed);
490
301
  if (typeof tag !== 'string') throw new TypeError('hasLoadTag(tag): tag must be a string');
491
302
  return this.#loadTags.has(tag.toUpperCase());
492
303
  }
@@ -498,6 +309,7 @@ class TinySmartScroller {
498
309
  * @throws {TypeError} If `addDefault` is not a boolean.
499
310
  */
500
311
  resetLoadTags(addDefault = false) {
312
+ checkDestroy(this.#destroyed);
501
313
  if (typeof addDefault !== 'boolean')
502
314
  throw new TypeError('resetLoadTags(addDefault): addDefault must be a boolean');
503
315
  this.#loadTags.clear();
@@ -513,6 +325,7 @@ class TinySmartScroller {
513
325
  * @returns {string[]} Array of attribute names.
514
326
  */
515
327
  getAttributeFilters() {
328
+ checkDestroy(this.#destroyed);
516
329
  return Array.from(this.#attributeFilter);
517
330
  }
518
331
 
@@ -522,6 +335,7 @@ class TinySmartScroller {
522
335
  * @param {string} attr - The attribute name to add.
523
336
  */
524
337
  addAttributeFilter(attr) {
338
+ checkDestroy(this.#destroyed);
525
339
  if (typeof attr !== 'string')
526
340
  throw new TypeError('addAttributeFilter(attr): attr must be a string');
527
341
  this.#attributeFilter.add(attr);
@@ -533,6 +347,7 @@ class TinySmartScroller {
533
347
  * @param {string} attr - The attribute name to remove.
534
348
  */
535
349
  removeAttributeFilter(attr) {
350
+ checkDestroy(this.#destroyed);
536
351
  if (typeof attr !== 'string')
537
352
  throw new TypeError('removeAttributeFilter(attr): attr must be a string');
538
353
  this.#attributeFilter.delete(attr);
@@ -545,6 +360,7 @@ class TinySmartScroller {
545
360
  * @returns {boolean} True if the attribute is being filtered.
546
361
  */
547
362
  hasAttributeFilter(attr) {
363
+ checkDestroy(this.#destroyed);
548
364
  if (typeof attr !== 'string')
549
365
  throw new TypeError('hasAttributeFilter(attr): attr must be a string');
550
366
  return this.#attributeFilter.has(attr);
@@ -558,6 +374,7 @@ class TinySmartScroller {
558
374
  * @throws {TypeError} If `addDefault` is not a boolean.
559
375
  */
560
376
  resetAttributeFilters(addDefault = false) {
377
+ checkDestroy(this.#destroyed);
561
378
  if (typeof addDefault !== 'boolean')
562
379
  throw new TypeError('resetAttributeFilters(addDefault): addDefault must be a boolean');
563
380
  this.#attributeFilter.clear();
@@ -573,7 +390,7 @@ class TinySmartScroller {
573
390
  * @param {NodeSizesEvent} handler - Function that compares old and new sizes.
574
391
  */
575
392
  onSize(handler) {
576
- if (this.#destroyed) return;
393
+ checkDestroy(this.#destroyed);
577
394
  if (typeof handler !== 'function')
578
395
  throw new TypeError('onSize(handler): handler must be a function');
579
396
  this.#sizeFilter.add(handler);
@@ -585,7 +402,7 @@ class TinySmartScroller {
585
402
  * @param {NodeSizesEvent} handler - The handler function to remove.
586
403
  */
587
404
  offSize(handler) {
588
- if (this.#destroyed) return;
405
+ checkDestroy(this.#destroyed);
589
406
  if (typeof handler !== 'function')
590
407
  throw new TypeError('offSize(handler): handler must be a function');
591
408
  this.#sizeFilter.delete(handler);
@@ -595,6 +412,7 @@ class TinySmartScroller {
595
412
  * Checks which elements inside the target are currently visible and updates internal maps.
596
413
  *
597
414
  * @returns {Map<Element, { oldIsVisible: boolean; isVisible: boolean }>} Visibility comparison results.
415
+ * @private
598
416
  */
599
417
  _scrollDataUpdater() {
600
418
  const results = new Map();
@@ -612,6 +430,7 @@ class TinySmartScroller {
612
430
 
613
431
  /**
614
432
  * Handles scroll events, calculates position-related statuses, and emits appropriate events.
433
+ * @private
615
434
  */
616
435
  _onScroll() {
617
436
  if (this.#destroyed) return;
@@ -673,6 +492,7 @@ class TinySmartScroller {
673
492
  * Attempts to correct the scroll position when layout shifts happen, preserving the user position if needed.
674
493
  *
675
494
  * @param {Element[]} [targets=[]] - List of elements involved in the size change.
495
+ * @private
676
496
  */
677
497
  _fixScroll(targets = []) {
678
498
  if (this.#destroyed) return;
@@ -762,6 +582,7 @@ class TinySmartScroller {
762
582
  }
763
583
  /**
764
584
  * Sets up a MutationObserver to watch for DOM changes and react accordingly to maintain scroll consistency.
585
+ * @private
765
586
  */
766
587
  _observeMutations() {
767
588
  this.#mutationObserver = new MutationObserver((mutations) => {
@@ -802,6 +623,7 @@ class TinySmartScroller {
802
623
  * Adds a ResizeObserver to monitor elements' size changes and trigger layout adjustments.
803
624
  *
804
625
  * @param {NodeListOf<Element>|Element[]|HTMLCollection} elements - Elements to observe.
626
+ * @private
805
627
  */
806
628
  _observeResizes(elements) {
807
629
  // Add resize observer
@@ -842,6 +664,7 @@ class TinySmartScroller {
842
664
  * Listens for media/content load events (e.g., images, iframes, videos) to trigger scroll updates.
843
665
  *
844
666
  * @param {NodeListOf<Element>|Element} elements - Target element(s) to listen on.
667
+ * @private
845
668
  */
846
669
  _listenLoadEvents(elements) {
847
670
  if (this.#destroyed) return;
@@ -880,6 +703,7 @@ class TinySmartScroller {
880
703
  * @returns {NodeSizes|null} The old size, or undefined.
881
704
  */
882
705
  getOldSize(el) {
706
+ checkDestroy(this.#destroyed);
883
707
  return this.#oldSizes.get(el) ?? null;
884
708
  }
885
709
 
@@ -890,6 +714,7 @@ class TinySmartScroller {
890
714
  * @returns {NodeSizes|null} The new size, or undefined.
891
715
  */
892
716
  getNewSize(el) {
717
+ checkDestroy(this.#destroyed);
893
718
  return this.#newSizes.get(el) ?? null;
894
719
  }
895
720
 
@@ -900,6 +725,7 @@ class TinySmartScroller {
900
725
  * @returns {boolean} True if visible, false if not, or undefined if not tracked.
901
726
  */
902
727
  wasVisible(el) {
728
+ checkDestroy(this.#destroyed);
903
729
  return this.#oldVisibles.get(el) ?? false;
904
730
  }
905
731
 
@@ -910,6 +736,7 @@ class TinySmartScroller {
910
736
  * @returns {boolean} True if visible, false if not, or undefined if not tracked.
911
737
  */
912
738
  isVisible(el) {
739
+ checkDestroy(this.#destroyed);
913
740
  return this.#newVisibles.get(el) ?? false;
914
741
  }
915
742
 
@@ -920,6 +747,7 @@ class TinySmartScroller {
920
747
  * @returns {boolean} Visibility state from the previous timed check.
921
748
  */
922
749
  wasTimedVisible(el) {
750
+ checkDestroy(this.#destroyed);
923
751
  return this.#oldVisiblesByTime.get(el) ?? false;
924
752
  }
925
753
 
@@ -930,6 +758,7 @@ class TinySmartScroller {
930
758
  * @returns {boolean} Visibility state from the current timed check.
931
759
  */
932
760
  isTimedVisible(el) {
761
+ checkDestroy(this.#destroyed);
933
762
  return this.#newVisiblesByTime.get(el) ?? false;
934
763
  }
935
764
 
@@ -939,6 +768,7 @@ class TinySmartScroller {
939
768
  * @param {number} value - Pixels of additional margin to use.
940
769
  */
941
770
  setExtraScrollBoundary(value) {
771
+ checkDestroy(this.#destroyed);
942
772
  if (typeof value !== 'number' || Number.isNaN(value))
943
773
  throw new TypeError('setExtraScrollBoundary(value): value must be a valid number');
944
774
  this.#extraScrollBoundary = value;
@@ -950,6 +780,7 @@ class TinySmartScroller {
950
780
  * @returns {number}
951
781
  */
952
782
  getExtraScrollBoundary() {
783
+ checkDestroy(this.#destroyed);
953
784
  return this.#extraScrollBoundary;
954
785
  }
955
786
 
@@ -959,6 +790,7 @@ class TinySmartScroller {
959
790
  * @returns {number}
960
791
  */
961
792
  getLastKnownScrollBottomOffset() {
793
+ checkDestroy(this.#destroyed);
962
794
  return this.#lastKnownScrollBottomOffset;
963
795
  }
964
796
 
@@ -966,6 +798,7 @@ class TinySmartScroller {
966
798
  * Forces the scroll position to move to the very bottom of the target.
967
799
  */
968
800
  scrollToBottom() {
801
+ checkDestroy(this.#destroyed);
969
802
  this.#targetElement.scrollTop = this.#targetElement.scrollHeight;
970
803
  }
971
804
 
@@ -973,6 +806,7 @@ class TinySmartScroller {
973
806
  * Forces the scroll position to move to the very top of the target.
974
807
  */
975
808
  scrollToTop() {
809
+ checkDestroy(this.#destroyed);
976
810
  this.#targetElement.scrollTop = 0;
977
811
  }
978
812
 
@@ -982,6 +816,7 @@ class TinySmartScroller {
982
816
  * @returns {boolean}
983
817
  */
984
818
  isAtCustomBottom() {
819
+ checkDestroy(this.#destroyed);
985
820
  return this.#isAtCustomBottom;
986
821
  }
987
822
 
@@ -991,6 +826,7 @@ class TinySmartScroller {
991
826
  * @returns {boolean}
992
827
  */
993
828
  isAtCustomTop() {
829
+ checkDestroy(this.#destroyed);
994
830
  return this.#isAtCustomTop;
995
831
  }
996
832
 
@@ -1000,6 +836,7 @@ class TinySmartScroller {
1000
836
  * @returns {boolean}
1001
837
  */
1002
838
  isAtBottom() {
839
+ checkDestroy(this.#destroyed);
1003
840
  return this.#isAtBottom;
1004
841
  }
1005
842
 
@@ -1009,6 +846,7 @@ class TinySmartScroller {
1009
846
  * @returns {boolean}
1010
847
  */
1011
848
  isAtTop() {
849
+ checkDestroy(this.#destroyed);
1012
850
  return this.#isAtTop;
1013
851
  }
1014
852
 
@@ -1018,6 +856,7 @@ class TinySmartScroller {
1018
856
  * @returns {boolean}
1019
857
  */
1020
858
  isPastAtBottom() {
859
+ checkDestroy(this.#destroyed);
1021
860
  return this.#isPastAtBottom;
1022
861
  }
1023
862
 
@@ -1027,6 +866,7 @@ class TinySmartScroller {
1027
866
  * @returns {boolean}
1028
867
  */
1029
868
  isPastAtTop() {
869
+ checkDestroy(this.#destroyed);
1030
870
  return this.#isPastAtTop;
1031
871
  }
1032
872
 
@@ -1036,6 +876,7 @@ class TinySmartScroller {
1036
876
  * @returns {boolean}
1037
877
  */
1038
878
  isPastAtCustomTop() {
879
+ checkDestroy(this.#destroyed);
1039
880
  return this.#isPastAtCustomTop;
1040
881
  }
1041
882
 
@@ -1045,6 +886,7 @@ class TinySmartScroller {
1045
886
  * @returns {boolean}
1046
887
  */
1047
888
  isPastAtCustomBottom() {
889
+ checkDestroy(this.#destroyed);
1048
890
  return this.#isPastAtCustomBottom;
1049
891
  }
1050
892
 
@@ -1054,6 +896,7 @@ class TinySmartScroller {
1054
896
  * @returns {boolean}
1055
897
  */
1056
898
  isScrollPaused() {
899
+ checkDestroy(this.#destroyed);
1057
900
  return this.#scrollPaused;
1058
901
  }
1059
902
 
@@ -1063,6 +906,7 @@ class TinySmartScroller {
1063
906
  * @returns {boolean} True if the scroll target is window, false otherwise.
1064
907
  */
1065
908
  isWindow() {
909
+ checkDestroy(this.#destroyed);
1066
910
  return this.#useWindow;
1067
911
  }
1068
912
 
@@ -1081,6 +925,7 @@ class TinySmartScroller {
1081
925
  * @returns {boolean} True if auto-scroll is active, false otherwise.
1082
926
  */
1083
927
  getAutoScrollBottom() {
928
+ checkDestroy(this.#destroyed);
1084
929
  return this.#autoScrollBottom;
1085
930
  }
1086
931
 
@@ -1090,6 +935,7 @@ class TinySmartScroller {
1090
935
  * @returns {boolean} True if mutation observation is active, false otherwise.
1091
936
  */
1092
937
  getObserveMutations() {
938
+ checkDestroy(this.#destroyed);
1093
939
  return this.#observeMutations;
1094
940
  }
1095
941
 
@@ -1099,6 +945,7 @@ class TinySmartScroller {
1099
945
  * @returns {boolean} True if scroll preservation is active, false otherwise.
1100
946
  */
1101
947
  getPreserveScrollOnLayoutShift() {
948
+ checkDestroy(this.#destroyed);
1102
949
  return this.#preserveScrollOnLayoutShift;
1103
950
  }
1104
951
 
@@ -1108,6 +955,7 @@ class TinySmartScroller {
1108
955
  * @returns {number} Debounce delay time.
1109
956
  */
1110
957
  getDebounceTime() {
958
+ checkDestroy(this.#destroyed);
1111
959
  return this.#debounceTime;
1112
960
  }
1113
961
 
@@ -1117,6 +965,7 @@ class TinySmartScroller {
1117
965
  * @returns {number} Current count of matching elements.
1118
966
  */
1119
967
  getElemAmount() {
968
+ checkDestroy(this.#destroyed);
1120
969
  return this.#elemAmount;
1121
970
  }
1122
971
 
@@ -1126,6 +975,7 @@ class TinySmartScroller {
1126
975
  * @returns {number} Previous count of matching elements.
1127
976
  */
1128
977
  getPrevElemAmount() {
978
+ checkDestroy(this.#destroyed);
1129
979
  return this.#elemOldAmount;
1130
980
  }
1131
981
 
@@ -1135,6 +985,7 @@ class TinySmartScroller {
1135
985
  * @returns {string} The CSS selector string, or an empty string if none was provided.
1136
986
  */
1137
987
  getQuerySelector() {
988
+ checkDestroy(this.#destroyed);
1138
989
  return this.#querySelector;
1139
990
  }
1140
991
 
@@ -1144,7 +995,6 @@ class TinySmartScroller {
1144
995
  */
1145
996
  destroy() {
1146
997
  if (this.#destroyed) return;
1147
- this.#destroyed = true;
1148
998
 
1149
999
  // Disconnects MutationObserver
1150
1000
  if (this.#mutationObserver) {
@@ -1171,9 +1021,10 @@ class TinySmartScroller {
1171
1021
  this.#oldVisiblesByTime = new WeakMap();
1172
1022
 
1173
1023
  // Cleans listeners and filters
1174
- this.#events.offAllTypes();
1024
+ this.removeAllListeners();
1175
1025
  this.#sizeFilter.clear();
1176
1026
  this.#loadTags.clear();
1027
+ this.#destroyed = true;
1177
1028
  }
1178
1029
  }
1179
1030