@tixyel/streamelements 7.6.8 → 7.7.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 +137 -1
- package/dist/index.es.js +289 -107
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2468,7 +2468,43 @@ declare class ElementHelper {
|
|
|
2468
2468
|
*/
|
|
2469
2469
|
skipWhitespaceIndex?: boolean;
|
|
2470
2470
|
}): string;
|
|
2471
|
+
/**
|
|
2472
|
+
* Retrieves CSS variables defined in the stylesheets of the document for a given selector, with optional filtering and helper variable exclusion.
|
|
2473
|
+
* @param selector - The CSS selector to search for (default is ':root' to target global variables).
|
|
2474
|
+
* @param filter - A function to filter the retrieved CSS variables. It receives each variable as a [key, value] pair, along with its index and the full array of variables. Should return true to include the variable in the results.
|
|
2475
|
+
* @param options - Optional settings for retrieving CSS variables, including filterHelpers to exclude common helper variables (those ending with -min, -max, or -step).
|
|
2476
|
+
* @returns - An array of [key, value] pairs representing the CSS variables that match the selector and filter criteria.
|
|
2477
|
+
* @example
|
|
2478
|
+
* ```javascript
|
|
2479
|
+
* // Retrieve all CSS variables defined under :root
|
|
2480
|
+
* const variables = getElementCSSVariables();
|
|
2481
|
+
* console.log(variables);
|
|
2482
|
+
* // Retrieve CSS variables defined under a specific selector, e.g., .my-class
|
|
2483
|
+
* const classVariables = getElementCSSVariables('.my-class');
|
|
2484
|
+
* console.log(classVariables);
|
|
2485
|
+
* // Retrieve CSS variables with a custom filter, e.g., only variables that include 'color' in their name
|
|
2486
|
+
* const colorVariables = getElementCSSVariables(':root', ([key]) => key.includes('color'));
|
|
2487
|
+
* console.log(colorVariables);
|
|
2488
|
+
*/
|
|
2489
|
+
getElementCSSVariables(selector?: string, filter?: ([k, v]: [string, string], i: number, array: [string, string][]) => boolean, options?: {
|
|
2490
|
+
filterHelpers?: boolean;
|
|
2491
|
+
}): [string, string][];
|
|
2492
|
+
/**
|
|
2493
|
+
* Applies CSS styles to an HTML or SVG element, supporting both standard and custom properties, as well as '!important' values.
|
|
2494
|
+
* @param element - The target HTML or SVG element to which the styles will be applied.
|
|
2495
|
+
* @param styles - An object containing CSS property-value pairs. Property names can be in camelCase or kebab-case, and values can include '!important'.
|
|
2496
|
+
* @example
|
|
2497
|
+
* ```javascript
|
|
2498
|
+
* CSS(document.getElementById('myElement'), {
|
|
2499
|
+
* backgroundColor: 'red',
|
|
2500
|
+
* '--custom-var': '10px',
|
|
2501
|
+
* color: 'blue !important',
|
|
2502
|
+
* });
|
|
2503
|
+
* ```
|
|
2504
|
+
*/
|
|
2505
|
+
CSS(element: HTMLElement | SVGElement, styles: Partial<Record<keyof CSSStyleProperties | `--${string}`, CSSValue>>): void;
|
|
2471
2506
|
}
|
|
2507
|
+
type CSSValue = string | number | null | undefined;
|
|
2472
2508
|
|
|
2473
2509
|
declare class ObjectHelper {
|
|
2474
2510
|
/**
|
|
@@ -3061,7 +3097,7 @@ declare class UtilsHelper {
|
|
|
3061
3097
|
userId: string;
|
|
3062
3098
|
name: string;
|
|
3063
3099
|
broadcasterId?: string;
|
|
3064
|
-
}, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<
|
|
3100
|
+
}, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<1 | 2 | 3>;
|
|
3065
3101
|
/**
|
|
3066
3102
|
* Identifies a user based on the received event and session data, returning their ID, name, role, badges, and top status.
|
|
3067
3103
|
* @param receivedEvent - The event received from the provider (Twitch or YouTube) containing user information.
|
|
@@ -3400,6 +3436,105 @@ declare class AnimateHelper {
|
|
|
3400
3436
|
sequence(animations: AnimResult[], delayFrames?: number | number[]): AnimResult;
|
|
3401
3437
|
}
|
|
3402
3438
|
|
|
3439
|
+
declare class SEHelper {
|
|
3440
|
+
/**
|
|
3441
|
+
* Assign StreamElements custom field schemas from a given data object, with optional prefixing and grouping
|
|
3442
|
+
* @param data - Object containing StreamElements custom field schemas to assign
|
|
3443
|
+
* @param prefix - Optional string to prefix each field key with
|
|
3444
|
+
* @param assign - Optional object to assign the resulting field schemas to (defaults to a new object)
|
|
3445
|
+
* @param group - Optional string to group the fields under (will use existing group if not provided)
|
|
3446
|
+
* @returns - Object containing the assigned StreamElements custom field schemas
|
|
3447
|
+
* @example
|
|
3448
|
+
* ```javascript
|
|
3449
|
+
* const data = {
|
|
3450
|
+
* 'field1': { type: 'text', label: 'Field 1', value: 'Value 1' },
|
|
3451
|
+
* 'field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000' },
|
|
3452
|
+
* 'field3': { type: 'number', label: 'Field 3', value: 10, min: 0, max: 100, step: 1 },
|
|
3453
|
+
* }
|
|
3454
|
+
*
|
|
3455
|
+
* const fields = assignFields(data, 'prefix-', {}, 'Group 1');
|
|
3456
|
+
*
|
|
3457
|
+
* console.log(fields);
|
|
3458
|
+
* // Output:
|
|
3459
|
+
* // {
|
|
3460
|
+
* // 'prefix-field1': { type: 'text', label: 'Field 1', value: 'Value 1', group: 'Group 1' },
|
|
3461
|
+
* // 'prefix-field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000', group: 'Group 1' },
|
|
3462
|
+
* // 'prefix-field3': { type: 'number', label: 'Field 3', value: 10, min: 0, max: 100, step: 1, group: 'Group 1' },
|
|
3463
|
+
* // }
|
|
3464
|
+
* ```
|
|
3465
|
+
*/
|
|
3466
|
+
assignFields(data: Record<string, StreamElements.CustomField.Schema>, prefix?: string, assign?: Record<string, StreamElements.CustomField.Schema>, group?: string): Record<string, StreamElements.CustomField.Schema> | undefined;
|
|
3467
|
+
/**
|
|
3468
|
+
* Check for errors in StreamElements custom fields and throw an error if any are found
|
|
3469
|
+
* @param fields - Object containing StreamElements custom field schemas to check for errors
|
|
3470
|
+
* @throws Will throw an error if any custom field has a label that includes 'undefined', if a non-hidden/button field has an undefined value, or if a hidden/button field has an undefined label
|
|
3471
|
+
* @example
|
|
3472
|
+
* ```javascript
|
|
3473
|
+
* const fields = {
|
|
3474
|
+
* 'field1': { type: 'text', label: 'Field 1', value: 'Value 1' },
|
|
3475
|
+
* 'field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000' },
|
|
3476
|
+
* 'field3': { type: 'hidden', label: 'Hidden Field' },
|
|
3477
|
+
* 'field4': { type: 'button', label: 'Button Field' },
|
|
3478
|
+
* 'field5': { type: 'text', label: 'Undefined Value Field' },
|
|
3479
|
+
* }
|
|
3480
|
+
*
|
|
3481
|
+
* checkFieldErrors(fields);
|
|
3482
|
+
*
|
|
3483
|
+
* // Output:
|
|
3484
|
+
* // Error: StreamElements custom fields have errors: field5 (Undefined Value Field)
|
|
3485
|
+
* ```
|
|
3486
|
+
*/
|
|
3487
|
+
checkFieldErrors(fields: Record<string, StreamElements.CustomField.Schema>): void;
|
|
3488
|
+
/**
|
|
3489
|
+
* Transform CSS variables into StreamElements custom fields
|
|
3490
|
+
* @param data - Array of CSS variable entries (name and value)
|
|
3491
|
+
* @param method - Whether to determine field type based on variable name or value
|
|
3492
|
+
* @param replace - Function to modify the field label based on the variable name
|
|
3493
|
+
* @param subgroup - Function to determine subgrouping of fields based on variable name and value
|
|
3494
|
+
* @returns - Object containing StreamElements custom field schemas
|
|
3495
|
+
* @example
|
|
3496
|
+
* ```javascript
|
|
3497
|
+
* const cssVariables = [
|
|
3498
|
+
* ['--primary-gradient-color', '#ff0000'],
|
|
3499
|
+
* ['--secondary-gradient-color', '#00ff00'],
|
|
3500
|
+
* ];
|
|
3501
|
+
* const fields = transformCSSIntoFields(
|
|
3502
|
+
* cssVariables,
|
|
3503
|
+
* 'name',
|
|
3504
|
+
* (x) => x.replace('gradient', '').trim(),
|
|
3505
|
+
* (key, value) => {
|
|
3506
|
+
* if (key.includes('gradient')) return 'Gradients';
|
|
3507
|
+
* return null;
|
|
3508
|
+
* }
|
|
3509
|
+
* );
|
|
3510
|
+
*
|
|
3511
|
+
* console.log(fields);
|
|
3512
|
+
*
|
|
3513
|
+
* /* Output:
|
|
3514
|
+
* {
|
|
3515
|
+
* '/Gradients': {
|
|
3516
|
+
* type: 'hidden',
|
|
3517
|
+
* label: 'Gradients',
|
|
3518
|
+
* },
|
|
3519
|
+
* '--primary-gradient-color': {
|
|
3520
|
+
* type: 'colorpicker',
|
|
3521
|
+
* label: 'Primary color',
|
|
3522
|
+
* value: '#ff0000',
|
|
3523
|
+
* },
|
|
3524
|
+
* '--secondary-gradient-color': {
|
|
3525
|
+
* type: 'colorpicker',
|
|
3526
|
+
* label: 'Secondary color',
|
|
3527
|
+
* value: '#00ff00',
|
|
3528
|
+
* },
|
|
3529
|
+
* }
|
|
3530
|
+
* ```
|
|
3531
|
+
*/
|
|
3532
|
+
transformCSSIntoFields(data: [string, string][], method?: 'name' | 'value', replace?: (name: string) => string, subgroup?: (key: string, value: string) => string | null): Record<string, StreamElements.CustomField.Schema>;
|
|
3533
|
+
splitFieldLabel(keyPrefix: string, text: string, maxLabelLength?: number): {
|
|
3534
|
+
[k: string]: StreamElements.CustomField.Schema;
|
|
3535
|
+
};
|
|
3536
|
+
}
|
|
3537
|
+
|
|
3403
3538
|
declare namespace Helper {
|
|
3404
3539
|
const animate: AnimateHelper;
|
|
3405
3540
|
const number: NumberHelper;
|
|
@@ -3413,6 +3548,7 @@ declare namespace Helper {
|
|
|
3413
3548
|
const random: RandomHelper;
|
|
3414
3549
|
const fn: FunctionHelper;
|
|
3415
3550
|
const utils: UtilsHelper;
|
|
3551
|
+
const streamelements: SEHelper;
|
|
3416
3552
|
}
|
|
3417
3553
|
|
|
3418
3554
|
declare class Emulator {
|