tiny-essentials 1.27.1 → 1.28.0

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 (60) hide show
  1. package/README.md +1 -0
  2. package/changelog/1/28/0.md +16 -0
  3. package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
  4. package/dist/v1/TinyBasicsEs.min.js +1 -2
  5. package/dist/v1/TinyEssentials.min.js +1 -2
  6. package/dist/v1/TinyIframeEvents.min.js +1 -1
  7. package/dist/v1/TinyLocalStorage.min.js +1 -1
  8. package/dist/v1/TinyMediaPlayer.min.js +1 -1
  9. package/dist/v1/TinyNewWinEvents.min.js +1 -1
  10. package/dist/v1/TinyRadioFm.min.js +1 -1
  11. package/dist/v1/TinySmartScroller.min.js +1 -1
  12. package/dist/v1/TinyUploadClicker.min.js +1 -2
  13. package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
  14. package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
  15. package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
  16. package/dist/v1/basics/objFilter.cjs +0 -11
  17. package/dist/v1/basics/objFilter.mjs +0 -10
  18. package/dist/v1/index.cjs +0 -2
  19. package/dist/v1/index.d.mts +1 -2
  20. package/dist/v1/index.mjs +1 -2
  21. package/dist/v1/libs/TinyAdvancedRaffle.cjs +7 -205
  22. package/dist/v1/libs/TinyAdvancedRaffle.d.mts +2 -121
  23. package/dist/v1/libs/TinyAdvancedRaffle.mjs +7 -179
  24. package/dist/v1/libs/TinyIframeEvents.cjs +8 -195
  25. package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
  26. package/dist/v1/libs/TinyIframeEvents.mjs +8 -170
  27. package/dist/v1/libs/TinyLocalStorage.cjs +5 -205
  28. package/dist/v1/libs/TinyLocalStorage.d.mts +3 -130
  29. package/dist/v1/libs/TinyLocalStorage.mjs +5 -178
  30. package/dist/v1/libs/TinyMediaPlayer.cjs +2 -2
  31. package/dist/v1/libs/TinyMediaPlayer.d.mts +2 -2
  32. package/dist/v1/libs/TinyMediaPlayer.mjs +2 -2
  33. package/dist/v1/libs/TinyNewWinEvents.cjs +10 -197
  34. package/dist/v1/libs/TinyNewWinEvents.d.mts +3 -122
  35. package/dist/v1/libs/TinyNewWinEvents.mjs +10 -172
  36. package/dist/v1/libs/TinyRadioFm.cjs +2 -3
  37. package/dist/v1/libs/TinyRadioFm.d.mts +2 -3
  38. package/dist/v1/libs/TinyRadioFm.mjs +2 -3
  39. package/dist/v1/libs/TinySmartScroller.cjs +4 -202
  40. package/dist/v1/libs/TinySmartScroller.d.mts +8 -143
  41. package/dist/v1/libs/TinySmartScroller.mjs +4 -176
  42. package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
  43. package/docs/v1/Exports.md +0 -1
  44. package/docs/v1/README.md +0 -1
  45. package/docs/v1/basics/objFilter.md +1 -1
  46. package/docs/v1/libs/TinyIframeEvents.md +8 -8
  47. package/docs/v1/libs/TinyLocalStorage.md +3 -3
  48. package/docs/v1/libs/TinyNewWinEvents.md +8 -9
  49. package/package.json +6 -5
  50. package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
  51. package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
  52. package/dist/v1/TinyEvents.min.js +0 -1
  53. package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
  54. package/dist/v1/build/TinyEvents.cjs +0 -7
  55. package/dist/v1/build/TinyEvents.d.mts +0 -3
  56. package/dist/v1/build/TinyEvents.mjs +0 -2
  57. package/dist/v1/libs/TinyEvents.cjs +0 -395
  58. package/dist/v1/libs/TinyEvents.d.mts +0 -164
  59. package/dist/v1/libs/TinyEvents.mjs +0 -360
  60. package/docs/v1/libs/TinyEvents.md +0 -187
@@ -1,5 +1,5 @@
1
+ import { EventEmitter } from 'events';
1
2
  import { isJsonObject } from '../basics/objChecker.mjs';
2
- import TinyEvents from './TinyEvents.mjs';
3
3
  /** @type {Map<any, EncodeFn>} */
4
4
  const customEncoders = new Map();
5
5
  /** @type {Map<any, DecodeFn>} */
