tiny-essentials 1.27.1 → 1.28.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.
- package/README.md +1 -0
- package/changelog/1/28/0.md +16 -0
- package/changelog/1/28/1.md +23 -0
- package/dist/v1/TinyAdvancedRaffle.min.js +1 -1
- package/dist/v1/TinyAfterScrollWatcher.min.js +1 -1
- package/dist/v1/TinyAnalogClock.min.js +1 -1
- package/dist/v1/TinyBasicsEs.min.js +1 -2
- package/dist/v1/TinyDayNightCycle.min.js +1 -1
- package/dist/v1/TinyDragDropDetector.min.js +1 -1
- package/dist/v1/TinyDragger.min.js +1 -1
- package/dist/v1/TinyElementObserver.min.js +1 -1
- package/dist/v1/TinyEssentials.min.js +1 -2
- package/dist/v1/TinyGamepad.min.js +1 -1
- package/dist/v1/TinyHtml.min.js +1 -1
- package/dist/v1/TinyI18.min.js +1 -1
- 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/TinyNotifyCenter.min.js +1 -1
- package/dist/v1/TinyRadioFm.min.js +1 -1
- package/dist/v1/TinyRateLimiter.min.js +1 -1
- package/dist/v1/TinySmartScroller.min.js +1 -1
- package/dist/v1/TinyTextDiffer.min.js +1 -1
- package/dist/v1/TinyTextarea.min.js +1 -1
- package/dist/v1/TinyTimeout.min.js +1 -1
- package/dist/v1/TinyToastNotify.min.js +1 -1
- package/dist/v1/TinyUploadClicker.min.js +1 -2
- package/dist/v1/UltraRandomMsgGen.min.js +1 -1
- package/dist/v1/basics/array.cjs +57 -9
- package/dist/v1/basics/array.d.mts +27 -11
- package/dist/v1/basics/array.mjs +51 -9
- package/dist/v1/basics/clock.cjs +94 -42
- package/dist/v1/basics/clock.d.mts +10 -10
- package/dist/v1/basics/clock.mjs +91 -54
- package/dist/v1/basics/deprecated/html.cjs +246 -0
- package/dist/v1/basics/deprecated/html.d.mts +63 -0
- package/dist/v1/basics/deprecated/html.mjs +190 -0
- 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/html.cjs +149 -130
- package/dist/v1/basics/html.d.mts +26 -61
- package/dist/v1/basics/html.mjs +113 -105
- package/dist/v1/basics/index.cjs +2 -0
- package/dist/v1/basics/index.d.mts +3 -1
- package/dist/v1/basics/index.mjs +3 -3
- package/dist/v1/basics/mediaContent.cjs +51 -9
- package/dist/v1/basics/mediaContent.d.mts +0 -87
- package/dist/v1/basics/mediaContent.mjs +40 -10
- package/dist/v1/basics/objChecker.cjs +7 -5
- package/dist/v1/basics/objChecker.d.mts +3 -2
- package/dist/v1/basics/objChecker.mjs +6 -6
- package/dist/v1/basics/objFilter.cjs +40 -18
- package/dist/v1/basics/objFilter.d.mts +6 -6
- package/dist/v1/basics/objFilter.mjs +32 -17
- package/dist/v1/basics/simpleMath.cjs +81 -25
- package/dist/v1/basics/simpleMath.d.mts +2 -2
- package/dist/v1/basics/simpleMath.mjs +70 -27
- package/dist/v1/basics/text.cjs +76 -31
- package/dist/v1/basics/text.d.mts +69 -7
- package/dist/v1/basics/text.mjs +62 -31
- package/dist/v1/index.cjs +4 -2
- package/dist/v1/index.d.mts +4 -2
- package/dist/v1/index.mjs +4 -4
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +71 -255
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +6 -134
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +69 -228
- package/dist/v1/libs/TinyAfterScrollWatcher.cjs +17 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.d.mts +4 -1
- package/dist/v1/libs/TinyAfterScrollWatcher.mjs +15 -1
- package/dist/v1/libs/TinyAnalogClock.cjs +60 -0
- package/dist/v1/libs/TinyAnalogClock.d.mts +6 -0
- package/dist/v1/libs/TinyAnalogClock.mjs +57 -0
- package/dist/v1/libs/TinyClipboard.cjs +2 -0
- package/dist/v1/libs/TinyClipboard.d.mts +4 -2
- package/dist/v1/libs/TinyClipboard.mjs +2 -0
- package/dist/v1/libs/TinyColorConverter.cjs +1 -0
- package/dist/v1/libs/TinyColorConverter.d.mts +2 -1
- package/dist/v1/libs/TinyColorConverter.mjs +1 -0
- package/dist/v1/libs/TinyDayNightCycle.cjs +67 -42
- package/dist/v1/libs/TinyDayNightCycle.d.mts +2 -7
- package/dist/v1/libs/TinyDayNightCycle.mjs +65 -41
- package/dist/v1/libs/TinyDragDropDetector.cjs +25 -0
- package/dist/v1/libs/TinyDragDropDetector.d.mts +6 -0
- package/dist/v1/libs/TinyDragDropDetector.mjs +22 -0
- package/dist/v1/libs/TinyDragger.cjs +46 -19
- package/dist/v1/libs/TinyDragger.mjs +45 -18
- package/dist/v1/libs/TinyElementObserver.cjs +39 -0
- package/dist/v1/libs/TinyElementObserver.d.mts +6 -0
- package/dist/v1/libs/TinyElementObserver.mjs +36 -0
- package/dist/v1/libs/TinyGamepad.cjs +131 -1
- package/dist/v1/libs/TinyGamepad.mjs +129 -1
- package/dist/v1/libs/TinyHtml.cjs +1 -1
- package/dist/v1/libs/TinyHtml.mjs +2 -2
- package/dist/v1/libs/TinyI18.cjs +61 -0
- package/dist/v1/libs/TinyI18.d.mts +14 -0
- package/dist/v1/libs/TinyI18.mjs +55 -0
- package/dist/v1/libs/TinyIframeEvents.cjs +26 -196
- package/dist/v1/libs/TinyIframeEvents.d.mts +3 -122
- package/dist/v1/libs/TinyIframeEvents.mjs +26 -171
- package/dist/v1/libs/TinyLocalStorage.cjs +53 -205
- package/dist/v1/libs/TinyLocalStorage.d.mts +6 -127
- package/dist/v1/libs/TinyLocalStorage.mjs +50 -178
- package/dist/v1/libs/TinyMediaPlayer.cjs +74 -2
- package/dist/v1/libs/TinyMediaPlayer.d.mts +12 -2
- package/dist/v1/libs/TinyMediaPlayer.mjs +68 -2
- package/dist/v1/libs/TinyNewWinEvents.cjs +39 -197
- package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -119
- package/dist/v1/libs/TinyNewWinEvents.mjs +36 -172
- package/dist/v1/libs/TinyNotifyCenter.cjs +36 -0
- package/dist/v1/libs/TinyNotifyCenter.d.mts +6 -0
- package/dist/v1/libs/TinyNotifyCenter.mjs +32 -0
- package/dist/v1/libs/TinyRadioFm.cjs +40 -3
- package/dist/v1/libs/TinyRadioFm.d.mts +3 -3
- package/dist/v1/libs/TinyRadioFm.mjs +37 -3
- package/dist/v1/libs/TinyRateLimiter.cjs +52 -0
- package/dist/v1/libs/TinyRateLimiter.d.mts +6 -0
- package/dist/v1/libs/TinyRateLimiter.mjs +48 -0
- package/dist/v1/libs/TinySmartScroller.cjs +56 -205
- package/dist/v1/libs/TinySmartScroller.d.mts +19 -152
- package/dist/v1/libs/TinySmartScroller.mjs +55 -181
- package/dist/v1/libs/TinyTextDiffer.cjs +19 -18
- package/dist/v1/libs/TinyTextDiffer.d.mts +1 -0
- package/dist/v1/libs/TinyTextDiffer.mjs +16 -17
- package/dist/v1/libs/TinyTextarea.cjs +19 -0
- package/dist/v1/libs/TinyTextarea.d.mts +6 -0
- package/dist/v1/libs/TinyTextarea.mjs +17 -0
- package/dist/v1/libs/TinyTimeout.cjs +11 -1
- package/dist/v1/libs/TinyTimeout.mjs +9 -1
- package/dist/v1/libs/TinyToastNotify.cjs +35 -0
- package/dist/v1/libs/TinyToastNotify.d.mts +6 -0
- package/dist/v1/libs/TinyToastNotify.mjs +31 -0
- package/dist/v1/libs/TinyUploadClicker.cjs +20 -0
- package/dist/v1/libs/TinyUploadClicker.d.mts +6 -0
- package/dist/v1/libs/TinyUploadClicker.mjs +17 -0
- package/dist/v1/libs/UltraRandomMsgGen.cjs +148 -35
- package/dist/v1/libs/UltraRandomMsgGen.d.mts +17 -3
- package/dist/v1/libs/UltraRandomMsgGen.mjs +133 -34
- package/dist/v1/libs/utils.cjs +21 -0
- package/dist/v1/libs/utils.d.mts +2 -0
- package/dist/v1/libs/utils.mjs +16 -0
- package/docs/v1/Exports.md +0 -1
- package/docs/v1/README.md +1 -1
- package/docs/v1/basics/array.md +2 -2
- package/docs/v1/basics/deprecated/html.md +17 -0
- package/docs/v1/basics/fullScreen.md +1 -1
- package/docs/v1/basics/html.md +12 -26
- package/docs/v1/basics/mediaContent.md +1 -1
- package/docs/v1/basics/objChecker.md +1 -1
- package/docs/v1/basics/objFilter.md +1 -1
- package/docs/v1/basics/text.md +2 -2
- package/docs/v1/fileManager/main.md +1 -1
- package/docs/v1/libs/ColorSafeStringify.md +1 -1
- package/docs/v1/libs/TinyAfterScrollWatcher.md +1 -1
- package/docs/v1/libs/TinyAnalogClock.md +1 -1
- package/docs/v1/libs/TinyArrayComparator.md +1 -1
- package/docs/v1/libs/TinyArrayPaginator.md +1 -1
- package/docs/v1/libs/TinyClassManager/TinyPluginInliner.md +2 -2
- package/docs/v1/libs/TinyClassManager.md +1 -1
- package/docs/v1/libs/TinyClipboard.md +1 -1
- package/docs/v1/libs/TinyCookieConsent.md +1 -1
- package/docs/v1/libs/TinyDomReadyManager.md +1 -1
- package/docs/v1/libs/TinyDragDropDetector.md +1 -1
- package/docs/v1/libs/TinyDragger.md +1 -1
- package/docs/v1/libs/TinyElementObserver.md +1 -1
- package/docs/v1/libs/TinyHtml.md +1 -1
- package/docs/v1/libs/TinyIframeEvents.md +10 -10
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyLocalStorage.md +3 -3
- package/docs/v1/libs/TinyNewWinEvents.md +10 -11
- package/docs/v1/libs/TinyNotifications.md +1 -1
- package/docs/v1/libs/TinyPromiseQueue.md +2 -2
- package/docs/v1/libs/TinyTextDiffer.md +1 -1
- package/docs/v1/libs/TinyTextarea.md +1 -1
- package/package.json +15 -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,3 +1,5 @@
|
|
|
1
|
+
import { createCheckDestroyed } from './utils.mjs';
|
|
2
|
+
const checkDestroy = createCheckDestroyed('TinyToastNotify');
|
|
1
3
|
/**
|
|
2
4
|
* A callback function used to manually close a notification.
|
|
3
5
|
* Passed as a second argument to `onClick` handlers, allowing programmatic dismissal of the toast.
|
|
@@ -44,6 +46,19 @@ class TinyToastNotify {
|
|
|
44
46
|
#fadeOutDuration;
|
|
45
47
|
/** @type {HTMLElement|null} */
|
|
46
48
|
#container;
|
|
49
|
+
/**
|
|
50
|
+
* Tracks whether the instance has been destroyed.
|
|
51
|
+
* @type {boolean}
|
|
52
|
+
*/
|
|
53
|
+
#destroyed = false;
|
|
54
|
+
/**
|
|
55
|
+
* Gets the current destruction status of the instance.
|
|
56
|
+
*
|
|
57
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
58
|
+
*/
|
|
59
|
+
get destroyed() {
|
|
60
|
+
return this.#destroyed;
|
|
61
|
+
}
|
|
47
62
|
/**
|
|
48
63
|
* @param {'top'|'bottom'} y - 'top' or 'bottom'
|
|
49
64
|
* @param {'right'|'left'|'center'} x - 'right', 'left', or 'center'
|
|
@@ -80,6 +95,7 @@ class TinyToastNotify {
|
|
|
80
95
|
* @throws {Error} If the container is not a valid HTMLElement.
|
|
81
96
|
*/
|
|
82
97
|
getContainer() {
|
|
98
|
+
checkDestroy(this.#destroyed);
|
|
83
99
|
if (!(this.#container instanceof HTMLElement))
|
|
84
100
|
throw new Error('Container is not a valid HTMLElement.');
|
|
85
101
|
return this.#container;
|
|
@@ -127,6 +143,7 @@ class TinyToastNotify {
|
|
|
127
143
|
* @returns {'top'|'bottom'} The vertical direction of the notification container.
|
|
128
144
|
*/
|
|
129
145
|
getY() {
|
|
146
|
+
checkDestroy(this.#destroyed);
|
|
130
147
|
return this.#y;
|
|
131
148
|
}
|
|
132
149
|
/**
|
|
@@ -137,6 +154,7 @@ class TinyToastNotify {
|
|
|
137
154
|
* @throws {Error} If the value is invalid.
|
|
138
155
|
*/
|
|
139
156
|
setY(value) {
|
|
157
|
+
checkDestroy(this.#destroyed);
|
|
140
158
|
this.#validateY(value);
|
|
141
159
|
const container = this.getContainer();
|
|
142
160
|
container.classList.remove(this.#y);
|
|
@@ -149,6 +167,7 @@ class TinyToastNotify {
|
|
|
149
167
|
* @returns {'left'|'right'|'center'} The horizontal direction of the notification container.
|
|
150
168
|
*/
|
|
151
169
|
getX() {
|
|
170
|
+
checkDestroy(this.#destroyed);
|
|
152
171
|
return this.#x;
|
|
153
172
|
}
|
|
154
173
|
/**
|
|
@@ -159,6 +178,7 @@ class TinyToastNotify {
|
|
|
159
178
|
* @throws {Error} If the value is invalid.
|
|
160
179
|
*/
|
|
161
180
|
setX(value) {
|
|
181
|
+
checkDestroy(this.#destroyed);
|
|
162
182
|
this.#validateX(value);
|
|
163
183
|
const container = this.getContainer();
|
|
164
184
|
container.classList.remove(this.#x);
|
|
@@ -171,6 +191,7 @@ class TinyToastNotify {
|
|
|
171
191
|
* @returns {number} Base time (in milliseconds) that a notification stays on screen.
|
|
172
192
|
*/
|
|
173
193
|
getBaseDuration() {
|
|
194
|
+
checkDestroy(this.#destroyed);
|
|
174
195
|
return this.#baseDuration;
|
|
175
196
|
}
|
|
176
197
|
/**
|
|
@@ -180,6 +201,7 @@ class TinyToastNotify {
|
|
|
180
201
|
* @throws {Error} If the value is not a valid non-negative finite number.
|
|
181
202
|
*/
|
|
182
203
|
setBaseDuration(value) {
|
|
204
|
+
checkDestroy(this.#destroyed);
|
|
183
205
|
this.#validateTiming(value, 'baseDuration');
|
|
184
206
|
this.#baseDuration = value;
|
|
185
207
|
}
|
|
@@ -189,6 +211,7 @@ class TinyToastNotify {
|
|
|
189
211
|
* @returns {number} Extra time (in milliseconds) per character in the notification.
|
|
190
212
|
*/
|
|
191
213
|
getExtraPerChar() {
|
|
214
|
+
checkDestroy(this.#destroyed);
|
|
192
215
|
return this.#extraPerChar;
|
|
193
216
|
}
|
|
194
217
|
/**
|
|
@@ -198,6 +221,7 @@ class TinyToastNotify {
|
|
|
198
221
|
* @throws {Error} If the value is not a valid non-negative finite number.
|
|
199
222
|
*/
|
|
200
223
|
setExtraPerChar(value) {
|
|
224
|
+
checkDestroy(this.#destroyed);
|
|
201
225
|
this.#validateTiming(value, 'extraPerChar');
|
|
202
226
|
this.#extraPerChar = value;
|
|
203
227
|
}
|
|
@@ -207,6 +231,7 @@ class TinyToastNotify {
|
|
|
207
231
|
* @returns {number} Time (in milliseconds) used for fade-out transition.
|
|
208
232
|
*/
|
|
209
233
|
getFadeOutDuration() {
|
|
234
|
+
checkDestroy(this.#destroyed);
|
|
210
235
|
return this.#fadeOutDuration;
|
|
211
236
|
}
|
|
212
237
|
/**
|
|
@@ -216,6 +241,7 @@ class TinyToastNotify {
|
|
|
216
241
|
* @throws {Error} If the value is not a valid non-negative finite number.
|
|
217
242
|
*/
|
|
218
243
|
setFadeOutDuration(value) {
|
|
244
|
+
checkDestroy(this.#destroyed);
|
|
219
245
|
this.#validateTiming(value, 'fadeOutDuration');
|
|
220
246
|
this.#fadeOutDuration = value;
|
|
221
247
|
}
|
|
@@ -233,6 +259,7 @@ class TinyToastNotify {
|
|
|
233
259
|
* @param {NotifyData} data
|
|
234
260
|
*/
|
|
235
261
|
show(data) {
|
|
262
|
+
checkDestroy(this.#destroyed);
|
|
236
263
|
let message = '';
|
|
237
264
|
let title = '';
|
|
238
265
|
let onClick = null;
|
|
@@ -337,6 +364,8 @@ class TinyToastNotify {
|
|
|
337
364
|
* @returns {void}
|
|
338
365
|
*/
|
|
339
366
|
destroy() {
|
|
367
|
+
if (this.#destroyed)
|
|
368
|
+
return;
|
|
340
369
|
if (!(this.#container instanceof HTMLElement))
|
|
341
370
|
return;
|
|
342
371
|
// Remove all child notifications
|
|
@@ -347,6 +376,8 @@ class TinyToastNotify {
|
|
|
347
376
|
}
|
|
348
377
|
// Optional: Clean internal references (safe practice)
|
|
349
378
|
this.#container = null;
|
|
379
|
+
// Lock the instance
|
|
380
|
+
this.#destroyed = true;
|
|
350
381
|
}
|
|
351
382
|
}
|
|
352
383
|
export default TinyToastNotify;
|
|
@@ -6,6 +6,7 @@ require('fs');
|
|
|
6
6
|
require('path');
|
|
7
7
|
require('fs/promises');
|
|
8
8
|
require('./TinyHtml.cjs');
|
|
9
|
+
require('events');
|
|
9
10
|
require('./TinyLocalStorage.cjs');
|
|
10
11
|
require('./TinyColorValidator.cjs');
|
|
11
12
|
|
|
@@ -63,6 +64,21 @@ require('./TinyColorValidator.cjs');
|
|
|
63
64
|
* uploader.destroy();
|
|
64
65
|
*/
|
|
65
66
|
class TinyUploadClicker {
|
|
67
|
+
/**
|
|
68
|
+
* Tracks whether the instance has been destroyed.
|
|
69
|
+
* @type {boolean}
|
|
70
|
+
*/
|
|
71
|
+
#destroyed = false;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets the current destruction status of the instance.
|
|
75
|
+
*
|
|
76
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
77
|
+
*/
|
|
78
|
+
get destroyed() {
|
|
79
|
+
return this.#destroyed;
|
|
80
|
+
}
|
|
81
|
+
|
|
66
82
|
/** @type {UploaderConfig} */
|
|
67
83
|
#config;
|
|
68
84
|
|
|
@@ -211,6 +227,7 @@ class TinyUploadClicker {
|
|
|
211
227
|
* Cleans up all internal elements and event listeners, removing created inputs and breaking references.
|
|
212
228
|
*/
|
|
213
229
|
destroy() {
|
|
230
|
+
if (this.destroyed) return;
|
|
214
231
|
for (const trigger of this.#triggerElements) {
|
|
215
232
|
if (!(trigger instanceof HTMLElement)) return;
|
|
216
233
|
trigger.removeEventListener('click', this.#boundClick);
|
|
@@ -222,6 +239,9 @@ class TinyUploadClicker {
|
|
|
222
239
|
}
|
|
223
240
|
|
|
224
241
|
this.#triggerElements = [];
|
|
242
|
+
|
|
243
|
+
// Lock the instance
|
|
244
|
+
this.#destroyed = true;
|
|
225
245
|
}
|
|
226
246
|
}
|
|
227
247
|
|
|
@@ -71,6 +71,12 @@ declare class TinyUploadClicker {
|
|
|
71
71
|
* @throws {TypeError} If the config is invalid or required options are missing.
|
|
72
72
|
*/
|
|
73
73
|
constructor(options: UploaderConfig);
|
|
74
|
+
/**
|
|
75
|
+
* Gets the current destruction status of the instance.
|
|
76
|
+
*
|
|
77
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
78
|
+
*/
|
|
79
|
+
get destroyed(): boolean;
|
|
74
80
|
/**
|
|
75
81
|
* Cleans up all internal elements and event listeners, removing created inputs and breaking references.
|
|
76
82
|
*/
|
|
@@ -51,6 +51,19 @@ import { isJsonObject } from '../index.mjs';
|
|
|
51
51
|
* uploader.destroy();
|
|
52
52
|
*/
|
|
53
53
|
class TinyUploadClicker {
|
|
54
|
+
/**
|
|
55
|
+
* Tracks whether the instance has been destroyed.
|
|
56
|
+
* @type {boolean}
|
|
57
|
+
*/
|
|
58
|
+
#destroyed = false;
|
|
59
|
+
/**
|
|
60
|
+
* Gets the current destruction status of the instance.
|
|
61
|
+
*
|
|
62
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
63
|
+
*/
|
|
64
|
+
get destroyed() {
|
|
65
|
+
return this.#destroyed;
|
|
66
|
+
}
|
|
54
67
|
/** @type {UploaderConfig} */
|
|
55
68
|
#config;
|
|
56
69
|
/** @type {Array<HTMLElement|Element|null>} */
|
|
@@ -167,6 +180,8 @@ class TinyUploadClicker {
|
|
|
167
180
|
* Cleans up all internal elements and event listeners, removing created inputs and breaking references.
|
|
168
181
|
*/
|
|
169
182
|
destroy() {
|
|
183
|
+
if (this.destroyed)
|
|
184
|
+
return;
|
|
170
185
|
for (const trigger of this.#triggerElements) {
|
|
171
186
|
if (!(trigger instanceof HTMLElement))
|
|
172
187
|
return;
|
|
@@ -177,6 +192,8 @@ class TinyUploadClicker {
|
|
|
177
192
|
this.#inputs.delete(trigger);
|
|
178
193
|
}
|
|
179
194
|
this.#triggerElements = [];
|
|
195
|
+
// Lock the instance
|
|
196
|
+
this.#destroyed = true;
|
|
180
197
|
}
|
|
181
198
|
}
|
|
182
199
|
export default TinyUploadClicker;
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var utils = require('./utils.cjs');
|
|
4
|
+
|
|
5
|
+
const checkDestroy = utils.createCheckDestroyed('UltraRandomMsgGen');
|
|
6
|
+
|
|
3
7
|
const defaultWords = [
|
|
4
8
|
'lorem',
|
|
5
9
|
'ipsum',
|
|
@@ -53,6 +57,33 @@ const defaultEmojis = [
|
|
|
53
57
|
'🎮',
|
|
54
58
|
'🥓',
|
|
55
59
|
'🍮',
|
|
60
|
+
'🍬',
|
|
61
|
+
'🍓',
|
|
62
|
+
'🍒',
|
|
63
|
+
'🥝',
|
|
64
|
+
'🥑',
|
|
65
|
+
'🍄',
|
|
66
|
+
'🌊',
|
|
67
|
+
'☁️',
|
|
68
|
+
'🌟',
|
|
69
|
+
'🌙',
|
|
70
|
+
'🧚',
|
|
71
|
+
'🐾',
|
|
72
|
+
'🐥',
|
|
73
|
+
'🐼',
|
|
74
|
+
'🐨',
|
|
75
|
+
'🐳',
|
|
76
|
+
'✨',
|
|
77
|
+
'🧁',
|
|
78
|
+
'🌸',
|
|
79
|
+
'🍃',
|
|
80
|
+
'💎',
|
|
81
|
+
'🎐',
|
|
82
|
+
'🎀',
|
|
83
|
+
'🫧',
|
|
84
|
+
'☄️',
|
|
85
|
+
'🛸',
|
|
86
|
+
'🔮',
|
|
56
87
|
];
|
|
57
88
|
|
|
58
89
|
const defaultNouns = [
|
|
@@ -248,6 +279,16 @@ const defaultTemplates = [
|
|
|
248
279
|
'I trusted the {noun} and all I got was a glitter-covered sock.',
|
|
249
280
|
'Plot twist: the {adj} {noun} was inside us all along.',
|
|
250
281
|
|
|
282
|
+
// ✨ Magical/Dreamy (New Category)
|
|
283
|
+
'In the glow of the {adj} moon, the {noun} began to {verb}.',
|
|
284
|
+
'A sprinkle of {adj} dust made the {noun} {verb} through the air.',
|
|
285
|
+
'The {noun} whispered a {adj} secret that made everyone {verb}.',
|
|
286
|
+
'Everything felt {adj} and {adj}, especially when the {noun} {verb}ed.',
|
|
287
|
+
|
|
288
|
+
// 🌀 Chaos/Glitch (New Category)
|
|
289
|
+
'The {noun} is {verb}ing! The {noun} is {verb}ing! AAAAA!',
|
|
290
|
+
'Glitch in the {noun}: the {adj} {noun} just {verb}ed out of existence.',
|
|
291
|
+
|
|
251
292
|
// Mini cute explosions and chaos
|
|
252
293
|
'The {adj} {noun} {verb} and {verb} all over the {adj} {noun}!',
|
|
253
294
|
'Oops! {noun}s {verb}ed into the {adj} {noun} while {verb}ing crazily.',
|
|
@@ -461,8 +502,23 @@ class UltraRandomMsgGen {
|
|
|
461
502
|
this.#defaultTemplates = [...value];
|
|
462
503
|
}
|
|
463
504
|
|
|
505
|
+
/**
|
|
506
|
+
* Tracks whether the instance has been destroyed.
|
|
507
|
+
* @type {boolean}
|
|
508
|
+
*/
|
|
509
|
+
#destroyed = false;
|
|
510
|
+
|
|
511
|
+
/**
|
|
512
|
+
* Gets the current destruction status of the instance.
|
|
513
|
+
*
|
|
514
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
515
|
+
*/
|
|
516
|
+
get destroyed() {
|
|
517
|
+
return this.#destroyed;
|
|
518
|
+
}
|
|
519
|
+
|
|
464
520
|
/** @type {MsgGenConfig} */
|
|
465
|
-
config = {
|
|
521
|
+
#config = {
|
|
466
522
|
minLength: 10,
|
|
467
523
|
maxLength: 300,
|
|
468
524
|
readable: true,
|
|
@@ -488,6 +544,18 @@ class UltraRandomMsgGen {
|
|
|
488
544
|
},
|
|
489
545
|
};
|
|
490
546
|
|
|
547
|
+
get config() {
|
|
548
|
+
checkDestroy(this.#destroyed);
|
|
549
|
+
return structuredClone(this.#config);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
#symbols = '!@#$%^&*()-_=+[]{}|;:,.<>?/\\~'.split('');
|
|
553
|
+
|
|
554
|
+
get symbols() {
|
|
555
|
+
checkDestroy(this.#destroyed);
|
|
556
|
+
return structuredClone(this.#symbols);
|
|
557
|
+
}
|
|
558
|
+
|
|
491
559
|
/**
|
|
492
560
|
* Creates an instance of UltraRandomMsgGen.
|
|
493
561
|
*
|
|
@@ -518,8 +586,6 @@ class UltraRandomMsgGen {
|
|
|
518
586
|
* @param {number} [config.line.emojiChance=0.3] - Probability (0–1) of placing emoji per line.
|
|
519
587
|
*/
|
|
520
588
|
constructor(config = {}) {
|
|
521
|
-
this.symbols = '!@#$%^&*()-_=+[]{}|;:,.<>?/\\~'.split('');
|
|
522
|
-
|
|
523
589
|
const {
|
|
524
590
|
minLength,
|
|
525
591
|
maxLength,
|
|
@@ -648,14 +714,14 @@ class UltraRandomMsgGen {
|
|
|
648
714
|
}
|
|
649
715
|
}
|
|
650
716
|
|
|
651
|
-
this
|
|
652
|
-
this
|
|
717
|
+
this.#config.emojiSet = [...UltraRandomMsgGen.#defaultEmojis];
|
|
718
|
+
this.#config.wordSet = [...UltraRandomMsgGen.#defaultWords];
|
|
653
719
|
|
|
654
|
-
this
|
|
655
|
-
this
|
|
656
|
-
this
|
|
657
|
-
this
|
|
658
|
-
Object.assign(this
|
|
720
|
+
this.#config.grammar.templates = [...UltraRandomMsgGen.#defaultTemplates];
|
|
721
|
+
this.#config.grammar.nouns = [...UltraRandomMsgGen.#defaultNouns];
|
|
722
|
+
this.#config.grammar.verbs = [...UltraRandomMsgGen.#defaultVerbs];
|
|
723
|
+
this.#config.grammar.adjectives = [...UltraRandomMsgGen.#defaultAdjectives];
|
|
724
|
+
Object.assign(this.#config, config);
|
|
659
725
|
}
|
|
660
726
|
|
|
661
727
|
/**
|
|
@@ -664,7 +730,8 @@ class UltraRandomMsgGen {
|
|
|
664
730
|
* @returns {this} - The instance for chaining.
|
|
665
731
|
*/
|
|
666
732
|
configure(newConfig = {}) {
|
|
667
|
-
|
|
733
|
+
checkDestroy(this.#destroyed);
|
|
734
|
+
Object.assign(this.#config, newConfig);
|
|
668
735
|
return this;
|
|
669
736
|
}
|
|
670
737
|
|
|
@@ -674,7 +741,8 @@ class UltraRandomMsgGen {
|
|
|
674
741
|
* @returns {this} - The instance for chaining.
|
|
675
742
|
*/
|
|
676
743
|
setGrammarTemplates(...templates) {
|
|
677
|
-
this
|
|
744
|
+
checkDestroy(this.#destroyed);
|
|
745
|
+
this.#config.grammar.templates = templates.flat();
|
|
678
746
|
return this;
|
|
679
747
|
}
|
|
680
748
|
|
|
@@ -684,7 +752,8 @@ class UltraRandomMsgGen {
|
|
|
684
752
|
* @returns {this} - The instance for chaining.
|
|
685
753
|
*/
|
|
686
754
|
addGrammarTemplates(...templates) {
|
|
687
|
-
this
|
|
755
|
+
checkDestroy(this.#destroyed);
|
|
756
|
+
this.#config.grammar.templates.push(...templates.flat());
|
|
688
757
|
return this;
|
|
689
758
|
}
|
|
690
759
|
|
|
@@ -694,7 +763,8 @@ class UltraRandomMsgGen {
|
|
|
694
763
|
* @returns {this} - The instance for chaining.
|
|
695
764
|
*/
|
|
696
765
|
setGrammarNouns(...nouns) {
|
|
697
|
-
this
|
|
766
|
+
checkDestroy(this.#destroyed);
|
|
767
|
+
this.#config.grammar.nouns = nouns.flat();
|
|
698
768
|
return this;
|
|
699
769
|
}
|
|
700
770
|
|
|
@@ -704,7 +774,8 @@ class UltraRandomMsgGen {
|
|
|
704
774
|
* @returns {this} - The instance for chaining.
|
|
705
775
|
*/
|
|
706
776
|
addGrammarNouns(...nouns) {
|
|
707
|
-
this
|
|
777
|
+
checkDestroy(this.#destroyed);
|
|
778
|
+
this.#config.grammar.nouns.push(...nouns.flat());
|
|
708
779
|
return this;
|
|
709
780
|
}
|
|
710
781
|
|
|
@@ -714,7 +785,8 @@ class UltraRandomMsgGen {
|
|
|
714
785
|
* @returns {this} - The instance for chaining.
|
|
715
786
|
*/
|
|
716
787
|
setGrammarVerbs(...verbs) {
|
|
717
|
-
this
|
|
788
|
+
checkDestroy(this.#destroyed);
|
|
789
|
+
this.#config.grammar.verbs = verbs.flat();
|
|
718
790
|
return this;
|
|
719
791
|
}
|
|
720
792
|
|
|
@@ -724,7 +796,8 @@ class UltraRandomMsgGen {
|
|
|
724
796
|
* @returns {this} - The instance for chaining.
|
|
725
797
|
*/
|
|
726
798
|
addGrammarVerbs(...verbs) {
|
|
727
|
-
this
|
|
799
|
+
checkDestroy(this.#destroyed);
|
|
800
|
+
this.#config.grammar.verbs.push(...verbs.flat());
|
|
728
801
|
return this;
|
|
729
802
|
}
|
|
730
803
|
|
|
@@ -734,7 +807,8 @@ class UltraRandomMsgGen {
|
|
|
734
807
|
* @returns {this} - The instance for chaining.
|
|
735
808
|
*/
|
|
736
809
|
setGrammarAdjectives(...adjectives) {
|
|
737
|
-
this
|
|
810
|
+
checkDestroy(this.#destroyed);
|
|
811
|
+
this.#config.grammar.adjectives = adjectives.flat();
|
|
738
812
|
return this;
|
|
739
813
|
}
|
|
740
814
|
|
|
@@ -744,7 +818,8 @@ class UltraRandomMsgGen {
|
|
|
744
818
|
* @returns {this} - The instance for chaining.
|
|
745
819
|
*/
|
|
746
820
|
addGrammarAdjectives(...adjectives) {
|
|
747
|
-
this
|
|
821
|
+
checkDestroy(this.#destroyed);
|
|
822
|
+
this.#config.grammar.adjectives.push(...adjectives.flat());
|
|
748
823
|
return this;
|
|
749
824
|
}
|
|
750
825
|
|
|
@@ -754,8 +829,11 @@ class UltraRandomMsgGen {
|
|
|
754
829
|
* @returns {this} - The instance for chaining.
|
|
755
830
|
*/
|
|
756
831
|
removeGrammarTemplates(...templates) {
|
|
832
|
+
checkDestroy(this.#destroyed);
|
|
757
833
|
const removeSet = new Set(templates.flat());
|
|
758
|
-
this
|
|
834
|
+
this.#config.grammar.templates = this.#config.grammar.templates.filter(
|
|
835
|
+
(t) => !removeSet.has(t),
|
|
836
|
+
);
|
|
759
837
|
return this;
|
|
760
838
|
}
|
|
761
839
|
|
|
@@ -765,8 +843,9 @@ class UltraRandomMsgGen {
|
|
|
765
843
|
* @returns {this} - The instance for chaining.
|
|
766
844
|
*/
|
|
767
845
|
removeGrammarNouns(...nouns) {
|
|
846
|
+
checkDestroy(this.#destroyed);
|
|
768
847
|
const removeSet = new Set(nouns.flat());
|
|
769
|
-
this
|
|
848
|
+
this.#config.grammar.nouns = this.#config.grammar.nouns.filter((n) => !removeSet.has(n));
|
|
770
849
|
return this;
|
|
771
850
|
}
|
|
772
851
|
|
|
@@ -776,8 +855,9 @@ class UltraRandomMsgGen {
|
|
|
776
855
|
* @returns {this} - The instance for chaining.
|
|
777
856
|
*/
|
|
778
857
|
removeGrammarVerbs(...verbs) {
|
|
858
|
+
checkDestroy(this.#destroyed);
|
|
779
859
|
const removeSet = new Set(verbs.flat());
|
|
780
|
-
this
|
|
860
|
+
this.#config.grammar.verbs = this.#config.grammar.verbs.filter((v) => !removeSet.has(v));
|
|
781
861
|
return this;
|
|
782
862
|
}
|
|
783
863
|
|
|
@@ -787,8 +867,9 @@ class UltraRandomMsgGen {
|
|
|
787
867
|
* @returns {this} - The instance for chaining.
|
|
788
868
|
*/
|
|
789
869
|
removeGrammarAdjectives(...adjectives) {
|
|
870
|
+
checkDestroy(this.#destroyed);
|
|
790
871
|
const removeSet = new Set(adjectives.flat());
|
|
791
|
-
this
|
|
872
|
+
this.#config.grammar.adjectives = this.#config.grammar.adjectives.filter(
|
|
792
873
|
(a) => !removeSet.has(a),
|
|
793
874
|
);
|
|
794
875
|
return this;
|
|
@@ -800,7 +881,8 @@ class UltraRandomMsgGen {
|
|
|
800
881
|
* @returns {this} - The instance for chaining.
|
|
801
882
|
*/
|
|
802
883
|
setWords(...words) {
|
|
803
|
-
this
|
|
884
|
+
checkDestroy(this.#destroyed);
|
|
885
|
+
this.#config.wordSet = words.flat();
|
|
804
886
|
return this;
|
|
805
887
|
}
|
|
806
888
|
|
|
@@ -810,7 +892,8 @@ class UltraRandomMsgGen {
|
|
|
810
892
|
* @returns {this} - The instance for chaining.
|
|
811
893
|
*/
|
|
812
894
|
addWords(...words) {
|
|
813
|
-
this
|
|
895
|
+
checkDestroy(this.#destroyed);
|
|
896
|
+
this.#config.wordSet.push(...words.flat());
|
|
814
897
|
return this;
|
|
815
898
|
}
|
|
816
899
|
|
|
@@ -820,8 +903,9 @@ class UltraRandomMsgGen {
|
|
|
820
903
|
* @returns {this} - The instance for chaining.
|
|
821
904
|
*/
|
|
822
905
|
removeWords(...words) {
|
|
906
|
+
checkDestroy(this.#destroyed);
|
|
823
907
|
const removeSet = new Set(words.flat());
|
|
824
|
-
this
|
|
908
|
+
this.#config.wordSet = this.#config.wordSet.filter((word) => !removeSet.has(word));
|
|
825
909
|
return this;
|
|
826
910
|
}
|
|
827
911
|
|
|
@@ -831,7 +915,8 @@ class UltraRandomMsgGen {
|
|
|
831
915
|
* @returns {this} - The instance for chaining.
|
|
832
916
|
*/
|
|
833
917
|
setEmojis(...emojis) {
|
|
834
|
-
this
|
|
918
|
+
checkDestroy(this.#destroyed);
|
|
919
|
+
this.#config.emojiSet = emojis.flat();
|
|
835
920
|
return this;
|
|
836
921
|
}
|
|
837
922
|
|
|
@@ -841,7 +926,8 @@ class UltraRandomMsgGen {
|
|
|
841
926
|
* @returns {this} - The instance for chaining.
|
|
842
927
|
*/
|
|
843
928
|
addEmojis(...emojis) {
|
|
844
|
-
this
|
|
929
|
+
checkDestroy(this.#destroyed);
|
|
930
|
+
this.#config.emojiSet.push(...emojis.flat());
|
|
845
931
|
return this;
|
|
846
932
|
}
|
|
847
933
|
|
|
@@ -851,8 +937,9 @@ class UltraRandomMsgGen {
|
|
|
851
937
|
* @returns {this} - The instance for chaining.
|
|
852
938
|
*/
|
|
853
939
|
removeEmojis(...emojis) {
|
|
940
|
+
checkDestroy(this.#destroyed);
|
|
854
941
|
const removeSet = new Set(emojis.flat());
|
|
855
|
-
this
|
|
942
|
+
this.#config.emojiSet = this.#config.emojiSet.filter((emoji) => !removeSet.has(emoji));
|
|
856
943
|
return this;
|
|
857
944
|
}
|
|
858
945
|
|
|
@@ -881,7 +968,7 @@ class UltraRandomMsgGen {
|
|
|
881
968
|
readable,
|
|
882
969
|
mode,
|
|
883
970
|
emojiPlacement,
|
|
884
|
-
} = this
|
|
971
|
+
} = this.#config;
|
|
885
972
|
|
|
886
973
|
if (mode === 'natural') {
|
|
887
974
|
return this._generateNaturalSentence();
|
|
@@ -902,7 +989,7 @@ class UltraRandomMsgGen {
|
|
|
902
989
|
}
|
|
903
990
|
|
|
904
991
|
if (includeSymbols) {
|
|
905
|
-
pools.push(this._getRandomItem(this
|
|
992
|
+
pools.push(this._getRandomItem(this.#symbols));
|
|
906
993
|
}
|
|
907
994
|
|
|
908
995
|
if (emojiPlacement === 'inline' && useEmojis && emojiSet.length) {
|
|
@@ -918,7 +1005,7 @@ class UltraRandomMsgGen {
|
|
|
918
1005
|
* @returns {string} - A generated sentence.
|
|
919
1006
|
*/
|
|
920
1007
|
_generateNaturalSentence() {
|
|
921
|
-
const { templates, nouns, verbs, adjectives } = this
|
|
1008
|
+
const { templates, nouns, verbs, adjectives } = this.#config.grammar;
|
|
922
1009
|
|
|
923
1010
|
let template = this._getRandomItem(templates);
|
|
924
1011
|
|
|
@@ -937,7 +1024,7 @@ class UltraRandomMsgGen {
|
|
|
937
1024
|
*/
|
|
938
1025
|
_generateLine(targetLength, seenWords) {
|
|
939
1026
|
const { allowWeirdSpacing, repeatWords, readable, emojiSet, useEmojis, emojiPlacement, line } =
|
|
940
|
-
this
|
|
1027
|
+
this.#config;
|
|
941
1028
|
|
|
942
1029
|
const parts = [];
|
|
943
1030
|
seenWords ??= new Set();
|
|
@@ -978,7 +1065,7 @@ class UltraRandomMsgGen {
|
|
|
978
1065
|
* @returns {string[]} - Array of lines that form the paragraph.
|
|
979
1066
|
*/
|
|
980
1067
|
_generateParagraphLines(totalLength) {
|
|
981
|
-
const { line } = this
|
|
1068
|
+
const { line } = this.#config;
|
|
982
1069
|
const lines = [];
|
|
983
1070
|
const seenWords = new Set();
|
|
984
1071
|
let currentTotal = 0;
|
|
@@ -1003,7 +1090,8 @@ class UltraRandomMsgGen {
|
|
|
1003
1090
|
* @returns {string} - A full generated message.
|
|
1004
1091
|
*/
|
|
1005
1092
|
generate() {
|
|
1006
|
-
|
|
1093
|
+
checkDestroy(this.#destroyed);
|
|
1094
|
+
const { minLength, maxLength, paragraphs } = this.#config;
|
|
1007
1095
|
|
|
1008
1096
|
const totalLength = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength;
|
|
1009
1097
|
|
|
@@ -1023,6 +1111,31 @@ class UltraRandomMsgGen {
|
|
|
1023
1111
|
|
|
1024
1112
|
return this._generateParagraphLines(totalLength).join('\n');
|
|
1025
1113
|
}
|
|
1114
|
+
|
|
1115
|
+
/**
|
|
1116
|
+
* Safely destroys the instance by clearing references to aid garbage collection.
|
|
1117
|
+
* Once destroyed, the instance cannot be used to generate new messages.
|
|
1118
|
+
*
|
|
1119
|
+
* @throws {Error} If the instance has already been destroyed.
|
|
1120
|
+
* @returns {void}
|
|
1121
|
+
*/
|
|
1122
|
+
destroy() {
|
|
1123
|
+
if (this.destroyed) return;
|
|
1124
|
+
|
|
1125
|
+
// Clear primary memory references
|
|
1126
|
+
this.#symbols = [];
|
|
1127
|
+
|
|
1128
|
+
this.#config.emojiSet = [];
|
|
1129
|
+
this.#config.wordSet = [];
|
|
1130
|
+
|
|
1131
|
+
this.#config.grammar.templates = [];
|
|
1132
|
+
this.#config.grammar.nouns = [];
|
|
1133
|
+
this.#config.grammar.verbs = [];
|
|
1134
|
+
this.#config.grammar.adjectives = [];
|
|
1135
|
+
|
|
1136
|
+
// Lock the instance
|
|
1137
|
+
this.#destroyed = true;
|
|
1138
|
+
}
|
|
1026
1139
|
}
|
|
1027
1140
|
|
|
1028
1141
|
module.exports = UltraRandomMsgGen;
|
|
@@ -259,9 +259,14 @@ declare class UltraRandomMsgGen {
|
|
|
259
259
|
emojiChance?: number | undefined;
|
|
260
260
|
} | undefined;
|
|
261
261
|
});
|
|
262
|
-
/**
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
/**
|
|
263
|
+
* Gets the current destruction status of the instance.
|
|
264
|
+
*
|
|
265
|
+
* @returns {boolean} True if the instance is destroyed, false otherwise.
|
|
266
|
+
*/
|
|
267
|
+
get destroyed(): boolean;
|
|
268
|
+
get config(): MsgGenConfig;
|
|
269
|
+
get symbols(): string[];
|
|
265
270
|
/**
|
|
266
271
|
* Merges new configuration values into the current instance.
|
|
267
272
|
* @param {Object} newConfig - Object with one or more configuration overrides.
|
|
@@ -416,5 +421,14 @@ declare class UltraRandomMsgGen {
|
|
|
416
421
|
* @returns {string} - A full generated message.
|
|
417
422
|
*/
|
|
418
423
|
generate(): string;
|
|
424
|
+
/**
|
|
425
|
+
* Safely destroys the instance by clearing references to aid garbage collection.
|
|
426
|
+
* Once destroyed, the instance cannot be used to generate new messages.
|
|
427
|
+
*
|
|
428
|
+
* @throws {Error} If the instance has already been destroyed.
|
|
429
|
+
* @returns {void}
|
|
430
|
+
*/
|
|
431
|
+
destroy(): void;
|
|
432
|
+
#private;
|
|
419
433
|
}
|
|
420
434
|
//# sourceMappingURL=UltraRandomMsgGen.d.mts.map
|