@tixyel/streamelements 4.5.4 → 4.5.6

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
@@ -1826,7 +1826,7 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
1826
1826
  }
1827
1827
 
1828
1828
  declare namespace Simulation {
1829
- export const data: {
1829
+ const data: {
1830
1830
  names: string[];
1831
1831
  messages: string[];
1832
1832
  tiers: string[];
@@ -1857,246 +1857,45 @@ declare namespace Simulation {
1857
1857
  pronouns: typeof Alejo.Pronouns.map;
1858
1858
  css_color_names: string[];
1859
1859
  };
1860
- export const color: {
1861
- /**
1862
- * Generate opacity hex value
1863
- * @param opacity - Opacity value from 0 to 100
1864
- * @param color - Hex color code
1865
- * @returns - Hex color code with opacity
1866
- */
1860
+ const color: {
1867
1861
  opacity(opacity?: number, color?: string): string;
1868
- /**
1869
- * Extract color and opacity from hex code
1870
- * @param hex - Hex color code
1871
- * @returns - Object with color and opacity
1872
- */
1873
1862
  extract(hex: string): {
1874
1863
  color: string;
1875
1864
  opacity: number;
1876
1865
  };
1877
1866
  validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name";
1878
- /**
1879
- * Convert color to different format
1880
- * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)")
1881
- * @param format - Target format
1882
- * @returns - Converted color string
1883
- * @example
1884
- * ```javascript
1885
- * const hexColor = Simulation.color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733"
1886
- * const rgbColor = Simulation.color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)"
1887
- * const hslColor = Simulation.color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)"
1888
- * const colorName = Simulation.color.convert("#FF5733", "css-color-name"); // "orangered"
1889
- * ```
1890
- */
1891
1867
  convert(str: string, format: "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string | null;
1868
+ random: (type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name") => string;
1892
1869
  };
1893
- export const rand: {
1894
- /**
1895
- * Generate random color
1896
- * @param type - Color format
1897
- * @returns - Random color in specified format
1898
- * @example
1899
- * ```javascript
1900
- * const hexColor = Simulation.rand.color('hex');
1901
- * console.log(hexColor); // e.g. #3e92cc
1902
- *
1903
- * const rgbColor = Simulation.rand.color('rgb');
1904
- * console.log(rgbColor); // e.g. rgb(62, 146, 204)
1905
- * ```
1906
- */
1870
+ const rand: {
1907
1871
  color(type?: "hex" | "hexa" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"): string;
1908
- /**
1909
- * Generate random number
1910
- * @param min - Minimum value
1911
- * @param max - Maximum value
1912
- * @param float - Number of decimal places (0 for integer)
1913
- * @returns - Random number
1914
- * @example
1915
- * ```javascript
1916
- * const intNumber = Simulation.rand.number(1, 10);
1917
- * console.log(intNumber); // e.g. 7
1918
- *
1919
- * const floatNumber = Simulation.rand.number(1, 10, 2);
1920
- * console.log(floatNumber); // e.g. 3.14
1921
- * ```
1922
- */
1923
1872
  number(min: number, max: number, float?: number): number;
1924
- /**
1925
- * Generate random boolean
1926
- * @param threshold - Threshold between 0 and 1
1927
- * @returns - Random boolean
1928
- * @example
1929
- * ```javascript
1930
- * const boolValue = Simulation.rand.boolean(0.7);
1931
- * console.log(boolValue); // e.g. true (70% chance)
1932
- * ```
1933
- */
1934
1873
  boolean(threshold?: number): boolean;
1935
- /**
1936
- * Generate random string
1937
- * @param length - Length of the string
1938
- * @param chars - Characters to use
1939
- * @returns - Random string
1940
- * @example
1941
- * ```javascript
1942
- * const randString = Simulation.rand.string(10);
1943
- * console.log(randString); // e.g. "aZ3bT9xYqP"
1944
- * ```
1945
- */
1946
1874
  string(length: number, chars?: string): string;
1947
- /**
1948
- * Pick random element from array
1949
- * @param arr - Array to pick from
1950
- * @returns - Random element and its index
1951
- * @example
1952
- * ```javascript
1953
- * const [element, index] = Simulation.rand.array(['apple', 'banana', 'cherry']);
1954
- * console.log(element, index); // e.g. "banana", 1
1955
- * ```
1956
- */
1957
1875
  array<T>(arr: T[]): [value: T, index: number];
1958
- /**
1959
- * Generate random date
1960
- * @param start - Start date
1961
- * @param end - End date
1962
- * @returns - Random date between start and end
1963
- * @example
1964
- * ```javascript
1965
- * const randDate = Simulation.rand.date(new Date(2020, 0, 1), new Date());
1966
- * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z
1967
- * ```
1968
- */
1969
1876
  date(start?: Date, end?: Date): Date;
1970
- /**
1971
- * Generate ISO date string offset by days
1972
- * @param daysAgo - Number of days to go back
1973
- * @returns - ISO date string
1974
- * @example
1975
- * ```javascript
1976
- * const isoDate = Simulation.rand.daysOffset(7);
1977
- * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z"
1978
- *
1979
- * const isoDate30 = Simulation.rand.daysOffset(30);
1980
- * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z"
1981
- * ```
1982
- */
1983
1877
  daysOffset(daysAgo: number): string;
1984
- /**
1985
- * Generate UUID v4
1986
- * @returns - UUID string
1987
- * @example
1988
- * ```javascript
1989
- * const uuid = Simulation.rand.uuid();
1990
- * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b"
1991
- * ```
1992
- */
1993
1878
  uuid(): string;
1994
1879
  };
1995
- type Modifier = (value: string, param: string | null | undefined, values: {
1996
- amount?: number;
1997
- count?: number;
1998
- }) => string;
1999
- export const string: {
2000
- /**
2001
- * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
2002
- * @param string - The input string to perform replacements on.
2003
- * @param pattern - The pattern to match in the string (can be a string or a regular expression).
2004
- * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string.
2005
- * @returns A promise that resolves to the modified string with replacements applied.
2006
- * @example
2007
- * ```javascript
2008
- * const result = await Simulation.string.replace("Hello World", /World/, async (match) => {
2009
- * return await fetchSomeData(match); // Assume this function fetches data asynchronously
2010
- * });
2011
- * console.log(result); // Output will depend on the fetched data
2012
- * ```
2013
- */
1880
+ const string: {
2014
1881
  replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise<string> | string): Promise<string>;
2015
- /**
2016
- * Capitalizes the first letter of a given string.
2017
- * @param string - The input string to be capitalized.
2018
- * @returns The capitalized string.
2019
- * @example
2020
- * ```javascript
2021
- * const result = Simulation.string.capitalize("hello world");
2022
- * console.log(result); // Output: "Hello world"
2023
- * ```
2024
- */
2025
1882
  capitalize(string: string): string;
2026
- /**
2027
- * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers.
2028
- * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value].
2029
- * @param values - An object containing key-value pairs to replace the placeholders in the template.
2030
- * @param options - Optional settings for the composition process.
2031
- * @returns The composed string with placeholders replaced and modifiers applied.
2032
- * @example
2033
- * ```javascript
2034
- * const template = "Hello, {username}! You have {amount} [UPPERCASE=messages] and your name is [CAPITALIZE=name].";
2035
- * const values = { username: "john_doe", amount: 5, name: "john" };
2036
- * const result = Simulation.string.compose(template, values);
2037
- * console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
2038
- * ```
2039
- */
2040
1883
  compose(template: string, values?: Record<string, any>, options?: {
2041
1884
  method?: "loop" | "index";
2042
1885
  html?: boolean;
2043
- modifiers?: Record<string, Modifier>;
1886
+ modifiers?: Record<string, (value: string, param: string | null | undefined, values: {
1887
+ amount?: number;
1888
+ count?: number;
1889
+ }) => string>;
2044
1890
  aliases?: Record<string, string[]>;
2045
1891
  }): string;
2046
1892
  };
2047
- export const number: {
2048
- /**
2049
- * Translate number to words
2050
- * @param num - Number to translate
2051
- * @param type - Translation type
2052
- * @returns - Number in words
2053
- * @example
2054
- * ```javascript
2055
- * const cardinal = Simulation.number.translate(42, 'cardinal');
2056
- * console.log(cardinal); // "forty-two"
2057
- * ```
2058
- */
1893
+ const number: {
2059
1894
  translate(num: number, type?: "cardinal" | "ordinal" | "suffix"): string;
2060
- /**
2061
- * Balances a number within a specified range
2062
- * @param amount - Number to balance
2063
- * @param min - Minimum value
2064
- * @param max - Maximum value
2065
- * @returns - Balanced number
2066
- * @example
2067
- * ```javascript
2068
- * const balancedValue = Simulation.number.balance(150, 0, 100);
2069
- * console.log(balancedValue); // 100
2070
- * ```
2071
- */
2072
1895
  balance(amount: number, min?: number, max?: number): number;
2073
1896
  };
2074
- export const element: {
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 = Simulation.element.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
- mergeSpanStyles(outerStyle: string, innerHTML: 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
- * Simulation.element.scale(element, 0.5, 1, { return: false });
2098
- * ```
2099
- */
1897
+ const element: {
1898
+ mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string;
2100
1899
  scale(element: HTMLElement, min?: number, max?: number, options?: {
2101
1900
  return: boolean;
2102
1901
  parent: HTMLElement;
@@ -2106,37 +1905,12 @@ declare namespace Simulation {
2106
1905
  height: number;
2107
1906
  scale: number;
2108
1907
  } | void;
2109
- /**
2110
- * Splits the text content of an HTML string into individual characters wrapped in span elements with a data-index attribute.
2111
- * @param htmlString - The input HTML string to be processed.
2112
- * @param startIndex - The starting index for the data-index attribute (default is 0).
2113
- * @returns - A new HTML string with each character wrapped in a span element.
2114
- * @example
2115
- * ```javascript
2116
- * const result = Simulation.element.splitTextToChars("<p>Hello</p>", 0);
2117
- * console.log(result);
2118
- * // Output: '<p><span class="char" data-index="0">H</span><span class="char" data-index="1">e</span><span class="char" data-index="2">l</span><span class="char" data-index="3">l</span><span class="char" data-index="4">o</span></p>'
2119
- * ```
2120
- */
2121
1908
  splitTextToChars(htmlString: string, startIndex?: number): string;
2122
1909
  };
2123
- export const object: {
2124
- /**
2125
- * Flattens a nested object into a single-level object with dot-separated keys.
2126
- * @param obj - The nested object to be flattened.
2127
- * @param prefix - The prefix to be added to each key (used for recursion).
2128
- * @returns A flattened object with dot-separated keys.
2129
- * @example
2130
- * ```javascript
2131
- * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] };
2132
- * const flatObj = Simulation.object.flatten(nestedObj);
2133
- * console.log(flatObj);
2134
- * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
2135
- * ```
2136
- */
1910
+ const object: {
2137
1911
  flatten(obj: Record<string, any>, prefix?: string): Record<string, string>;
2138
1912
  };
2139
- export const generate: {
1913
+ const generate: {
2140
1914
  session: {
2141
1915
  types: Record<string, StreamElements.Session.Config.Any>;
2142
1916
  available(): StreamElements.Session.Config.Available.Data;
@@ -2175,7 +1949,7 @@ declare namespace Simulation {
2175
1949
  onEventReceived(provider?: Provider$1 | "random", type?: StreamElements.Event.onEventReceived["listener"] | "random" | "tip" | "cheer" | "follower" | "raid" | "subscriber", options?: Record<string, string | number | boolean>): Promise<StreamElements.Event.onEventReceived | null>;
2176
1950
  };
2177
1951
  };
2178
- export var queue: useQueue<{
1952
+ var queue: useQueue<{
2179
1953
  listener: 'onEventReceived';
2180
1954
  data: StreamElements.Event.onEventReceived;
2181
1955
  session?: boolean;
@@ -2186,7 +1960,7 @@ declare namespace Simulation {
2186
1960
  listener: 'onSessionUpdate';
2187
1961
  data: StreamElements.Event.onSessionUpdate;
2188
1962
  }> | undefined;
2189
- export const emulate: {
1963
+ const emulate: {
2190
1964
  twitch: {
2191
1965
  message(data?: Partial<{
2192
1966
  name: string;
@@ -2276,16 +2050,15 @@ declare namespace Simulation {
2276
2050
  * @param ms - The number of milliseconds to delay.
2277
2051
  * @returns A Promise that resolves after the specified delay.
2278
2052
  */
2279
- export function delay(ms: number): Promise<void>;
2053
+ function delay(ms: number): Promise<void>;
2280
2054
  /**
2281
2055
  * Returns typed entries of an object.
2282
2056
  * @param obj - The object to get entries from.
2283
2057
  * @returns - An array of key-value pairs from the object.
2284
2058
  */
2285
- export function typedEntries<K extends string, V>(obj: Record<K, V>): [K, V][];
2286
- export function probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2287
- export function start(fieldsFile?: string[], dataFiles?: string[], session?: StreamElements.Session.Data): Promise<void>;
2288
- export {};
2059
+ function typedEntries<K extends string, V>(obj: Record<K, V>): [K, V][];
2060
+ function probability<K extends string, V extends number>(items: Record<K, V>): K | undefined;
2061
+ function start(fieldsFile?: string[], dataFiles?: string[], session?: StreamElements.Session.Data): Promise<void>;
2289
2062
  }
2290
2063
 
2291
2064
  type JSONPrimitive = string | number | boolean | null;