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,6 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var TinyEvents = require('./TinyEvents.cjs');
3
+ var events = require('events');
4
+ var utils = require('./utils.cjs');
5
+
6
+ const checkDestroy = utils.createCheckDestroyed('TinyNewWinEvents');
4
7
 
5
8
  /**
6
9
  * Stores polling intervals associated with window references.
@@ -26,195 +29,7 @@ const pollClosedInterval = new WeakMap();
26
29
  *
27
30
  * @class
28
31
  */
29
- class TinyNewWinEvents {
30
- #events = new TinyEvents();
31
-
32
- /**
33
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
34
- *
35
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
36
- */
37
- setThrowOnMaxListeners(shouldThrow) {
38
- return this.#events.setThrowOnMaxListeners(shouldThrow);
39
- }
40
-
41
- /**
42
- * Checks whether an error will be thrown when the max listener limit is exceeded.
43
- *
44
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
45
- */
46
- getThrowOnMaxListeners() {
47
- return this.#events.getThrowOnMaxListeners();
48
- }
49
-
50
- /////////////////////////////////////////////////////////////
51
-
52
- /**
53
- * Adds a listener to the beginning of the listeners array for the specified event.
54
- *
55
- * @param {string|string[]} event - Event name.
56
- * @param {handler} handler - The callback function.
57
- */
58
- prependListener(event, handler) {
59
- return this.#events.prependListener(event, handler);
60
- }
61
-
62
- /**
63
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
64
- *
65
- * @param {string|string[]} event - Event name.
66
- * @param {handler} handler - The callback function.
67
- * @returns {handler[]} - The wrapped handler used internally.
68
- */
69
- prependListenerOnce(event, handler) {
70
- return this.#events.prependListenerOnce(event, handler);
71
- }
72
-
73
- //////////////////////////////////////////////////////////////////////
74
-
75
- /**
76
- * Adds a event listener.
77
- *
78
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
79
- * @param {handler} handler - Callback function to be called when event fires.
80
- */
81
- appendListener(event, handler) {
82
- return this.#events.appendListener(event, handler);
83
- }
84
-
85
- /**
86
- * Registers an event listener that runs only once, then is removed.
87
- *
88
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
89
- * @param {handler} handler - The callback function to run on event.
90
- * @returns {handler[]} - The wrapped version of the handler.
91
- */
92
- appendListenerOnce(event, handler) {
93
- return this.#events.appendListenerOnce(event, handler);
94
- }
95
-
96
- /**
97
- * Adds a event listener.
98
- *
99
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
100
- * @param {handler} handler - Callback function to be called when event fires.
101
- */
102
- on(event, handler) {
103
- return this.#events.on(event, handler);
104
- }
105
-
106
- /**
107
- * Registers an event listener that runs only once, then is removed.
108
- *
109
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
110
- * @param {handler} handler - The callback function to run on event.
111
- * @returns {handler[]} - The wrapped version of the handler.
112
- */
113
- once(event, handler) {
114
- return this.#events.once(event, handler);
115
- }
116
-
117
- ////////////////////////////////////////////////////////////////////
118
-
119
- /**
120
- * Removes a previously registered event listener.
121
- *
122
- * @param {string|string[]} event - The name of the event to remove the handler from.
123
- * @param {handler} handler - The specific callback function to remove.
124
- */
125
- off(event, handler) {
126
- return this.#events.off(event, handler);
127
- }
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
- /**
139
- * Removes all event listeners of all types from the element.
140
- */
141
- offAllTypes() {
142
- return this.#events.offAllTypes();
143
- }
144
-
145
- ////////////////////////////////////////////////////////////
146
-
147
- /**
148
- * Returns the number of listeners for a given event.
149
- *
150
- * @param {string} event - The name of the event.
151
- * @returns {number} Number of listeners for the event.
152
- */
153
- listenerCount(event) {
154
- return this.#events.listenerCount(event);
155
- }
156
-
157
- /**
158
- * Returns a copy of the array of listeners for the specified event.
159
- *
160
- * @param {string} event - The name of the event.
161
- * @returns {handler[]} Array of listener functions.
162
- */
163
- listeners(event) {
164
- return this.#events.listeners(event);
165
- }
166
-
167
- /**
168
- * Returns a copy of the array of listeners for the specified event.
169
- *
170
- * @param {string} event - The name of the event.
171
- * @returns {handler[]} Array of listener functions.
172
- */
173
- onceListeners(event) {
174
- return this.#events.onceListeners(event);
175
- }
176
-
177
- /**
178
- * Returns a copy of the internal listeners array for the specified event,
179
- * including wrapper functions like those used by `.once()`.
180
- * @param {string | symbol} event - The event name.
181
- * @returns {handler[]} An array of raw listener functions.
182
- */
183
- allListeners(event) {
184
- return this.#events.allListeners(event);
185
- }
186
-
187
- /**
188
- * Returns an array of event names for which there are registered listeners.
189
- *
190
- * @returns {string[]} Array of registered event names.
191
- */
192
- eventNames() {
193
- return this.#events.eventNames();
194
- }
195
-
196
- //////////////////////////////////////////////////////
197
-
198
- /**
199
- * Sets the maximum number of listeners per event before a warning is shown.
200
- *
201
- * @param {number} n - The maximum number of listeners.
202
- */
203
- setMaxListeners(n) {
204
- return this.#events.setMaxListeners(n);
205
- }
206
-
207
- /**
208
- * Gets the maximum number of listeners allowed per event.
209
- *
210
- * @returns {number} The maximum number of listeners.
211
- */
212
- getMaxListeners() {
213
- return this.#events.getMaxListeners();
214
- }
215
-
216
- ///////////////////////////////////////////////////
217
-
32
+ class TinyNewWinEvents extends events.EventEmitter {
218
33
  /** @type {Window|null} Reference to the opened or parent window */
219
34
  #windowRef;
220
35
 
@@ -239,11 +54,27 @@ class TinyNewWinEvents {
239
54
  /** @type {string} Internal message type for routed communication */
240
55
  #routeEventName = '__TNE_ROUTE__';
241
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
+
242
72
  /**
243
73
  * Gets the internal handshake event name.
244
74
  * @returns {string}
245
75
  */
246
76
  get readyEventName() {
77
+ checkDestroy(this.#destroyed);
247
78
  return this.#readyEventName;
248
79
  }
249
80
 
@@ -253,6 +84,7 @@ class TinyNewWinEvents {
253
84
  * @throws {TypeError} If the value is not a string.
254
85
  */
255
86
  set readyEventName(name) {
87
+ checkDestroy(this.#destroyed);
256
88
  if (typeof name !== 'string')
257
89
  throw new TypeError('TinyNewWinEvents: readyEventName must be a string.');
258
90
  this.#readyEventName = name;
@@ -263,6 +95,7 @@ class TinyNewWinEvents {
263
95
  * @returns {string}
264
96
  */
265
97
  get routeEventName() {
98
+ checkDestroy(this.#destroyed);
266
99
  return this.#routeEventName;
267
100
  }
268
101
 
@@ -272,6 +105,7 @@ class TinyNewWinEvents {
272
105
  * @throws {TypeError} If the value is not a string.
273
106
  */
274
107
  set routeEventName(name) {
108
+ checkDestroy(this.#destroyed);
275
109
  if (typeof name !== 'string')
276
110
  throw new TypeError('TinyNewWinEvents: routeEventName must be a string.');
277
111
  this.#routeEventName = name;
@@ -291,6 +125,7 @@ class TinyNewWinEvents {
291
125
  * @throws {Error} If the window reference is invalid or already being tracked.
292
126
  */
293
127
  constructor({ targetOrigin, url, name, features } = {}) {
128
+ super();
294
129
  if (typeof name === 'string' && name === '_blank')
295
130
  throw new Error(
296
131
  'TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.',
@@ -329,6 +164,7 @@ class TinyNewWinEvents {
329
164
  * @returns {Window|null}
330
165
  */
331
166
  getWin() {
167
+ checkDestroy(this.#destroyed);
332
168
  return this.#windowRef;
333
169
  }
334
170
 
@@ -350,7 +186,7 @@ class TinyNewWinEvents {
350
186
  return;
351
187
  }
352
188
 
353
- if (type === this.#routeEventName) this.#events.emit(route, payload, event);
189
+ if (type === this.#routeEventName) this.emit(`win:${route}`, payload, event);
354
190
  }
355
191
 
356
192
  /**
@@ -363,7 +199,7 @@ class TinyNewWinEvents {
363
199
  const data = this.#pendingQueue.shift();
364
200
  if (data) {
365
201
  const { route, payload } = data;
366
- this.emit(route, payload);
202
+ this.winEmit(route, payload);
367
203
  }
368
204
  }
369
205
  }
@@ -387,6 +223,7 @@ class TinyNewWinEvents {
387
223
  * @returns {void}
388
224
  */
389
225
  close() {
226
+ checkDestroy(this.#destroyed);
390
227
  if (!this.#isHost) throw new Error('Only host can close the window.');
391
228
  if (this.#windowRef && !this.#windowRef.closed) this.#windowRef.close();
392
229
  }
@@ -401,7 +238,8 @@ class TinyNewWinEvents {
401
238
  * @throws {Error} If the instance is already destroyed.
402
239
  * @returns {void}
403
240
  */
404
- emit(route, payload) {
241
+ winEmit(route, payload) {
242
+ checkDestroy(this.#destroyed);
405
243
  if (typeof route !== 'string') throw new TypeError('Event name must be a string.');
406
244
  if (this.isDestroyed()) throw new Error('Cannot emit: instance has been destroyed.');
407
245
  if (!this.#ready) {
@@ -417,6 +255,7 @@ class TinyNewWinEvents {
417
255
  * @returns {boolean}
418
256
  */
419
257
  isConnected() {
258
+ checkDestroy(this.#destroyed);
420
259
  return this.#ready && this.#windowRef && !this.#windowRef.closed ? true : false;
421
260
  }
422
261
 
@@ -429,7 +268,7 @@ class TinyNewWinEvents {
429
268
  if (!this.#windowRef || this.#pollClosedInterval) return;
430
269
  this.#pollClosedInterval = setInterval(() => {
431
270
  if (this.#windowRef?.closed) {
432
- this.#events.emit('WINDOW_REF_CLOSED');
271
+ this.emit('WINDOW_REF_CLOSED');
433
272
  this.destroy();
434
273
  }
435
274
  }, 500);
@@ -443,7 +282,8 @@ class TinyNewWinEvents {
443
282
  * @returns {void}
444
283
  */
445
284
  onClose(callback) {
446
- return this.#events.on('WINDOW_REF_CLOSED', callback);
285
+ checkDestroy(this.#destroyed);
286
+ this.on('WINDOW_REF_CLOSED', callback);
447
287
  }
448
288
 
449
289
  /**
@@ -453,7 +293,8 @@ class TinyNewWinEvents {
453
293
  * @returns {void}
454
294
  */
455
295
  offClose(callback) {
456
- return this.#events.off('WINDOW_REF_CLOSED', callback);
296
+ checkDestroy(this.#destroyed);
297
+ this.off('WINDOW_REF_CLOSED', callback);
457
298
  }
458
299
 
459
300
  /**
@@ -481,7 +322,8 @@ class TinyNewWinEvents {
481
322
  this.#pendingQueue = [];
482
323
  this.#ready = false;
483
324
  this.#windowRef = null;
484
- this.#events.offAllTypes();
325
+ this.removeAllListeners();
326
+ this.#destroyed = true;
485
327
  }
486
328
  }
487
329
 
@@ -18,7 +18,7 @@ export type handler = (payload: any, event: MessageEvent<any>) => any;
18
18
  *
19
19
  * @class
20
20
  */
21
- declare class TinyNewWinEvents {
21
+ declare class TinyNewWinEvents extends EventEmitter<any> {
22
22
  /**
23
23
  * Initializes a TinyNewWinEvents instance for communication.
24
24
  *
@@ -39,125 +39,11 @@ declare class TinyNewWinEvents {
39
39
  features?: string | undefined;
40
40
  });
41
41
  /**
42
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
42
+ * Gets the current destruction status of the instance.
43
43
  *
44
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
44
+ * @returns {boolean} True if the instance is destroyed, false otherwise.
45
45
  */
46
- setThrowOnMaxListeners(shouldThrow: boolean): void;
47
- /**
48
- * Checks whether an error will be thrown when the max listener limit is exceeded.
49
- *
50
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
51
- */
52
- getThrowOnMaxListeners(): boolean;
53
- /**
54
- * Adds a listener to the beginning of the listeners array for the specified event.
55
- *
56
- * @param {string|string[]} event - Event name.
57
- * @param {handler} handler - The callback function.
58
- */
59
- prependListener(event: string | string[], handler: handler): void;
60
- /**
61
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
62
- *
63
- * @param {string|string[]} event - Event name.
64
- * @param {handler} handler - The callback function.
65
- * @returns {handler[]} - The wrapped handler used internally.
66
- */
67
- prependListenerOnce(event: string | string[], handler: handler): handler[];
68
- /**
69
- * Adds a event listener.
70
- *
71
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
72
- * @param {handler} handler - Callback function to be called when event fires.
73
- */
74
- appendListener(event: string | string[], handler: handler): void;
75
- /**
76
- * Registers an event listener that runs only once, then is removed.
77
- *
78
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
79
- * @param {handler} handler - The callback function to run on event.
80
- * @returns {handler[]} - The wrapped version of the handler.
81
- */
82
- appendListenerOnce(event: string | string[], handler: handler): handler[];
83
- /**
84
- * Adds a event listener.
85
- *
86
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
87
- * @param {handler} handler - Callback function to be called when event fires.
88
- */
89
- on(event: string | string[], handler: handler): void;
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
- once(event: string | string[], handler: handler): handler[];
98
- /**
99
- * Removes a previously registered event listener.
100
- *
101
- * @param {string|string[]} event - The name of the event to remove the handler from.
102
- * @param {handler} handler - The specific callback function to remove.
103
- */
104
- off(event: string | string[], handler: handler): void;
105
- /**
106
- * Removes all event listeners of a specific type from the element.
107
- *
108
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
109
- */
110
- offAll(event: string | string[]): void;
111
- /**
112
- * Removes all event listeners of all types from the element.
113
- */
114
- offAllTypes(): void;
115
- /**
116
- * Returns the number of listeners for a given event.
117
- *
118
- * @param {string} event - The name of the event.
119
- * @returns {number} Number of listeners for the event.
120
- */
121
- listenerCount(event: string): number;
122
- /**
123
- * Returns a copy of the array of listeners for the specified event.
124
- *
125
- * @param {string} event - The name of the event.
126
- * @returns {handler[]} Array of listener functions.
127
- */
128
- listeners(event: string): handler[];
129
- /**
130
- * Returns a copy of the array of listeners for the specified event.
131
- *
132
- * @param {string} event - The name of the event.
133
- * @returns {handler[]} Array of listener functions.
134
- */
135
- onceListeners(event: string): handler[];
136
- /**
137
- * Returns a copy of the internal listeners array for the specified event,
138
- * including wrapper functions like those used by `.once()`.
139
- * @param {string | symbol} event - The event name.
140
- * @returns {handler[]} An array of raw listener functions.
141
- */
142
- allListeners(event: string | symbol): handler[];
143
- /**
144
- * Returns an array of event names for which there are registered listeners.
145
- *
146
- * @returns {string[]} Array of registered event names.
147
- */
148
- eventNames(): string[];
149
- /**
150
- * Sets the maximum number of listeners per event before a warning is shown.
151
- *
152
- * @param {number} n - The maximum number of listeners.
153
- */
154
- setMaxListeners(n: number): void;
155
- /**
156
- * Gets the maximum number of listeners allowed per event.
157
- *
158
- * @returns {number} The maximum number of listeners.
159
- */
160
- getMaxListeners(): number;
46
+ get destroyed(): boolean;
161
47
  /**
162
48
  * Sets the internal handshake event name.
163
49
  * @param {string} name
@@ -203,7 +89,7 @@ declare class TinyNewWinEvents {
203
89
  * @throws {Error} If the instance is already destroyed.
204
90
  * @returns {void}
205
91
  */
206
- emit(route: string, payload: any): void;
92
+ winEmit(route: string, payload: any): void;
207
93
  /**
208
94
  * Checks if the connection is active and the window is still open.
209
95
  *
@@ -238,4 +124,5 @@ declare class TinyNewWinEvents {
238
124
  destroy(): void;
239
125
  #private;
240
126
  }
127
+ import { EventEmitter } from 'events';
241
128
  //# sourceMappingURL=TinyNewWinEvents.d.mts.map