tiny-essentials 1.20.0 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/v1/TinyBasicsEs.min.js +1 -1
  2. package/dist/v1/TinyDragger.min.js +1 -1
  3. package/dist/v1/TinyEssentials.min.js +1 -1
  4. package/dist/v1/TinyHtml.min.js +1 -1
  5. package/dist/v1/TinySmartScroller.min.js +1 -1
  6. package/dist/v1/TinyUploadClicker.min.js +1 -1
  7. package/dist/v1/libs/TinyDragger.cjs +1 -1
  8. package/dist/v1/libs/TinyDragger.mjs +1 -1
  9. package/dist/v1/libs/TinyHtml.cjs +292 -103
  10. package/dist/v1/libs/TinyHtml.d.mts +142 -39
  11. package/dist/v1/libs/TinyHtml.mjs +266 -94
  12. package/dist/v1/libs/TinyIframeEvents.cjs +2 -1
  13. package/dist/v1/libs/TinyNewWinEvents.cjs +4 -2
  14. package/docs/v1/libs/TinyHtml.md +128 -6
  15. package/package.json +1 -1
  16. package/dist/v1/ColorSafeStringify.js +0 -235
  17. package/dist/v1/TinyAfterScrollWatcher.js +0 -219
  18. package/dist/v1/TinyBasicsEs.js +0 -9334
  19. package/dist/v1/TinyClipboard.js +0 -459
  20. package/dist/v1/TinyColorConverter.js +0 -617
  21. package/dist/v1/TinyDomReadyManager.js +0 -213
  22. package/dist/v1/TinyDragDropDetector.js +0 -307
  23. package/dist/v1/TinyDragger.js +0 -6569
  24. package/dist/v1/TinyEssentials.js +0 -20792
  25. package/dist/v1/TinyEvents.js +0 -402
  26. package/dist/v1/TinyHtml.js +0 -5545
  27. package/dist/v1/TinyIframeEvents.js +0 -854
  28. package/dist/v1/TinyLevelUp.js +0 -291
  29. package/dist/v1/TinyLocalStorage.js +0 -1440
  30. package/dist/v1/TinyNewWinEvents.js +0 -888
  31. package/dist/v1/TinyNotifications.js +0 -408
  32. package/dist/v1/TinyNotifyCenter.js +0 -493
  33. package/dist/v1/TinyPromiseQueue.js +0 -299
  34. package/dist/v1/TinyRateLimiter.js +0 -611
  35. package/dist/v1/TinySmartScroller.js +0 -7039
  36. package/dist/v1/TinyTextRangeEditor.js +0 -497
  37. package/dist/v1/TinyTimeout.js +0 -233
  38. package/dist/v1/TinyToastNotify.js +0 -441
  39. package/dist/v1/TinyUploadClicker.js +0 -14353
  40. package/dist/v1/UltraRandomMsgGen.js +0 -995
