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.
- package/README.md +1 -0
- package/changelog/1/28/0.md +16 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -2
- package/dist/v1/TinyEssentials.min.js +1 -2
- package/dist/v1/TinyIframeEvents.min.js +1 -1
- package/dist/v1/TinyLocalStorage.min.js +1 -1
- package/dist/v1/TinyMediaPlayer.min.js +1 -1
- package/dist/v1/TinyNewWinEvents.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -2
- package/dist/v1/basics/extendObjType/Buffer.cjs +13 -0
- package/dist/v1/basics/extendObjType/Buffer.d.mts +4 -0
- package/dist/v1/basics/extendObjType/Buffer.mjs +8 -0
- package/dist/v1/basics/objFilter.cjs +0 -11
- package/dist/v1/basics/objFilter.mjs +0 -10
- package/dist/v1/index.cjs +0 -2
- package/dist/v1/index.d.mts +1 -2
- package/dist/v1/index.mjs +1 -2
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +7 -205
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +2 -121
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +7 -179
- package/dist/v1/libs/TinyIframeEvents.cjs +8 -195
- package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
- package/dist/v1/libs/TinyIframeEvents.mjs +8 -170
- package/dist/v1/libs/TinyLocalStorage.cjs +5 -205
- package/dist/v1/libs/TinyLocalStorage.d.mts +3 -130
- package/dist/v1/libs/TinyLocalStorage.mjs +5 -178
- package/dist/v1/libs/TinyMediaPlayer.cjs +2 -2
- package/dist/v1/libs/TinyMediaPlayer.d.mts +2 -2
- package/dist/v1/libs/TinyMediaPlayer.mjs +2 -2
- package/dist/v1/libs/TinyNewWinEvents.cjs +10 -197
- package/dist/v1/libs/TinyNewWinEvents.d.mts +3 -122
- package/dist/v1/libs/TinyNewWinEvents.mjs +10 -172
- package/dist/v1/libs/TinyRadioFm.cjs +2 -3
- package/dist/v1/libs/TinyRadioFm.d.mts +2 -3
- package/dist/v1/libs/TinyRadioFm.mjs +2 -3
- package/dist/v1/libs/TinySmartScroller.cjs +4 -202
- package/dist/v1/libs/TinySmartScroller.d.mts +8 -143
- package/dist/v1/libs/TinySmartScroller.mjs +4 -176
- package/dist/v1/libs/TinyUploadClicker.cjs +1 -0
- package/docs/v1/Exports.md +0 -1
- package/docs/v1/README.md +0 -1
- package/docs/v1/basics/objFilter.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +8 -8
- package/docs/v1/libs/TinyLocalStorage.md +3 -3
- package/docs/v1/libs/TinyNewWinEvents.md +8 -9
- package/package.json +6 -5
- package/dist/v1/TinyBasicsEs.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEssentials.min.js.LICENSE.txt +0 -8
- package/dist/v1/TinyEvents.min.js +0 -1
- package/dist/v1/TinyUploadClicker.min.js.LICENSE.txt +0 -8
- package/dist/v1/build/TinyEvents.cjs +0 -7
- package/dist/v1/build/TinyEvents.d.mts +0 -3
- package/dist/v1/build/TinyEvents.mjs +0 -2
- package/dist/v1/libs/TinyEvents.cjs +0 -395
- package/dist/v1/libs/TinyEvents.d.mts +0 -164
- package/dist/v1/libs/TinyEvents.mjs +0 -360
- package/docs/v1/libs/TinyEvents.md +0 -187
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
2
2
|
/**
|
|
3
3
|
* Stores polling intervals associated with window references.
|
|
4
4
|
* Used to detect when the window is closed.
|
|
@@ -21,170 +21,7 @@ const pollClosedInterval = new WeakMap();
|
|
|
21
21
|
*
|
|
22
22
|
* @class
|
|
23
23
|
*/
|
|
24
|
-
class TinyNewWinEvents {
|
|
25
|
-
#events = new TinyEvents();
|
|
26
|
-
/**
|
|
27
|
-
* Enables or disables throwing an error when the maximum number of listeners is exceeded.
|
|
28
|
-
*
|
|
29
|
-
* @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
|
|
30
|
-
*/
|
|
31
|
-
setThrowOnMaxListeners(shouldThrow) {
|
|
32
|
-
return this.#events.setThrowOnMaxListeners(shouldThrow);
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Checks whether an error will be thrown when the max listener limit is exceeded.
|
|
36
|
-
*
|
|
37
|
-
* @returns {boolean} True if an error will be thrown, false if only a warning is shown.
|
|
38
|
-
*/
|
|
39
|
-
getThrowOnMaxListeners() {
|
|
40
|
-
return this.#events.getThrowOnMaxListeners();
|
|
41
|
-
}
|
|
42
|
-
/////////////////////////////////////////////////////////////
|
|
43
|
-
/**
|
|
44
|
-
* Adds a listener to the beginning of the listeners array for the specified event.
|
|
45
|
-
*
|
|
46
|
-
* @param {string|string[]} event - Event name.
|
|
47
|
-
* @param {handler} handler - The callback function.
|
|
48
|
-
*/
|
|
49
|
-
prependListener(event, handler) {
|
|
50
|
-
return this.#events.prependListener(event, handler);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Adds a one-time 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
|
-
* @returns {handler[]} - The wrapped handler used internally.
|
|
58
|
-
*/
|
|
59
|
-
prependListenerOnce(event, handler) {
|
|
60
|
-
return this.#events.prependListenerOnce(event, handler);
|
|
61
|
-
}
|
|
62
|
-
//////////////////////////////////////////////////////////////////////
|
|
63
|
-
/**
|
|
64
|
-
* Adds a event listener.
|
|
65
|
-
*
|
|
66
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
67
|
-
* @param {handler} handler - Callback function to be called when event fires.
|
|
68
|
-
*/
|
|
69
|
-
appendListener(event, handler) {
|
|
70
|
-
return this.#events.appendListener(event, handler);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Registers an event listener that runs only once, then is removed.
|
|
74
|
-
*
|
|
75
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
76
|
-
* @param {handler} handler - The callback function to run on event.
|
|
77
|
-
* @returns {handler[]} - The wrapped version of the handler.
|
|
78
|
-
*/
|
|
79
|
-
appendListenerOnce(event, handler) {
|
|
80
|
-
return this.#events.appendListenerOnce(event, handler);
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* Adds a event listener.
|
|
84
|
-
*
|
|
85
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
86
|
-
* @param {handler} handler - Callback function to be called when event fires.
|
|
87
|
-
*/
|
|
88
|
-
on(event, handler) {
|
|
89
|
-
return this.#events.on(event, handler);
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Registers an event listener that runs only once, then is removed.
|
|
93
|
-
*
|
|
94
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
95
|
-
* @param {handler} handler - The callback function to run on event.
|
|
96
|
-
* @returns {handler[]} - The wrapped version of the handler.
|
|
97
|
-
*/
|
|
98
|
-
once(event, handler) {
|
|
99
|
-
return this.#events.once(event, handler);
|
|
100
|
-
}
|
|
101
|
-
////////////////////////////////////////////////////////////////////
|
|
102
|
-
/**
|
|
103
|
-
* Removes a previously registered event listener.
|
|
104
|
-
*
|
|
105
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
106
|
-
* @param {handler} handler - The specific callback function to remove.
|
|
107
|
-
*/
|
|
108
|
-
off(event, handler) {
|
|
109
|
-
return this.#events.off(event, handler);
|
|
110
|
-
}
|
|
111
|
-
/**
|
|
112
|
-
* Removes all event listeners of a specific type from the element.
|
|
113
|
-
*
|
|
114
|
-
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
115
|
-
*/
|
|
116
|
-
offAll(event) {
|
|
117
|
-
return this.#events.offAll(event);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Removes all event listeners of all types from the element.
|
|
121
|
-
*/
|
|
122
|
-
offAllTypes() {
|
|
123
|
-
return this.#events.offAllTypes();
|
|
124
|
-
}
|
|
125
|
-
////////////////////////////////////////////////////////////
|
|
126
|
-
/**
|
|
127
|
-
* Returns the number of listeners for a given event.
|
|
128
|
-
*
|
|
129
|
-
* @param {string} event - The name of the event.
|
|
130
|
-
* @returns {number} Number of listeners for the event.
|
|
131
|
-
*/
|
|
132
|
-
listenerCount(event) {
|
|
133
|
-
return this.#events.listenerCount(event);
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
137
|
-
*
|
|
138
|
-
* @param {string} event - The name of the event.
|
|
139
|
-
* @returns {handler[]} Array of listener functions.
|
|
140
|
-
*/
|
|
141
|
-
listeners(event) {
|
|
142
|
-
return this.#events.listeners(event);
|
|
143
|
-
}
|
|
144
|
-
/**
|
|
145
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
146
|
-
*
|
|
147
|
-
* @param {string} event - The name of the event.
|
|
148
|
-
* @returns {handler[]} Array of listener functions.
|
|
149
|
-
*/
|
|
150
|
-
onceListeners(event) {
|
|
151
|
-
return this.#events.onceListeners(event);
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* Returns a copy of the internal listeners array for the specified event,
|
|
155
|
-
* including wrapper functions like those used by `.once()`.
|
|
156
|
-
* @param {string | symbol} event - The event name.
|
|
157
|
-
* @returns {handler[]} An array of raw listener functions.
|
|
158
|
-
*/
|
|
159
|
-
allListeners(event) {
|
|
160
|
-
return this.#events.allListeners(event);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Returns an array of event names for which there are registered listeners.
|
|
164
|
-
*
|
|
165
|
-
* @returns {string[]} Array of registered event names.
|
|
166
|
-
*/
|
|
167
|
-
eventNames() {
|
|
168
|
-
return this.#events.eventNames();
|
|
169
|
-
}
|
|
170
|
-
//////////////////////////////////////////////////////
|
|
171
|
-
/**
|
|
172
|
-
* Sets the maximum number of listeners per event before a warning is shown.
|
|
173
|
-
*
|
|
174
|
-
* @param {number} n - The maximum number of listeners.
|
|
175
|
-
*/
|
|
176
|
-
setMaxListeners(n) {
|
|
177
|
-
return this.#events.setMaxListeners(n);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Gets the maximum number of listeners allowed per event.
|
|
181
|
-
*
|
|
182
|
-
* @returns {number} The maximum number of listeners.
|
|
183
|
-
*/
|
|
184
|
-
getMaxListeners() {
|
|
185
|
-
return this.#events.getMaxListeners();
|
|
186
|
-
}
|
|
187
|
-
///////////////////////////////////////////////////
|
|
24
|
+
class TinyNewWinEvents extends EventEmitter {
|
|
188
25
|
/** @type {Window|null} Reference to the opened or parent window */
|
|
189
26
|
#windowRef;
|
|
190
27
|
/** @type {string} Expected origin for postMessage communication */
|
|
@@ -249,6 +86,7 @@ class TinyNewWinEvents {
|
|
|
249
86
|
* @throws {Error} If the window reference is invalid or already being tracked.
|
|
250
87
|
*/
|
|
251
88
|
constructor({ targetOrigin, url, name, features } = {}) {
|
|
89
|
+
super();
|
|
252
90
|
if (typeof name === 'string' && name === '_blank')
|
|
253
91
|
throw new Error('TinyNewWinEvents: The window name "_blank" is not supported. Please use a custom name to allow tracking.');
|
|
254
92
|
if (typeof targetOrigin !== 'undefined' && typeof targetOrigin !== 'string')
|
|
@@ -303,7 +141,7 @@ class TinyNewWinEvents {
|
|
|
303
141
|
return;
|
|
304
142
|
}
|
|
305
143
|
if (type === this.#routeEventName)
|
|
306
|
-
this
|
|
144
|
+
this.emit(`win:${route}`, payload, event);
|
|
307
145
|
}
|
|
308
146
|
/**
|
|
309
147
|
* Sends all pending messages queued before handshake completion.
|
|
@@ -315,7 +153,7 @@ class TinyNewWinEvents {
|
|
|
315
153
|
const data = this.#pendingQueue.shift();
|
|
316
154
|
if (data) {
|
|
317
155
|
const { route, payload } = data;
|
|
318
|
-
this.
|
|
156
|
+
this.winEmit(route, payload);
|
|
319
157
|
}
|
|
320
158
|
}
|
|
321
159
|
}
|
|
@@ -353,7 +191,7 @@ class TinyNewWinEvents {
|
|
|
353
191
|
* @throws {Error} If the instance is already destroyed.
|
|
354
192
|
* @returns {void}
|
|
355
193
|
*/
|
|
356
|
-
|
|
194
|
+
winEmit(route, payload) {
|
|
357
195
|
if (typeof route !== 'string')
|
|
358
196
|
throw new TypeError('Event name must be a string.');
|
|
359
197
|
if (this.isDestroyed())
|
|
@@ -382,7 +220,7 @@ class TinyNewWinEvents {
|
|
|
382
220
|
return;
|
|
383
221
|
this.#pollClosedInterval = setInterval(() => {
|
|
384
222
|
if (this.#windowRef?.closed) {
|
|
385
|
-
this
|
|
223
|
+
this.emit('WINDOW_REF_CLOSED');
|
|
386
224
|
this.destroy();
|
|
387
225
|
}
|
|
388
226
|
}, 500);
|
|
@@ -395,7 +233,7 @@ class TinyNewWinEvents {
|
|
|
395
233
|
* @returns {void}
|
|
396
234
|
*/
|
|
397
235
|
onClose(callback) {
|
|
398
|
-
|
|
236
|
+
this.on('WINDOW_REF_CLOSED', callback);
|
|
399
237
|
}
|
|
400
238
|
/**
|
|
401
239
|
* Unregisters a previously registered close callback.
|
|
@@ -404,7 +242,7 @@ class TinyNewWinEvents {
|
|
|
404
242
|
* @returns {void}
|
|
405
243
|
*/
|
|
406
244
|
offClose(callback) {
|
|
407
|
-
|
|
245
|
+
this.off('WINDOW_REF_CLOSED', callback);
|
|
408
246
|
}
|
|
409
247
|
/**
|
|
410
248
|
* Checks if the communication instance has been destroyed.
|
|
@@ -431,7 +269,7 @@ class TinyNewWinEvents {
|
|
|
431
269
|
this.#pendingQueue = [];
|
|
432
270
|
this.#ready = false;
|
|
433
271
|
this.#windowRef = null;
|
|
434
|
-
this
|
|
272
|
+
this.removeAllListeners();
|
|
435
273
|
}
|
|
436
274
|
}
|
|
437
275
|
export default TinyNewWinEvents;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var events = require('events');
|
|
3
4
|
var mediaContent = require('../basics/mediaContent.cjs');
|
|
4
|
-
var TinyEvents = require('./TinyEvents.cjs');
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* @typedef {import('../basics/mediaContent.mjs').MediaContentBase} MediaContentBase
|
|
@@ -126,10 +126,9 @@ var TinyEvents = require('./TinyEvents.cjs');
|
|
|
126
126
|
|
|
127
127
|
/**
|
|
128
128
|
* A deterministic, seed-based radio management system with scheduled adaptations and weighted random generation.
|
|
129
|
-
* @extends TinyEvents
|
|
130
129
|
* @beta
|
|
131
130
|
*/
|
|
132
|
-
class TinyRadioFm extends
|
|
131
|
+
class TinyRadioFm extends events.EventEmitter {
|
|
133
132
|
/**
|
|
134
133
|
* A Static Factory Method that prepares a MediaContent object by
|
|
135
134
|
* extracting metadata from an audio source.
|
|
@@ -327,10 +327,9 @@ export type TinyRadioFmImport = {
|
|
|
327
327
|
*/
|
|
328
328
|
/**
|
|
329
329
|
* A deterministic, seed-based radio management system with scheduled adaptations and weighted random generation.
|
|
330
|
-
* @extends TinyEvents
|
|
331
330
|
* @beta
|
|
332
331
|
*/
|
|
333
|
-
declare class TinyRadioFm extends
|
|
332
|
+
declare class TinyRadioFm extends EventEmitter<any> {
|
|
334
333
|
/**
|
|
335
334
|
* A Static Factory Method that prepares a MediaContent object by
|
|
336
335
|
* extracting metadata from an audio source.
|
|
@@ -550,5 +549,5 @@ declare class TinyRadioFm extends TinyEvents {
|
|
|
550
549
|
destroy(destroyThumbs?: boolean): void;
|
|
551
550
|
#private;
|
|
552
551
|
}
|
|
553
|
-
import
|
|
552
|
+
import { EventEmitter } from 'events';
|
|
554
553
|
//# sourceMappingURL=TinyRadioFm.d.mts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
1
2
|
import { blobUrlToBase64, convertToBlobUrl, parseMediaMetadata, revokeContentUrls, } from '../basics/mediaContent.mjs';
|
|
2
|
-
import TinyEvents from './TinyEvents.mjs';
|
|
3
3
|
/**
|
|
4
4
|
* @typedef {import('../basics/mediaContent.mjs').MediaContentBase} MediaContentBase
|
|
5
5
|
* @typedef {import('../basics/mediaContent.mjs').MediaContentMetadata} MediaContentMetadata
|
|
@@ -105,10 +105,9 @@ import TinyEvents from './TinyEvents.mjs';
|
|
|
105
105
|
//////////////////////////////////////////////////////////////////
|
|
106
106
|
/**
|
|
107
107
|
* A deterministic, seed-based radio management system with scheduled adaptations and weighted random generation.
|
|
108
|
-
* @extends TinyEvents
|
|
109
108
|
* @beta
|
|
110
109
|
*/
|
|
111
|
-
class TinyRadioFm extends
|
|
110
|
+
class TinyRadioFm extends EventEmitter {
|
|
112
111
|
/**
|
|
113
112
|
* A Static Factory Method that prepares a MediaContent object by
|
|
114
113
|
* extracting metadata from an audio source.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var events = require('events');
|
|
3
4
|
var TinyHtml = require('./TinyHtml.cjs');
|
|
4
5
|
var collision = require('../basics/collision.cjs');
|
|
5
|
-
var TinyEvents = require('./TinyEvents.cjs');
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Represents the dimensions of a DOM element.
|
|
@@ -48,208 +48,9 @@ var TinyEvents = require('./TinyEvents.cjs');
|
|
|
48
48
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
49
49
|
* @template {Element|Window} HTMLTarget
|
|
50
50
|
*/
|
|
51
|
-
class TinySmartScroller {
|
|
51
|
+
class TinySmartScroller extends events.EventEmitter {
|
|
52
52
|
static Utils = { ...collision, TinyHtml };
|
|
53
53
|
|
|
54
|
-
#events = new TinyEvents();
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Enables or disables throwing an error when the maximum number of listeners is exceeded.
|
|
58
|
-
*
|
|
59
|
-
* @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
|
|
60
|
-
*/
|
|
61
|
-
setThrowOnMaxListeners(shouldThrow) {
|
|
62
|
-
return this.#events.setThrowOnMaxListeners(shouldThrow);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Checks whether an error will be thrown when the max listener limit is exceeded.
|
|
67
|
-
*
|
|
68
|
-
* @returns {boolean} True if an error will be thrown, false if only a warning is shown.
|
|
69
|
-
*/
|
|
70
|
-
getThrowOnMaxListeners() {
|
|
71
|
-
return this.#events.getThrowOnMaxListeners();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/////////////////////////////////////////////////////////////
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Adds a listener to the beginning of the listeners array for the specified event.
|
|
78
|
-
*
|
|
79
|
-
* @param {string|string[]} event - Event name.
|
|
80
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
81
|
-
*/
|
|
82
|
-
prependListener(event, handler) {
|
|
83
|
-
return this.#events.prependListener(event, handler);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Adds a one-time listener to the beginning of the listeners array for the specified event.
|
|
88
|
-
*
|
|
89
|
-
* @param {string|string[]} event - Event name.
|
|
90
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
91
|
-
* @returns {ScrollListenersFunc[]} - The wrapped handler used internally.
|
|
92
|
-
*/
|
|
93
|
-
prependListenerOnce(event, handler) {
|
|
94
|
-
return this.#events.prependListenerOnce(event, handler);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//////////////////////////////////////////////////////////////////////
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Adds a event listener.
|
|
101
|
-
*
|
|
102
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
103
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
104
|
-
*/
|
|
105
|
-
appendListener(event, handler) {
|
|
106
|
-
return this.#events.appendListener(event, handler);
|
|
107
|
-
}
|
|
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 {ScrollListenersFunc} handler - The callback function to run on event.
|
|
114
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
115
|
-
*/
|
|
116
|
-
appendListenerOnce(event, handler) {
|
|
117
|
-
return this.#events.appendListenerOnce(event, handler);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* Adds a event listener.
|
|
122
|
-
*
|
|
123
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
124
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
125
|
-
*/
|
|
126
|
-
on(event, handler) {
|
|
127
|
-
return this.#events.on(event, handler);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Registers an event listener that runs only once, then is removed.
|
|
132
|
-
*
|
|
133
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
134
|
-
* @param {ScrollListenersFunc} handler - The callback function to run on event.
|
|
135
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
136
|
-
*/
|
|
137
|
-
once(event, handler) {
|
|
138
|
-
return this.#events.once(event, handler);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
////////////////////////////////////////////////////////////////////
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Removes a previously registered event listener.
|
|
145
|
-
*
|
|
146
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
147
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
148
|
-
*/
|
|
149
|
-
off(event, handler) {
|
|
150
|
-
return this.#events.off(event, handler);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Removes all event listeners of a specific type from the element.
|
|
155
|
-
*
|
|
156
|
-
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
157
|
-
*/
|
|
158
|
-
offAll(event) {
|
|
159
|
-
return this.#events.offAll(event);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/**
|
|
163
|
-
* Removes all event listeners of all types from the element.
|
|
164
|
-
*/
|
|
165
|
-
offAllTypes() {
|
|
166
|
-
return this.#events.offAllTypes();
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
////////////////////////////////////////////////////////////
|
|
170
|
-
|
|
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) {
|
|
178
|
-
return this.#events.listenerCount(event);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
183
|
-
*
|
|
184
|
-
* @param {string} event - The name of the event.
|
|
185
|
-
* @returns {ScrollListenersFunc[]} Array of listener functions.
|
|
186
|
-
*/
|
|
187
|
-
listeners(event) {
|
|
188
|
-
return this.#events.listeners(event);
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
193
|
-
*
|
|
194
|
-
* @param {string} event - The name of the event.
|
|
195
|
-
* @returns {ScrollListenersFunc[]} Array of listener functions.
|
|
196
|
-
*/
|
|
197
|
-
onceListeners(event) {
|
|
198
|
-
return this.#events.onceListeners(event);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/**
|
|
202
|
-
* Returns a copy of the internal listeners array for the specified event,
|
|
203
|
-
* including wrapper functions like those used by `.once()`.
|
|
204
|
-
* @param {string | symbol} event - The event name.
|
|
205
|
-
* @returns {ScrollListenersFunc[]} An array of raw listener functions.
|
|
206
|
-
*/
|
|
207
|
-
allListeners(event) {
|
|
208
|
-
return this.#events.allListeners(event);
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
* Returns an array of event names for which there are registered listeners.
|
|
213
|
-
*
|
|
214
|
-
* @returns {string[]} Array of registered event names.
|
|
215
|
-
*/
|
|
216
|
-
eventNames() {
|
|
217
|
-
return this.#events.eventNames();
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
//////////////////////////////////////////////////////
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Emits an event, triggering all registered handlers for that event.
|
|
224
|
-
*
|
|
225
|
-
* @param {string} event - The event name to emit.
|
|
226
|
-
* @param {...any} payload - Optional data to pass to each handler.
|
|
227
|
-
* @returns {boolean[]} True if any listeners were called, false otherwise.
|
|
228
|
-
*/
|
|
229
|
-
emit(event, ...payload) {
|
|
230
|
-
return this.#events.emit(event, ...payload);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Sets the maximum number of listeners per event before a warning is shown.
|
|
235
|
-
*
|
|
236
|
-
* @param {number} n - The maximum number of listeners.
|
|
237
|
-
*/
|
|
238
|
-
setMaxListeners(n) {
|
|
239
|
-
return this.#events.setMaxListeners(n);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
/**
|
|
243
|
-
* Gets the maximum number of listeners allowed per event.
|
|
244
|
-
*
|
|
245
|
-
* @returns {number} The maximum number of listeners.
|
|
246
|
-
*/
|
|
247
|
-
getMaxListeners() {
|
|
248
|
-
return this.#events.getMaxListeners();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
///////////////////////////////////////////////////
|
|
252
|
-
|
|
253
54
|
/** @type {WeakMap<Element, NodeSizes>} */
|
|
254
55
|
#oldSizes = new WeakMap();
|
|
255
56
|
/** @type {WeakMap<Element, NodeSizes>} */
|
|
@@ -338,6 +139,7 @@ class TinySmartScroller {
|
|
|
338
139
|
attributeFilter = ['class', 'style', 'src', 'data-*', 'height', 'width'],
|
|
339
140
|
} = {},
|
|
340
141
|
) {
|
|
142
|
+
super();
|
|
341
143
|
// === target ===
|
|
342
144
|
if (!(
|
|
343
145
|
target instanceof Element ||
|
|
@@ -1171,7 +973,7 @@ class TinySmartScroller {
|
|
|
1171
973
|
this.#oldVisiblesByTime = new WeakMap();
|
|
1172
974
|
|
|
1173
975
|
// Cleans listeners and filters
|
|
1174
|
-
this
|
|
976
|
+
this.removeAllListeners();
|
|
1175
977
|
this.#sizeFilter.clear();
|
|
1176
978
|
this.#loadTags.clear();
|
|
1177
979
|
}
|