tiny-essentials 1.28.0 → 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 (168) hide show
  1. package/changelog/1/28/1.md +23 -0
  2. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  3. package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
  4. package/dist/v1/TinyAnalogClock.min.js +1 -1
  5. package/dist/v1/TinyBasicsEs.min.js +1 -1
  6. package/dist/v1/TinyDayNightCycle.min.js +1 -1
  7. package/dist/v1/TinyDragDropDetector.min.js +1 -1
  8. package/dist/v1/TinyDragger.min.js +1 -1
  9. package/dist/v1/TinyElementObserver.min.js +1 -1
  10. package/dist/v1/TinyEssentials.min.js +1 -1
  11. package/dist/v1/TinyGamepad.min.js +1 -1
  12. package/dist/v1/TinyHtml.min.js +1 -1
  13. package/dist/v1/TinyI18.min.js +1 -1
  14. package/dist/v1/TinyIframeEvents.min.js +1 -1
  15. package/dist/v1/TinyLocalStorage.min.js +1 -1
  16. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  17. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  18. package/dist/v1/TinyNotifyCenter.min.js +1 -1
  19. package/dist/v1/TinyRadioFm.min.js +1 -1
  20. package/dist/v1/TinyRateLimiter.min.js +1 -1
  21. package/dist/v1/TinySmartScroller.min.js +1 -1
  22. package/dist/v1/TinyTextDiffer.min.js +1 -1
  23. package/dist/v1/TinyTextarea.min.js +1 -1
  24. package/dist/v1/TinyTimeout.min.js +1 -1
  25. package/dist/v1/TinyToastNotify.min.js +1 -1
  26. package/dist/v1/TinyUploadClicker.min.js +1 -1
  27. package/dist/v1/UltraRandomMsgGen.min.js +1 -1
  28. package/dist/v1/basics/array.cjs +57 -9
  29. package/dist/v1/basics/array.d.mts +27 -11
  30. package/dist/v1/basics/array.mjs +51 -9
  31. package/dist/v1/basics/clock.cjs +94 -42
  32. package/dist/v1/basics/clock.d.mts +10 -10
  33. package/dist/v1/basics/clock.mjs +91 -54
  34. package/dist/v1/basics/deprecated/html.cjs +246 -0
  35. package/dist/v1/basics/deprecated/html.d.mts +63 -0
  36. package/dist/v1/basics/deprecated/html.mjs +190 -0
  37. package/dist/v1/basics/html.cjs +149 -130
  38. package/dist/v1/basics/html.d.mts +26 -61
  39. package/dist/v1/basics/html.mjs +113 -105
  40. package/dist/v1/basics/index.cjs +2 -0
  41. package/dist/v1/basics/index.d.mts +3 -1
  42. package/dist/v1/basics/index.mjs +3 -3
  43. package/dist/v1/basics/mediaContent.cjs +51 -9
  44. package/dist/v1/basics/mediaContent.d.mts +0 -87
  45. package/dist/v1/basics/mediaContent.mjs +40 -10
  46. package/dist/v1/basics/objChecker.cjs +7 -5
  47. package/dist/v1/basics/objChecker.d.mts +3 -2
  48. package/dist/v1/basics/objChecker.mjs +6 -6
  49. package/dist/v1/basics/objFilter.cjs +40 -7
  50. package/dist/v1/basics/objFilter.d.mts +6 -6
  51. package/dist/v1/basics/objFilter.mjs +32 -7
  52. package/dist/v1/basics/simpleMath.cjs +81 -25
  53. package/dist/v1/basics/simpleMath.d.mts +2 -2
  54. package/dist/v1/basics/simpleMath.mjs +70 -27
  55. package/dist/v1/basics/text.cjs +76 -31
  56. package/dist/v1/basics/text.d.mts +69 -7
  57. package/dist/v1/basics/text.mjs +62 -31
  58. package/dist/v1/index.cjs +4 -0
  59. package/dist/v1/index.d.mts +4 -1
  60. package/dist/v1/index.mjs +4 -3
  61. package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
  62. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +4 -13
  63. package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
  64. package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
  65. package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
  66. package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
  67. package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
  68. package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
  69. package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
  70. package/dist/v1/libs/TinyClipboard.cjs +2 -0
  71. package/dist/v1/libs/TinyClipboard.d.mts +4 -2
  72. package/dist/v1/libs/TinyClipboard.mjs +2 -0
  73. package/dist/v1/libs/TinyColorConverter.cjs +1 -0
  74. package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
  75. package/dist/v1/libs/TinyColorConverter.mjs +1 -0
  76. package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
  77. package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
  78. package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
  79. package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
  80. package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
  81. package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
  82. package/dist/v1/libs/TinyDragger.cjs +46 -19
  83. package/dist/v1/libs/TinyDragger.mjs +45 -18
  84. package/dist/v1/libs/TinyElementObserver.cjs +39 -0
  85. package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
  86. package/dist/v1/libs/TinyElementObserver.mjs +36 -0
  87. package/dist/v1/libs/TinyGamepad.cjs +131 -1
  88. package/dist/v1/libs/TinyGamepad.mjs +129 -1
  89. package/dist/v1/libs/TinyHtml.cjs +1 -1
  90. package/dist/v1/libs/TinyHtml.mjs +2 -2
  91. package/dist/v1/libs/TinyI18.cjs +61 -0
  92. package/dist/v1/libs/TinyI18.d.mts +14 -0
  93. package/dist/v1/libs/TinyI18.mjs +55 -0
  94. package/dist/v1/libs/TinyIframeEvents.cjs +18 -1
  95. package/dist/v1/libs/TinyIframeEvents.mjs +18 -1
  96. package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
  97. package/dist/v1/libs/TinyLocalStorage.d.mts +6 -0
  98. package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
  99. package/dist/v1/libs/TinyMediaPlayer.cjs +72 -0
  100. package/dist/v1/libs/TinyMediaPlayer.d.mts +10 -0
  101. package/dist/v1/libs/TinyMediaPlayer.mjs +66 -0
  102. package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
  103. package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -0
  104. package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
  105. package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
  106. package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
  107. package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
  108. package/dist/v1/libs/TinyRadioFm.cjs +38 -0
  109. package/dist/v1/libs/TinyRadioFm.d.mts +1 -0
  110. package/dist/v1/libs/TinyRadioFm.mjs +35 -0
  111. package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
  112. package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
  113. package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
  114. package/dist/v1/libs/TinySmartScroller.cjs +52 -3
  115. package/dist/v1/libs/TinySmartScroller.d.mts +17 -15
  116. package/dist/v1/libs/TinySmartScroller.mjs +51 -5
  117. package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
  118. package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
  119. package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
  120. package/dist/v1/libs/TinyTextarea.cjs +19 -0
  121. package/dist/v1/libs/TinyTextarea.d.mts +6 -0
  122. package/dist/v1/libs/TinyTextarea.mjs +17 -0
  123. package/dist/v1/libs/TinyTimeout.cjs +11 -1
  124. package/dist/v1/libs/TinyTimeout.mjs +9 -1
  125. package/dist/v1/libs/TinyToastNotify.cjs +35 -0
  126. package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
  127. package/dist/v1/libs/TinyToastNotify.mjs +31 -0
  128. package/dist/v1/libs/TinyUploadClicker.cjs +19 -0
  129. package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
  130. package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
  131. package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
  132. package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
  133. package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
  134. package/dist/v1/libs/utils.cjs +21 -0
  135. package/dist/v1/libs/utils.d.mts +2 -0
  136. package/dist/v1/libs/utils.mjs +16 -0
  137. package/docs/v1/README.md +1 -0
  138. package/docs/v1/basics/array.md +2 -2
  139. package/docs/v1/basics/deprecated/html.md +17 -0
  140. package/docs/v1/basics/fullScreen.md +1 -1
  141. package/docs/v1/basics/html.md +12 -26
  142. package/docs/v1/basics/mediaContent.md +1 -1
  143. package/docs/v1/basics/objChecker.md +1 -1
  144. package/docs/v1/basics/text.md +2 -2
  145. package/docs/v1/fileManager/main.md +1 -1
  146. package/docs/v1/libs/ColorSafeStringify.md +1 -1
  147. package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
  148. package/docs/v1/libs/TinyAnalogClock.md +1 -1
  149. package/docs/v1/libs/TinyArrayComparator.md +1 -1
  150. package/docs/v1/libs/TinyArrayPaginator.md +1 -1
  151. package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
  152. package/docs/v1/libs/TinyClassManager.md +1 -1
  153. package/docs/v1/libs/TinyClipboard.md +1 -1
  154. package/docs/v1/libs/TinyCookieConsent.md +1 -1
  155. package/docs/v1/libs/TinyDomReadyManager.md +1 -1
  156. package/docs/v1/libs/TinyDragDropDetector.md +1 -1
  157. package/docs/v1/libs/TinyDragger.md +1 -1
  158. package/docs/v1/libs/TinyElementObserver.md +1 -1
  159. package/docs/v1/libs/TinyHtml.md +1 -1
  160. package/docs/v1/libs/TinyIframeEvents.md +2 -2
  161. package/docs/v1/libs/TinyLevelUp.md +1 -1
  162. package/docs/v1/libs/TinyLoadingScreen.md +1 -1
  163. package/docs/v1/libs/TinyNewWinEvents.md +2 -2
  164. package/docs/v1/libs/TinyNotifications.md +1 -1
  165. package/docs/v1/libs/TinyPromiseQueue.md +2 -2
  166. package/docs/v1/libs/TinyTextDiffer.md +1 -1
  167. package/docs/v1/libs/TinyTextarea.md +1 -1
  168. package/package.json +10 -1
