tiny-essentials 1.19.3 → 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 (57) 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/TinyIframeEvents.min.js +1 -0
  6. package/dist/v1/TinyNewWinEvents.min.js +1 -0
  7. package/dist/v1/TinySmartScroller.min.js +1 -1
  8. package/dist/v1/TinyUploadClicker.min.js +1 -1
  9. package/dist/v1/build/TinyIframeEvents.cjs +7 -0
  10. package/dist/v1/build/TinyIframeEvents.d.mts +3 -0
  11. package/dist/v1/build/TinyIframeEvents.mjs +2 -0
  12. package/dist/v1/build/TinyNewWinEvents.cjs +7 -0
  13. package/dist/v1/build/TinyNewWinEvents.d.mts +3 -0
  14. package/dist/v1/build/TinyNewWinEvents.mjs +2 -0
  15. package/dist/v1/index.cjs +4 -0
  16. package/dist/v1/index.d.mts +3 -1
  17. package/dist/v1/index.mjs +3 -1
  18. package/dist/v1/libs/TinyDragger.cjs +1 -1
  19. package/dist/v1/libs/TinyDragger.mjs +1 -1
  20. package/dist/v1/libs/TinyHtml.cjs +292 -103
  21. package/dist/v1/libs/TinyHtml.d.mts +142 -39
  22. package/dist/v1/libs/TinyHtml.mjs +266 -94
  23. package/dist/v1/libs/TinyIframeEvents.cjs +410 -0
  24. package/dist/v1/libs/TinyIframeEvents.d.mts +193 -0
  25. package/dist/v1/libs/TinyIframeEvents.mjs +348 -0
  26. package/dist/v1/libs/TinyNewWinEvents.cjs +488 -0
  27. package/dist/v1/libs/TinyNewWinEvents.d.mts +241 -0
  28. package/dist/v1/libs/TinyNewWinEvents.mjs +437 -0
  29. package/docs/v1/README.md +2 -0
  30. package/docs/v1/libs/TinyHtml.md +128 -6
  31. package/docs/v1/libs/TinyIframeEvents.md +149 -0
  32. package/docs/v1/libs/TinyNewWinEvents.md +186 -0
  33. package/docs/v1/libs/TinyNotifyCenter.md +1 -1
  34. package/package.json +1 -1
  35. package/dist/v1/ColorSafeStringify.js +0 -235
  36. package/dist/v1/TinyAfterScrollWatcher.js +0 -219
  37. package/dist/v1/TinyBasicsEs.js +0 -9334
  38. package/dist/v1/TinyClipboard.js +0 -459
  39. package/dist/v1/TinyColorConverter.js +0 -617
  40. package/dist/v1/TinyDomReadyManager.js +0 -213
  41. package/dist/v1/TinyDragDropDetector.js +0 -307
  42. package/dist/v1/TinyDragger.js +0 -6569
  43. package/dist/v1/TinyEssentials.js +0 -19893
  44. package/dist/v1/TinyEvents.js +0 -402
  45. package/dist/v1/TinyHtml.js +0 -5545
  46. package/dist/v1/TinyLevelUp.js +0 -291
  47. package/dist/v1/TinyLocalStorage.js +0 -1440
  48. package/dist/v1/TinyNotifications.js +0 -408
  49. package/dist/v1/TinyNotifyCenter.js +0 -493
  50. package/dist/v1/TinyPromiseQueue.js +0 -299
  51. package/dist/v1/TinyRateLimiter.js +0 -611
  52. package/dist/v1/TinySmartScroller.js +0 -7039
  53. package/dist/v1/TinyTextRangeEditor.js +0 -497
  54. package/dist/v1/TinyTimeout.js +0 -233
  55. package/dist/v1/TinyToastNotify.js +0 -441
  56. package/dist/v1/TinyUploadClicker.js +0 -13456
  57. package/dist/v1/UltraRandomMsgGen.js +0 -995
