@tixyel/streamelements 5.3.0 → 5.4.0

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/dist/index.d.ts CHANGED
@@ -1621,6 +1621,7 @@ type BttvEmote = {
1621
1621
  height: number;
1622
1622
  };
1623
1623
  };
1624
+ type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1624
1625
 
1625
1626
  interface ButtonOptions {
1626
1627
  field: string | ((field: string, value: string | boolean | number) => boolean);
@@ -1967,8 +1968,493 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1967
1968
  on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
1968
1969
  }
1969
1970
 
1970
- type Emote = TwitchEmote | BttvEmote | SeventvEmote;
1971
- type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}, ${Twitch.roles}` | `${Twitch.roles}, ${Twitch.roles}, ${Twitch.roles}`;
1971
+ declare namespace Helper {
1972
+ namespace number {
1973
+ /**
1974
+ * Translate number to words
1975
+ * @param num - Number to translate
1976
+ * @param type - Translation type
1977
+ * @returns - Number in words
1978
+ * @example
1979
+ * ```javascript
1980
+ * const cardinal = Simulation.number.translate(42, 'cardinal');
1981
+ * console.log(cardinal); // "forty-two"
1982
+ * ```
1983
+ */
1984
+ function translate(num: number, type?: 'cardinal' | 'ordinal' | 'suffix'): string;
1985
+ /**
1986
+ * Balances a number within a specified range
1987
+ * @param amount - Number to balance
1988
+ * @param min - Minimum value
1989
+ * @param max - Maximum value
1990
+ * @returns - Balanced number
1991
+ * @example
1992
+ * ```javascript
1993
+ * const balancedValue = Simulation.number.balance(150, 0, 100);
1994
+ * console.log(balancedValue); // 100
1995
+ * ```
1996
+ */
1997
+ function balance(amount: number, min?: number, max?: number): number;
1998
+ /**
1999
+ * Rounds a number to a specified number of decimal places
2000
+ * @param value - Number to round
2001
+ * @param decimals - Number of decimal places (default is 2)
2002
+ * @returns Rounded number
2003
+ * @example
2004
+ * ```javascript
2005
+ * const roundedValue = Simulation.number.float(3.14159, 3);
2006
+ * console.log(roundedValue); // 3.142
2007
+ * ```
2008
+ */
2009
+ function round(value: number, decimals?: number): number;
2010
+ }
2011
+ namespace utils {
2012
+ /**
2013
+ * Delays execution for a specified number of milliseconds.
2014
+ * @param ms - The number of milliseconds to delay.
2015
+ * @returns A Promise that resolves after the specified delay.
2016
+ */
2017
+ function delay<R extends any, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2018
+ /**
2019
+ * Returns typed entries of an object.
2020
+ * @param obj - The object to get entries from.
2021
+ * @returns An array of key-value pairs from the object.
2022
+ */
2023
+ function typedEntries<K extends string, V>(obj: Record<K, V> | Array<V>): [K, V][];
2024
+ /**
2025
+ * Returns typed values of an object.
2026
+ * @param obj - The object to get values from.
2027
+ * @returns An array of values from the object.
2028
+ */
2029
+ function typedValues<K extends string, V>(obj: Record<K, V> | Array<V>): V[];
2030
+ /**
2031
+ * Returns typed keys of an object.
2032
+ * @param obj - The object to get keys from.
2033
+ * @returns An array of keys from the object.
2034
+ */
2035
+ function typedKeys<K extends string, V>(obj: Record<K, V> | Array<V>): K[];
2036
+ /**
2037
+ * Selects an item based on weighted probabilities.
2038
+ * @param items - An object where keys are items and values are their weights.
2039
+ * @returns A randomly selected item based on the given probabilities.
2040
+ */
2041
+ function probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2042
+ }
2043
+ namespace element {
2044
+ interface ScaleOptions<T extends HTMLElement> {
2045
+ /**
2046
+ * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
2047
+ */
2048
+ parent?: HTMLElement;
2049
+ /**
2050
+ * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
2051
+ */
2052
+ prefer?: 'width' | 'height' | 'auto';
2053
+ /**
2054
+ * The minimum percentage of the parent size to scale to. Default is 0.
2055
+ */
2056
+ min?: number;
2057
+ /**
2058
+ * The maximum percentage of the parent size to scale to. Default is 1 (100%).
2059
+ */
2060
+ max?: number;
2061
+ /**
2062
+ * A callback function that is called after scaling is applied.
2063
+ * @param this - The HTML element being scaled.
2064
+ * @param number - The scale factor applied to the element.
2065
+ * @param element - The HTML element being scaled.
2066
+ * @returns void
2067
+ */
2068
+ apply?: (this: T, number: number, element: T) => void;
2069
+ }
2070
+ type FitTextOptions = {
2071
+ minFontSize?: number;
2072
+ maxFontSize?: number;
2073
+ parent?: HTMLElement;
2074
+ };
2075
+ /**
2076
+ * Merges outer span styles with inner span styles in the provided HTML string.
2077
+ * @param outerStyle - The style string to be applied to the outer span.
2078
+ * @param innerHTML - The inner HTML string which may contain a span with its own styles.
2079
+ * @returns A new HTML string with merged styles applied to a single span.
2080
+ * @example
2081
+ * ```javascript
2082
+ * const result = mergeSpanStyles("color: red; font-weight: bold;", '<span style="font-size: 14px;">Hello World</span>');
2083
+ * console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
2084
+ * ```
2085
+ */
2086
+ function mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2087
+ /**
2088
+ * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors.
2089
+ * @param element - The HTML element to be scaled.
2090
+ * @param min - Minimum scale factor (default is 0).
2091
+ * @param max - Maximum scale factor (default is 1).
2092
+ * @param options - Optional settings for scaling.
2093
+ * @returns - An object containing the new width, height, and scale factor, or void if not applied.
2094
+ * @example
2095
+ * ```javascript
2096
+ * const element = document.getElementById('myElement');
2097
+ * scale(element, 0.5, 1, { return: false });
2098
+ * ```
2099
+ */
2100
+ function scale(element: HTMLElement, min?: number, max?: number, options?: {
2101
+ return: boolean;
2102
+ parent: HTMLElement;
2103
+ base: 'width' | 'height';
2104
+ }): {
2105
+ width: number;
2106
+ height: number;
2107
+ scale: number;
2108
+ } | void;
2109
+ /**
2110
+ * Scales an HTML element to fit within its parent element based on specified options.
2111
+ * @param element - The HTML element to be scaled.
2112
+ * @param options - Optional settings for scaling.
2113
+ * @returns The scale factor applied to the element.
2114
+ * @example
2115
+ * ```javascript
2116
+ * const element = document.getElementById('myElement');
2117
+ * const scaleFactor scalev2(element, {
2118
+ * min: 0.5,
2119
+ * max: 1,
2120
+ * prefer: 'width',
2121
+ * apply: (scale, el) => el.style.transform = `scale(${scale})`
2122
+ * });
2123
+ * console.log(`Element scaled by a factor of ${scaleFactor}`);
2124
+ * ```
2125
+ */
2126
+ function scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2127
+ /**
2128
+ * Fits the text within the parent element by adjusting the font size.
2129
+ * @param element - The HTML element containing the text to be fitted.
2130
+ * @param compressor - A multiplier to adjust the fitting sensitivity (default is 1).
2131
+ * @param options - Optional settings for fitting text.
2132
+ * @returns The HTML element with adjusted font size.
2133
+ * @example
2134
+ * ```javascript
2135
+ * const element = document.getElementById('myTextElement');
2136
+ * fitText(element, 1, { minFontSize: 12, maxFontSize: 36 });
2137
+ * console.log(`Adjusted font size: ${element.style.fontSize}`);
2138
+ * ```
2139
+ */
2140
+ function fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2141
+ /**
2142
+ * Wraps formatted HTML text with containers and splits characters into indexed spans.
2143
+ * Adds 'container' class and data-index to all parent elements, and wraps each character in a span with class 'char' and data-index.
2144
+ * @param htmlString - The input HTML string containing formatted text elements (span, strong, em, etc).
2145
+ * @param startIndex - The starting index for the data-index attribute (default is 0).
2146
+ * @returns - A new HTML string with containers and character-level indexing.
2147
+ * @example
2148
+ * ```javascript
2149
+ * const result = splitTextToChars('<span>TesTe</span> <strong>bold</strong>', 0);
2150
+ * console.log(result);
2151
+ * // Output: '<span class="container" data-index="0"><span class="char" data-index="0">T</span><span class="char" data-index="1">e</span>...'
2152
+ * ```
2153
+ */
2154
+ function splitTextToChars(htmlString: string, startIndex?: number): string;
2155
+ }
2156
+ namespace object {
2157
+ /**
2158
+ * Flattens a nested object into a single-level object with dot-separated keys.
2159
+ * @param obj - The nested object to be flattened.
2160
+ * @param prefix - The prefix to be added to each key (used for recursion).
2161
+ * @returns A flattened object with dot-separated keys.
2162
+ * @example
2163
+ * ```javascript
2164
+ * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] };
2165
+ * const flatObj = flatten(nestedObj);
2166
+ * console.log(flatObj);
2167
+ * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
2168
+ * ```
2169
+ */
2170
+ function flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2171
+ }
2172
+ namespace message {
2173
+ type BadgeOptions = Twitch.roles[] | Twitch.roles | `${Twitch.roles}, ${Twitch.roles}` | `${Twitch.roles}, ${Twitch.roles}, ${Twitch.roles}`;
2174
+ type TwitchResult = {
2175
+ keys: Twitch.roles[];
2176
+ badges: Twitch.badge[];
2177
+ };
2178
+ type YouTubeResult = {
2179
+ isVerified: boolean;
2180
+ isChatOwner: boolean;
2181
+ isChatSponsor: boolean;
2182
+ isChatModerator: boolean;
2183
+ };
2184
+ /**
2185
+ * Finds emotes in a given text.
2186
+ * @param text - The text to search for emotes.
2187
+ * @param emotes - An array of emotes to search for. Defaults to Local data emotes.
2188
+ * @returns An array of emotes found in the text with their positions.
2189
+ */
2190
+ function findEmotesInText(text: string, emotes?: Emote[]): Emote[];
2191
+ /**
2192
+ * Replaces emotes in the text with corresponding HTML image tags.
2193
+ * @param text - The text containing emotes.
2194
+ * @param emotes - An array of emotes with their positions in the text.
2195
+ * @returns The text with emotes replaced by HTML image tags.
2196
+ */
2197
+ function replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2198
+ /**
2199
+ * Replaces YouTube emotes in the text with corresponding HTML image tags.
2200
+ * @param text - The text containing YouTube emotes.
2201
+ * @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes.
2202
+ * @returns The text with YouTube emotes replaced by HTML image tags.
2203
+ */
2204
+ function replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2205
+ emojiId: string;
2206
+ shortcuts: string[];
2207
+ searchTerms: string[];
2208
+ image: {
2209
+ thumbnails: {
2210
+ url: string;
2211
+ width: number;
2212
+ height: number;
2213
+ }[];
2214
+ accessibility: {
2215
+ accessibilityData: {
2216
+ label: string;
2217
+ };
2218
+ };
2219
+ };
2220
+ isCustomEmoji: boolean;
2221
+ index: number;
2222
+ }[]): string;
2223
+ /**
2224
+ * Generates badge data based on the provided badges and platform.
2225
+ * @param badges - The badges to generate. Can be an array or a comma-separated string.
2226
+ * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'.
2227
+ * @returns A promise that resolves to the generated badge data.
2228
+ * @example
2229
+ * ```javascript
2230
+ * // Generate Twitch badges
2231
+ * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch');
2232
+ * // Generate YouTube badges
2233
+ * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube');
2234
+ * ```
2235
+ */
2236
+ function generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends 'twitch' ? TwitchResult : YouTubeResult>;
2237
+ }
2238
+ namespace event {
2239
+ /**
2240
+ * Parses the provider information from the event detail object.
2241
+ * @param detail - The event detail object received from the StreamElements event.
2242
+ * @returns An object containing the provider and the original event data.
2243
+ */
2244
+ function parseProvider(detail: StreamElements.Event.onEventReceived): ClientEvents$1;
2245
+ }
2246
+ namespace string {
2247
+ type Modifier = (value: string, param: string | null | undefined, values: {
2248
+ amount?: number;
2249
+ count?: number;
2250
+ }) => string;
2251
+ /**
2252
+ * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
2253
+ * @param string - The input string to perform replacements on.
2254
+ * @param pattern - The pattern to match in the string (can be a string or a regular expression).
2255
+ * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string.
2256
+ * @returns A promise that resolves to the modified string with replacements applied.
2257
+ * @example
2258
+ * ```javascript
2259
+ * const result = await string.replace("Hello World", /World/, async (match) => {
2260
+ * return await fetchSomeData(match); // Assume this function fetches data asynchronously
2261
+ * });
2262
+ * console.log(result); // Output will depend on the fetched data
2263
+ * ```
2264
+ */
2265
+ function replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2266
+ /**
2267
+ * Capitalizes the first letter of a given string.
2268
+ * @param string - The input string to be capitalized.
2269
+ * @returns The capitalized string.
2270
+ * @example
2271
+ * ```javascript
2272
+ * const result = string.capitalize("hello world");
2273
+ * console.log(result); // Output: "Hello world"
2274
+ * ```
2275
+ */
2276
+ function capitalize(string: string): Capitalize<string>;
2277
+ /**
2278
+ * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
2279
+ * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value].
2280
+ * @param values - An object containing key-value pairs to replace the placeholders in the template.
2281
+ * @param options - Optional settings for the composition process.
2282
+ * @returns The composed string with placeholders replaced and modifiers applied.
2283
+ * @example
2284
+ * ```javascript
2285
+ * const template = "Hello, {username}! You have {amount} [UPPERCASE=messages] and your name is [CAPITALIZE=name].";
2286
+ * const values = { username: "john_doe", amount: 5, name: "john" };
2287
+ * const result = string.compose(template, values);
2288
+ * console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
2289
+ * ```
2290
+ */
2291
+ function compose(template: string, values?: Record<string, any>, options?: {
2292
+ method?: 'loop' | 'index';
2293
+ html?: boolean;
2294
+ modifiers?: Record<string, Modifier>;
2295
+ aliases?: Record<string, string[]>;
2296
+ }): string;
2297
+ }
2298
+ namespace sound {
2299
+ let playing: boolean;
2300
+ let audio: AudioContext;
2301
+ /**
2302
+ * Play sound from URL with optional volume and replace parameters
2303
+ * @param url - Sound URL to play
2304
+ * @param volume - Volume level from 0 to 100 (default: 100)
2305
+ * @param replace - If true, replaces currently playing sound (default: false)
2306
+ */
2307
+ function play(url: string, volume?: number, replace?: boolean): void;
2308
+ }
2309
+ namespace color {
2310
+ /**
2311
+ * Generate opacity hex value
2312
+ * @param opacity - Opacity value from 0 to 100
2313
+ * @param color - Hex color code
2314
+ * @returns - Hex color code with opacity
2315
+ */
2316
+ function opacity(opacity?: number, color?: string): string;
2317
+ /**
2318
+ * Extract color and opacity from hex code
2319
+ * @param hex - Hex color code
2320
+ * @returns - Object with color and opacity
2321
+ */
2322
+ function extract(hex: string): {
2323
+ color: string;
2324
+ opacity: number;
2325
+ };
2326
+ /**
2327
+ * Validate color string format
2328
+ * @param str - Color string to validate
2329
+ * @returns Detected color format or false if invalid
2330
+ * @example
2331
+ * ```javascript
2332
+ * const format1 = color.validate("#FF5733"); // "hex"
2333
+ * const format2 = color.validate("rgb(255, 87, 51)"); // "rgb"
2334
+ * const format3 = color.validate("hsl(14, 100%, 60%)"); // "hsl"
2335
+ * const format4 = color.validate("orangered"); // "css-color-name"
2336
+ * const format5 = color.validate("invalid-color"); // false
2337
+ * ```
2338
+ */
2339
+ function validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2340
+ /**
2341
+ * Convert color to different format
2342
+ * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
2343
+ * @param format - Target format
2344
+ * @returns - Converted color string
2345
+ * @example
2346
+ * ```javascript
2347
+ * const hexColor = color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
2348
+ * const rgbColor = color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
2349
+ * const hslColor = color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
2350
+ * const colorName = color.convert("#FF5733", "css-color-name"); // "orangered"
2351
+ * ```
2352
+ */
2353
+ function convert(str: string, format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): Promise<string | null>;
2354
+ }
2355
+ namespace random {
2356
+ /**
2357
+ * Generate random color
2358
+ * @param type - Color format
2359
+ * @returns - Random color in specified format
2360
+ * @example
2361
+ * ```javascript
2362
+ * const hexColor = random.color('hex');
2363
+ * console.log(hexColor); // e.g. #3e92cc
2364
+ *
2365
+ * const rgbColor = random.color('rgb');
2366
+ * console.log(rgbColor); // e.g. rgb(62, 146, 204)
2367
+ * ```
2368
+ */
2369
+ function color(type?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): string;
2370
+ /**
2371
+ * Generate random number
2372
+ * @param min - Minimum value
2373
+ * @param max - Maximum value
2374
+ * @param float - Number of decimal places (0 for integer)
2375
+ * @returns - Random number
2376
+ * @example
2377
+ * ```javascript
2378
+ * const intNumber = random.number(1, 10);
2379
+ * console.log(intNumber); // e.g. 7
2380
+ *
2381
+ * const floatNumber = random.number(1, 10, 2);
2382
+ * console.log(floatNumber); // e.g. 3.14
2383
+ * ```
2384
+ */
2385
+ function number(min: number, max: number, float?: number): number;
2386
+ /**
2387
+ * Generate random boolean
2388
+ * @param threshold - Threshold between 0 and 1
2389
+ * @returns - Random boolean
2390
+ * @example
2391
+ * ```javascript
2392
+ * const boolValue = random.boolean(0.7);
2393
+ * console.log(boolValue); // e.g. true (70% chance)
2394
+ * ```
2395
+ */
2396
+ function boolean(threshold?: number): boolean;
2397
+ /**
2398
+ * Generate random string
2399
+ * @param length - Length of the string
2400
+ * @param chars - Characters to use
2401
+ * @returns - Random string
2402
+ * @example
2403
+ * ```javascript
2404
+ * const randString = random.string(10);
2405
+ * console.log(randString); // e.g. "aZ3bT9xYqP"
2406
+ * ```
2407
+ */
2408
+ function string(length: number, chars?: string): string;
2409
+ /**
2410
+ * Pick random element from array
2411
+ * @param arr - Array to pick from
2412
+ * @returns - Random element and its index
2413
+ * @example
2414
+ * ```javascript
2415
+ * const [element, index] = random.array(['apple', 'banana', 'cherry']);
2416
+ * console.log(element, index); // e.g. "banana", 1
2417
+ * ```
2418
+ */
2419
+ function array<T>(arr: T[]): [value: T, index: number];
2420
+ /**
2421
+ * Generate random date
2422
+ * @param start - Start date
2423
+ * @param end - End date
2424
+ * @returns - Random date between start and end
2425
+ * @example
2426
+ * ```javascript
2427
+ * const randDate = random.date(new Date(2020, 0, 1), new Date());
2428
+ * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
2429
+ * ```
2430
+ */
2431
+ function date(start?: Date, end?: Date): Date;
2432
+ /**
2433
+ * Generate ISO date string offset by days
2434
+ * @param daysAgo - Number of days to go back
2435
+ * @returns - ISO date string
2436
+ * @example
2437
+ * ```javascript
2438
+ * const isoDate = random.daysOffset(7);
2439
+ * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
2440
+ *
2441
+ * const isoDate30 = random.daysOffset(30);
2442
+ * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
2443
+ * ```
2444
+ */
2445
+ function daysOffset(daysAgo: number): string;
2446
+ /**
2447
+ * Generate UUID v4
2448
+ * @returns - UUID string
2449
+ * @example
2450
+ * ```javascript
2451
+ * const uuid = random.uuid();
2452
+ * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
2453
+ * ```
2454
+ */
2455
+ function uuid(): string;
2456
+ }
2457
+ }
1972
2458
 
1973
2459
  declare namespace Local {
1974
2460
  type Queue = useQueue<{
@@ -2027,7 +2513,7 @@ declare namespace Local {
2027
2513
  message(data?: Partial<{
2028
2514
  name: string;
2029
2515
  message: string;
2030
- badges: BadgeOptions;
2516
+ badges: Helper.message.BadgeOptions;
2031
2517
  color: string;
2032
2518
  userId: string;
2033
2519
  msgId: string;
@@ -2074,7 +2560,7 @@ declare namespace Local {
2074
2560
  message(data?: Partial<{
2075
2561
  name: string;
2076
2562
  message: string;
2077
- badges: BadgeOptions;
2563
+ badges: Helper.message.BadgeOptions;
2078
2564
  color: string;
2079
2565
  userId: string;
2080
2566
  msgId: string;
@@ -2203,144 +2689,6 @@ declare class useLogger {
2203
2689
  readonly simple: LogMethod;
2204
2690
  }
2205
2691
 
2206
- interface ScaleOptions<T extends HTMLElement> {
2207
- /**
2208
- * The parent element to use for scaling calculations. If not provided, the element's parent will be used.
2209
- */
2210
- parent?: HTMLElement;
2211
- /**
2212
- * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default).
2213
- */
2214
- prefer?: 'width' | 'height' | 'auto';
2215
- /**
2216
- * The minimum percentage of the parent size to scale to. Default is 0.
2217
- */
2218
- min?: number;
2219
- /**
2220
- * The maximum percentage of the parent size to scale to. Default is 1 (100%).
2221
- */
2222
- max?: number;
2223
- /**
2224
- * A callback function that is called after scaling is applied.
2225
- * @param this - The HTML element being scaled.
2226
- * @param number - The scale factor applied to the element.
2227
- * @param element - The HTML element being scaled.
2228
- * @returns void
2229
- */
2230
- apply?: (this: T, number: number, element: T) => void;
2231
- }
2232
- type FitTextOptions = {
2233
- minFontSize?: number;
2234
- maxFontSize?: number;
2235
- parent?: HTMLElement;
2236
- };
2237
-
2238
- declare namespace Helper {
2239
- const sound: {
2240
- playing: boolean;
2241
- audio: AudioContext | null;
2242
- play(url: string, volume?: number, replace?: boolean): void;
2243
- };
2244
- const element: {
2245
- mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2246
- scale(element: HTMLElement, min?: number, max?: number, options?: {
2247
- return: boolean;
2248
- parent: HTMLElement;
2249
- base: "width" | "height";
2250
- }): {
2251
- width: number;
2252
- height: number;
2253
- scale: number;
2254
- } | void;
2255
- scalev2<T extends HTMLElement>(element: T, options?: ScaleOptions<T>): number;
2256
- fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement;
2257
- splitTextToChars(htmlString: string, startIndex?: number): string;
2258
- };
2259
- const color: {
2260
- opacity(opacity?: number, color?: string): string;
2261
- extract(hex: string): {
2262
- color: string;
2263
- opacity: number;
2264
- };
2265
- validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
2266
- convert(str: string, format: "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): Promise<string | null>;
2267
- random: (type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name") => string;
2268
- };
2269
- const object: {
2270
- flatten(obj: Record<string, any>, stringify?: boolean, prefix?: string): Record<string, typeof stringify extends true ? string : string | number | boolean>;
2271
- };
2272
- const utils: {
2273
- delay<R extends unknown, M extends number>(ms: M, callback?: () => R): Promise<R | null>;
2274
- typedEntries<K extends string, V>(obj: Record<K, V> | Array<V>): [K, V][];
2275
- typedValues<K extends string, V>(obj: Record<K, V> | Array<V>): V[];
2276
- typedKeys<K extends string, V>(obj: Record<K, V> | Array<V>): K[];
2277
- probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2278
- };
2279
- const random: {
2280
- color(type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string;
2281
- number(min: number, max: number, float?: number): number;
2282
- boolean(threshold?: number): boolean;
2283
- string(length: number, chars?: string): string;
2284
- array<T>(arr: T[]): [value: T, index: number];
2285
- date(start?: Date, end?: Date): Date;
2286
- daysOffset(daysAgo: number): string;
2287
- uuid(): string;
2288
- };
2289
- const number: {
2290
- translate(num: number, type?: "cardinal" | "ordinal" | "suffix"): string;
2291
- balance(amount: number, min?: number, max?: number): number;
2292
- round(value: number, decimals?: number): number;
2293
- };
2294
- const string: {
2295
- replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2296
- capitalize(string: string): Capitalize<string>;
2297
- compose(template: string, values?: Record<string, any>, options?: {
2298
- method?: "loop" | "index";
2299
- html?: boolean;
2300
- modifiers?: Record<string, (value: string, param: string | null | undefined, values: {
2301
- amount?: number;
2302
- count?: number;
2303
- }) => string>;
2304
- aliases?: Record<string, string[]>;
2305
- }): string;
2306
- };
2307
- const message: {
2308
- findEmotesInText(text: string, emotes?: Emote[]): Emote[];
2309
- replaceEmotesWithHTML(text: string, emotes: Emote[]): string;
2310
- replaceYoutubeEmotesWithHTML(text: string, emotes?: {
2311
- emojiId: string;
2312
- shortcuts: string[];
2313
- searchTerms: string[];
2314
- image: {
2315
- thumbnails: {
2316
- url: string;
2317
- width: number;
2318
- height: number;
2319
- }[];
2320
- accessibility: {
2321
- accessibilityData: {
2322
- label: string;
2323
- };
2324
- };
2325
- };
2326
- isCustomEmoji: boolean;
2327
- index: number;
2328
- }[]): string;
2329
- generateBadges<T extends Provider$1>(badges: BadgeOptions | undefined, provider: T): Promise<T extends "twitch" ? {
2330
- keys: Twitch.roles[];
2331
- badges: Twitch.badge[];
2332
- } : {
2333
- isVerified: boolean;
2334
- isChatOwner: boolean;
2335
- isChatSponsor: boolean;
2336
- isChatModerator: boolean;
2337
- }>;
2338
- };
2339
- const event: {
2340
- parseProvider(detail: StreamElements.Event.onEventReceived): ClientEvents$1;
2341
- };
2342
- }
2343
-
2344
2692
  declare namespace Data {
2345
2693
  const avatars: string[];
2346
2694
  const badges: Record<Twitch.roles, Twitch.badge>;
@@ -2417,4 +2765,4 @@ declare global {
2417
2765
  }
2418
2766
 
2419
2767
  export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage };
2420
- export type { BttvEmote, ClientEvents$1 as ClientEvents, Provider$1 as Provider, SeventvEmote, TwitchEmote };
2768
+ export type { BttvEmote, ClientEvents$1 as ClientEvents, Emote, Provider$1 as Provider, SeventvEmote, TwitchEmote };