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,7 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var events = require('events');
3
4
  var objChecker = require('../basics/objChecker.cjs');
4
- var TinyEvents = require('./TinyEvents.cjs');
5
+ var utils = require('./utils.cjs');
6
+
7
+ const checkDestroy = utils.createCheckDestroyed('TinyIframeEvents');
5
8
 
6
9
  /** @type {WeakMap<Window, TinyIframeEvents>} */
7
10
  const instances = new WeakMap();
@@ -46,199 +49,12 @@ const instances = new WeakMap();
46
49
  * - Queue management for messages sent before the connection is established.
47
50
  * - Auto-reconnects and resets ports if the target iframe is reloaded.
48
51
  */
49
- class TinyIframeEvents {
50
- #events = new TinyEvents();
51
-
52
- /**
53
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
54
- *
55
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
56
- */
57
- setThrowOnMaxListeners(shouldThrow) {
58
- return this.#events.setThrowOnMaxListeners(shouldThrow);
59
- }
60
-
61
- /**
62
- * Checks whether an error will be thrown when the max listener limit is exceeded.
63
- *
64
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
65
- */
66
- getThrowOnMaxListeners() {
67
- return this.#events.getThrowOnMaxListeners();
68
- }
69
-
70
- /////////////////////////////////////////////////////////////
71
-
72
- /**
73
- * Adds a listener to the beginning of the listeners array for the specified event.
74
- *
75
- * @param {string|string[]} event - Event name.
76
- * @param {handler} handler - The callback function.
77
- */
78
- prependListener(event, handler) {
79
- return this.#events.prependListener(event, handler);
80
- }
81
-
82
- /**
83
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
84
- *
85
- * @param {string|string[]} event - Event name.
86
- * @param {handler} handler - The callback function.
87
- * @returns {handler[]} - The wrapped handler used internally.
88
- */
89
- prependListenerOnce(event, handler) {
90
- return this.#events.prependListenerOnce(event, handler);
91
- }
92
-
93
- //////////////////////////////////////////////////////////////////////
94
-
95
- /**
96
- * Adds a event listener.
97
- *
98
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
99
- * @param {handler} handler - Callback function to be called when event fires.
100
- */
101
- appendListener(event, handler) {
102
- return this.#events.appendListener(event, handler);
103
- }
104
-
105
- /**
106
- * Registers an event listener that runs only once, then is removed.
107
- *
108
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
109
- * @param {handler} handler - The callback function to run on event.
110
- * @returns {handler[]} - The wrapped version of the handler.
111
- */
112
- appendListenerOnce(event, handler) {
113
- return this.#events.appendListenerOnce(event, handler);
114
- }
115
-
116
- /**
117
- * Adds a event listener.
118
- *
119
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
120
- * @param {handler} handler - Callback function to be called when event fires.
121
- */
122
- on(event, handler) {
123
- return this.#events.on(event, handler);
124
- }
125
-
126
- /**
127
- * Registers an event listener that runs only once, then is removed.
128
- *
129
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
130
- * @param {handler} handler - The callback function to run on event.
131
- * @returns {handler[]} - The wrapped version of the handler.
132
- */
133
- once(event, handler) {
134
- return this.#events.once(event, handler);
135
- }
136
-
137
- ////////////////////////////////////////////////////////////////////
138
-
139
- /**
140
- * Removes a previously registered event listener.
141
- *
142
- * @param {string|string[]} event - The name of the event to remove the handler from.
143
- * @param {handler} handler - The specific callback function to remove.
144
- */
145
- off(event, handler) {
146
- return this.#events.off(event, handler);
147
- }
148
-
149
- /**
150
- * Removes all event listeners of a specific type from the element.
151
- *
152
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
153
- */
154
- offAll(event) {
155
- return this.#events.offAll(event);
156
- }
157
-
158
- /**
159
- * Removes all event listeners of all types from the element.
160
- */
161
- offAllTypes() {
162
- return this.#events.offAllTypes();
163
- }
164
-
165
- ////////////////////////////////////////////////////////////
166
-
167
- /**
168
- * Returns the number of listeners for a given event.
169
- *
170
- * @param {string} event - The name of the event.
171
- * @returns {number} Number of listeners for the event.
172
- */
173
- listenerCount(event) {
174
- return this.#events.listenerCount(event);
175
- }
176
-
177
- /**
178
- * Returns a copy of the array of listeners for the specified event.
179
- *
180
- * @param {string} event - The name of the event.
181
- * @returns {handler[]} Array of listener functions.
182
- */
183
- listeners(event) {
184
- return this.#events.listeners(event);
185
- }
186
-
187
- /**
188
- * Returns a copy of the array of listeners for the specified event.
189
- *
190
- * @param {string} event - The name of the event.
191
- * @returns {handler[]} Array of listener functions.
192
- */
193
- onceListeners(event) {
194
- return this.#events.onceListeners(event);
195
- }
196
-
197
- /**
198
- * Returns a copy of the internal listeners array for the specified event,
199
- * including wrapper functions like those used by `.once()`.
200
- * @param {string | symbol} event - The event name.
201
- * @returns {handler[]} An array of raw listener functions.
202
- */
203
- allListeners(event) {
204
- return this.#events.allListeners(event);
205
- }
206
-
207
- /**
208
- * Returns an array of event names for which there are registered listeners.
209
- *
210
- * @returns {string[]} Array of registered event names.
211
- */
212
- eventNames() {
213
- return this.#events.eventNames();
214
- }
215
-
216
- //////////////////////////////////////////////////////
217
-
218
- /**
219
- * Sets the maximum number of listeners per event before a warning is shown.
220
- *
221
- * @param {number} n - The maximum number of listeners.
222
- */
223
- setMaxListeners(n) {
224
- return this.#events.setMaxListeners(n);
225
- }
226
-
227
- /**
228
- * Gets the maximum number of listeners allowed per event.
229
- *
230
- * @returns {number} The maximum number of listeners.
231
- */
232
- getMaxListeners() {
233
- return this.#events.getMaxListeners();
234
- }
235
-
236
- ///////////////////////////////////////////////////
237
-
52
+ class TinyIframeEvents extends events.EventEmitter {
238
53
  /** @type {Window} */
239
54
  #targetWindow;
240
55
 
241
56
  get targetWindow() {
57
+ checkDestroy(this.#isDestroyed);
242
58
  return this.#targetWindow;
243
59
  }
244
60
 
@@ -246,6 +62,7 @@ class TinyIframeEvents {
246
62
  #targetIframeElement;
247
63
 
248
64
  get targetIframeElement() {
65
+ checkDestroy(this.#isDestroyed);
249
66
  return this.#targetIframeElement;
250
67
  }
251
68
 
@@ -253,6 +70,7 @@ class TinyIframeEvents {
253
70
  #targetOrigin;
254
71
 
255
72
  get targetOrigin() {
73
+ checkDestroy(this.#isDestroyed);
256
74
  return this.#targetOrigin;
257
75
  }
258
76
 
@@ -260,6 +78,7 @@ class TinyIframeEvents {
260
78
  #selfType;
261
79
 
262
80
  get selfType() {
81
+ checkDestroy(this.#isDestroyed);
263
82
  return this.#selfType;
264
83
  }
265
84
 
@@ -270,6 +89,7 @@ class TinyIframeEvents {
270
89
  #ready = false;
271
90
 
272
91
  get ready() {
92
+ checkDestroy(this.#isDestroyed);
273
93
  return this.#ready;
274
94
  }
275
95
 
@@ -280,10 +100,11 @@ class TinyIframeEvents {
280
100
  * @param {function(): void} handler - The callback function to execute.
281
101
  */
282
102
  onReady(handler) {
103
+ checkDestroy(this.#isDestroyed);
283
104
  if (this.#ready) {
284
105
  handler();
285
106
  } else {
286
- this.#events.once(this.#readyEventName, handler);
107
+ this.once(this.#readyEventName, handler);
287
108
  }
288
109
  }
289
110
 
@@ -318,6 +139,7 @@ class TinyIframeEvents {
318
139
  handshakeEventName = '__tinyIframeHandshake__',
319
140
  readyEventName = '__tinyIframeReady__',
320
141
  } = {}) {
142
+ super();
321
143
  if (
322
144
  targetIframe !== undefined &&
323
145
  (!(targetIframe instanceof HTMLIFrameElement) || !targetIframe.contentWindow)
@@ -355,6 +177,7 @@ class TinyIframeEvents {
355
177
  * @returns {string}
356
178
  */
357
179
  get secretEventName() {
180
+ checkDestroy(this.#isDestroyed);
358
181
  return this.#secretEventName;
359
182
  }
360
183
 
@@ -364,6 +187,7 @@ class TinyIframeEvents {
364
187
  * @throws {TypeError} If the value is not a string.
365
188
  */
366
189
  set secretEventName(name) {
190
+ checkDestroy(this.#isDestroyed);
367
191
  if (typeof name !== 'string')
368
192
  throw new TypeError('TinyIframeEvents: secretEventName must be a string.');
369
193
  this.#secretEventName = name;
@@ -374,6 +198,7 @@ class TinyIframeEvents {
374
198
  * @returns {string}
375
199
  */
376
200
  get handshakeEventName() {
201
+ checkDestroy(this.#isDestroyed);
377
202
  return this.#handshakeEventName;
378
203
  }
379
204
 
@@ -383,6 +208,7 @@ class TinyIframeEvents {
383
208
  * @throws {TypeError} If the value is not a string.
384
209
  */
385
210
  set handshakeEventName(name) {
211
+ checkDestroy(this.#isDestroyed);
386
212
  if (typeof name !== 'string')
387
213
  throw new TypeError('TinyIframeEvents: handshakeEventName must be a string.');
388
214
  this.#handshakeEventName = name;
@@ -393,6 +219,7 @@ class TinyIframeEvents {
393
219
  * @returns {string}
394
220
  */
395
221
  get readyEventName() {
222
+ checkDestroy(this.#isDestroyed);
396
223
  return this.#readyEventName;
397
224
  }
398
225
 
@@ -402,6 +229,7 @@ class TinyIframeEvents {
402
229
  * @throws {TypeError} If the value is not a string.
403
230
  */
404
231
  set readyEventName(name) {
232
+ checkDestroy(this.#isDestroyed);
405
233
  if (typeof name !== 'string')
406
234
  throw new TypeError('TinyIframeEvents: readyEventName must be a string.');
407
235
  this.#readyEventName = name;
@@ -489,7 +317,7 @@ class TinyIframeEvents {
489
317
  return;
490
318
  }
491
319
 
492
- this.#events.emit(eventName, payload, event);
320
+ this.emit(`win:${eventName}`, payload, event);
493
321
  }
494
322
 
495
323
  /**
@@ -500,7 +328,7 @@ class TinyIframeEvents {
500
328
  if (this.#ready) return;
501
329
  this.#ready = true;
502
330
  this.#flushQueue();
503
- this.#events.emit(this.#readyEventName);
331
+ this.emit(this.#readyEventName);
504
332
  }
505
333
 
506
334
  /**
@@ -525,7 +353,8 @@ class TinyIframeEvents {
525
353
  * @throws {TypeError} If `eventName` is not a string.
526
354
  * @throws {Error} If instance has been destroyed.
527
355
  */
528
- emit(eventName, payload) {
356
+ winEmit(eventName, payload) {
357
+ checkDestroy(this.#isDestroyed);
529
358
  if (typeof eventName !== 'string') throw new TypeError('Event name must be a string.');
530
359
  if (this.#isDestroyed) throw new Error('Cannot emit: instance has been destroyed.');
531
360
 
@@ -559,7 +388,7 @@ class TinyIframeEvents {
559
388
  * Call this when the instance is no longer needed to prevent memory leaks.
560
389
  */
561
390
  destroy() {
562
- this.#isDestroyed = true;
391
+ if (this.#isDestroyed) return;
563
392
  this.#ready = false;
564
393
 
565
394
  window.removeEventListener('message', this._boundWindowMessage);
@@ -573,9 +402,10 @@ class TinyIframeEvents {
573
402
  this.#port = null;
574
403
  }
575
404
 
576
- this.#events.offAllTypes();
405
+ this.removeAllListeners();
577
406
  this.#pendingQueue = [];
578
407
  instances.delete(this.#targetWindow);
408
+ this.#isDestroyed = true;
579
409
  }
580
410
  }
581
411
 
@@ -86,7 +86,7 @@ export type IframeEventBase = {
86
86
  * - Queue management for messages sent before the connection is established.
87
87
  * - Auto-reconnects and resets ports if the target iframe is reloaded.
88
88
  */
89
- declare class TinyIframeEvents {
89
+ declare class TinyIframeEvents extends EventEmitter<any> {
90
90
  /**
91
91
  * Creates a new TinyIframeEvents instance to manage secure communication.
92
92
  * Automatically establishes a MessageChannel connection between contexts.
@@ -94,126 +94,6 @@ declare class TinyIframeEvents {
94
94
  * @param {TinyIframeEventsConfig} config - Configuration object.
95
95
  */
96
96
  constructor({ targetIframe, targetOrigin, secretEventName, handshakeEventName, readyEventName, }?: TinyIframeEventsConfig);
97
- /**
98
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
99
- *
100
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
101
- */
102
- setThrowOnMaxListeners(shouldThrow: boolean): void;
103
- /**
104
- * Checks whether an error will be thrown when the max listener limit is exceeded.
105
- *
106
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
107
- */
108
- getThrowOnMaxListeners(): boolean;
109
- /**
110
- * Adds a listener to the beginning of the listeners array for the specified event.
111
- *
112
- * @param {string|string[]} event - Event name.
113
- * @param {handler} handler - The callback function.
114
- */
115
- prependListener(event: string | string[], handler: handler): void;
116
- /**
117
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
118
- *
119
- * @param {string|string[]} event - Event name.
120
- * @param {handler} handler - The callback function.
121
- * @returns {handler[]} - The wrapped handler used internally.
122
- */
123
- prependListenerOnce(event: string | string[], handler: handler): handler[];
124
- /**
125
- * Adds a event listener.
126
- *
127
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
128
- * @param {handler} handler - Callback function to be called when event fires.
129
- */
130
- appendListener(event: string | string[], handler: handler): void;
131
- /**
132
- * Registers an event listener that runs only once, then is removed.
133
- *
134
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
135
- * @param {handler} handler - The callback function to run on event.
136
- * @returns {handler[]} - The wrapped version of the handler.
137
- */
138
- appendListenerOnce(event: string | string[], handler: handler): handler[];
139
- /**
140
- * Adds a event listener.
141
- *
142
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
143
- * @param {handler} handler - Callback function to be called when event fires.
144
- */
145
- on(event: string | string[], handler: handler): void;
146
- /**
147
- * Registers an event listener that runs only once, then is removed.
148
- *
149
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
150
- * @param {handler} handler - The callback function to run on event.
151
- * @returns {handler[]} - The wrapped version of the handler.
152
- */
153
- once(event: string | string[], handler: handler): handler[];
154
- /**
155
- * Removes a previously registered event listener.
156
- *
157
- * @param {string|string[]} event - The name of the event to remove the handler from.
158
- * @param {handler} handler - The specific callback function to remove.
159
- */
160
- off(event: string | string[], handler: handler): void;
161
- /**
162
- * Removes all event listeners of a specific type from the element.
163
- *
164
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
165
- */
166
- offAll(event: string | string[]): void;
167
- /**
168
- * Removes all event listeners of all types from the element.
169
- */
170
- offAllTypes(): void;
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: string): number;
178
- /**
179
- * Returns a copy of the array of listeners for the specified event.
180
- *
181
- * @param {string} event - The name of the event.
182
- * @returns {handler[]} Array of listener functions.
183
- */
184
- listeners(event: string): handler[];
185
- /**
186
- * Returns a copy of the array of listeners for the specified event.
187
- *
188
- * @param {string} event - The name of the event.
189
- * @returns {handler[]} Array of listener functions.
190
- */
191
- onceListeners(event: string): handler[];
192
- /**
193
- * Returns a copy of the internal listeners array for the specified event,
194
- * including wrapper functions like those used by `.once()`.
195
- * @param {string | symbol} event - The event name.
196
- * @returns {handler[]} An array of raw listener functions.
197
- */
198
- allListeners(event: string | symbol): handler[];
199
- /**
200
- * Returns an array of event names for which there are registered listeners.
201
- *
202
- * @returns {string[]} Array of registered event names.
203
- */
204
- eventNames(): string[];
205
- /**
206
- * Sets the maximum number of listeners per event before a warning is shown.
207
- *
208
- * @param {number} n - The maximum number of listeners.
209
- */
210
- setMaxListeners(n: number): void;
211
- /**
212
- * Gets the maximum number of listeners allowed per event.
213
- *
214
- * @returns {number} The maximum number of listeners.
215
- */
216
- getMaxListeners(): number;
217
97
  get targetWindow(): Window;
218
98
  get targetIframeElement(): HTMLIFrameElement | undefined;
219
99
  get targetOrigin(): string;
@@ -269,7 +149,7 @@ declare class TinyIframeEvents {
269
149
  * @throws {TypeError} If `eventName` is not a string.
270
150
  * @throws {Error} If instance has been destroyed.
271
151
  */
272
- emit(eventName: string, payload: any): void;
152
+ winEmit(eventName: string, payload: any): void;
273
153
  /**
274
154
  * Checks if the communication instance has been destroyed.
275
155
  *
@@ -283,4 +163,5 @@ declare class TinyIframeEvents {
283
163
  destroy(): void;
284
164
  #private;
285
165
  }
166
+ import { EventEmitter } from 'events';
286
167
  //# sourceMappingURL=TinyIframeEvents.d.mts.map