@@ -1,299 +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
- TinyPromiseQueue: () => (/* reexport */ libs_TinyPromiseQueue)
30
- });
31
-
32
- ;// ./src/v1/libs/TinyPromiseQueue.mjs
33
- /**
34
- * @typedef {Object} QueuedTask
35
- * @property {(...args: any[]) => Promise<any>|Promise<any>} task - The async task to execute.
36
- * @property {(value: any) => any} resolve - The resolve function from the Promise.
37
- * @property {(reason?: any) => any} reject - The reject function from the Promise.
38
- * @property {string|undefined} [id] - Optional identifier for the task.
39
- * @property {string|null|undefined} [marker] - Optional marker for the task.
40
- * @property {number|null|undefined} [delay] - Optional delay (in ms) before the task is executed.
41
- */
42
-
43
- /**
44
- * A queue system for managing and executing asynchronous tasks sequentially, one at a time.
45
- *
46
- * Tasks can be delayed, reordered, canceled, and processed in strict order. The queue ensures that each task
47
- * is executed after the previous one finishes, and any task can be skipped or canceled if needed.
48
- *
49
- * @class
50
- */
51
- class TinyPromiseQueue {
52
- /** @type {QueuedTask[]} */
53
- #queue = [];
54
- #running = false;
55
- /** @type {Record<string, ReturnType<typeof setTimeout>>} */
56
- #timeouts = {};
57
- /** @type {Set<string>} */
58
- #blacklist = new Set();
59
-
60
- /**
61
- * Returns whether the queue is currently processing a task.
62
- *
63
- * @returns {boolean}
64
- */
65
- isRunning() {
66
- return this.#running;
67
- }
68
-
69
- /**
70
- * Processes the a normal task.
71
- *
72
- * @param {QueuedTask} data
73
- *
74
- * @returns {Promise<void>}
75
- */
76
- async #normalProcessQueue(data) {
77
- if (
78
- data &&
79
- typeof data.task === 'function' &&
80
- typeof data.resolve === 'function' &&
81
- typeof data.reject === 'function'
82
- ) {
83
- const { task, resolve, reject, delay, id } = data;
84
- try {
85
- if (id && this.#blacklist.has(id)) {
86
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
87
- this.#blacklist.delete(id);
88
- this.#running = false;
89
- this.#processQueue();
90
- return;
91
- }
92
-
93
- if (delay && id) {
94
- await new Promise((resolveDelay) => {
95
- const timeoutId = setTimeout(() => {
96
- delete this.#timeouts[id];
97
- resolveDelay(null);
98
- }, delay);
99
- this.#timeouts[id] = timeoutId;
100
- });
101
- }
102
-
103
- const result = await task();
104
- resolve(result);
105
- } catch (error) {
106
- reject(error);
107
- } finally {
108
- this.#running = false;
109
- this.#processQueue();
110
- }
111
- }
112
- }
113
-
114
- /**
115
- * Processes a group task.
116
- *
117
- * @returns {Promise<void>}
118
- */
119
- async #groupProcessQueue() {
120
- /** @type {Array<QueuedTask>} */
121
- const grouped = [];
122
- while (this.#queue.length && this.#queue[0]?.marker === 'POINT_MARKER') {
123
- // @ts-ignore
124
- grouped.push(this.#queue.shift());
125
- }
126
-
127
- if (grouped.length === 0) {
128
- this.#running = false;
129
- this.#processQueue();
130
- return;
131
- }
132
-
133
- await Promise.all(
134
- grouped.map(
135
- ({ task, resolve, reject, id }) =>
136
- new Promise(async (pResolve) => {
137
- if (id && this.#blacklist.has(id)) {
138
- this.#blacklist.delete(id);
139
- reject(new Error('The function was canceled on TinyPromiseQueue.'));
140
- pResolve(true);
141
- return;
142
- }
143
- await task().then(resolve).catch(reject);
144
- pResolve(true);
145
- }),
146
- ),
147
- );
148
-
149
- this.#running = false;
150
- this.#processQueue();
151
- }
152
-
153
- /**
154
- * Processes the next task in the queue if not already running.
155
- * Ensures tasks are executed in order, one at a time.
156
- *
157
- * @returns {Promise<void>}
158
- */
159
- async #processQueue() {
160
- if (this.#running || this.#queue.length === 0) return;
161
- this.#running = true;
162
- if (typeof this.#queue[0]?.marker !== 'string' || this.#queue[0]?.marker !== 'POINT_MARKER') {
163
- const data = this.#queue.shift();
164
- // @ts-ignore
165
- this.#normalProcessQueue(data);
166
- } else this.#groupProcessQueue();
167
- }
168
-
169
- /**
170
- * Returns the index of a task by its ID.
171
- *
172
- * @param {string} id The ID of the task to locate.
173
- * @returns {number} The index of the task in the queue, or -1 if not found.
174
- */
175
- getIndexById(id) {
176
- return this.#queue.findIndex((item) => item.id === id);
177
- }
178
-
179
- /**
180
- * Returns a list of IDs for all tasks currently in the queue.
181
- *
182
- * @returns {{ index: number, id: string }[]} An array of task IDs currently queued.
183
- */
184
- getQueuedIds() {
185
- // @ts-ignore
186
- return this.#queue
187
- .map((item, index) => ({ index, id: item.id }))
188
- .filter((entry) => typeof entry.id === 'string');
189
- }
190
-
191
- /**
192
- * Reorders a task in the queue from one index to another.
193
- *
194
- * @param {number} fromIndex The current index of the task to move.
195
- * @param {number} toIndex The index where the task should be placed.
196
- */
197
- reorderQueue(fromIndex, toIndex) {
198
- if (
199
- typeof fromIndex !== 'number' ||
200
- typeof toIndex !== 'number' ||
201
- fromIndex < 0 ||
202
- toIndex < 0 ||
203
- fromIndex >= this.#queue.length ||
204
- toIndex >= this.#queue.length
205
- )
206
- return;
207
- const [item] = this.#queue.splice(fromIndex, 1);
208
- this.#queue.splice(toIndex, 0, item);
209
- }
210
-
211
- /**
212
- * Inserts a point in the queue where subsequent tasks will be grouped and executed together in a Promise.all.
213
- * If the queue is currently empty, behaves like a regular promise.
214
- *
215
- * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise.
216
- * @param {string} [id] Optional ID to identify the task in the queue.
217
- * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
218
- * @throws {Error} Throws if param is invalid.
219
- */
220
- async enqueuePoint(task, id) {
221
- if (typeof task !== 'function')
222
- return Promise.reject(new Error('Task must be a function returning a Promise.'));
223
- if (typeof id !== 'undefined' && typeof id !== 'string')
224
- throw new Error('The "id" parameter must be a string.');
225
- if (!this.#running) return task();
226
- return new Promise((resolve, reject) => {
227
- this.#queue.push({ marker: 'POINT_MARKER', task, resolve, reject, id });
228
- this.#processQueue();
229
- });
230
- }
231
-
232
- /**
233
- * Adds a new async task to the queue and ensures it runs in order after previous tasks.
234
- * Optionally, a delay can be added before the task is executed.
235
- *
236
- * If the task is canceled before execution, it will be rejected with the message:
237
- * "The function was canceled on TinyPromiseQueue."
238
- *
239
- * @param {(...args: any[]) => Promise<any>|Promise<any>} task A function that returns a Promise to be executed sequentially.
240
- * @param {number|null} [delay] Optional delay (in ms) before the task is executed.
241
- * @param {string} [id] Optional ID to identify the task in the queue.
242
- * @returns {Promise<any>} A Promise that resolves or rejects with the result of the task once it's processed.
243
- * @throws {Error} Throws if param is invalid.
244
- */
245
- enqueue(task, delay, id) {
246
- if (typeof task !== 'function')
247
- return Promise.reject(new Error('Task must be a function returning a Promise.'));
248
- if (typeof delay !== 'undefined' && (typeof delay !== 'number' || delay < 0))
249
- return Promise.reject(new Error('Delay must be a positive number or undefined.'));
250
- if (typeof id !== 'undefined' && typeof id !== 'string')
251
- throw new Error('The "id" parameter must be a string.');
252
-
253
- return new Promise((resolve, reject) => {
254
- this.#queue.push({ task, resolve, reject, id, delay });
255
- this.#processQueue();
256
- });
257
- }
258
-
259
- /**
260
- * Cancels a scheduled delay and removes the task from the queue.
261
- * Adds the ID to a blacklist so the task is skipped if already being processed.
262
- *
263
- * @param {string} id The ID of the task to cancel.
264
- * @returns {boolean} True if a delay was cancelled and the task was removed.
265
- * @throws {Error} Throws if `id` is not a string.
266
- */
267
- cancelTask(id) {
268
- if (typeof id !== 'string') throw new Error('The "id" parameter must be a string.');
269
- let cancelled = false;
270
-
271
- if (id in this.#timeouts) {
272
- clearTimeout(this.#timeouts[id]);
273
- delete this.#timeouts[id];
274
- cancelled = true;
275
- }
276
-
277
- const index = this.getIndexById(id);
278
- if (index !== -1) {
279
- const [removed] = this.#queue.splice(index, 1);
280
- removed?.reject?.(new Error('The function was canceled on TinyPromiseQueue.'));
281
- cancelled = true;
282
- }
283
-
284
- if (cancelled) this.#blacklist.add(id);
285
-
286
- return cancelled;
287
- }
288
- }
289
-
290
- /* harmony default export */ const libs_TinyPromiseQueue = (TinyPromiseQueue);
291
-
292
- ;// ./src/v1/build/TinyPromiseQueue.mjs
293
-
294
-
295
-
296
-
297
- window.TinyPromiseQueue = __webpack_exports__.TinyPromiseQueue;
298
- /******/ })()
299
- ;