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,5 +1,9 @@
1
1
  'use strict';
2
2
 
3
+ var utils = require('./utils.cjs');
4
+
5
+ const checkDestroy = utils.createCheckDestroyed('TinyTextDiffer');
6
+
3
7
  /**
4
8
  * Represents the result of a single text segment comparison.
5
9
  * @typedef {Object} DiffResult
@@ -18,11 +22,16 @@ class TinyTextDiffer {
18
22
  /** @type {boolean} */
19
23
  #destroyed = false;
20
24
 
25
+ get destroyed() {
26
+ return this.#destroyed;
27
+ }
28
+
21
29
  /**
22
30
  * Retrieves a shallow copy of the current history array.
23
31
  * @returns {string[]}
24
32
  */
25
33
  get history() {
34
+ checkDestroy(this.#destroyed);
26
35
  return [...this.#history];
27
36
  }
28
37
 
@@ -31,6 +40,7 @@ class TinyTextDiffer {
31
40
  * @param {string[]} history
32
41
  */
33
42
  set history(history) {
43
+ checkDestroy(this.#destroyed);
34
44
  if (!Array.isArray(history)) {
35
45
  throw new TypeError('History data must be provided as an array.');
36
46
  }
@@ -46,6 +56,7 @@ class TinyTextDiffer {
46
56
  * @returns {number}
47
57
  */
48
58
  get size() {
59
+ checkDestroy(this.#destroyed);
49
60
  return this.#history.length;
50
61
  }
51
62
 
@@ -57,16 +68,6 @@ class TinyTextDiffer {
57
68
  this.history = history;
58
69
  }
59
70
 
60
- /**
61
- * @throws {Error}
62
- * @returns {void}
63
- */
64
- #checkDestroyed() {
65
- if (this.#destroyed) {
66
- throw new Error('Cannot perform operations on a destroyed TinyTextDiffer instance.');
67
- }
68
- }
69
-
70
71
  /**
71
72
  * @param {any} index
72
73
  * @throws {TypeError}
@@ -95,7 +96,7 @@ class TinyTextDiffer {
95
96
  * @returns {string}
96
97
  */
97
98
  get(index) {
98
- this.#checkDestroyed();
99
+ checkDestroy(this.#destroyed);
99
100
  this.#checkIndex(index);
100
101
  if (typeof this.#history[index] === 'undefined') {
101
102
  throw new Error(`No text version found at index ${index}.`);
@@ -109,7 +110,7 @@ class TinyTextDiffer {
109
110
  * @returns {boolean}
110
111
  */
111
112
  has(index) {
112
- this.#checkDestroyed();
113
+ checkDestroy(this.#destroyed);
113
114
  this.#checkIndex(index);
114
115
  return typeof this.#history[index] !== 'undefined';
115
116
  }
@@ -120,7 +121,7 @@ class TinyTextDiffer {
120
121
  * @returns {void}
121
122
  */
122
123
  add(text) {
123
- this.#checkDestroyed();
124
+ checkDestroy(this.#destroyed);
124
125
  this.#checkText(text);
125
126
  this.#history.push(text);
126
127
  }
@@ -130,7 +131,7 @@ class TinyTextDiffer {
130
131
  * @returns {string | undefined}
131
132
  */
132
133
  remove() {
133
- this.#checkDestroyed();
134
+ checkDestroy(this.#destroyed);
134
135
  return this.#history.pop();
135
136
  }
136
137
 
@@ -141,7 +142,7 @@ class TinyTextDiffer {
141
142
  * @returns {void}
142
143
  */
143
144
  addAt(index, text) {
144
- this.#checkDestroyed();
145
+ checkDestroy(this.#destroyed);
145
146
  this.#checkIndex(index);
146
147
  this.#checkText(text);
147
148
  this.#history.splice(index, 0, text);
@@ -153,7 +154,7 @@ class TinyTextDiffer {
153
154
  * @returns {boolean}
154
155
  */
155
156
  removeAt(index) {
156
- this.#checkDestroyed();
157
+ checkDestroy(this.#destroyed);
157
158
  this.#checkIndex(index);
158
159
  const oldSize = this.#history.length;
159
160
  this.#history.splice(index, 1);
@@ -166,7 +167,7 @@ class TinyTextDiffer {
166
167
  * @returns {void}
167
168
  */
168
169
  clear() {
169
- this.#checkDestroyed();
170
+ checkDestroy(this.#destroyed);
170
171
  this.#history = [];
171
172
  }
172
173
 
@@ -177,7 +178,7 @@ class TinyTextDiffer {
177
178
  * @returns {(DiffResult[])[]} An array of DiffResult arrays for each compared pair.
178
179
  */
179
180
  compare(...indexes) {
180
- this.#checkDestroyed();
181
+ checkDestroy(this.#destroyed);
181
182
 
182
183
  /** @type {number} */
183
184
  const totalIndexes = indexes.length;
@@ -28,6 +28,7 @@ declare class TinyTextDiffer {
28
28
  * @param {string[]} [history=[]]
29
29
  */
30
30
  constructor(history?: string[]);
31
+ get destroyed(): boolean;
31
32
  /**
32
33
  * Overwrites the current history array, ensuring all elements are valid strings.
33
34
  * @param {string[]} history
@@ -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.