@@ -73,7 +73,7 @@ const customTypesFreezed = new Set([
73
73
  * - Type-specific `set` and `get` methods (`setDate`, `getBool`, etc.)
74
74
  * - `getValue()` to retrieve any structure regardless of type
75
75
  * - Auto-encoding/decoding with support for custom types via `registerJsonType`
76
- * - Built-in event system (`TinyEvents`) to listen for changes
76
+ * - Built-in event system to listen for changes
77
77
  * - Optional fallback values on decoding errors
78
78
  *
79
79
  * Supports registering and unregistering custom types via:
@@ -82,181 +82,7 @@ const customTypesFreezed = new Set([
82
82
  *
83
83
  * This class is suitable for applications that require structured persistence in the browser.
84
84
  */
85
- class TinyLocalStorage {
86
- /** @typedef {import('./TinyEvents.mjs').handler} handler */
87
- #events = new TinyEvents();
88
- /**
89
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
90
- *
91
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
92
- */
93
- setThrowOnMaxListeners(shouldThrow) {
94
- return this.#events.setThrowOnMaxListeners(shouldThrow);
95
- }
96
- /**
97
- * Checks whether an error will be thrown when the max listener limit is exceeded.
98
- *
99
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
100
- */
101
- getThrowOnMaxListeners() {
102
- return this.#events.getThrowOnMaxListeners();
103
- }
104
- /////////////////////////////////////////////////////////////
105
- /**
106
- * Adds a listener to the beginning of the listeners array for the specified event.
107
- *
108
- * @param {string|string[]} event - Event name.
109
- * @param {handler} handler - The callback function.
110
- */
111
- prependListener(event, handler) {
112
- return this.#events.prependListener(event, handler);
113
- }
114
- /**
115
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
116
- *
117
- * @param {string|string[]} event - Event name.
118
- * @param {handler} handler - The callback function.
119
- * @returns {handler[]} - The wrapped handler used internally.
120
- */
121
- prependListenerOnce(event, handler) {
122
- return this.#events.prependListenerOnce(event, handler);
123
- }
124
- //////////////////////////////////////////////////////////////////////
125
- /**
126
- * Adds a event listener.
127
- *
128
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
129
- * @param {handler} handler - Callback function to be called when event fires.
130
- */
131
- appendListener(event, handler) {
132
- return this.#events.appendListener(event, handler);
133
- }
134
- /**
135
- * Registers an event listener that runs only once, then is removed.
136
- *
137
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
138
- * @param {handler} handler - The callback function to run on event.
139
- * @returns {handler[]} - The wrapped version of the handler.
140
- */
141
- appendListenerOnce(event, handler) {
142
- return this.#events.appendListenerOnce(event, handler);
143
- }
144
- /**
145
- * Adds a event listener.
146
- *
147
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
148
- * @param {handler} handler - Callback function to be called when event fires.
149
- */
150
- on(event, handler) {
151
- return this.#events.on(event, handler);
152
- }
153
- /**
154
- * Registers an event listener that runs only once, then is removed.
155
- *
156
- * @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
157
- * @param {handler} handler - The callback function to run on event.
158
- * @returns {handler[]} - The wrapped version of the handler.
159
- */
160
- once(event, handler) {
161
- return this.#events.once(event, handler);
162
- }
163
- ////////////////////////////////////////////////////////////////////
164
- /**
165
- * Removes a previously registered event listener.
166
- *
167
- * @param {string|string[]} event - The name of the event to remove the handler from.
168
- * @param {handler} handler - The specific callback function to remove.
169
- */
170
- off(event, handler) {
171
- return this.#events.off(event, handler);
172
- }
173
- /**
174
- * Removes all event listeners of a specific type from the element.
175
- *
176
- * @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
177
- */
178
- offAll(event) {
179
- return this.#events.offAll(event);
180
- }
181
- /**
182
- * Removes all event listeners of all types from the element.
183
- */
184
- offAllTypes() {
185
- return this.#events.offAllTypes();
186
- }
187
- ////////////////////////////////////////////////////////////
188
- /**
189
- * Returns the number of listeners for a given event.
190
- *
191
- * @param {string} event - The name of the event.
192
- * @returns {number} Number of listeners for the event.
193
- */
194
- listenerCount(event) {
195
- return this.#events.listenerCount(event);
196
- }
197
- /**
198
- * Returns a copy of the array of listeners for the specified event.
199
- *
200
- * @param {string} event - The name of the event.
201
- * @returns {handler[]} Array of listener functions.
202
- */
203
- listeners(event) {
204
- return this.#events.listeners(event);
205
- }
206
- /**
207
- * Returns a copy of the array of listeners for the specified event.
208
- *
209
- * @param {string} event - The name of the event.
210
- * @returns {handler[]} Array of listener functions.
211
- */
212
- onceListeners(event) {
213
- return this.#events.onceListeners(event);
214
- }
215
- /**
216
- * Returns a copy of the internal listeners array for the specified event,
217
- * including wrapper functions like those used by `.once()`.
218
- * @param {string | symbol} event - The event name.
219
- * @returns {handler[]} An array of raw listener functions.
220
- */
221
- allListeners(event) {
222
- return this.#events.allListeners(event);
223
- }
224
- /**
225
- * Returns an array of event names for which there are registered listeners.
226
- *
227
- * @returns {string[]} Array of registered event names.
228
- */
229
- eventNames() {
230
- return this.#events.eventNames();
231
- }
232
- //////////////////////////////////////////////////////
233
- /**
234
- * Emits an event, triggering all registered handlers for that event.
235
- *
236
- * @param {string} event - The event name to emit.
237
- * @param {...any} payload - Optional data to pass to each handler.
238
- * @returns {boolean[]} True if any listeners were called, false otherwise.
239
- */
240
- emit(event, ...payload) {
241
- return this.#events.emit(event, ...payload);
242
- }
243
- /**
244
- * Sets the maximum number of listeners per event before a warning is shown.
245
- *
246
- * @param {number} n - The maximum number of listeners.
247
- */
248
- setMaxListeners(n) {
249
- return this.#events.setMaxListeners(n);
250
- }
251
- /**
252
- * Gets the maximum number of listeners allowed per event.
253
- *
254
- * @returns {number} The maximum number of listeners.
255
- */
256
- getMaxListeners() {
257
- return this.#events.getMaxListeners();
258
- }
259
- ///////////////////////////////////////////////////
85
+ class TinyLocalStorage extends EventEmitter {
260
86
  /**
261
87
  * Checks whether a JSON-serializable type is already registered.
262
88
  *
@@ -387,6 +213,7 @@ class TinyLocalStorage {
387
213
  * @param {string} [dbName] - Unique database name.
388
214
  */
389
215
  constructor(dbName) {
216
+ super();
390
217
  if (typeof dbName !== 'undefined' && typeof dbName !== 'string')
391
218
  throw new TypeError('TinyLocalStorage: dbName must be a string if provided.');
392
219
  if (typeof dbName === 'string')
@@ -809,7 +636,7 @@ class TinyLocalStorage {
809
636
  */
810
637
  destroy() {
811
638
  window.removeEventListener('storage', this.#storageEvent);
812
- this.#events.offAllTypes();
639
+ this.removeAllListeners();
813
640
  }
814
641
  }
815
642
  // First registers
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var TinyEvents = require('./TinyEvents.cjs');
3
+ var events = require('events');
4
4
  var mediaContent = require('../basics/mediaContent.cjs');
5
5
 
6
6
  /**
@@ -107,7 +107,7 @@ class BaseMediaAdapter {
107
107
  /**
108
108
  * A universal media player manager capable of orchestrating multiple API adapters.
109
109
  */
110
- class TinyMediaPlayer extends TinyEvents {
110
+ class TinyMediaPlayer extends events.EventEmitter {
111
111
  static BaseMediaAdapter = BaseMediaAdapter;
112
112
 
113
113
  /**
@@ -42,7 +42,7 @@ export type SearchResult = {
42
42
  /**
43
43
  * A universal media player manager capable of orchestrating multiple API adapters.
44
44
  */
45
- declare class TinyMediaPlayer extends TinyEvents {
45
+ declare class TinyMediaPlayer extends EventEmitter<any> {
46
46
  static BaseMediaAdapter: typeof BaseMediaAdapter;
47
47
  /**
48
48
  * @type {UnknownArtistGetter}
@@ -238,7 +238,7 @@ declare class TinyMediaPlayer extends TinyEvents {
238
238
  step(stepMs: number): Promise<void>;
239
239
  #private;
240
240
  }
241
- import TinyEvents from './TinyEvents.mjs';
241
+ import { EventEmitter } from 'events';
242
242
  /**
243
243
  * @typedef {import('../basics/mediaContent.mjs').MediaContent} MediaContent
244
244
  * @typedef {import('../basics/mediaContent.mjs').MediaContentBase} MediaContentBase
@@ -1,4 +1,4 @@
1
- import TinyEvents from './TinyEvents.mjs';
1
+ import { EventEmitter } from 'events';
2
2
  import { getMediaContentBase, getMediaContentMetadata, parseMediaMetadata, valMediaContentMetadata, } from '../basics/mediaContent.mjs';
3
3
  /**
4
4
  * @typedef {import('../basics/mediaContent.mjs').MediaContent} MediaContent
@@ -92,7 +92,7 @@ class BaseMediaAdapter {
92
92
  /**
93
93
  * A universal media player manager capable of orchestrating multiple API adapters.
94
94
  */
95
- class TinyMediaPlayer extends TinyEvents {
95
+ class TinyMediaPlayer extends EventEmitter {
96
96
  static BaseMediaAdapter = BaseMediaAdapter;
97
97
  /**
98
98
  * @type {UnknownArtistGetter}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var TinyEvents = require('./TinyEvents.cjs');
3
+ var events = require('events');
4
4
 
5
5
  /**
6
6
  * Stores polling intervals associated with window references.
@@ -26,195 +26,7 @@ const pollClosedInterval = new WeakMap();
26
26
  *
27
27
  * @class
28
28
  */
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
-
29
+ class TinyNewWinEvents extends events.EventEmitter {
218
30
  /** @type {Window|null} Reference to the opened or parent window */
219
31
  #windowRef;
220
32
 
@@ -291,6 +103,7 @@ class TinyNewWinEvents {
291
103
  * @throws {Error} If the window reference is invalid or already being tracked.
292
104
  */
293
105
  constructor({ targetOrigin, url, name, features } = {}) {
106
+ super();
294
107
  if (typeof name === 'string' && name === '_blank')
295
108
  throw new Error(
296
109
  'TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.',
@@ -350,7 +163,7 @@ class TinyNewWinEvents {
350
163
  return;
351
164
  }
352
165
 
353
- if (type === this.#routeEventName) this.#events.emit(route, payload, event);
166
+ if (type === this.#routeEventName) this.emit(`win:${route}`, payload, event);
354
167
  }
355
168
 
356
169
  /**
@@ -363,7 +176,7 @@ class TinyNewWinEvents {
363
176
  const data = this.#pendingQueue.shift();
364
177
  if (data) {
365
178
  const { route, payload } = data;
366
- this.emit(route, payload);
179
+ this.winEmit(route, payload);
367
180
  }
368
181
  }
369
182
  }
@@ -401,7 +214,7 @@ class TinyNewWinEvents {
401
214
  * @throws {Error} If the instance is already destroyed.
402
215
  * @returns {void}
403
216
  */
404
- emit(route, payload) {
217
+ winEmit(route, payload) {
405
218
  if (typeof route !== 'string') throw new TypeError('Event name must be a string.');
406
219
  if (this.isDestroyed()) throw new Error('Cannot emit: instance has been destroyed.');
407
220
  if (!this.#ready) {
@@ -429,7 +242,7 @@ class TinyNewWinEvents {
429
242
  if (!this.#windowRef || this.#pollClosedInterval) return;
430
243
  this.#pollClosedInterval = setInterval(() => {
431
244
  if (this.#windowRef?.closed) {
432
- this.#events.emit('WINDOW_REF_CLOSED');
245
+ this.emit('WINDOW_REF_CLOSED');
433
246
  this.destroy();
434
247
  }
435
248
  }, 500);
@@ -443,7 +256,7 @@ class TinyNewWinEvents {
443
256
  * @returns {void}
444
257
  */
445
258
  onClose(callback) {
446
- return this.#events.on('WINDOW_REF_CLOSED', callback);
259
+ this.on('WINDOW_REF_CLOSED', callback);
447
260
  }
448
261
 
449
262
  /**
@@ -453,7 +266,7 @@ class TinyNewWinEvents {
453
266
  * @returns {void}
454
267
  */
455
268
  offClose(callback) {
456
- return this.#events.off('WINDOW_REF_CLOSED', callback);
269
+ this.off('WINDOW_REF_CLOSED', callback);
457
270
  }
458
271
 
459
272
  /**
@@ -481,7 +294,7 @@ class TinyNewWinEvents {
481
294
  this.#pendingQueue = [];
482
295
  this.#ready = false;
483
296
  this.#windowRef = null;
484
- this.#events.offAllTypes();
297
+ this.removeAllListeners();
485
298
  }
486
299
  }
487
300
 
@@ -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
  *
@@ -38,126 +38,6 @@ declare class TinyNewWinEvents {
38
38
  name?: string | undefined;
39
39
  features?: string | undefined;
40
40
  });
41
- /**
42
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
43
- *
44
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
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;
161
41
  /**
162
42
  * Sets the internal handshake event name.
163
43
  * @param {string} name
@@ -203,7 +83,7 @@ declare class TinyNewWinEvents {
203
83
  * @throws {Error} If the instance is already destroyed.
204
84
  * @returns {void}
205
85
  */
206
- emit(route: string, payload: any): void;
86
+ winEmit(route: string, payload: any): void;
207
87
  /**
208
88
  * Checks if the connection is active and the window is still open.
209
89
  *
@@ -238,4 +118,5 @@ declare class TinyNewWinEvents {
238
118
  destroy(): void;
239
119
  #private;
240
120
  }
121
+ import { EventEmitter } from 'events';
241
122
  //# sourceMappingURL=TinyNewWinEvents.d.mts.map