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
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
* @param {string} str - The input string to perform replacements on.
|
|
5
5
|
* @param {RegExp} regex - The regular expression to match substrings for replacement.
|
|
6
6
|
* @param {Function} asyncFn - An asynchronous function that returns a replacement for each match.
|
|
7
|
-
*
|
|
7
|
+
* It receives the same arguments as a standard `replace` callback.
|
|
8
8
|
* @returns {Promise<string>} The resulting string with all async replacements applied.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* await asyncReplace("Hello @user1 and @user2!", /@\w+/g, async (mention) => {
|
|
12
|
-
*
|
|
12
|
+
* return await getUserNameFromMention(mention);
|
|
13
13
|
* });
|
|
14
14
|
*/
|
|
15
15
|
export function asyncReplace(str: string, regex: RegExp, asyncFn: Function): Promise<string>;
|
|
@@ -79,7 +79,7 @@ export function addAiMarkerShortcut({ key, className }?: {
|
|
|
79
79
|
* @param {string} text - The input text to be trimmed.
|
|
80
80
|
* @param {number} limit - The maximum number of characters allowed.
|
|
81
81
|
* @param {number} [safeCutZone=0.6] - A decimal between 0 and 1 representing the minimal acceptable position
|
|
82
|
-
*
|
|
82
|
+
* (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
|
|
83
83
|
* @returns {string} - The trimmed text, possibly ending with an ellipsis ("...").
|
|
84
84
|
* @throws {TypeError} - Throws if `text` is not a string.
|
|
85
85
|
* @throws {TypeError} - Throws if `limit` is not a positive integer.
|
|
@@ -87,9 +87,71 @@ export function addAiMarkerShortcut({ key, className }?: {
|
|
|
87
87
|
*/
|
|
88
88
|
export function safeTextTrim(text: string, limit: number, safeCutZone?: number): string;
|
|
89
89
|
/**
|
|
90
|
-
*
|
|
91
|
-
* @
|
|
92
|
-
* @
|
|
90
|
+
* @template {Record<string, any>} CompareValue
|
|
91
|
+
* @typedef {Object} DiffStringsModifiedValue
|
|
92
|
+
* @property {CompareValue[keyof CompareValue]} old - The value before the modification.
|
|
93
|
+
* @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
|
|
93
94
|
*/
|
|
94
|
-
|
|
95
|
+
/**
|
|
96
|
+
* @template {Record<string, any>} CompareValue
|
|
97
|
+
* @typedef {Object} DiffStringsData
|
|
98
|
+
* @property {Partial<CompareValue>} added - Properties that only exist in the new object.
|
|
99
|
+
* @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
|
|
100
|
+
* @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
|
|
101
|
+
*/
|
|
102
|
+
/**
|
|
103
|
+
* Diff two objects.
|
|
104
|
+
* @template {Record<string, any>} CompareValue1
|
|
105
|
+
* @template {Record<string, any>} CompareValue2
|
|
106
|
+
* @param {CompareValue1} oldStrings - The original/old object for comparison.
|
|
107
|
+
* @param {CompareValue2} newStrings - The new object for comparison.
|
|
108
|
+
* @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
|
|
109
|
+
*/
|
|
110
|
+
export function diffObjList<CompareValue1_1 extends Record<string, any>, CompareValue2_1 extends Record<string, any>>(oldStrings: CompareValue1_1, newStrings: CompareValue2_1): DiffStringsData<CompareValue1_1 & CompareValue2_1>;
|
|
111
|
+
/**
|
|
112
|
+
* @template {Record<string, any>} CompareValue
|
|
113
|
+
* @typedef {Object} DiffStringsModifiedValue
|
|
114
|
+
* @property {CompareValue[keyof CompareValue]} old - The value before the modification.
|
|
115
|
+
* @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
|
|
116
|
+
*/
|
|
117
|
+
/**
|
|
118
|
+
* @template {Record<string, any>} CompareValue
|
|
119
|
+
* @typedef {Object} DiffStringsData
|
|
120
|
+
* @property {Partial<CompareValue>} added - Properties that only exist in the new object.
|
|
121
|
+
* @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
|
|
122
|
+
* @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
|
|
123
|
+
*/
|
|
124
|
+
/**
|
|
125
|
+
* Diff two objects.
|
|
126
|
+
* @template {Record<string, any>} CompareValue1
|
|
127
|
+
* @template {Record<string, any>} CompareValue2
|
|
128
|
+
* @param {CompareValue1} oldStrings - The original/old object for comparison.
|
|
129
|
+
* @param {CompareValue2} newStrings - The new object for comparison.
|
|
130
|
+
* @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
|
|
131
|
+
*/
|
|
132
|
+
export function diffStrings<CompareValue1_1 extends Record<string, any>, CompareValue2_1 extends Record<string, any>>(oldStrings: CompareValue1_1, newStrings: CompareValue2_1): DiffStringsData<CompareValue1_1 & CompareValue2_1>;
|
|
133
|
+
export type DiffStringsModifiedValue<CompareValue extends Record<string, any>> = {
|
|
134
|
+
/**
|
|
135
|
+
* - The value before the modification.
|
|
136
|
+
*/
|
|
137
|
+
old: CompareValue[keyof CompareValue];
|
|
138
|
+
/**
|
|
139
|
+
* - The new value after the modification.
|
|
140
|
+
*/
|
|
141
|
+
new: CompareValue[keyof CompareValue];
|
|
142
|
+
};
|
|
143
|
+
export type DiffStringsData<CompareValue extends Record<string, any>> = {
|
|
144
|
+
/**
|
|
145
|
+
* - Properties that only exist in the new object.
|
|
146
|
+
*/
|
|
147
|
+
added: Partial<CompareValue>;
|
|
148
|
+
/**
|
|
149
|
+
* - Properties that only existed in the old object.
|
|
150
|
+
*/
|
|
151
|
+
removed: Partial<CompareValue>;
|
|
152
|
+
/**
|
|
153
|
+
* - Properties that changed, containing their old and new values.
|
|
154
|
+
*/
|
|
155
|
+
modified: Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>;
|
|
156
|
+
};
|
|
95
157
|
//# sourceMappingURL=text.d.mts.map
|
package/dist/v1/basics/text.mjs
CHANGED
|
@@ -4,15 +4,24 @@
|
|
|
4
4
|
* @param {string} str - The input string to perform replacements on.
|
|
5
5
|
* @param {RegExp} regex - The regular expression to match substrings for replacement.
|
|
6
6
|
* @param {Function} asyncFn - An asynchronous function that returns a replacement for each match.
|
|
7
|
-
*
|
|
7
|
+
* It receives the same arguments as a standard `replace` callback.
|
|
8
8
|
* @returns {Promise<string>} The resulting string with all async replacements applied.
|
|
9
9
|
*
|
|
10
10
|
* @example
|
|
11
11
|
* await asyncReplace("Hello @user1 and @user2!", /@\w+/g, async (mention) => {
|
|
12
|
-
*
|
|
12
|
+
* return await getUserNameFromMention(mention);
|
|
13
13
|
* });
|
|
14
14
|
*/
|
|
15
15
|
export async function asyncReplace(str, regex, asyncFn) {
|
|
16
|
+
if (typeof str !== 'string') {
|
|
17
|
+
throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
|
|
18
|
+
}
|
|
19
|
+
if (!(regex instanceof RegExp)) {
|
|
20
|
+
throw new TypeError(`Expected a RegExp for 'regex', but received ${typeof regex}`);
|
|
21
|
+
}
|
|
22
|
+
if (typeof asyncFn !== 'function') {
|
|
23
|
+
throw new TypeError(`Expected a function for 'asyncFn', but received ${typeof asyncFn}`);
|
|
24
|
+
}
|
|
16
25
|
/**
|
|
17
26
|
* @type {any[]}
|
|
18
27
|
*/
|
|
@@ -36,6 +45,9 @@ export async function asyncReplace(str, regex, asyncFn) {
|
|
|
36
45
|
* @returns {string} The string converted to title case.
|
|
37
46
|
*/
|
|
38
47
|
export function toTitleCase(str) {
|
|
48
|
+
if (typeof str !== 'string') {
|
|
49
|
+
throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
|
|
50
|
+
}
|
|
39
51
|
return str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
|
|
40
52
|
}
|
|
41
53
|
/**
|
|
@@ -48,6 +60,9 @@ export function toTitleCase(str) {
|
|
|
48
60
|
* @returns {string} The string converted to title case with the first letter in lowercase.
|
|
49
61
|
*/
|
|
50
62
|
export function toTitleCaseLowerFirst(str) {
|
|
63
|
+
if (typeof str !== 'string') {
|
|
64
|
+
throw new TypeError(`Expected a string for 'str', but received ${typeof str}`);
|
|
65
|
+
}
|
|
51
66
|
const titleCased = str.replace(/\w\S*/g, (txt) => txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase());
|
|
52
67
|
return titleCased.charAt(0).toLowerCase() + titleCased.slice(1);
|
|
53
68
|
}
|
|
@@ -87,6 +102,12 @@ export function toTitleCaseLowerFirst(str) {
|
|
|
87
102
|
export function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai' } = {}) {
|
|
88
103
|
if (typeof HTMLElement === 'undefined')
|
|
89
104
|
throw new Error('[AiMarkerShortcut] Environment does not support the DOM. This function must be run in a browser.');
|
|
105
|
+
if (typeof key !== 'string') {
|
|
106
|
+
throw new TypeError(`Expected a string for 'config.key', but received ${typeof key}`);
|
|
107
|
+
}
|
|
108
|
+
if (typeof className !== 'string') {
|
|
109
|
+
throw new TypeError(`Expected a string for 'config.className', but received ${typeof className}`);
|
|
110
|
+
}
|
|
90
111
|
/** @type {(this: Document, ev: KeyboardEvent) => any} */
|
|
91
112
|
const keydownEvent = function (event) {
|
|
92
113
|
if (event.ctrlKey && event.altKey && event.key.toLowerCase() === key) {
|
|
@@ -110,7 +131,7 @@ export function addAiMarkerShortcut({ key = 'a', className = 'detect-made-by-ai'
|
|
|
110
131
|
* @param {string} text - The input text to be trimmed.
|
|
111
132
|
* @param {number} limit - The maximum number of characters allowed.
|
|
112
133
|
* @param {number} [safeCutZone=0.6] - A decimal between 0 and 1 representing the minimal acceptable position
|
|
113
|
-
*
|
|
134
|
+
* (as a fraction of `limit`) to cut at a space. Defaults to 0.6.
|
|
114
135
|
* @returns {string} - The trimmed text, possibly ending with an ellipsis ("...").
|
|
115
136
|
* @throws {TypeError} - Throws if `text` is not a string.
|
|
116
137
|
* @throws {TypeError} - Throws if `limit` is not a positive integer.
|
|
@@ -139,17 +160,40 @@ export function safeTextTrim(text, limit, safeCutZone = 0.6) {
|
|
|
139
160
|
return result;
|
|
140
161
|
}
|
|
141
162
|
/**
|
|
142
|
-
*
|
|
143
|
-
* @
|
|
144
|
-
* @
|
|
163
|
+
* @template {Record<string, any>} CompareValue
|
|
164
|
+
* @typedef {Object} DiffStringsModifiedValue
|
|
165
|
+
* @property {CompareValue[keyof CompareValue]} old - The value before the modification.
|
|
166
|
+
* @property {CompareValue[keyof CompareValue]} new - The new value after the modification.
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* @template {Record<string, any>} CompareValue
|
|
170
|
+
* @typedef {Object} DiffStringsData
|
|
171
|
+
* @property {Partial<CompareValue>} added - Properties that only exist in the new object.
|
|
172
|
+
* @property {Partial<CompareValue>} removed - Properties that only existed in the old object.
|
|
173
|
+
* @property {Partial<Record<keyof CompareValue, DiffStringsModifiedValue<CompareValue>>>} modified - Properties that changed, containing their old and new values.
|
|
145
174
|
*/
|
|
146
|
-
|
|
147
|
-
|
|
175
|
+
/**
|
|
176
|
+
* Diff two objects.
|
|
177
|
+
* @template {Record<string, any>} CompareValue1
|
|
178
|
+
* @template {Record<string, any>} CompareValue2
|
|
179
|
+
* @param {CompareValue1} oldStrings - The original/old object for comparison.
|
|
180
|
+
* @param {CompareValue2} newStrings - The new object for comparison.
|
|
181
|
+
* @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
|
|
182
|
+
*/
|
|
183
|
+
export function diffObjList(oldStrings, newStrings) {
|
|
184
|
+
if (typeof oldStrings !== 'object' || oldStrings === null || Array.isArray(oldStrings)) {
|
|
185
|
+
throw new TypeError(`Expected an object for 'oldStrings', but received ${oldStrings === null ? 'null' : typeof oldStrings}`);
|
|
186
|
+
}
|
|
187
|
+
if (typeof newStrings !== 'object' || newStrings === null || Array.isArray(newStrings)) {
|
|
188
|
+
throw new TypeError(`Expected an object for 'newStrings', but received ${newStrings === null ? 'null' : typeof newStrings}`);
|
|
189
|
+
}
|
|
190
|
+
/** @type {DiffStringsData<CompareValue1 & CompareValue2>} */
|
|
148
191
|
const changes = { added: {}, removed: {}, modified: {} };
|
|
149
192
|
// detect removed and modified
|
|
150
193
|
for (const prop in oldStrings) {
|
|
151
194
|
if (!(prop in newStrings)) {
|
|
152
195
|
changes.removed[prop] = oldStrings[prop];
|
|
196
|
+
// @ts-ignore
|
|
153
197
|
}
|
|
154
198
|
else if (oldStrings[prop] !== newStrings[prop]) {
|
|
155
199
|
changes.modified[prop] = { old: oldStrings[prop], new: newStrings[prop] };
|
|
@@ -163,26 +207,13 @@ export function diffStrings(oldStrings, newStrings) {
|
|
|
163
207
|
}
|
|
164
208
|
return changes;
|
|
165
209
|
}
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
document.addEventListener("keydown", handleKeyDown);
|
|
179
|
-
return () => {
|
|
180
|
-
document.removeEventListener("keydown", handleKeyDown);
|
|
181
|
-
};
|
|
182
|
-
}, []);
|
|
183
|
-
|
|
184
|
-
return null;
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
export default KeyPressHandler;
|
|
188
|
-
*/
|
|
210
|
+
/**
|
|
211
|
+
* Diff two objects.
|
|
212
|
+
* @template {Record<string, any>} CompareValue1
|
|
213
|
+
* @template {Record<string, any>} CompareValue2
|
|
214
|
+
* @param {CompareValue1} oldStrings - The original/old object for comparison.
|
|
215
|
+
* @param {CompareValue2} newStrings - The new object for comparison.
|
|
216
|
+
* @returns {DiffStringsData<CompareValue1 & CompareValue2>} An object containing what was added, removed, and modified.
|
|
217
|
+
* @deprecated Function rename! Use {@link diffObjList} instead.
|
|
218
|
+
*/
|
|
219
|
+
export const diffStrings = diffObjList;
|
package/dist/v1/index.cjs
CHANGED
|
@@ -30,7 +30,6 @@ var TinyTextRangeEditor = require('./libs/TinyTextRangeEditor.cjs');
|
|
|
30
30
|
var TinyClipboard = require('./libs/TinyClipboard.cjs');
|
|
31
31
|
var TinyColorConverter = require('./libs/TinyColorConverter.cjs');
|
|
32
32
|
var TinyTimeout = require('./libs/TinyTimeout.cjs');
|
|
33
|
-
var TinyEvents = require('./libs/TinyEvents.cjs');
|
|
34
33
|
var TinyLocalStorage = require('./libs/TinyLocalStorage.cjs');
|
|
35
34
|
var TinyIframeEvents = require('./libs/TinyIframeEvents.cjs');
|
|
36
35
|
var TinyNewWinEvents = require('./libs/TinyNewWinEvents.cjs');
|
|
@@ -55,12 +54,14 @@ var TinyMamdaniInferenceSystem = require('./libs/TinyMamdaniInferenceSystem.cjs'
|
|
|
55
54
|
var TinyClassManager = require('./libs/TinyClassManager.cjs');
|
|
56
55
|
var TinyRadioFm = require('./libs/TinyRadioFm.cjs');
|
|
57
56
|
var TinyMediaPlayer = require('./libs/TinyMediaPlayer.cjs');
|
|
57
|
+
var utils = require('./libs/utils.cjs');
|
|
58
58
|
|
|
59
59
|
|
|
60
60
|
|
|
61
61
|
exports.TinyLevelUp = TinyLevelUp;
|
|
62
62
|
exports.arraySortPositions = array.arraySortPositions;
|
|
63
63
|
exports.diffArrayList = array.diffArrayList;
|
|
64
|
+
exports.multiplyArrayBlocks = array.multiplyArrayBlocks;
|
|
64
65
|
exports.shuffleArray = array.shuffleArray;
|
|
65
66
|
exports.breakdownDuration = clock.breakdownDuration;
|
|
66
67
|
exports.formatCustomTimer = clock.formatCustomTimer;
|
|
@@ -91,6 +92,7 @@ exports.getSimplePerc = simpleMath.getSimplePerc;
|
|
|
91
92
|
exports.ruleOfThree = simpleMath.ruleOfThree;
|
|
92
93
|
exports.addAiMarkerShortcut = text.addAiMarkerShortcut;
|
|
93
94
|
exports.asyncReplace = text.asyncReplace;
|
|
95
|
+
exports.diffObjList = text.diffObjList;
|
|
94
96
|
exports.diffStrings = text.diffStrings;
|
|
95
97
|
exports.safeTextTrim = text.safeTextTrim;
|
|
96
98
|
exports.toTitleCase = text.toTitleCase;
|
|
@@ -169,7 +171,6 @@ exports.TinyTextRangeEditor = TinyTextRangeEditor;
|
|
|
169
171
|
exports.TinyClipboard = TinyClipboard;
|
|
170
172
|
exports.TinyColorConverter = TinyColorConverter;
|
|
171
173
|
exports.TinyTimeout = TinyTimeout;
|
|
172
|
-
exports.TinyEvents = TinyEvents;
|
|
173
174
|
exports.TinyLocalStorage = TinyLocalStorage;
|
|
174
175
|
exports.TinyIframeEvents = TinyIframeEvents;
|
|
175
176
|
exports.TinyNewWinEvents = TinyNewWinEvents;
|
|
@@ -197,3 +198,4 @@ exports.trapezoid = TinyMamdaniInferenceSystem.trapezoid;
|
|
|
197
198
|
exports.TinyClassManager = TinyClassManager;
|
|
198
199
|
exports.TinyRadioFm = TinyRadioFm;
|
|
199
200
|
exports.TinyMediaPlayer = TinyMediaPlayer;
|
|
201
|
+
exports.createCheckDestroyed = utils.createCheckDestroyed;
|
package/dist/v1/index.d.mts
CHANGED
|
@@ -23,7 +23,6 @@ import TinyTextarea from './libs/TinyTextarea.mjs';
|
|
|
23
23
|
import TinyNewWinEvents from './libs/TinyNewWinEvents.mjs';
|
|
24
24
|
import TinyIframeEvents from './libs/TinyIframeEvents.mjs';
|
|
25
25
|
import TinyLocalStorage from './libs/TinyLocalStorage.mjs';
|
|
26
|
-
import TinyEvents from './libs/TinyEvents.mjs';
|
|
27
26
|
import TinyTimeout from './libs/TinyTimeout.mjs';
|
|
28
27
|
import TinyColorConverter from './libs/TinyColorConverter.mjs';
|
|
29
28
|
import TinyClipboard from './libs/TinyClipboard.mjs';
|
|
@@ -42,6 +41,8 @@ import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
|
42
41
|
import ColorSafeStringify from './libs/ColorSafeStringify.mjs';
|
|
43
42
|
import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
44
43
|
import TinyLevelUp from './libs/TinyLevelUp.mjs';
|
|
44
|
+
import { multiplyArrayBlocks } from './basics/array.mjs';
|
|
45
|
+
import { createCheckDestroyed } from './libs/utils.mjs';
|
|
45
46
|
import { valMediaContentMetadata } from './basics/mediaContent.mjs';
|
|
46
47
|
import { valMediaContentMetadataPartial } from './basics/mediaContent.mjs';
|
|
47
48
|
import { parseMediaMetadata } from './basics/mediaContent.mjs';
|
|
@@ -50,6 +51,7 @@ import { defuzzifyCentroid } from './libs/TinyMamdaniInferenceSystem.mjs';
|
|
|
50
51
|
import { trapezoid } from './libs/TinyMamdaniInferenceSystem.mjs';
|
|
51
52
|
import { diffArrayList } from './basics/array.mjs';
|
|
52
53
|
import { diffStrings } from './basics/text.mjs';
|
|
54
|
+
import { diffObjList } from './basics/text.mjs';
|
|
53
55
|
import { breakdownDuration } from './basics/clock.mjs';
|
|
54
56
|
import { calculateMarketcap } from './basics/simpleMath.mjs';
|
|
55
57
|
import { compareMarketcap } from './basics/simpleMath.mjs';
|
|
@@ -137,5 +139,5 @@ import { getTimeDuration } from './basics/clock.mjs';
|
|
|
137
139
|
import { shuffleArray } from './basics/array.mjs';
|
|
138
140
|
import { toTitleCase } from './basics/text.mjs';
|
|
139
141
|
import { toTitleCaseLowerFirst } from './basics/text.mjs';
|
|
140
|
-
export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock, TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage,
|
|
142
|
+
export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock, TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst };
|
|
141
143
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/v1/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import TinyLevelUp from './libs/TinyLevelUp.mjs';
|
|
2
|
-
import { diffArrayList, shuffleArray, arraySortPositions } from './basics/array.mjs';
|
|
2
|
+
import { diffArrayList, shuffleArray, arraySortPositions, multiplyArrayBlocks, } from './basics/array.mjs';
|
|
3
3
|
import { breakdownDuration, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, } from './basics/clock.mjs';
|
|
4
4
|
import { extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, objType, checkObj, } from './basics/objFilter.mjs';
|
|
5
5
|
import { countObj, isJsonObject } from './basics/objChecker.mjs';
|
|
6
6
|
import { documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, } from './basics/fullScreen.mjs';
|
|
7
7
|
import { calculateMarketcap, compareMarketcap, formatBytes, genFibonacciSeq, getAge, getPercentage, getSimplePerc, ruleOfThree, } from './basics/simpleMath.mjs';
|
|
8
|
-
import { addAiMarkerShortcut, diffStrings, safeTextTrim, toTitleCase, toTitleCaseLowerFirst, asyncReplace, } from './basics/text.mjs';
|
|
8
|
+
import { addAiMarkerShortcut, diffStrings, diffObjList, safeTextTrim, toTitleCase, toTitleCaseLowerFirst, asyncReplace, } from './basics/text.mjs';
|
|
9
9
|
import ColorSafeStringify from './libs/ColorSafeStringify.mjs';
|
|
10
10
|
import TinyPromiseQueue from './libs/TinyPromiseQueue.mjs';
|
|
11
11
|
import TinyRateLimiter from './libs/TinyRateLimiter.mjs';
|
|
@@ -28,7 +28,6 @@ import TinyTextRangeEditor from './libs/TinyTextRangeEditor.mjs';
|
|
|
28
28
|
import TinyClipboard from './libs/TinyClipboard.mjs';
|
|
29
29
|
import TinyColorConverter from './libs/TinyColorConverter.mjs';
|
|
30
30
|
import TinyTimeout from './libs/TinyTimeout.mjs';
|
|
31
|
-
import TinyEvents from './libs/TinyEvents.mjs';
|
|
32
31
|
import TinyLocalStorage from './libs/TinyLocalStorage.mjs';
|
|
33
32
|
import TinyIframeEvents from './libs/TinyIframeEvents.mjs';
|
|
34
33
|
import TinyNewWinEvents from './libs/TinyNewWinEvents.mjs';
|
|
@@ -53,7 +52,8 @@ import { FuzzySet, MamdaniInferenceSystem, trapezoid, defuzzifyCentroid, } from
|
|
|
53
52
|
import TinyClassManager from './libs/TinyClassManager.mjs';
|
|
54
53
|
import TinyRadioFm from './libs/TinyRadioFm.mjs';
|
|
55
54
|
import TinyMediaPlayer from './libs/TinyMediaPlayer.mjs';
|
|
55
|
+
import { createCheckDestroyed } from './libs/utils.mjs';
|
|
56
56
|
// import TinyHtmlElems from './libs/TinyHtml/index.mjs';
|
|
57
57
|
export { TinyMediaPlayer, TinyRadioFm, TinyClassManager, FuzzySet, MamdaniInferenceSystem, TinyArrayComparator, TinyTextDiffer, TinyAnalogClock,
|
|
58
58
|
// TinyHtmlElems,
|
|
59
|
-
TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage,
|
|
59
|
+
TinyColorValidator, TinyLoadingScreen, TinyElementObserver, TinySimpleDice, TinyNeedBar, TinyI18, TinyCookieConsent, TinyInventory, TinyInventoryTrader, TinyArrayPaginator, TinyAdvancedRaffle, TinyDayNightCycle, TinyGamepad, TinyTextarea, TinyNewWinEvents, TinyIframeEvents, TinyLocalStorage, TinyTimeout, TinyColorConverter, TinyClipboard, TinyTextRangeEditor, TinySmartScroller, UltraRandomMsgGen, TinyAfterScrollWatcher, TinyHtml, TinyNotifications, TinyDomReadyManager, TinyDragger, TinyDragDropDetector, TinyToastNotify, TinyNotifyCenter, TinyRateLimiter, ColorSafeStringify, TinyPromiseQueue, TinyLevelUp, multiplyArrayBlocks, createCheckDestroyed, valMediaContentMetadata, valMediaContentMetadataPartial, parseMediaMetadata, extractMediaId3Tags, defuzzifyCentroid, trapezoid, diffArrayList, diffStrings, diffObjList, breakdownDuration, calculateMarketcap, compareMarketcap, getPercentage, areElsCollTop, areElsCollBottom, areElsCollLeft, areElsCollRight, areElsCollPerfTop, areElsCollPerfBottom, areElsCollPerfLeft, areElsCollPerfRight, areElsColliding, areElsPerfColliding, getElsColliding, getElsPerfColliding, getElsCollOverlap, getElsCollOverlapPos, getRectCenter, getElsRelativeCenterOffset, getElsCollDirDepth, getElsCollDetails, safeTextTrim, installWindowHiddenScript, genFibonacciSeq, isDirEmptyAsync, fileSizeAsync, dirSizeAsync, listFilesAsync, listDirsAsync, getLatestBackupPath, fetchJson, fetchText, readJsonBlob, readFileBlob, readBase64Blob, saveJsonFile, readJsonFile, writeJsonFile, ensureDirectory, clearDirectoryAsync, clearDirectory, fileExists, dirExists, isDirEmpty, ensureCopyFile, tryDeleteFile, writeTextFile, listFiles, listDirs, fileSize, dirSize, backupFile, restoreLatestBackup, renameFileBatch, renameFileRegex, renameFileAddPrefixSuffix, renameFileNormalizeCase, renameFilePadNumbers, documentIsFullScreen, isScreenFilled, requestFullScreen, exitFullScreen, isFullScreenMode, onFullScreenChange, offFullScreenChange, isJsonObject, arraySortPositions, formatBytes, addAiMarkerShortcut, extendObjType, reorderObjTypeOrder, cloneObjTypeOrder, countObj, checkObj, objType, ruleOfThree, getSimplePerc, asyncReplace, getAge, formatCustomTimer, formatDayTimer, formatTimer, getTimeDuration, shuffleArray, toTitleCase, toTitleCaseLowerFirst, };
|