@@ -1,402 +0,0 @@
1
- /******/ (() => { // webpackBootstrap
2
- /******/ "use strict";
3
- /******/ // The require scope
4
- /******/ var __webpack_require__ = {};
5
- /******/
6
- /************************************************************************/
7
- /******/ /* webpack/runtime/define property getters */
8
- /******/ (() => {
9
- /******/ // define getter functions for harmony exports
10
- /******/ __webpack_require__.d = (exports, definition) => {
11
- /******/ for(var key in definition) {
12
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
13
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
14
- /******/ }
15
- /******/ }
16
- /******/ };
17
- /******/ })();
18
- /******/
19
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
20
- /******/ (() => {
21
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
22
- /******/ })();
23
- /******/
24
- /************************************************************************/
25
- var __webpack_exports__ = {};
26
-
27
- // EXPORTS
28
- __webpack_require__.d(__webpack_exports__, {
29
- TinyEvents: () => (/* reexport */ libs_TinyEvents)
30
- });
31
-
32
- ;// ./src/v1/libs/TinyEvents.mjs
33
- /**
34
- * A generic event listener callback function.
35
- *
36
- * @callback handler
37
- * @param {...any} payload - The data payload passed when the event is triggered.
38
- * @returns {void}
39
- */
40
-
41
- /**
42
- * TinyEvents provides a minimalistic event emitter system similar to Node.js's EventEmitter,
43
- * enabling components to subscribe to, emit, and manage events and their listeners.
44
- *
45
- * Features include:
46
- * - Adding/removing event listeners (`on`, `off`, `offAll`, `offAllTypes`)
47
- * - One-time listeners (`once`)
48
- * - Emitting events (`emit`)
49
- * - Listener inspection and limits (`listenerCount`, `listeners`, `eventNames`)
50
- * - Maximum listener control (`setMaxListeners`, `getMaxListeners`)
51
- *
52
- * This class is useful for lightweight, dependency-free publish/subscribe event handling
53
- * within modular JavaScript applications.
54
- *
55
- * @class
56
- */
57
- class TinyEvents {
58
- /** @type {Map<string, { handler: handler; config: { once: boolean } }[]>} */
59
- #listeners = new Map();
60
-
61
- /** @type {number} */
62
- #maxListeners = 10;
63
-
64
- /** @type {boolean} */
65
- #throwMaxListeners = false;
66
-
67
- /**
68
- * Enables or disables throwing an error when the maximum number of listeners is exceeded.
69
- *
70
- * @param {boolean} shouldThrow - If true, an error will be thrown when the max is exceeded.
71
- */
72
- setThrowOnMaxListeners(shouldThrow) {
73
- if (typeof shouldThrow !== 'boolean')
74
- throw new TypeError('setThrowOnMaxListeners(value): value must be a boolean');
75
- this.#throwMaxListeners = shouldThrow;
76
- }
77
-
78
- /**
79
- * Checks whether an error will be thrown when the max listener limit is exceeded.
80
- *
81
- * @returns {boolean} True if an error will be thrown, false if only a warning is shown.
82
- */
83
- getThrowOnMaxListeners() {
84
- return this.#throwMaxListeners;
85
- }
86
-
87
- ///////////////////////////////////////////////////
88
-
89
- /**
90
- * Internal method to prepend a listener with options.
91
- *
92
- * @param {string} event - Event name.
93
- * @param {handler} handler - The callback function.
94
- * @param {Object} [settings={}] - Optional settings.
95
- * @param {boolean} [settings.once=false] - If the listener should be executed once.
96
- */
97
- #prepend(event, handler, { once = false } = {}) {
98
- let eventData = this.#listeners.get(event);
99
- if (!Array.isArray(eventData)) {
100
- eventData = [];
101
- this.#listeners.set(event, eventData);
102
- }
103
- eventData.unshift({ handler, config: { once } });
104
-
105
- const max = this.#maxListeners;
106
- if (max > 0 && eventData.length > max) {
107
- const warnMessage =
108
- `Possible memory leak detected. ${eventData.length} "${event}" listeners added. ` +
109
- `Use setMaxListeners() to increase limit.`;
110
- if (!this.#throwMaxListeners) console.warn(warnMessage);
111
- else throw new Error(warnMessage);
112
- }
113
- }
114
-
115
- /**
116
- * Adds a listener to the beginning of the listeners array for the specified event.
117
- *
118
- * @param {string} event - Event name.
119
- * @param {handler} handler - The callback function.
120
- */
121
- prependListener(event, handler) {
122
- if (typeof event !== 'string')
123
- throw new TypeError('prepend(event, handler): event name must be a string');
124
- if (typeof handler !== 'function')
125
- throw new TypeError('prepend(event, handler): handler must be a function');
126
- this.#prepend(event, handler);
127
- }
128
-
129
- /**
130
- * Adds a one-time listener to the beginning of the listeners array for the specified event.
131
- *
132
- * @param {string} event - Event name.
133
- * @param {handler} handler - The callback function.
134
- * @returns {handler} - The wrapped handler used internally.
135
- */
136
- prependListenerOnce(event, handler) {
137
- if (typeof event !== 'string')
138
- throw new TypeError('prependOnceListener(event, handler): event name must be a string');
139
- if (typeof handler !== 'function')
140
- throw new TypeError('prependOnceListener(event, handler): handler must be a function');
141
-
142
- /** @type {handler} */
143
- const wrapped = (...args) => {
144
- this.off(event, wrapped);
145
- handler(...args);
146
- };
147
-
148
- this.#prepend(event, wrapped, { once: true });
149
- return wrapped;
150
- }
151
-
152
- ////////////////////////////////////////////////////////////
153
-
154
- /**
155
- * Adds a event listener.
156
- *
157
- * @param {string} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
158
- * @param {handler} handler - Callback function to be called when event fires.
159
- * @param {Object} [settings={}] - Optional settings.
160
- * @param {boolean} [settings.once=false] - This is a once event.
161
- */
162
- #on(event, handler, { once = false } = {}) {
163
- let eventData = this.#listeners.get(event);
164
- if (!Array.isArray(eventData)) {
165
- eventData = [];
166
- this.#listeners.set(event, eventData);
167
- }
168
- eventData.push({ handler, config: { once } });
169
- // Warn if listener count exceeds the max allowed
170
- const max = this.#maxListeners;
171
- if (max > 0 && eventData.length > max) {
172
- const warnMessage =
173
- `Possible memory leak detected. ${eventData.length} "${event}" listeners added. ` +
174
- `Use setMaxListeners() to increase limit.`;
175
- if (!this.#throwMaxListeners) console.warn(warnMessage);
176
- else throw new Error(warnMessage);
177
- }
178
- }
179
-
180
- /**
181
- * Adds a event listener.
182
- *
183
- * @param {string} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
184
- * @param {handler} handler - Callback function to be called when event fires.
185
- */
186
- on(event, handler) {
187
- if (typeof event !== 'string')
188
- throw new TypeError('on(event, handler): event name must be a string');
189
- if (typeof handler !== 'function')
190
- throw new TypeError('on(event, handler): handler must be a function');
191
- return this.#on(event, handler);
192
- }
193
-
194
- /**
195
- * Registers an event listener that runs only once, then is removed.
196
- *
197
- * @param {string} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
198
- * @param {handler} handler - The callback function to run on event.
199
- * @returns {handler} - The wrapped version of the handler.
200
- */
201
- once(event, handler) {
202
- if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
203
- if (typeof handler !== 'function')
204
- throw new TypeError('once(event, handler): handler must be a function');
205
-
206
- /** @type {handler} */
207
- const wrapped = (e) => {
208
- this.off(event, wrapped);
209
- if (typeof handler === 'function') handler(e);
210
- };
211
- this.#on(event, wrapped, { once: true });
212
- return wrapped;
213
- }
214
-
215
- /**
216
- * Adds a event listener.
217
- *
218
- * @param {string} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
219
- * @param {handler} handler - Callback function to be called when event fires.
220
- */
221
- appendListener(event, handler) {
222
- return this.on(event, handler);
223
- }
224
-
225
- /**
226
- * Registers an event listener that runs only once, then is removed.
227
- *
228
- * @param {string} event - Event name, such as 'onScrollBoundary' or 'onAutoScroll'.
229
- * @param {handler} handler - The callback function to run on event.
230
- * @returns {handler} - The wrapped version of the handler.
231
- */
232
- appendListenerOnce(event, handler) {
233
- return this.once(event, handler);
234
- }
235
-
236
- ///////////////////////////////////////////////
237
-
238
- /**
239
- * Removes a previously registered event listener.
240
- *
241
- * @param {string} event - The name of the event to remove the handler from.
242
- * @param {handler} handler - The specific callback function to remove.
243
- */
244
- off(event, handler) {
245
- if (typeof event !== 'string')
246
- throw new TypeError('off(event, handler): event name must be a string');
247
- if (typeof handler !== 'function')
248
- throw new TypeError('off(event, handler): handler must be a function');
249
-
250
- const listeners = this.#listeners.get(event);
251
- if (!Array.isArray(listeners)) return;
252
-
253
- const index = listeners.findIndex((listener) => listener.handler === handler);
254
- if (index !== -1) listeners.splice(index, 1);
255
-
256
- // Optionally clean up empty arrays (optional)
257
- if (listeners.length === 0) this.#listeners.delete(event);
258
- }
259
-
260
- /**
261
- * Removes all event listeners of a specific type from the element.
262
- *
263
- * @param {string} event - The event type to remove (e.g. 'onScrollBoundary').
264
- */
265
- offAll(event) {
266
- if (typeof event !== 'string') throw new TypeError('The event name must be a string.');
267
- this.#listeners.delete(event);
268
- }
269
-
270
- /**
271
- * Removes all event listeners of all types from the element.
272
- */
273
- offAllTypes() {
274
- this.#listeners.clear();
275
- }
276
-
277
- /////////////////////////////////////////////
278
-
279
- /**
280
- * Returns the number of listeners for a given event.
281
- *
282
- * @param {string} event - The name of the event.
283
- * @returns {number} Number of listeners for the event.
284
- */
285
- listenerCount(event) {
286
- if (typeof event !== 'string')
287
- throw new TypeError('listenerCount(event): event name must be a string');
288
-
289
- const listeners = this.#listeners.get(event);
290
- return Array.isArray(listeners) ? listeners.length : 0;
291
- }
292
-
293
- /**
294
- * Returns a copy of the array of listeners for the specified event.
295
- *
296
- * @param {string} event - The name of the event.
297
- * @returns {handler[]} Array of listener functions.
298
- */
299
- listeners(event) {
300
- if (typeof event !== 'string')
301
- throw new TypeError('listeners(event): event name must be a string');
302
-
303
- const listeners = this.#listeners.get(event);
304
- return Array.isArray(listeners)
305
- ? [...listeners]
306
- .filter((listener) => !listener.config.once)
307
- .map((listener) => listener.handler)
308
- : [];
309
- }
310
-
311
- /**
312
- * Returns a copy of the array of listeners for the specified event.
313
- *
314
- * @param {string} event - The name of the event.
315
- * @returns {handler[]} Array of listener functions.
316
- */
317
- onceListeners(event) {
318
- if (typeof event !== 'string')
319
- throw new TypeError('onceListeners(event): event name must be a string');
320
-
321
- const listeners = this.#listeners.get(event);
322
- return Array.isArray(listeners)
323
- ? [...listeners]
324
- .filter((listener) => listener.config.once)
325
- .map((listener) => listener.handler)
326
- : [];
327
- }
328
-
329
- /**
330
- * Returns a copy of the internal listeners array for the specified event,
331
- * including wrapper functions like those used by `.once()`.
332
- * @param {string | symbol} event - The event name.
333
- * @returns {handler[]} An array of raw listener functions.
334
- */
335
- allListeners(event) {
336
- if (typeof event !== 'string')
337
- throw new TypeError('allListeners(event): event name must be a string');
338
- const listeners = this.#listeners.get(event);
339
- return Array.isArray(listeners) ? [...listeners].map((listener) => listener.handler) : [];
340
- }
341
-
342
- /**
343
- * Returns an array of event names for which there are registered listeners.
344
- *
345
- * @returns {string[]} Array of registered event names.
346
- */
347
- eventNames() {
348
- return [...this.#listeners.keys()];
349
- }
350
-
351
- /**
352
- * Emits an event, triggering all registered handlers for that event.
353
- *
354
- * @param {string} event - The event name to emit.
355
- * @param {...any} payload - Optional data to pass to each handler.
356
- * @returns {boolean} True if any listeners were called, false otherwise.
357
- */
358
- emit(event, ...payload) {
359
- if (typeof event !== 'string')
360
- throw new TypeError('emit(event, data): event name must be a string');
361
-
362
- const listeners = this.#listeners.get(event);
363
- if (!Array.isArray(listeners) || listeners.length === 0) return false;
364
-
365
- // Call all listeners with the provided data
366
- listeners.forEach((listener) => listener.handler(...payload));
367
- return true;
368
- }
369
-
370
- ///////////////////////////////////
371
-
372
- /**
373
- * Sets the maximum number of listeners per event before a warning is shown.
374
- *
375
- * @param {number} n - The maximum number of listeners.
376
- */
377
- setMaxListeners(n) {
378
- if (!Number.isInteger(n) || n < 0)
379
- throw new TypeError('setMaxListeners(n): n must be a non-negative integer');
380
- this.#maxListeners = n;
381
- }
382
-
383
- /**
384
- * Gets the maximum number of listeners allowed per event.
385
- *
386
- * @returns {number} The maximum number of listeners.
387
- */
388
- getMaxListeners() {
389
- return this.#maxListeners;
390
- }
391
- }
392
-
393
- /* harmony default export */ const libs_TinyEvents = (TinyEvents);
394
-
395
- ;// ./src/v1/build/TinyEvents.mjs
396
-
397
-
398
-
399
-
400
- window.TinyEvents = __webpack_exports__.TinyEvents;
401
- /******/ })()
402
- ;