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
|
@@ -67,7 +67,7 @@ export type ScrollListenersFunc = (payload: any) => void;
|
|
|
67
67
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
68
68
|
* @template {Element|Window} HTMLTarget
|
|
69
69
|
*/
|
|
70
|
-
declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
70
|
+
declare class TinySmartScroller<HTMLTarget extends Element | Window> extends EventEmitter<any> {
|
|
71
71
|
static Utils: {
|
|
72
72
|
TinyHtml: typeof TinyHtml;
|
|
73
73
|
getElsRelativeCenterOffset(rect1: ObjRect, rect2: ObjRect): {
|
|
@@ -86,22 +86,18 @@ declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
|
86
86
|
dirs: CollDirs;
|
|
87
87
|
isNeg: NegCollDirs;
|
|
88
88
|
};
|
|
89
|
-
areElsCollTop: (rect1: ObjRect
|
|
89
|
+
areElsCollTop: (rect1: ObjRect
|
|
90
|
+
/** @type {MutationObserver|null} */
|
|
91
|
+
, /** @type {MutationObserver|null} */ rect2: ObjRect) => boolean;
|
|
90
92
|
areElsCollBottom: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
91
93
|
areElsCollLeft: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
92
|
-
areElsCollRight: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
94
|
+
areElsCollRight: (rect1: ObjRect, rect2: ObjRect /** @type {HTMLTarget} */) => boolean;
|
|
93
95
|
areElsCollPerfTop: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
94
96
|
areElsCollPerfBottom: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
95
97
|
areElsCollPerfLeft: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
96
98
|
areElsCollPerfRight: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
97
99
|
areElsColliding: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
98
|
-
areElsPerfColliding: (rect1: ObjRect, rect2: ObjRect
|
|
99
|
-
/**
|
|
100
|
-
* Removes all event listeners of a specific type from the element.
|
|
101
|
-
*
|
|
102
|
-
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
103
|
-
*/
|
|
104
|
-
) => boolean;
|
|
100
|
+
areElsPerfColliding: (rect1: ObjRect, rect2: ObjRect) => boolean;
|
|
105
101
|
getElsColliding: (rect1: ObjRect, rect2: ObjRect) => string | null;
|
|
106
102
|
getElsPerfColliding: (rect1: ObjRect, rect2: ObjRect) => "top" | "bottom" | "left" | "right" | null;
|
|
107
103
|
getElsCollOverlap: (rect1: ObjRect, rect2: ObjRect) => {
|
|
@@ -119,11 +115,7 @@ declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
|
119
115
|
dirX: Dirs;
|
|
120
116
|
dirY: Dirs;
|
|
121
117
|
};
|
|
122
|
-
getRectCenter: (
|
|
123
|
-
/** @type {WeakMap<Element, NodeSizes>} */
|
|
124
|
-
rect: ObjRect
|
|
125
|
-
/** @type {WeakMap<Element, NodeSizes>} */
|
|
126
|
-
) => {
|
|
118
|
+
getRectCenter: (rect: ObjRect) => {
|
|
127
119
|
x: number;
|
|
128
120
|
y: number;
|
|
129
121
|
};
|
|
@@ -152,134 +144,6 @@ declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
|
152
144
|
querySelector?: string | null | undefined;
|
|
153
145
|
attributeFilter?: string[] | Set<string> | null | undefined;
|
|
154
146
|
});
|
|
155
|
-
/**
|
|
156
|
-
* Enables or disables throwing an error when the maximum number of listeners is exceeded.
|
|
157
|
-
*
|
|
158
|
-
* @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
|
|
159
|
-
*/
|
|
160
|
-
setThrowOnMaxListeners(shouldThrow: boolean): void;
|
|
161
|
-
/**
|
|
162
|
-
* Checks whether an error will be thrown when the max listener limit is exceeded.
|
|
163
|
-
*
|
|
164
|
-
* @returns {boolean} True if an error will be thrown, false if only a warning is shown.
|
|
165
|
-
*/
|
|
166
|
-
getThrowOnMaxListeners(): boolean;
|
|
167
|
-
/**
|
|
168
|
-
* Adds a listener to the beginning of the listeners array for the specified event.
|
|
169
|
-
*
|
|
170
|
-
* @param {string|string[]} event - Event name.
|
|
171
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
172
|
-
*/
|
|
173
|
-
prependListener(event: string | string[], handler: ScrollListenersFunc): void;
|
|
174
|
-
/**
|
|
175
|
-
* Adds a one-time listener to the beginning of the listeners array for the specified event.
|
|
176
|
-
*
|
|
177
|
-
* @param {string|string[]} event - Event name.
|
|
178
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
179
|
-
* @returns {ScrollListenersFunc[]} - The wrapped handler used internally.
|
|
180
|
-
*/
|
|
181
|
-
prependListenerOnce(event: string | string[], handler: ScrollListenersFunc): ScrollListenersFunc[];
|
|
182
|
-
/**
|
|
183
|
-
* Adds a event listener.
|
|
184
|
-
*
|
|
185
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
186
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
187
|
-
*/
|
|
188
|
-
appendListener(event: string | string[], handler: ScrollListenersFunc): void;
|
|
189
|
-
/**
|
|
190
|
-
* Registers an event listener that runs only once, then is removed.
|
|
191
|
-
*
|
|
192
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
193
|
-
* @param {ScrollListenersFunc} handler - The callback function to run on event.
|
|
194
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
195
|
-
*/
|
|
196
|
-
appendListenerOnce(event: string | string[], handler: ScrollListenersFunc): ScrollListenersFunc[];
|
|
197
|
-
/**
|
|
198
|
-
* Adds a event listener.
|
|
199
|
-
*
|
|
200
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
201
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
202
|
-
*/
|
|
203
|
-
on(event: string | string[], handler: ScrollListenersFunc): void;
|
|
204
|
-
/**
|
|
205
|
-
* Registers an event listener that runs only once, then is removed.
|
|
206
|
-
*
|
|
207
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
208
|
-
* @param {ScrollListenersFunc} handler - The callback function to run on event.
|
|
209
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
210
|
-
*/
|
|
211
|
-
once(event: string | string[], handler: ScrollListenersFunc): ScrollListenersFunc[];
|
|
212
|
-
/**
|
|
213
|
-
* Removes a previously registered event listener.
|
|
214
|
-
*
|
|
215
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
216
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
217
|
-
*/
|
|
218
|
-
off(event: string | string[], handler: ScrollListenersFunc): void;
|
|
219
|
-
/**
|
|
220
|
-
* Removes all event listeners of a specific type from the element.
|
|
221
|
-
*
|
|
222
|
-
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
223
|
-
*/
|
|
224
|
-
offAll(event: string | string[]): void;
|
|
225
|
-
/**
|
|
226
|
-
* Removes all event listeners of all types from the element.
|
|
227
|
-
*/
|
|
228
|
-
offAllTypes(): void;
|
|
229
|
-
/**
|
|
230
|
-
* Returns the number of listeners for a given event.
|
|
231
|
-
*
|
|
232
|
-
* @param {string} event - The name of the event.
|
|
233
|
-
* @returns {number} Number of listeners for the event.
|
|
234
|
-
*/
|
|
235
|
-
listenerCount(event: string): number;
|
|
236
|
-
/**
|
|
237
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
238
|
-
*
|
|
239
|
-
* @param {string} event - The name of the event.
|
|
240
|
-
* @returns {ScrollListenersFunc[]} Array of listener functions.
|
|
241
|
-
*/
|
|
242
|
-
listeners(event: string): ScrollListenersFunc[];
|
|
243
|
-
/**
|
|
244
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
245
|
-
*
|
|
246
|
-
* @param {string} event - The name of the event.
|
|
247
|
-
* @returns {ScrollListenersFunc[]} Array of listener functions.
|
|
248
|
-
*/
|
|
249
|
-
onceListeners(event: string): ScrollListenersFunc[];
|
|
250
|
-
/**
|
|
251
|
-
* Returns a copy of the internal listeners array for the specified event,
|
|
252
|
-
* including wrapper functions like those used by `.once()`.
|
|
253
|
-
* @param {string | symbol} event - The event name.
|
|
254
|
-
* @returns {ScrollListenersFunc[]} An array of raw listener functions.
|
|
255
|
-
*/
|
|
256
|
-
allListeners(event: string | symbol): ScrollListenersFunc[];
|
|
257
|
-
/**
|
|
258
|
-
* Returns an array of event names for which there are registered listeners.
|
|
259
|
-
*
|
|
260
|
-
* @returns {string[]} Array of registered event names.
|
|
261
|
-
*/
|
|
262
|
-
eventNames(): string[];
|
|
263
|
-
/**
|
|
264
|
-
* Emits an event, triggering all registered handlers for that event.
|
|
265
|
-
*
|
|
266
|
-
* @param {string} event - The event name to emit.
|
|
267
|
-
* @param {...any} payload - Optional data to pass to each handler.
|
|
268
|
-
* @returns {boolean[]} True if any listeners were called, false otherwise.
|
|
269
|
-
*/
|
|
270
|
-
emit(event: string, ...payload: any[]): boolean[];
|
|
271
|
-
/**
|
|
272
|
-
* Sets the maximum number of listeners per event before a warning is shown.
|
|
273
|
-
*
|
|
274
|
-
* @param {number} n - The maximum number of listeners.
|
|
275
|
-
*/
|
|
276
|
-
setMaxListeners(n: number): void;
|
|
277
|
-
/**
|
|
278
|
-
* Gets the maximum number of listeners allowed per event.
|
|
279
|
-
*
|
|
280
|
-
* @returns {number} The maximum number of listeners.
|
|
281
|
-
*/
|
|
282
|
-
getMaxListeners(): number;
|
|
283
147
|
/**
|
|
284
148
|
* Returns a size difference callback that only reacts when height changes, filtered by tag name.
|
|
285
149
|
*
|
|
@@ -594,6 +458,7 @@ declare class TinySmartScroller<HTMLTarget extends Element | Window> {
|
|
|
594
458
|
destroy(): void;
|
|
595
459
|
#private;
|
|
596
460
|
}
|
|
461
|
+
import { EventEmitter } from 'events';
|
|
597
462
|
import TinyHtml from './TinyHtml.mjs';
|
|
598
463
|
import * as TinyCollision from '../basics/collision.mjs';
|
|
599
464
|
//# sourceMappingURL=TinySmartScroller.d.mts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { EventEmitter } from 'events';
|
|
1
2
|
import TinyHtml from './TinyHtml.mjs';
|
|
2
3
|
import * as TinyCollision from '../basics/collision.mjs';
|
|
3
|
-
import TinyEvents from './TinyEvents.mjs';
|
|
4
4
|
/**
|
|
5
5
|
* Represents the dimensions of a DOM element.
|
|
6
6
|
*
|
|
@@ -42,181 +42,8 @@ import TinyEvents from './TinyEvents.mjs';
|
|
|
42
42
|
* This class is **not framework-dependent** and works with vanilla DOM elements and the window object.
|
|
43
43
|
* @template {Element|Window} HTMLTarget
|
|
44
44
|
*/
|
|
45
|
-
class TinySmartScroller {
|
|
45
|
+
class TinySmartScroller extends EventEmitter {
|
|
46
46
|
static Utils = { ...TinyCollision, TinyHtml };
|
|
47
|
-
#events = new TinyEvents();
|
|
48
|
-
/**
|
|
49
|
-
* Enables or disables throwing an error when the maximum number of listeners is exceeded.
|
|
50
|
-
*
|
|
51
|
-
* @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
|
|
52
|
-
*/
|
|
53
|
-
setThrowOnMaxListeners(shouldThrow) {
|
|
54
|
-
return this.#events.setThrowOnMaxListeners(shouldThrow);
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Checks whether an error will be thrown when the max listener limit is exceeded.
|
|
58
|
-
*
|
|
59
|
-
* @returns {boolean} True if an error will be thrown, false if only a warning is shown.
|
|
60
|
-
*/
|
|
61
|
-
getThrowOnMaxListeners() {
|
|
62
|
-
return this.#events.getThrowOnMaxListeners();
|
|
63
|
-
}
|
|
64
|
-
/////////////////////////////////////////////////////////////
|
|
65
|
-
/**
|
|
66
|
-
* Adds a listener to the beginning of the listeners array for the specified event.
|
|
67
|
-
*
|
|
68
|
-
* @param {string|string[]} event - Event name.
|
|
69
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
70
|
-
*/
|
|
71
|
-
prependListener(event, handler) {
|
|
72
|
-
return this.#events.prependListener(event, handler);
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Adds a one-time listener to the beginning of the listeners array for the specified event.
|
|
76
|
-
*
|
|
77
|
-
* @param {string|string[]} event - Event name.
|
|
78
|
-
* @param {ScrollListenersFunc} handler - The callback function.
|
|
79
|
-
* @returns {ScrollListenersFunc[]} - The wrapped handler used internally.
|
|
80
|
-
*/
|
|
81
|
-
prependListenerOnce(event, handler) {
|
|
82
|
-
return this.#events.prependListenerOnce(event, handler);
|
|
83
|
-
}
|
|
84
|
-
//////////////////////////////////////////////////////////////////////
|
|
85
|
-
/**
|
|
86
|
-
* Adds a event listener.
|
|
87
|
-
*
|
|
88
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
89
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
90
|
-
*/
|
|
91
|
-
appendListener(event, handler) {
|
|
92
|
-
return this.#events.appendListener(event, handler);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Registers an event listener that runs only once, then is removed.
|
|
96
|
-
*
|
|
97
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
98
|
-
* @param {ScrollListenersFunc} handler - The callback function to run on event.
|
|
99
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
100
|
-
*/
|
|
101
|
-
appendListenerOnce(event, handler) {
|
|
102
|
-
return this.#events.appendListenerOnce(event, handler);
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Adds a event listener.
|
|
106
|
-
*
|
|
107
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
108
|
-
* @param {ScrollListenersFunc} handler - Callback function to be called when event fires.
|
|
109
|
-
*/
|
|
110
|
-
on(event, handler) {
|
|
111
|
-
return this.#events.on(event, handler);
|
|
112
|
-
}
|
|
113
|
-
/**
|
|
114
|
-
* Registers an event listener that runs only once, then is removed.
|
|
115
|
-
*
|
|
116
|
-
* @param {string|string[]} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
|
|
117
|
-
* @param {ScrollListenersFunc} handler - The callback function to run on event.
|
|
118
|
-
* @returns {ScrollListenersFunc[]} - The wrapped version of the handler.
|
|
119
|
-
*/
|
|
120
|
-
once(event, handler) {
|
|
121
|
-
return this.#events.once(event, handler);
|
|
122
|
-
}
|
|
123
|
-
////////////////////////////////////////////////////////////////////
|
|
124
|
-
/**
|
|
125
|
-
* Removes a previously registered event listener.
|
|
126
|
-
*
|
|
127
|
-
* @param {string|string[]} event - The name of the event to remove the handler from.
|
|
128
|
-
* @param {ScrollListenersFunc} handler - The specific callback function to remove.
|
|
129
|
-
*/
|
|
130
|
-
off(event, handler) {
|
|
131
|
-
return this.#events.off(event, handler);
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Removes all event listeners of a specific type from the element.
|
|
135
|
-
*
|
|
136
|
-
* @param {string|string[]} event - The event type to remove (e.g. 'onScrollBoundary').
|
|
137
|
-
*/
|
|
138
|
-
offAll(event) {
|
|
139
|
-
return this.#events.offAll(event);
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Removes all event listeners of all types from the element.
|
|
143
|
-
*/
|
|
144
|
-
offAllTypes() {
|
|
145
|
-
return this.#events.offAllTypes();
|
|
146
|
-
}
|
|
147
|
-
////////////////////////////////////////////////////////////
|
|
148
|
-
/**
|
|
149
|
-
* Returns the number of listeners for a given event.
|
|
150
|
-
*
|
|
151
|
-
* @param {string} event - The name of the event.
|
|
152
|
-
* @returns {number} Number of listeners for the event.
|
|
153
|
-
*/
|
|
154
|
-
listenerCount(event) {
|
|
155
|
-
return this.#events.listenerCount(event);
|
|
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 {ScrollListenersFunc[]} Array of listener functions.
|
|
162
|
-
*/
|
|
163
|
-
listeners(event) {
|
|
164
|
-
return this.#events.listeners(event);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Returns a copy of the array of listeners for the specified event.
|
|
168
|
-
*
|
|
169
|
-
* @param {string} event - The name of the event.
|
|
170
|
-
* @returns {ScrollListenersFunc[]} Array of listener functions.
|
|
171
|
-
*/
|
|
172
|
-
onceListeners(event) {
|
|
173
|
-
return this.#events.onceListeners(event);
|
|
174
|
-
}
|
|
175
|
-
/**
|
|
176
|
-
* Returns a copy of the internal listeners array for the specified event,
|
|
177
|
-
* including wrapper functions like those used by `.once()`.
|
|
178
|
-
* @param {string | symbol} event - The event name.
|
|
179
|
-
* @returns {ScrollListenersFunc[]} An array of raw listener functions.
|
|
180
|
-
*/
|
|
181
|
-
allListeners(event) {
|
|
182
|
-
return this.#events.allListeners(event);
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* Returns an array of event names for which there are registered listeners.
|
|
186
|
-
*
|
|
187
|
-
* @returns {string[]} Array of registered event names.
|
|
188
|
-
*/
|
|
189
|
-
eventNames() {
|
|
190
|
-
return this.#events.eventNames();
|
|
191
|
-
}
|
|
192
|
-
//////////////////////////////////////////////////////
|
|
193
|
-
/**
|
|
194
|
-
* Emits an event, triggering all registered handlers for that event.
|
|
195
|
-
*
|
|
196
|
-
* @param {string} event - The event name to emit.
|
|
197
|
-
* @param {...any} payload - Optional data to pass to each handler.
|
|
198
|
-
* @returns {boolean[]} True if any listeners were called, false otherwise.
|
|
199
|
-
*/
|
|
200
|
-
emit(event, ...payload) {
|
|
201
|
-
return this.#events.emit(event, ...payload);
|
|
202
|
-
}
|
|
203
|
-
/**
|
|
204
|
-
* Sets the maximum number of listeners per event before a warning is shown.
|
|
205
|
-
*
|
|
206
|
-
* @param {number} n - The maximum number of listeners.
|
|
207
|
-
*/
|
|
208
|
-
setMaxListeners(n) {
|
|
209
|
-
return this.#events.setMaxListeners(n);
|
|
210
|
-
}
|
|
211
|
-
/**
|
|
212
|
-
* Gets the maximum number of listeners allowed per event.
|
|
213
|
-
*
|
|
214
|
-
* @returns {number} The maximum number of listeners.
|
|
215
|
-
*/
|
|
216
|
-
getMaxListeners() {
|
|
217
|
-
return this.#events.getMaxListeners();
|
|
218
|
-
}
|
|
219
|
-
///////////////////////////////////////////////////
|
|
220
47
|
/** @type {WeakMap<Element, NodeSizes>} */
|
|
221
48
|
#oldSizes = new WeakMap();
|
|
222
49
|
/** @type {WeakMap<Element, NodeSizes>} */
|
|
@@ -281,6 +108,7 @@ class TinySmartScroller {
|
|
|
281
108
|
* - Which attributes to observe for changes.
|
|
282
109
|
*/
|
|
283
110
|
constructor(target, { extraScrollBoundary = 0, autoScrollBottom = true, observeMutations = true, preserveScrollOnLayoutShift = true, debounceTime = 100, querySelector = null, attributeFilter = ['class', 'style', 'src', 'data-*', 'height', 'width'], } = {}) {
|
|
111
|
+
super();
|
|
284
112
|
// === target ===
|
|
285
113
|
if (!(target instanceof Element ||
|
|
286
114
|
// @ts-ignore
|
|
@@ -1016,7 +844,7 @@ class TinySmartScroller {
|
|
|
1016
844
|
this.#newVisiblesByTime = new WeakMap();
|
|
1017
845
|
this.#oldVisiblesByTime = new WeakMap();
|
|
1018
846
|
// Cleans listeners and filters
|
|
1019
|
-
this
|
|
847
|
+
this.removeAllListeners();
|
|
1020
848
|
this.#sizeFilter.clear();
|
|
1021
849
|
this.#loadTags.clear();
|
|
1022
850
|
}
|
package/docs/v1/Exports.md
CHANGED
package/docs/v1/README.md
CHANGED
|
@@ -41,7 +41,6 @@ Here, you can navigate through different sections of the project. Below are the
|
|
|
41
41
|
- โ๏ธ **[TinyTextRangeEditor](./libs/TinyTextRangeEditor.md)** โ An flexible text range manipulation utility for `input` and `textarea` elements. Supports selection, cursor control, tag insertion, attribute handling, inline editing, formatting, and advanced wrap/toggle logic with optional spacing auto-completion.
|
|
42
42
|
- โณ **[TinyTimeout](./libs/TinyTimeout.md)** โ A dynamic timeout and delay manager with support for usage-based throttling, delay scaling, configurable decay intervals, and asynchronous polling for conditions.
|
|
43
43
|
- ๐ **[TinyColorConverter](./libs/TinyColorConverter.md)** โ A complete color conversion toolkit supporting hex, RGB(A), HSL(A), and integer formats, with smooth gradient generation, color parsing, and multi-format output conversion.
|
|
44
|
-
- ๐ก **[TinyEvents](./libs/TinyEvents.md)** โ A lightweight and dependency-free event emitter inspired by Node.js, supporting persistent and one-time listeners, listener inspection, and max listener limits.
|
|
45
44
|
- ๐ฆ **[TinyLocalStorage](./libs/TinyLocalStorage.md)** โ A tiny wrapper for `localStorage` with full support for objects, arrays, `Map`, `Set`, and typed value helpers like string, number, and boolean.
|
|
46
45
|
- ๐ผ๏ธ **[TinyIframeEvents](./libs/TinyIframeEvents.md)** โ A structured `postMessage`-based event router for secure and reliable communication between a parent window and its embedded iframe. Supports directional filtering, origin enforcement, payload transport, and listener lifecycle.
|
|
47
46
|
- ๐ช **[TinyNewWinEvents](./libs/TinyNewWinEvents.md)** โ A smart, route-based `postMessage` system for structured communication between a main window and a popup (`window.open`). Includes queueing, origin enforcement, and lifecycle tracking.
|
|
@@ -12,7 +12,7 @@ Whether youโre validating inputs, writing schema validators, or building tools
|
|
|
12
12
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
|
-
- โ
Precise type detection (`undefined`, `null`, `array`, `
|
|
15
|
+
- โ
Precise type detection (`undefined`, `null`, `array`, `date`, etc.)
|
|
16
16
|
- โ Custom type extensions with ordering
|
|
17
17
|
- ๐ Reorder type checking priority
|
|
18
18
|
- ๐ Safe and predictable type checks
|
|
@@ -36,14 +36,14 @@ const parentEvents = new TinyIframeEvents({
|
|
|
36
36
|
|
|
37
37
|
// You can safely emit before the iframe is ready.
|
|
38
38
|
// It will be queued and sent automatically!
|
|
39
|
-
parentEvents.
|
|
39
|
+
parentEvents.winEmit('hello:iframe', { text: '๐ From parent!' });
|
|
40
40
|
|
|
41
41
|
// Wait for the secure channel to be fully established
|
|
42
42
|
parentEvents.onReady(() => {
|
|
43
43
|
console.log('โ
Secure connection established with iframe!');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
parentEvents.on('reply:fromIframe', (data, event) => {
|
|
46
|
+
parentEvents.on('win:reply:fromIframe', (data, event) => {
|
|
47
47
|
console.log('๐จ Received from iframe:', data, event);
|
|
48
48
|
});
|
|
49
49
|
```
|
|
@@ -62,10 +62,10 @@ const iframeEvents = new TinyIframeEvents({
|
|
|
62
62
|
|
|
63
63
|
iframeEvents.onReady(() => {
|
|
64
64
|
console.log('โ
Secure connection established with parent!');
|
|
65
|
-
iframeEvents.
|
|
65
|
+
iframeEvents.winEmit('reply:fromIframe', { text: '๐โโ๏ธ Hi parent!' });
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
iframeEvents.on('hello:iframe', (data, event) => {
|
|
68
|
+
iframeEvents.on('win:hello:iframe', (data, event) => {
|
|
69
69
|
console.log('๐ฅ Message from parent:', data);
|
|
70
70
|
});
|
|
71
71
|
```
|
|
@@ -102,7 +102,7 @@ iframeEvents.onReady(() => {
|
|
|
102
102
|
|
|
103
103
|
---
|
|
104
104
|
|
|
105
|
-
### `
|
|
105
|
+
### `winEmit(eventName, payload)`
|
|
106
106
|
|
|
107
107
|
Sends a message to the target frame through the secure port. If the port is not ready yet, the message is queued.
|
|
108
108
|
|
|
@@ -119,10 +119,10 @@ Sends a message to the target frame through the secure port. If the port is not
|
|
|
119
119
|
|
|
120
120
|
### `on(eventName, handler)`
|
|
121
121
|
|
|
122
|
-
Registers a listener for a specific event.
|
|
122
|
+
Registers a listener for a specific event (using `win:` to external events).
|
|
123
123
|
|
|
124
124
|
```js
|
|
125
|
-
iframeEvents.on('my:event', (payload, event) => {
|
|
125
|
+
iframeEvents.on('win:my:event', (payload, event) => {
|
|
126
126
|
// Access data via `payload`
|
|
127
127
|
});
|
|
128
128
|
```
|
|
@@ -162,7 +162,7 @@ if (events.isDestroyed()) {
|
|
|
162
162
|
|
|
163
163
|
This class internally wraps:
|
|
164
164
|
* `MessageChannel` and `MessagePort` for isolated communication.
|
|
165
|
-
* A minimal event router
|
|
165
|
+
* A minimal event router.
|
|
166
166
|
|
|
167
167
|
---
|
|
168
168
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ๐ฆ TinyLocalStorage
|
|
2
2
|
|
|
3
|
-
Tiny wrapper for `localStorage` with full support for complex structures like `Map`, `Set`, `Date`, `RegExp`, `BigInt`, and even custom types. Offers a type-safe interface and a powerful event system
|
|
3
|
+
Tiny wrapper for `localStorage` with full support for complex structures like `Map`, `Set`, `Date`, `RegExp`, `BigInt`, and even custom types. Offers a type-safe interface and a powerful event system.
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -27,7 +27,7 @@ console.log(storage.getDate('today') instanceof Date); // true
|
|
|
27
27
|
* โ
Store & restore `Map`, `Set`, `Date`, `RegExp`, `BigInt`, `Symbol`, `null`, `undefined`.
|
|
28
28
|
* โ
Custom type encoding and decoding system.
|
|
29
29
|
* โ
Type-safe methods for string, number and boolean.
|
|
30
|
-
* โ
Built-in event system
|
|
30
|
+
* โ
Built-in event system with optional native `storage` listener.
|
|
31
31
|
* โ
Optional fallback when decoding fails.
|
|
32
32
|
|
|
33
33
|
---
|
|
@@ -344,7 +344,7 @@ Returns `true` if the type has both encoder and decoder registered, otherwise `f
|
|
|
344
344
|
|
|
345
345
|
---
|
|
346
346
|
|
|
347
|
-
## ๐ฅ Events
|
|
347
|
+
## ๐ฅ Events
|
|
348
348
|
|
|
349
349
|
### Built-in Events
|
|
350
350
|
|
|
@@ -30,11 +30,11 @@ const events = new TinyNewWinEvents({
|
|
|
30
30
|
targetOrigin: window.location.origin
|
|
31
31
|
});
|
|
32
32
|
|
|
33
|
-
events.on('user:reply', (payload) => {
|
|
33
|
+
events.on('win:user:reply', (payload) => {
|
|
34
34
|
console.log('๐ฉ From popup:', payload);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
events.
|
|
37
|
+
events.winEmit('init:data', { id: 123 });
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
---
|
|
@@ -46,11 +46,11 @@ import TinyNewWinEvents from './TinyNewWinEvents.mjs';
|
|
|
46
46
|
|
|
47
47
|
const events = new TinyNewWinEvents();
|
|
48
48
|
|
|
49
|
-
events.on('init:data', (payload) => {
|
|
49
|
+
events.on('win:init:data', (payload) => {
|
|
50
50
|
console.log('๐ฆ Init payload from main window:', payload);
|
|
51
51
|
});
|
|
52
52
|
|
|
53
|
-
events.
|
|
53
|
+
events.winEmit('user:reply', { msg: '๐ Hello from popup!' });
|
|
54
54
|
```
|
|
55
55
|
|
|
56
56
|
---
|
|
@@ -74,7 +74,7 @@ Creates a new communication instance.
|
|
|
74
74
|
|
|
75
75
|
---
|
|
76
76
|
|
|
77
|
-
### `
|
|
77
|
+
### `winEmit(route, payload)`
|
|
78
78
|
|
|
79
79
|
Sends a message on a specific route.
|
|
80
80
|
|
|
@@ -89,10 +89,10 @@ Sends a message on a specific route.
|
|
|
89
89
|
|
|
90
90
|
### `on(route, handler)`
|
|
91
91
|
|
|
92
|
-
Registers a callback for a specific route.
|
|
92
|
+
Registers a callback for a specific route (using `win:` to external events).
|
|
93
93
|
|
|
94
94
|
```js
|
|
95
|
-
events.on('data:sync', (payload, event) => {
|
|
95
|
+
events.on('win:data:sync', (payload, event) => {
|
|
96
96
|
console.log(payload, event.origin);
|
|
97
97
|
});
|
|
98
98
|
```
|
|
@@ -159,7 +159,6 @@ Destroys the instance, cleans up all resources:
|
|
|
159
159
|
| Concept | Purpose |
|
|
160
160
|
| --------------- | ------------------------------------------- |
|
|
161
161
|
| `postMessage` | Core transport for messaging |
|
|
162
|
-
| `TinyEvents` | Internal event emitter and listener manager |
|
|
163
162
|
| `__TNE_READY__` | Handshake trigger message type |
|
|
164
163
|
| `__TNE_ROUTE__` | Route-based message delivery type |
|
|
165
164
|
|
|
@@ -180,7 +179,7 @@ type handler = (
|
|
|
180
179
|
|
|
181
180
|
## ๐ก๏ธ Safety and Validation
|
|
182
181
|
|
|
183
|
-
* ๐ฅ Throws if `
|
|
182
|
+
* ๐ฅ Throws if `winEmit()` is called after `.destroy()`
|
|
184
183
|
* ๐ฃ Throws if the popup was opened with `_blank` name
|
|
185
184
|
* โ
Only communicates with expected `targetOrigin`
|
|
186
185
|
* ๐งผ Automatically detects closed windows and emits `WINDOW_REF_CLOSED`
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tiny-essentials",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.28.0",
|
|
4
4
|
"description": "Collection of small, essential scripts designed to be used across various projects. These simple utilities are crafted for speed, ease of use, and versatility.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"tiny-essentials-fork": "./TinyFork.mjs"
|
|
@@ -92,6 +92,10 @@
|
|
|
92
92
|
"require": "./dist/v1/basics/objFilter.cjs",
|
|
93
93
|
"import": "./dist/v1/basics/objFilter.mjs"
|
|
94
94
|
},
|
|
95
|
+
"./basics/extendObjType/Buffer": {
|
|
96
|
+
"require": "./dist/v1/basics/extendObjType/Buffer.mjs.cjs",
|
|
97
|
+
"import": "./dist/v1/basics/extendObjType/Buffer.mjs.mjs"
|
|
98
|
+
},
|
|
95
99
|
"./basics/simpleMath": {
|
|
96
100
|
"require": "./dist/v1/basics/simpleMath.cjs",
|
|
97
101
|
"import": "./dist/v1/basics/simpleMath.mjs"
|
|
@@ -220,10 +224,6 @@
|
|
|
220
224
|
"require": "./dist/v1/libs/TinyGamepad.cjs",
|
|
221
225
|
"import": "./dist/v1/libs/TinyGamepad.mjs"
|
|
222
226
|
},
|
|
223
|
-
"./libs/TinyEvents": {
|
|
224
|
-
"require": "./dist/v1/libs/TinyEvents.cjs",
|
|
225
|
-
"import": "./dist/v1/libs/TinyEvents.mjs"
|
|
226
|
-
},
|
|
227
227
|
"./libs/TinyElementObserver": {
|
|
228
228
|
"require": "./dist/v1/libs/TinyElementObserver.cjs",
|
|
229
229
|
"import": "./dist/v1/libs/TinyElementObserver.mjs"
|
|
@@ -535,6 +535,7 @@
|
|
|
535
535
|
"@types/node": "^26.1.0",
|
|
536
536
|
"@types/node-fetch": "^2.6.12",
|
|
537
537
|
"babel-preset-es2015": "^6.24.1",
|
|
538
|
+
"buffer": "^6.0.3",
|
|
538
539
|
"esbuild": "^0.28.1",
|
|
539
540
|
"express": "^5.1.0",
|
|
540
541
|
"lodash": "^4.17.21",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(()=>{"use strict";const e={d:(t,n)=>{if(Array.isArray(n))for(var r=0;r<n.length;){var s=n[r++],i=n[r++];e.o(t,s)?0===i&&r++:0===i?Object.defineProperty(t,s,{enumerable:!0,value:n[r++]}):Object.defineProperty(t,s,{enumerable:!0,get:i})}else for(var s in n)e.o(n,s)&&!e.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:n[s]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};let t={};e.d(t,{TinyEvents:()=>n});const n=class{#e=new Map;#t=10;#n=!1;#r(e,t){if("string"==typeof e)return[e];if(Array.isArray(e)&&e.every(e=>"string"==typeof e))return e;throw new TypeError(`${t}(event): event must be a string or string[]`)}setThrowOnMaxListeners(e){if("boolean"!=typeof e)throw new TypeError("setThrowOnMaxListeners(value): value must be a boolean");this.#n=e}getThrowOnMaxListeners(){return this.#n}#s(e,t,{once:n=!1}={}){let r=this.#e.get(e);Array.isArray(r)||(r=[],this.#e.set(e,r)),r.unshift({handler:t,config:{once:n}});const s=this.#t;if(s>0&&r.length>s){const t=`Possible memory leak detected. ${r.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#n)throw new Error(t);console.warn(t)}}prependListener(e,t){const n=this.#r(e,"prependListener");if("function"!=typeof t)throw new TypeError("prependListener(event, handler): handler must be a function");for(const e of n)this.#s(e,t)}prependListenerOnce(e,t){const n=this.#r(e,"prependListenerOnce");if("function"!=typeof t)throw new TypeError("prependListenerOnce(event, handler): handler must be a function");const r=[];for(const e of n){const n=(...r)=>{this.off(e,n),t(...r)};this.#s(e,n,{once:!0}),r.push(n)}return r}#i(e,t,{once:n=!1}={}){const r=this.#r(e,"on");for(const e of r){let r=this.#e.get(e);Array.isArray(r)||(r=[],this.#e.set(e,r)),r.push({handler:t,config:{once:n}});const s=this.#t;if(s>0&&r.length>s){const t=`Possible memory leak detected. ${r.length} "${e}" listeners added. Use setMaxListeners() to increase limit.`;if(this.#n)throw new Error(t);console.warn(t)}}}on(e,t){if("function"!=typeof t)throw new TypeError("on(event, handler): handler must be a function");return this.#i(e,t)}once(e,t){const n=this.#r(e,"once");if("function"!=typeof t)throw new TypeError("once(event, handler): handler must be a function");const r=[];for(const e of n){const n=(...r)=>{this.off(e,n),t(...r)};this.#i(e,n,{once:!0}),r.push(n)}return r}appendListener(e,t){return this.on(e,t)}appendListenerOnce(e,t){return this.once(e,t)}off(e,t){const n=this.#r(e,"off");if("function"!=typeof t)throw new TypeError("off(event, handler): handler must be a function");for(const e of n){const n=this.#e.get(e);if(!Array.isArray(n))continue;const r=n.findIndex(e=>e.handler===t);-1!==r&&n.splice(r,1),0===n.length&&this.#e.delete(e)}}offAll(e){const t=this.#r(e,"offAll");for(const e of t)this.#e.delete(e)}offAllTypes(){this.#e.clear()}removeAllListeners(){return this.offAllTypes()}listenerCount(e){if("string"!=typeof e)throw new TypeError("listenerCount(event): event name must be a string");const t=this.#e.get(e);return Array.isArray(t)?t.length:0}listeners(e){if("string"!=typeof e)throw new TypeError("listeners(event): event name must be a string");const t=this.#e.get(e);return Array.isArray(t)?[...t].filter(e=>!e.config.once).map(e=>e.handler):[]}onceListeners(e){if("string"!=typeof e)throw new TypeError("onceListeners(event): event name must be a string");const t=this.#e.get(e);return Array.isArray(t)?[...t].filter(e=>e.config.once).map(e=>e.handler):[]}allListeners(e){if("string"!=typeof e)throw new TypeError("allListeners(event): event name must be a string");const t=this.#e.get(e);return Array.isArray(t)?[...t].map(e=>e.handler):[]}eventNames(){return[...this.#e.keys()]}emit(e,...t){const n=this.#r(e,"emit"),r=[];for(const e of n){const n=this.#e.get(e);Array.isArray(n)&&0!==n.length?(n.forEach(e=>e.handler(...t)),r.push(!0)):r.push(!1)}return r}setMaxListeners(e){if(!Number.isInteger(e)||e<0)throw new TypeError("setMaxListeners(n): n must be a non-negative integer");this.#t=e}getMaxListeners(){return this.#t}};window.TinyEvents=t.TinyEvents})();
|