@@ -1,3 +1,5 @@
1
+ import { createCheckDestroyed } from './utils.mjs';
2
+ const checkDestroy = createCheckDestroyed('TinyTextDiffer');
1
3
  /**
2
4
  * Represents the result of a single text segment comparison.
3
5
  * @typedef {Object} DiffResult
@@ -13,11 +15,15 @@ class TinyTextDiffer {
13
15
  #history = [];
14
16
  /** @type {boolean} */
15
17
  #destroyed = false;
18
+ get destroyed() {
19
+ return this.#destroyed;
20
+ }
16
21
  /**
17
22
  * Retrieves a shallow copy of the current history array.
18
23
  * @returns {string[]}
19
24
  */
20
25
  get history() {
26
+ checkDestroy(this.#destroyed);
21
27
  return [...this.#history];
22
28
  }
23
29
  /**
@@ -25,6 +31,7 @@ class TinyTextDiffer {
25
31
  * @param {string[]} history
26
32
  */
27
33
  set history(history) {
34
+ checkDestroy(this.#destroyed);
28
35
  if (!Array.isArray(history)) {
29
36
  throw new TypeError('History data must be provided as an array.');
30
37
  }
@@ -39,6 +46,7 @@ class TinyTextDiffer {
39
46
  * @returns {number}
40
47
  */
41
48
  get size() {
49
+ checkDestroy(this.#destroyed);
42
50
  return this.#history.length;
43
51
  }
44
52
  /**
@@ -48,15 +56,6 @@ class TinyTextDiffer {
48
56
  constructor(history = []) {
49
57
  this.history = history;
50
58
  }
51
- /**
52
- * @throws {Error}
53
- * @returns {void}
54
- */
55
- #checkDestroyed() {
56
- if (this.#destroyed) {
57
- throw new Error('Cannot perform operations on a destroyed TinyTextDiffer instance.');
58
- }
59
- }
60
59
  /**
61
60
  * @param {any} index
62
61
  * @throws {TypeError}
@@ -83,7 +82,7 @@ class TinyTextDiffer {
83
82
  * @returns {string}
84
83
  */
85
84
  get(index) {
86
- this.#checkDestroyed();
85
+ checkDestroy(this.#destroyed);
87
86
  this.#checkIndex(index);
88
87
  if (typeof this.#history[index] === 'undefined') {
89
88
  throw new Error(`No text version found at index ${index}.`);
@@ -96,7 +95,7 @@ class TinyTextDiffer {
96
95
  * @returns {boolean}
97
96
  */
98
97
  has(index) {
99
- this.#checkDestroyed();
98
+ checkDestroy(this.#destroyed);
100
99
  this.#checkIndex(index);
101
100
  return typeof this.#history[index] !== 'undefined';
102
101
  }
@@ -106,7 +105,7 @@ class TinyTextDiffer {
106
105
  * @returns {void}
107
106
  */
108
107
  add(text) {
109
- this.#checkDestroyed();
108
+ checkDestroy(this.#destroyed);
110
109
  this.#checkText(text);
111
110
  this.#history.push(text);
112
111
  }
@@ -115,7 +114,7 @@ class TinyTextDiffer {
115
114
  * @returns {string | undefined}
116
115
  */
117
116
  remove() {
118
- this.#checkDestroyed();
117
+ checkDestroy(this.#destroyed);
119
118
  return this.#history.pop();
120
119
  }
121
120
  /**
@@ -125,7 +124,7 @@ class TinyTextDiffer {
125
124
  * @returns {void}
126
125
  */
127
126
  addAt(index, text) {
128
- this.#checkDestroyed();
127
+ checkDestroy(this.#destroyed);
129
128
  this.#checkIndex(index);
130
129
  this.#checkText(text);
131
130
  this.#history.splice(index, 0, text);
@@ -136,7 +135,7 @@ class TinyTextDiffer {
136
135
  * @returns {boolean}
137
136
  */
138
137
  removeAt(index) {
139
- this.#checkDestroyed();
138
+ checkDestroy(this.#destroyed);
140
139
  this.#checkIndex(index);
141
140
  const oldSize = this.#history.length;
142
141
  this.#history.splice(index, 1);
@@ -148,7 +147,7 @@ class TinyTextDiffer {
148
147
  * @returns {void}
149
148
  */
150
149
  clear() {
151
- this.#checkDestroyed();
150
+ checkDestroy(this.#destroyed);
152
151
  this.#history = [];
153
152
  }
154
153
  /**
@@ -158,7 +157,7 @@ class TinyTextDiffer {
158
157
  * @returns {(DiffResult[])[]} An array of DiffResult arrays for each compared pair.
159
158
  */
160
159
  compare(...indexes) {
161
- this.#checkDestroyed();
160
+ checkDestroy(this.#destroyed);
162
161
  /** @type {number} */
163
162
  const totalIndexes = indexes.length;
164
163
  if (totalIndexes === 0 || totalIndexes % 2 !== 0) {
@@ -30,6 +30,21 @@
30
30
  * @beta
31
31
  */
32
32
  class TinyTextarea {
33
+ /**
34
+ * Tracks whether the instance has been destroyed.
35
+ * @type {boolean}
36
+ */
37
+ #destroyed = false;
38
+
39
+ /**
40
+ * Gets the current destruction status of the instance.
41
+ *
42
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
43
+ */
44
+ get destroyed() {
45
+ return this.#destroyed;
46
+ }
47
+
33
48
  #lineHeight;
34
49
  #maxRows;
35
50
  #extraHeight;
@@ -223,7 +238,11 @@ class TinyTextarea {
223
238
  * Cleans up internal listeners and disables dynamic behavior.
224
239
  */
225
240
  destroy() {
241
+ if (this.destroyed) return;
226
242
  this.#textarea.removeEventListener('input', this._handleInput);
243
+
244
+ // Lock the instance
245
+ this.#destroyed = true;
227
246
  }
228
247
  }
229
248
 
@@ -76,6 +76,12 @@ declare class TinyTextarea {
76
76
  onResize?: ((info: OnInputInfo) => void) | undefined;
77
77
  onInput?: ((info: OnInputInfo) => void) | undefined;
78
78
  });
79
+ /**
80
+ * Gets the current destruction status of the instance.
81
+ *
82
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
83
+ */
84
+ get destroyed(): boolean;
79
85
  /**
80
86
  * Returns the computed line height in pixels.
81
87
  * @returns {number}
@@ -27,6 +27,19 @@
27
27
  * @beta
28
28
  */
29
29
  class TinyTextarea {
30
+ /**
31
+ * Tracks whether the instance has been destroyed.
32
+ * @type {boolean}
33
+ */
34
+ #destroyed = false;
35
+ /**
36
+ * Gets the current destruction status of the instance.
37
+ *
38
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
39
+ */
40
+ get destroyed() {
41
+ return this.#destroyed;
42
+ }
30
43
  #lineHeight;
31
44
  #maxRows;
32
45
  #extraHeight;
@@ -192,7 +205,11 @@ class TinyTextarea {
192
205
  * Cleans up internal listeners and disables dynamic behavior.
193
206
  */
194
207
  destroy() {
208
+ if (this.destroyed)
209
+ return;
195
210
  this.#textarea.removeEventListener('input', this._handleInput);
211
+ // Lock the instance
212
+ this.#destroyed = true;
196
213
  }
197
214
  }
198
215
  export default TinyTextarea;
@@ -1,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var utils = require('./utils.cjs');
4
+
5
+ const checkDestroy = utils.createCheckDestroyed('TinyTimeout');
6
+
3
7
  /**
4
8
  * A utility class to manage dynamically adjusted timeouts based on how often
5
9
  * each unique ID is triggered. Also provides polling support for asynchronous conditions.
@@ -57,6 +61,7 @@ class TinyTimeout {
57
61
  * @returns {boolean}
58
62
  */
59
63
  getAllowAutoConfigChange() {
64
+ checkDestroy(this.#isDestroyed);
60
65
  return this.#allowAutoConfigChange;
61
66
  }
62
67
 
@@ -66,6 +71,7 @@ class TinyTimeout {
66
71
  * @returns {number}
67
72
  */
68
73
  getCooldownWatcherTime() {
74
+ checkDestroy(this.#isDestroyed);
69
75
  return this.#cooldownWatcherTime;
70
76
  }
71
77
 
@@ -75,6 +81,7 @@ class TinyTimeout {
75
81
  * @param {boolean} value
76
82
  */
77
83
  setAllowAutoConfigChange(value) {
84
+ checkDestroy(this.#isDestroyed);
78
85
  if (typeof value !== 'boolean') throw new TypeError(`Expected 'value' to be a boolean.`);
79
86
  this.#allowAutoConfigChange = value;
80
87
  }
@@ -86,6 +93,7 @@ class TinyTimeout {
86
93
  * @param {number} value
87
94
  */
88
95
  setCooldownWatcherTime(value) {
96
+ checkDestroy(this.#isDestroyed);
89
97
  if (this.#isDestroyed) throw new Error('TinyTimeout has been destroyed.');
90
98
  if (!Number.isFinite(value) || value <= 0)
91
99
  throw new TypeError(`Expected 'value' to be a positive number.`);
@@ -113,6 +121,7 @@ class TinyTimeout {
113
121
  * @throws {Error} Throws if the instance has been destroyed or arguments are invalid.
114
122
  */
115
123
  set(id, callback, value, limit = null) {
124
+ checkDestroy(this.#isDestroyed);
116
125
  if (this.#isDestroyed) throw new Error('TinyTimeout has been destroyed.');
117
126
  if (typeof id !== 'string' || id.trim() === '')
118
127
  throw new TypeError(`Expected 'id' to be a non-empty string.`);
@@ -170,6 +179,7 @@ class TinyTimeout {
170
179
  * @throws {Error} If the instance is destroyed or arguments are invalid.
171
180
  */
172
181
  waitForTrue(getValue, checkInterval = 100) {
182
+ checkDestroy(this.#isDestroyed);
173
183
  if (this.#isDestroyed) throw new Error('TinyTimeout has been destroyed.');
174
184
  if (typeof getValue !== 'function')
175
185
  throw new TypeError(`Expected 'getValue' to be a function.`);
@@ -184,10 +194,10 @@ class TinyTimeout {
184
194
  */
185
195
  destroy() {
186
196
  if (this.#isDestroyed) return;
187
- this.#isDestroyed = true;
188
197
  if (this.#cooldownWatcher) clearInterval(this.#cooldownWatcher);
189
198
  this.#cooldownWatcher = null;
190
199
  this.#timeoutFixer.clear();
200
+ this.#isDestroyed = true;
191
201
  }
192
202
  }
193
203
 
@@ -1,3 +1,5 @@
1
+ import { createCheckDestroyed } from './utils.mjs';
2
+ const checkDestroy = createCheckDestroyed('TinyTimeout');
1
3
  /**
2
4
  * A utility class to manage dynamically adjusted timeouts based on how often
3
5
  * each unique ID is triggered. Also provides polling support for asynchronous conditions.
@@ -48,6 +50,7 @@ class TinyTimeout {
48
50
  * @returns {boolean}
49
51
  */
50
52
  getAllowAutoConfigChange() {
53
+ checkDestroy(this.#isDestroyed);
51
54
  return this.#allowAutoConfigChange;
52
55
  }
53
56
  /**
@@ -56,6 +59,7 @@ class TinyTimeout {
56
59
  * @returns {number}
57
60
  */
58
61
  getCooldownWatcherTime() {
62
+ checkDestroy(this.#isDestroyed);
59
63
  return this.#cooldownWatcherTime;
60
64
  }
61
65
  /**
@@ -64,6 +68,7 @@ class TinyTimeout {
64
68
  * @param {boolean} value
65
69
  */
66
70
  setAllowAutoConfigChange(value) {
71
+ checkDestroy(this.#isDestroyed);
67
72
  if (typeof value !== 'boolean')
68
73
  throw new TypeError(`Expected 'value' to be a boolean.`);
69
74
  this.#allowAutoConfigChange = value;
@@ -75,6 +80,7 @@ class TinyTimeout {
75
80
  * @param {number} value
76
81
  */
77
82
  setCooldownWatcherTime(value) {
83
+ checkDestroy(this.#isDestroyed);
78
84
  if (this.#isDestroyed)
79
85
  throw new Error('TinyTimeout has been destroyed.');
80
86
  if (!Number.isFinite(value) || value <= 0)
@@ -102,6 +108,7 @@ class TinyTimeout {
102
108
  * @throws {Error} Throws if the instance has been destroyed or arguments are invalid.
103
109
  */
104
110
  set(id, callback, value, limit = null) {
111
+ checkDestroy(this.#isDestroyed);
105
112
  if (this.#isDestroyed)
106
113
  throw new Error('TinyTimeout has been destroyed.');
107
114
  if (typeof id !== 'string' || id.trim() === '')
@@ -154,6 +161,7 @@ class TinyTimeout {
154
161
  * @throws {Error} If the instance is destroyed or arguments are invalid.
155
162
  */
156
163
  waitForTrue(getValue, checkInterval = 100) {
164
+ checkDestroy(this.#isDestroyed);
157
165
  if (this.#isDestroyed)
158
166
  throw new Error('TinyTimeout has been destroyed.');
159
167
  if (typeof getValue !== 'function')
@@ -169,11 +177,11 @@ class TinyTimeout {
169
177
  destroy() {
170
178
  if (this.#isDestroyed)
171
179
  return;
172
- this.#isDestroyed = true;
173
180
  if (this.#cooldownWatcher)
174
181
  clearInterval(this.#cooldownWatcher);
175
182
  this.#cooldownWatcher = null;
176
183
  this.#timeoutFixer.clear();
184
+ this.#isDestroyed = true;
177
185
  }
178
186
  }
179
187
  export default TinyTimeout;
@@ -1,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var utils = require('./utils.cjs');
4
+
5
+ const checkDestroy = utils.createCheckDestroyed('TinyToastNotify');
6
+
3
7
  /**
4
8
  * A callback function used to manually close a notification.
5
9
  * Passed as a second argument to `onClick` handlers, allowing programmatic dismissal of the toast.
@@ -50,6 +54,21 @@ class TinyToastNotify {
50
54
  /** @type {HTMLElement|null} */
51
55
  #container;
52
56
 
57
+ /**
58
+ * Tracks whether the instance has been destroyed.
59
+ * @type {boolean}
60
+ */
61
+ #destroyed = false;
62
+
63
+ /**
64
+ * Gets the current destruction status of the instance.
65
+ *
66
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
67
+ */
68
+ get destroyed() {
69
+ return this.#destroyed;
70
+ }
71
+
53
72
  /**
54
73
  * @param {'top'|'bottom'} y - 'top' or 'bottom'
55
74
  * @param {'right'|'left'|'center'} x - 'right', 'left', or 'center'
@@ -94,6 +113,7 @@ class TinyToastNotify {
94
113
  * @throws {Error} If the container is not a valid HTMLElement.
95
114
  */
96
115
  getContainer() {
116
+ checkDestroy(this.#destroyed);
97
117
  if (!(this.#container instanceof HTMLElement))
98
118
  throw new Error('Container is not a valid HTMLElement.');
99
119
  return this.#container;
@@ -149,6 +169,7 @@ class TinyToastNotify {
149
169
  * @returns {'top'|'bottom'} The vertical direction of the notification container.
150
170
  */
151
171
  getY() {
172
+ checkDestroy(this.#destroyed);
152
173
  return this.#y;
153
174
  }
154
175
 
@@ -160,6 +181,7 @@ class TinyToastNotify {
160
181
  * @throws {Error} If the value is invalid.
161
182
  */
162
183
  setY(value) {
184
+ checkDestroy(this.#destroyed);
163
185
  this.#validateY(value);
164
186
  const container = this.getContainer();
165
187
  container.classList.remove(this.#y);
@@ -174,6 +196,7 @@ class TinyToastNotify {
174
196
  * @returns {'left'|'right'|'center'} The horizontal direction of the notification container.
175
197
  */
176
198
  getX() {
199
+ checkDestroy(this.#destroyed);
177
200
  return this.#x;
178
201
  }
179
202
 
@@ -185,6 +208,7 @@ class TinyToastNotify {
185
208
  * @throws {Error} If the value is invalid.
186
209
  */
187
210
  setX(value) {
211
+ checkDestroy(this.#destroyed);
188
212
  this.#validateX(value);
189
213
  const container = this.getContainer();
190
214
  container.classList.remove(this.#x);
@@ -199,6 +223,7 @@ class TinyToastNotify {
199
223
  * @returns {number} Base time (in milliseconds) that a notification stays on screen.
200
224
  */
201
225
  getBaseDuration() {
226
+ checkDestroy(this.#destroyed);
202
227
  return this.#baseDuration;
203
228
  }
204
229
 
@@ -209,6 +234,7 @@ class TinyToastNotify {
209
234
  * @throws {Error} If the value is not a valid non-negative finite number.
210
235
  */
211
236
  setBaseDuration(value) {
237
+ checkDestroy(this.#destroyed);
212
238
  this.#validateTiming(value, 'baseDuration');
213
239
  this.#baseDuration = value;
214
240
  }
@@ -219,6 +245,7 @@ class TinyToastNotify {
219
245
  * @returns {number} Extra time (in milliseconds) per character in the notification.
220
246
  */
221
247
  getExtraPerChar() {
248
+ checkDestroy(this.#destroyed);
222
249
  return this.#extraPerChar;
223
250
  }
224
251
 
@@ -229,6 +256,7 @@ class TinyToastNotify {
229
256
  * @throws {Error} If the value is not a valid non-negative finite number.
230
257
  */
231
258
  setExtraPerChar(value) {
259
+ checkDestroy(this.#destroyed);
232
260
  this.#validateTiming(value, 'extraPerChar');
233
261
  this.#extraPerChar = value;
234
262
  }
@@ -239,6 +267,7 @@ class TinyToastNotify {
239
267
  * @returns {number} Time (in milliseconds) used for fade-out transition.
240
268
  */
241
269
  getFadeOutDuration() {
270
+ checkDestroy(this.#destroyed);
242
271
  return this.#fadeOutDuration;
243
272
  }
244
273
 
@@ -249,6 +278,7 @@ class TinyToastNotify {
249
278
  * @throws {Error} If the value is not a valid non-negative finite number.
250
279
  */
251
280
  setFadeOutDuration(value) {
281
+ checkDestroy(this.#destroyed);
252
282
  this.#validateTiming(value, 'fadeOutDuration');
253
283
  this.#fadeOutDuration = value;
254
284
  }
@@ -267,6 +297,7 @@ class TinyToastNotify {
267
297
  * @param {NotifyData} data
268
298
  */
269
299
  show(data) {
300
+ checkDestroy(this.#destroyed);
270
301
  let message = '';
271
302
  let title = '';
272
303
  let onClick = null;
@@ -384,6 +415,7 @@ class TinyToastNotify {
384
415
  * @returns {void}
385
416
  */
386
417
  destroy() {
418
+ if (this.#destroyed) return;
387
419
  if (!(this.#container instanceof HTMLElement)) return;
388
420
 
389
421
  // Remove all child notifications
@@ -396,6 +428,9 @@ class TinyToastNotify {
396
428
 
397
429
  // Optional: Clean internal references (safe practice)
398
430
  this.#container = null;
431
+
432
+ // Lock the instance
433
+ this.#destroyed = true;
399
434
  }
400
435
  }
401
436
 
@@ -63,6 +63,12 @@ declare class TinyToastNotify {
63
63
  * @param {string} [selector='.notify-container'] - Base selector for container
64
64
  */
65
65
  constructor(y?: "top" | "bottom", x?: "right" | "left" | "center", baseDuration?: number, extraPerChar?: number, fadeOutDuration?: number, selector?: string);
66
+ /**
67
+ * Gets the current destruction status of the instance.
68
+ *
69
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
70
+ */
71
+ get destroyed(): boolean;
66
72
  /**
67
73
  * Returns the notification container element.
68
74
  * Ensures that the container is a valid HTMLElement.
@@ -1,3 +1,5 @@
1
+ import { createCheckDestroyed } from './utils.mjs';
2
+ const checkDestroy = createCheckDestroyed('TinyToastNotify');
1
3
  /**
2
4
  * A callback function used to manually close a notification.
3
5
  * Passed as a second argument to `onClick` handlers, allowing programmatic dismissal of the toast.
@@ -44,6 +46,19 @@ class TinyToastNotify {
44
46
  #fadeOutDuration;
45
47
  /** @type {HTMLElement|null} */
46
48
  #container;
49
+ /**
50
+ * Tracks whether the instance has been destroyed.
51
+ * @type {boolean}
52
+ */
53
+ #destroyed = false;
54
+ /**
55
+ * Gets the current destruction status of the instance.
56
+ *
57
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
58
+ */
59
+ get destroyed() {
60
+ return this.#destroyed;
61
+ }
47
62
  /**
48
63
  * @param {'top'|'bottom'} y - 'top' or 'bottom'
49
64
  * @param {'right'|'left'|'center'} x - 'right', 'left', or 'center'
@@ -80,6 +95,7 @@ class TinyToastNotify {
80
95
  * @throws {Error} If the container is not a valid HTMLElement.
81
96
  */
82
97
  getContainer() {
98
+ checkDestroy(this.#destroyed);
83
99
  if (!(this.#container instanceof HTMLElement))
84
100
  throw new Error('Container is not a valid HTMLElement.');
85
101
  return this.#container;
@@ -127,6 +143,7 @@ class TinyToastNotify {
127
143
  * @returns {'top'|'bottom'} The vertical direction of the notification container.
128
144
  */
129
145
  getY() {
146
+ checkDestroy(this.#destroyed);
130
147
  return this.#y;
131
148
  }
132
149
  /**
@@ -137,6 +154,7 @@ class TinyToastNotify {
137
154
  * @throws {Error} If the value is invalid.
138
155
  */
139
156
  setY(value) {
157
+ checkDestroy(this.#destroyed);
140
158
  this.#validateY(value);
141
159
  const container = this.getContainer();
142
160
  container.classList.remove(this.#y);
@@ -149,6 +167,7 @@ class TinyToastNotify {
149
167
  * @returns {'left'|'right'|'center'} The horizontal direction of the notification container.
150
168
  */
151
169
  getX() {
170
+ checkDestroy(this.#destroyed);
152
171
  return this.#x;
153
172
  }
154
173
  /**
@@ -159,6 +178,7 @@ class TinyToastNotify {
159
178
  * @throws {Error} If the value is invalid.
160
179
  */
161
180
  setX(value) {
181
+ checkDestroy(this.#destroyed);
162
182
  this.#validateX(value);
163
183
  const container = this.getContainer();
164
184
  container.classList.remove(this.#x);
@@ -171,6 +191,7 @@ class TinyToastNotify {
171
191
  * @returns {number} Base time (in milliseconds) that a notification stays on screen.
172
192
  */
173
193
  getBaseDuration() {
194
+ checkDestroy(this.#destroyed);
174
195
  return this.#baseDuration;
175
196
  }
176
197
  /**
@@ -180,6 +201,7 @@ class TinyToastNotify {
180
201
  * @throws {Error} If the value is not a valid non-negative finite number.
181
202
  */
182
203
  setBaseDuration(value) {
204
+ checkDestroy(this.#destroyed);
183
205
  this.#validateTiming(value, 'baseDuration');
184
206
  this.#baseDuration = value;
185
207
  }
@@ -189,6 +211,7 @@ class TinyToastNotify {
189
211
  * @returns {number} Extra time (in milliseconds) per character in the notification.
190
212
  */
191
213
  getExtraPerChar() {
214
+ checkDestroy(this.#destroyed);
192
215
  return this.#extraPerChar;
193
216
  }
194
217
  /**
@@ -198,6 +221,7 @@ class TinyToastNotify {
198
221
  * @throws {Error} If the value is not a valid non-negative finite number.
199
222
  */
200
223
  setExtraPerChar(value) {
224
+ checkDestroy(this.#destroyed);
201
225
  this.#validateTiming(value, 'extraPerChar');
202
226
  this.#extraPerChar = value;
203
227
  }
@@ -207,6 +231,7 @@ class TinyToastNotify {
207
231
  * @returns {number} Time (in milliseconds) used for fade-out transition.
208
232
  */
209
233
  getFadeOutDuration() {
234
+ checkDestroy(this.#destroyed);
210
235
  return this.#fadeOutDuration;
211
236
  }
212
237
  /**
@@ -216,6 +241,7 @@ class TinyToastNotify {
216
241
  * @throws {Error} If the value is not a valid non-negative finite number.
217
242
  */
218
243
  setFadeOutDuration(value) {
244
+ checkDestroy(this.#destroyed);
219
245
  this.#validateTiming(value, 'fadeOutDuration');
220
246
  this.#fadeOutDuration = value;
221
247
  }
@@ -233,6 +259,7 @@ class TinyToastNotify {
233
259
  * @param {NotifyData} data
234
260
  */
235
261
  show(data) {
262
+ checkDestroy(this.#destroyed);
236
263
  let message = '';
237
264
  let title = '';
238
265
  let onClick = null;
@@ -337,6 +364,8 @@ class TinyToastNotify {
337
364
  * @returns {void}
338
365
  */
339
366
  destroy() {
367
+ if (this.#destroyed)
368
+ return;
340
369
  if (!(this.#container instanceof HTMLElement))
341
370
  return;
342
371
  // Remove all child notifications
@@ -347,6 +376,8 @@ class TinyToastNotify {
347
376
  }
348
377
  // Optional: Clean internal references (safe practice)
349
378
  this.#container = null;
379
+ // Lock the instance
380
+ this.#destroyed = true;
350
381
  }
351
382
  }
352
383
  export default TinyToastNotify;
@@ -64,6 +64,21 @@ require('./TinyColorValidator.cjs');
64
64
  * uploader.destroy();
65
65
  */
66
66
  class TinyUploadClicker {
67
+ /**
68
+ * Tracks whether the instance has been destroyed.
69
+ * @type {boolean}
70
+ */
71
+ #destroyed = false;
72
+
73
+ /**
74
+ * Gets the current destruction status of the instance.
75
+ *
76
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
77
+ */
78
+ get destroyed() {
79
+ return this.#destroyed;
80
+ }
81
+
67
82
  /** @type {UploaderConfig} */
68
83
  #config;
69
84
 
@@ -212,6 +227,7 @@ class TinyUploadClicker {
212
227
  * Cleans up all internal elements and event listeners, removing created inputs and breaking references.
213
228
  */
214
229
  destroy() {
230
+ if (this.destroyed) return;
215
231
  for (const trigger of this.#triggerElements) {
216
232
  if (!(trigger instanceof HTMLElement)) return;
217
233
  trigger.removeEventListener('click', this.#boundClick);
@@ -223,6 +239,9 @@ class TinyUploadClicker {
223
239
  }
224
240
 
225
241
  this.#triggerElements = [];
242
+
243
+ // Lock the instance
244
+ this.#destroyed = true;
226
245
  }
227
246
  }
228
247
 
@@ -71,6 +71,12 @@ declare class TinyUploadClicker {
71
71
  * @throws {TypeError} If the config is invalid or required options are missing.
72
72
  */
73
73
  constructor(options: UploaderConfig);
74
+ /**
75
+ * Gets the current destruction status of the instance.
76
+ *
77
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
78
+ */
79
+ get destroyed(): boolean;
74
80
  /**
75
81
  * Cleans up all internal elements and event listeners, removing created inputs and breaking references.
76
82
  */