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,7 @@
1
+ import { EventEmitter } from 'events';
1
2
  import { isJsonObject } from '../basics/objChecker.mjs';
2
- import TinyEvents from './TinyEvents.mjs';
3
+ import { createCheckDestroyed } from './utils.mjs';
4
+ const checkDestroy = createCheckDestroyed('TinyIframeEvents');
3
5
  /** @type {WeakMap<Window, TinyIframeEvents>} */
4
6
  const instances = new WeakMap();
5
7
  /**
@@ -39,188 +41,29 @@ const instances = new WeakMap();
39
41
  * - Queue management for messages sent before the connection is established.
40
42
  * - Auto-reconnects and resets ports if the target iframe is reloaded.
41
43
  */
42
- class TinyIframeEvents {
43
- #events = new TinyEvents();
44
- /**
45
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
46
- *
47
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
48
- */
49
- setThrowOnMaxListeners(shouldThrow) {
50
- return this.#events.setThrowOnMaxListeners(shouldThrow);
51
- }
52
- /**
53
- * Checks whether an error will be thrown when the max listener limit is exceeded.
54
- *
55
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
56
- */
57
- getThrowOnMaxListeners() {
58
- return this.#events.getThrowOnMaxListeners();
59
- }
60
- /////////////////////////////////////////////////////////////
61
- /**
62
- * Adds a listener to the beginning of the listeners array for the specified event.
63
- *
64
- * @param {string|string[]} event - Event name.
65
- * @param {handler} handler - The callback function.
66
- */
67
- prependListener(event, handler) {
68
- return this.#events.prependListener(event, handler);
69
- }
70
- /**
71
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
72
- *
73
- * @param {string|string[]} event - Event name.
74
- * @param {handler} handler - The callback function.
75
- * @returns {handler[]} - The wrapped handler used internally.
76
- */
77
- prependListenerOnce(event, handler) {
78
- return this.#events.prependListenerOnce(event, handler);
79
- }
80
- //////////////////////////////////////////////////////////////////////
81
- /**
82
- * Adds a event listener.
83
- *
84
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
85
- * @param {handler} handler - Callback function to be called when event fires.
86
- */
87
- appendListener(event, handler) {
88
- return this.#events.appendListener(event, handler);
89
- }
90
- /**
91
- * Registers an event listener that runs only once, then is removed.
92
- *
93
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
94
- * @param {handler} handler - The callback function to run on event.
95
- * @returns {handler[]} - The wrapped version of the handler.
96
- */
97
- appendListenerOnce(event, handler) {
98
- return this.#events.appendListenerOnce(event, handler);
99
- }
100
- /**
101
- * Adds a event listener.
102
- *
103
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
104
- * @param {handler} handler - Callback function to be called when event fires.
105
- */
106
- on(event, handler) {
107
- return this.#events.on(event, handler);
108
- }
109
- /**
110
- * Registers an event listener that runs only once, then is removed.
111
- *
112
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
113
- * @param {handler} handler - The callback function to run on event.
114
- * @returns {handler[]} - The wrapped version of the handler.
115
- */
116
- once(event, handler) {
117
- return this.#events.once(event, handler);
118
- }
119
- ////////////////////////////////////////////////////////////////////
120
- /**
121
- * Removes a previously registered event listener.
122
- *
123
- * @param {string|string[]} event - The name of the event to remove the handler from.
124
- * @param {handler} handler - The specific callback function to remove.
125
- */
126
- off(event, handler) {
127
- return this.#events.off(event, handler);
128
- }
129
- /**
130
- * Removes all event listeners of a specific type from the element.
131
- *
132
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
133
- */
134
- offAll(event) {
135
- return this.#events.offAll(event);
136
- }
137
- /**
138
- * Removes all event listeners of all types from the element.
139
- */
140
- offAllTypes() {
141
- return this.#events.offAllTypes();
142
- }
143
- ////////////////////////////////////////////////////////////
144
- /**
145
- * Returns the number of listeners for a given event.
146
- *
147
- * @param {string} event - The name of the event.
148
- * @returns {number} Number of listeners for the event.
149
- */
150
- listenerCount(event) {
151
- return this.#events.listenerCount(event);
152
- }
153
- /**
154
- * Returns a copy of the array of listeners for the specified event.
155
- *
156
- * @param {string} event - The name of the event.
157
- * @returns {handler[]} Array of listener functions.
158
- */
159
- listeners(event) {
160
- return this.#events.listeners(event);
161
- }
162
- /**
163
- * Returns a copy of the array of listeners for the specified event.
164
- *
165
- * @param {string} event - The name of the event.
166
- * @returns {handler[]} Array of listener functions.
167
- */
168
- onceListeners(event) {
169
- return this.#events.onceListeners(event);
170
- }
171
- /**
172
- * Returns a copy of the internal listeners array for the specified event,
173
- * including wrapper functions like those used by `.once()`.
174
- * @param {string | symbol} event - The event name.
175
- * @returns {handler[]} An array of raw listener functions.
176
- */
177
- allListeners(event) {
178
- return this.#events.allListeners(event);
179
- }
180
- /**
181
- * Returns an array of event names for which there are registered listeners.
182
- *
183
- * @returns {string[]} Array of registered event names.
184
- */
185
- eventNames() {
186
- return this.#events.eventNames();
187
- }
188
- //////////////////////////////////////////////////////
189
- /**
190
- * Sets the maximum number of listeners per event before a warning is shown.
191
- *
192
- * @param {number} n - The maximum number of listeners.
193
- */
194
- setMaxListeners(n) {
195
- return this.#events.setMaxListeners(n);
196
- }
197
- /**
198
- * Gets the maximum number of listeners allowed per event.
199
- *
200
- * @returns {number} The maximum number of listeners.
201
- */
202
- getMaxListeners() {
203
- return this.#events.getMaxListeners();
204
- }
205
- ///////////////////////////////////////////////////
44
+ class TinyIframeEvents extends EventEmitter {
206
45
  /** @type {Window} */
207
46
  #targetWindow;
208
47
  get targetWindow() {
48
+ checkDestroy(this.#isDestroyed);
209
49
  return this.#targetWindow;
210
50
  }
211
51
  /** @type {HTMLIFrameElement | undefined} */
212
52
  #targetIframeElement;
213
53
  get targetIframeElement() {
54
+ checkDestroy(this.#isDestroyed);
214
55
  return this.#targetIframeElement;
215
56
  }
216
57
  /** @type {string} */
217
58
  #targetOrigin;
218
59
  get targetOrigin() {
60
+ checkDestroy(this.#isDestroyed);
219
61
  return this.#targetOrigin;
220
62
  }
221
63
  /** @type {'iframe' | 'parent'} */
222
64
  #selfType;
223
65
  get selfType() {
66
+ checkDestroy(this.#isDestroyed);
224
67
  return this.#selfType;
225
68
  }
226
69
  /** @type {boolean} */
@@ -228,6 +71,7 @@ class TinyIframeEvents {
228
71
  /** @type {boolean} */
229
72
  #ready = false;
230
73
  get ready() {
74
+ checkDestroy(this.#isDestroyed);
231
75
  return this.#ready;
232
76
  }
233
77
  /**
@@ -237,11 +81,12 @@ class TinyIframeEvents {
237
81
  * @param {function(): void} handler - The callback function to execute.
238
82
  */
239
83
  onReady(handler) {
84
+ checkDestroy(this.#isDestroyed);
240
85
  if (this.#ready) {
241
86
  handler();
242
87
  }
243
88
  else {
244
- this.#events.once(this.#readyEventName, handler);
89
+ this.once(this.#readyEventName, handler);
245
90
  }
246
91
  }
247
92
  /** @type {MessagePort | null} */
@@ -263,6 +108,7 @@ class TinyIframeEvents {
263
108
  * @param {TinyIframeEventsConfig} config - Configuration object.
264
109
  */
265
110
  constructor({ targetIframe, targetOrigin = window.location.origin, secretEventName = '__tinyIframeEvent__', handshakeEventName = '__tinyIframeHandshake__', readyEventName = '__tinyIframeReady__', } = {}) {
111
+ super();
266
112
  if (targetIframe !== undefined &&
267
113
  (!(targetIframe instanceof HTMLIFrameElement) || !targetIframe.contentWindow)) {
268
114
  throw new TypeError(`[TinyIframeEvents] Invalid "targetIframe": expected HTMLIFrameElement, received ${typeof targetIframe}`);
@@ -289,6 +135,7 @@ class TinyIframeEvents {
289
135
  * @returns {string}
290
136
  */
291
137
  get secretEventName() {
138
+ checkDestroy(this.#isDestroyed);
292
139
  return this.#secretEventName;
293
140
  }
294
141
  /**
@@ -297,6 +144,7 @@ class TinyIframeEvents {
297
144
  * @throws {TypeError} If the value is not a string.
298
145
  */
299
146
  set secretEventName(name) {
147
+ checkDestroy(this.#isDestroyed);
300
148
  if (typeof name !== 'string')
301
149
  throw new TypeError('TinyIframeEvents: secretEventName must be a string.');
302
150
  this.#secretEventName = name;
@@ -306,6 +154,7 @@ class TinyIframeEvents {
306
154
  * @returns {string}
307
155
  */
308
156
  get handshakeEventName() {
157
+ checkDestroy(this.#isDestroyed);
309
158
  return this.#handshakeEventName;
310
159
  }
311
160
  /**
@@ -314,6 +163,7 @@ class TinyIframeEvents {
314
163
  * @throws {TypeError} If the value is not a string.
315
164
  */
316
165
  set handshakeEventName(name) {
166
+ checkDestroy(this.#isDestroyed);
317
167
  if (typeof name !== 'string')
318
168
  throw new TypeError('TinyIframeEvents: handshakeEventName must be a string.');
319
169
  this.#handshakeEventName = name;
@@ -323,6 +173,7 @@ class TinyIframeEvents {
323
173
  * @returns {string}
324
174
  */
325
175
  get readyEventName() {
176
+ checkDestroy(this.#isDestroyed);
326
177
  return this.#readyEventName;
327
178
  }
328
179
  /**
@@ -331,6 +182,7 @@ class TinyIframeEvents {
331
182
  * @throws {TypeError} If the value is not a string.
332
183
  */
333
184
  set readyEventName(name) {
185
+ checkDestroy(this.#isDestroyed);
334
186
  if (typeof name !== 'string')
335
187
  throw new TypeError('TinyIframeEvents: readyEventName must be a string.');
336
188
  this.#readyEventName = name;
@@ -404,7 +256,7 @@ class TinyIframeEvents {
404
256
  (this.#selfType === 'parent' && direction !== 'parent')) {
405
257
  return;
406
258
  }
407
- this.#events.emit(eventName, payload, event);
259
+ this.emit(`win:${eventName}`, payload, event);
408
260
  }
409
261
  /**
410
262
  * Marks the communication as ready, flushes any queued messages,
@@ -415,7 +267,7 @@ class TinyIframeEvents {
415
267
  return;
416
268
  this.#ready = true;
417
269
  this.#flushQueue();
418
- this.#events.emit(this.#readyEventName);
270
+ this.emit(this.#readyEventName);
419
271
  }
420
272
  /**
421
273
  * Sends all pending messages queued before the secure port was established.
@@ -437,7 +289,8 @@ class TinyIframeEvents {
437
289
  * @throws {TypeError} If `eventName` is not a string.
438
290
  * @throws {Error} If instance has been destroyed.
439
291
  */
440
- emit(eventName, payload) {
292
+ winEmit(eventName, payload) {
293
+ checkDestroy(this.#isDestroyed);
441
294
  if (typeof eventName !== 'string')
442
295
  throw new TypeError('Event name must be a string.');
443
296
  if (this.#isDestroyed)
@@ -468,7 +321,8 @@ class TinyIframeEvents {
468
321
  * Call this when the instance is no longer needed to prevent memory leaks.
469
322
  */
470
323
  destroy() {
471
- this.#isDestroyed = true;
324
+ if (this.#isDestroyed)
325
+ return;
472
326
  this.#ready = false;
473
327
  window.removeEventListener('message', this._boundWindowMessage);
474
328
  if (this.#targetIframeElement && this.#boundSendPort) {
@@ -478,9 +332,10 @@ class TinyIframeEvents {
478
332
  this.#port.close();
479
333
  this.#port = null;
480
334
  }
481
- this.#events.offAllTypes();
335
+ this.removeAllListeners();
482
336
  this.#pendingQueue = [];
483
337
  instances.delete(this.#targetWindow);
338
+ this.#isDestroyed = true;
484
339
  }
485
340
  }
486
341
  export default TinyIframeEvents;