tiny-essentials 1.28.0 → 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/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 -1
- 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 -1
- 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 -1
- 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/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 -7
- package/dist/v1/basics/objFilter.d.mts +6 -6
- package/dist/v1/basics/objFilter.mjs +32 -7
- 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 -0
- package/dist/v1/index.d.mts +4 -1
- package/dist/v1/index.mjs +4 -3
- package/dist/v1/libs/TinyAdvancedRaffle.cjs +64 -50
- package/dist/v1/libs/TinyAdvancedRaffle.d.mts +4 -13
- package/dist/v1/libs/TinyAdvancedRaffle.mjs +62 -49
- 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 +18 -1
- package/dist/v1/libs/TinyIframeEvents.mjs +18 -1
- package/dist/v1/libs/TinyLocalStorage.cjs +48 -0
- package/dist/v1/libs/TinyLocalStorage.d.mts +6 -0
- package/dist/v1/libs/TinyLocalStorage.mjs +45 -0
- package/dist/v1/libs/TinyMediaPlayer.cjs +72 -0
- package/dist/v1/libs/TinyMediaPlayer.d.mts +10 -0
- package/dist/v1/libs/TinyMediaPlayer.mjs +66 -0
- package/dist/v1/libs/TinyNewWinEvents.cjs +29 -0
- package/dist/v1/libs/TinyNewWinEvents.d.mts +6 -0
- package/dist/v1/libs/TinyNewWinEvents.mjs +26 -0
- 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 +38 -0
- package/dist/v1/libs/TinyRadioFm.d.mts +1 -0
- package/dist/v1/libs/TinyRadioFm.mjs +35 -0
- 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 +52 -3
- package/dist/v1/libs/TinySmartScroller.d.mts +17 -15
- package/dist/v1/libs/TinySmartScroller.mjs +51 -5
- 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 +19 -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/README.md +1 -0
- 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/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 +2 -2
- package/docs/v1/libs/TinyLevelUp.md +1 -1
- package/docs/v1/libs/TinyLoadingScreen.md +1 -1
- package/docs/v1/libs/TinyNewWinEvents.md +2 -2
- 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 +10 -1
|
@@ -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
|