/*! * This bundled type file includes portions derived from comfy.js * Copyright (c) 2019 Instafluff — MIT License * See THIRD_PARTY_NOTICES.md for full license texts and attributions. */ import { ComfyJSInstance, OnErrorHandler, OnCommandHandler, OnChatHandler, OnWhisperHandler, OnMessageDeletedHandler, OnJoinHandler, OnPartHandler, OnHostedHandler, OnRaidHandler, OnSubHandler, OnResubHandler, OnSubGiftHandler, OnSubMysteryGiftHandler, OnGiftSubContinueHandler, OnCheerHandler, OnChatModeHandler, OnRewardHandler, OnConnectedHandler, OnReconnectHandler } from 'comfy.js'; export { ComfyJSInstance } from 'comfy.js'; type TwitchEmote = { type: 'twitch'; name: string; id: string; gif: boolean; urls: { '1': string; '2': string; '4': string; }; start: number; end: number; }; type FfzEmote = { type: 'ffz'; id: string; name: string; gif: boolean; animated: boolean; urls: { '1': string; '2': string; '4': string; }; start: number; end: number; }; type SeventvEmote = { type: '7tv'; name: string; id: string; gif: boolean; animated: boolean; urls: { '1': string; '2': string; '3': string; '4': string; }; start: number; end: number; }; type BttvEmote = { type: 'bttv'; name: string; id: string; gif: boolean; animated: boolean; urls: { '1': string; '2': string; '4': string; }; start: number; end: number; }; type Emoji = { type: 'emoji'; name: string; id: string; gif: boolean; urls: { '1': string; }; }; type Emote = TwitchEmote | BttvEmote | SeventvEmote | FfzEmote | Emoji; type PathValue = P extends `${infer K}.${infer Rest}` ? K extends keyof T ? PathValue : never : P extends keyof T ? T[P] : never; type NumberAsString = string; type MapNumberValuesToString = { [K in keyof T]: T[K] extends number ? `${T[K]}` | ReturnType : T[K]; }; declare namespace Twitch { type IRC = { /** * Contains metadata related to the chat badges in the badges tag. * Currently, this tag contains metadata only for subscriber badges, to indicate the number of months the user has been a subscriber. * @example * ```javascript * 'subscriber/25' * ``` */ 'badge-info': string; /** * Comma-separated list of chat badges in the form, /. For example admin/1. There are many possible badge values, but here are few: admin, bits, broadcaster, moderator, subscriber, staff, turbo * Most badges have only 1 version, but some badges like subscriber badges offer different versions of the badge depending on how long the user has subscribed. * @example * ```javascript * 'staff/1,bits/1000,partner/1' * ``` */ badges: string; /** * The color of the user's name in the chat. * @example * ```javascript * '#FF0000' * ``` */ color: string | undefined; /** * The user’s display name, escaped as described in the [IRCv3 spec](https://ircv3.net/specs/extensions/message-tags.html). This tag may be empty if it is never set. * @example * ```javascript * 'TwitchUser' * ``` */ 'display-name': string; /** * A comma-delimited list of IDs that identify the emote sets that the user has access to. Is always set to at least zero (0). */ 'emote-sets': string; /** * A slash-delimited list of emotes and their positions in the message. Each emote is in the form, `:`, where ranges are comma-delimited pairs of indices in the form `-`. The position indices are zero-based. * NOTE: It’s possible for a message to begin with with `\001ACTION` when /me is used by a user in chat. In these cases emote positions should be considered to begin after `001ACTION `, which includes its succeeding whitespace. * @example * ```javascript * '25:0-4,12-16/1902:6-10' * ``` */ emotes: string; flags: string; /** * A Boolean value that indicates whether the user has site-wide commercial free mode enabled. Is true (1) if enabled; otherwise, false (0). */ turbo: 0 | 1; /** * The User ID of the relevant user. * @example * ```javascript * '1337' * ``` */ 'user-id': string; /** * The type of user. Possible values are: * ``` * • "" - A normal user * • mod - A channel moderator * • admin - A Twitch administrator * • global_mod - A global moderator * • staff - A Twitch employee * ``` */ 'user-type': '' | 'mod' | 'admin' | 'global_mod' | 'staff'; /** * The amount of Bits the user cheered. Only a Bits cheer message includes this tag. */ bits: number; /** * A Boolean value that determines whether the user is a moderator. Is true (1) if the user is a moderator; otherwise, false (0). */ mod: 0 | 1; /** * The ID of the message. In UUID format. */ 'msg-id': string | undefined; /** * An ID that uniquely identifies the direct parent message that this message is replying to. The message does not include this tag if this message is not a reply. */ 'reply-parent-msg-id': string | undefined; /** * An ID that identifies the sender of the direct parent message. The message does not include this tag if this message is not a reply. */ 'reply-parent-user-id': string | undefined; /** * The login name of the sender of the direct parent message. The message does not include this tag if this message is not a reply. */ 'reply-parent-user-login': string | undefined; /** * The display name of the sender of the direct parent message. The message does not include this tag if this message is not a reply. */ 'reply-parent-display-name': string | undefined; /** * The text of the direct parent message. The message does not include this tag if this message is not a reply. */ 'reply-parent-msg-body': string | undefined; /** * An ID that uniquely identifies the top-level parent message of the reply thread that this message is replying to. The message does not include this tag if this message is not a reply. */ 'reply-thread-parent-msg-id': string | undefined; /** * The login name of the sender of the top-level parent message. The message does not include this tag if this message is not a reply. */ 'reply-thread-parent-user-login': string | undefined; /** * An ID that identifies the chat room (channel). */ 'room-id': string; /** * Comma-separated list of chat badges for the chatter in the room the message was sent from. This uses the same format as the `badges` tag. */ 'source-badges': string; /** * Contains metadata related to the chat badges in the source-badges tag. */ 'source-badge-info': string; /** * A UUID that identifies the source message from the channel the message was sent from. */ 'source-id': string; /** * A Boolean that indicates if a message sent during a shared chat session is only sent to the source channel. Has no effect if the message is not sent during a shared chat session. */ 'source-only': Boolean; /** * An ID that identifies the chat room (channel) the message was sent from. */ 'source-room-id': string; /** * A Boolean value that determines whether the user is a subscriber. Is true (1) if the user is a subscriber; otherwise, false (0). */ subscriber: 0 | 1; /** * The UNIX timestamp. */ 'tmi-sent-ts': number; /** * A Boolean value that determines whether the user that sent the chat is a VIP. The message includes this tag if the user is a VIP; otherwise, the message doesn’t include this tag (check for the presence of the tag instead of whether the tag is set to true or false). */ vip: undefined | ''; }; type Reply = { msgId: string; userId: string; userLogin: string; displayName: string; msgBody: string; }; type Thread = { parentMsgId: string; parentUserLogin: string; }; type badge = { type: string; version: string; url: string; description: string; }; type GlobalBadge = { set_id: tags; versions: Array<{ id: string; image_url_1x: string; image_url_2x: string; image_url_4x: string; title: string; description: string; click_action: string | null; click_url: string | null; }>; }; type CommonTags = 'no_video' | 'no_audio' | 'vip' | 'predictions' | 'lead_moderator' | 'moderator' | 'subscriber' | 'sub-gifter' | 'sub-gift-leader' | 'bits' | 'twitchbot' | 'staff' | 'admin' | 'partner' | 'turbo' | 'broadcaster' | 'hype-train' | 'bits' | 'bits-leader' | 'bot-badge' | 'founder' | 'admin' | 'extension' | 'game-developer' | 'global_mod' | 'artist-badge' | 'ambassador' | 'premium'; type tags = CommonTags | 'qsmp2' | 'jasontheween-7-day-survival' | 'support-a-streamer-ho26-badge' | 'twitch-recap-2025' | 'ugly-sweater' | 'fright-fest-2025' | 'gamerduo' | 'video-games-day' | 'twitch-intern-2022' | 'touch-grass' | 'twitchcon-referral-program-2025-chrome-star' | 'twitchcon-referral-program-2025-bleedpurple' | 'share-the-love' | 'gone-bananas' | 'twitchcon-2025---rotterdam' | 'clip-the-halls' | 'twitch-recap-2024' | 'subtember-2024' | 'twitch-intern-2024' | 'twitch-dj' | 'destiny-2-the-final-shape-streamer' | 'destiny-2-final-shape-raid-race' | 'twitchcon-2024---san-diego' | 'minecraft-15th-anniversary-celebration' | 'warcraft' | 'vga-champ-2017' | 'tyranny_1' | 'twitchconNA2023' | 'twitchconNA2020' | 'twitchconNA2022' | 'twitchconNA2019' | 'twitchconEU2023' | 'twitchconEU2022' | 'twitchcon2018' | 'twitchconAmsterdam2020' | 'twitchconEU2019' | 'twitchcon2017' | 'twitchcon-2024---rotterdam' | 'twitch-recap-2023' | 'twitch-intern-2023' | 'treasure-adventure-world_1' | 'titan-souls_1' | 'this-war-of-mine_1' | 'the-surge_2' | 'the-surge_1' | 'the-surge_3' | 'the-golden-predictor-of-the-game-awards-2023' | 'the-game-awards-2023' | 'superhot_1' | 'strafe_1' | 'streamer-awards-2024' | 'starbound_1' | 'samusoffer_beta' | 'rplace-2023' | 'rift_1' | 'raiden-v-directors-cut_1' | 'psychonauts_1' | 'overwatch-league-insider_2019B' | 'overwatch-league-insider_2019A' | 'okhlos_1' | 'overwatch-league-insider_2018B' | 'overwatch-league-insider_1' | 'kingdom-new-lands_1' | 'jackbox-party-pack_1' | 'innerspace_2' | 'innerspace_1' | 'hello_neighbor_1' | 'gold-pixel-heart' | 'heavy-bullets_1' | 'glitchcon2020' | 'glhf-pledge' | 'getting-over-it_2' | 'getting-over-it_1' | 'frozen-synapse_1' | 'frozen-cortext_1' | 'firewatch_1' | 'enter-the-gungeon_1' | 'duelyst_5' | 'duelyst_6' | 'duelyst_7' | 'duelyst_2' | 'duelyst_4' | 'duelyst_3' | 'duelyst_1' | 'devilian_1' | 'devil-may-cry-hd_4' | 'devil-may-cry-hd_3' | 'devil-may-cry-hd_2' | 'devil-may-cry-hd_1' | 'deceit_1' | 'darkest-dungeon_1' | 'cuphead_1' | 'clip-champ' | 'broken-age_1' | 'bubsy-the-woolies_1' | 'brawlhalla_1' | 'bits-charity' | 'battlechefbrigade_3' | 'battlerite_1' | 'battlechefbrigade_2' | 'battlechefbrigade_1' | 'axiom-verge_1' | 'anomaly-2_1' | 'anomaly-warzone-earth_1' | 'H1Z1_1' | '60-seconds_3' | '60-seconds_2' | '60-seconds_1' | '1979-revolution_1' | '10-years-as-twitch-staff' | '15-years-as-twitch-staff' | '5-years-as-twitch-staff' | 'aang' | 'alone' | 'anonymous-cheerer' | 'arc-raiders-launch-2025' | 'arcane-season-2-premiere' | 'battlefield-6' | 'bingbonglove' | 'black-ops-7-global-launch' | 'borderlands-4-badge---ripper' | 'borderlands-4-badge---vault-symbol' | 'bungie-foundation-ally' | 'bungie-foundation-supporter' | 'chatter-cs-go-2022' | 'clips-leader' | 'creator-cs-go-2022' | 'crimson-butterfly' | 'diablo-30th-anniversary' | 'diana' | 'ditto' | 'dragonscimmy' | 'dreamcon-2024' | 'elden-ring-recluse' | 'elden-ring-wylder' | 'eso_1' | 'evo-2025' | 'fallout-season-2-ghoul' | 'first-stand-2026-supporter' | 'first-stand-2026-viewer' | 'fischer' | 'frog-lantern' | 'gears-of-war-superfan-badge' | 'gingko-leaf' | 'gold-pixel-heart---together-for-good-24' | 'gp-explorer-3' | 'hornet' | 'hunt-crosses' | 'hypershot-celestial' | 'jeff-the-land-shark' | 'k4sen-con-2025' | 'kodama' | 'la-velada-iv' | 'la-velada-v-badge' | 'lamby' | 'league-of-legends-mid-season-invitational-2025---grey' | 'league-of-legends-mid-season-invitational-2025---purple' | 'legendus' | 'lol-worlds-2025' | 'lost-ark-anniversary' | 'low' | 'marathon-reveal-runner' | 'marathon-silkworm' | 'marathon-sub-burger' | 'mel' | 'moments' | 'mr-raccoon' | 'never-grave---witch-hat' | 'path-of-exile-2-badge' | 'pokemon-30th-anniversary' | 'pokemon-legends-z-a-chikorita' | 'pokemon-legends-z-a-tepig' | 'pokemon-legends-z-a-totodile' | 'power-rangers' | 'purple-noob' | 'purple-pixel-heart---together-for-good-24' | 'raging-wolf-helm' | 'raider-icon-badge' | 'rainbow-six-siege-x-10th-anniversary' | 'revedtv-stream-awards-2025' | 'ruby-pixel-heart---together-for-good-24' | 'rudy' | 'rustmas-2025' | 'sajam-slam-badge' | 'scampuss' | 'seeks-eye' | 'social-sharing' | 'sonic-racing-crossworlds' | 'speedons-5-badge' | 'stream-for-humanity-2-2025' | 'streamer-awards-tux' | 'subtember-2025' | 'superultracombo-2023' | 'survival-cup-4' | 'tft-paris-open' | 'the-deer' | 'the-first-descendant-badge' | 'the-man-without-fear' | 'the-onryos-mask' | 'together-for-good-25---good-badge' | 'together-for-good-25---gooder-badge' | 'together-for-good-25---goodest-badge' | 'together-for-good-25---wicked-dub-badge' | 'total-war-anniversary' | 'toxic-zombie' | 'twitchcon-2026-europe-row-houses' | 'twitchcon-2026-europe-windmill' | 'umbrella-corporation' | 'user-anniversary' | 'vct-paris-2025' | 'yellow-noob' | 'zevent-2024' | 'zevent25'; } declare namespace TwitchEvents { namespace Message { type Data = { listener: 'message'; event: Event; }; type Event = { service: 'twitch'; data: { time: number; tags: Partial> & { 'badge-info': string; badges: string; 'client-nonce': string; color: string; 'display-name': string; emotes: string; 'first-msg': '1' | '0'; flags: string; id: string; mod: '1' | '0'; 'returning-chatter': '1' | '0'; 'room-id': string; subscriber: '1' | '0'; 'tmi-sent-ts': string; turbo: '1' | '0'; 'user-id': string; 'user-type': '' | 'mod' | 'admin' | 'global_mod' | 'staff'; }; nick: string; displayName: string; displayColor: string; channel: string; text: string; isAction: boolean; userId: string; msgId: string; badges: Array; emotes: Array; }; renderedText: string; }; } namespace DeleteMessage { type Data = { listener: 'delete-message'; event: Event; }; type Event = { msgId: string; }; } namespace DeleteMessages { type Data = { listener: 'delete-messages'; event: Event; }; type Event = { userId: string; }; } namespace Follower { type Data = { listener: 'follower-latest'; event: Event; }; type Event = { avatar: string; name: string; displayName: string; providerId: string; _id: string; sessionTop: boolean; type: 'follower'; originalEventName: 'follower-latest'; }; } namespace Cheer { type Data = { listener: 'cheer-latest'; event: Event; }; type Event = { amount: number; avatar: string; name: string; displayName: string; providerId: string; message: string; _id: string; sessionTop: boolean; type: 'cheer'; originalEventName: 'cheer-latest'; }; } namespace Raid { type Data = { listener: 'raid-latest'; event: Event; }; type Event = { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'raid'; originalEventName: 'raid-latest'; }; } namespace Subscriber { export type Data = { listener: 'subscriber-latest'; event: Event; }; export type Event = common & (normal | gift | community | spam); export type SubscriberTier = 'prime' | '1000' | '2000' | '3000'; type common = { amount: number; name: string; displayName: string; tier: SubscriberTier; message?: string; providerId?: string; avatar?: string; sender?: string; gifted?: boolean; bulkGifted?: boolean; isCommunityGift?: boolean; _id?: string; sessionTop?: boolean; playedAsCommunityGift?: boolean; type: 'subscriber'; originalEventName: 'subscriber-latest'; }; export type normal = { sender?: undefined; gifted?: false; bulkGifted?: false; isCommunityGift?: false; }; export type gift = { sender: string; gifted: true; bulkGifted?: false; isCommunityGift?: false; }; export type community = { message: string; sender: string; gifted?: false; bulkGifted: true; isCommunityGift?: false; }; export type spam = { sender: string; gifted: true; bulkGifted?: false; isCommunityGift: true; }; export {}; } interface BaseEvent { provider: 'twitch'; flagged: boolean; channel: string; createdAt: string; _id: string; expiresAt: string; updatedAt: string; activityId: string; sessionEventsCount: number; isMock?: boolean; } namespace Event { type Data = { listener: 'event'; event: Event; }; type Event = ChannelPointsRedemption | Follower | Cheer | Subscriber; interface ChannelPointsRedemption extends BaseEvent { type: 'channelPointsRedemption'; data: { amount: number; username: string; displayName: string; providerId: string; redemption: string; message?: string; quantity: number; avatar: string; }; } interface Follower extends BaseEvent { type: 'follower'; data: { username: string; displayName: string; providerId: string; quantity: number; avatar: string; }; } interface Cheer extends BaseEvent { type: 'cheer'; data: { amount: number; username: string; displayName: string; providerId: string; message: string; quantity: number; avatar: string; }; } interface Subscriber extends BaseEvent { type: 'subscriber'; data: FirstTimeSubscriber | Resubscribe | GiftedSubscriber | CommunityGiftedSubscriber; } type FirstTimeSubscriber = { amount: number; username: string; displayName: string; providerId: string; tier: Subscriber.SubscriberTier; quantity: 0; avatar: string; }; type Resubscribe = { amount: number; username: string; displayName: string; providerId: string; message: string; tier: Subscriber.SubscriberTier; streak: number; quantity: number; avatar: string; }; type GiftedSubscriber = { amount: number; username: string; displayName: string; providerId: string; message: string; tier: Subscriber.SubscriberTier; sender: string; gifted: true; quantity: 0; avatar: string; }; type CommunityGiftedSubscriber = { amount: number; username: string; displayName: string; providerId: string; message: string; tier: Subscriber.SubscriberTier; sender: string; gifted: true; quantity: 0; avatar: string; }; } } declare namespace YoutubeEvents { namespace Message { export type Data = { listener: 'message'; event: Event; }; export type Event = { service: 'youtube'; data: { kind: string; etag: string; id: string; snippet: { type: string; liveChatId: string; authorChannelId: string; publishedAt: string; hasDisplayContent: boolean; displayMessage: string; textMessageDetails: { messageText: string; }; }; authorDetails: { channelId: string; channelUrl: string; displayName: string; profileImageUrl: string; isVerified: boolean; isChatOwner: boolean; isChatSponsor: boolean; isChatModerator: boolean; }; msgId: string; userId: string; nick: string; badges: Array; displayName: string; isAction: boolean; time: number; tags: Array; displayColor: string | null; channel: string; text: string; avatar: string; emotes: Array; }; renderedText: string; }; type Badges = {}; type Tags = {}; type Emotes = {}; export {}; } namespace Superchat { type Data = { listener: 'superchat-latest'; event: Event; }; type Event = { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'superchat'; originalEventName: 'superchat-latest'; }; } namespace Subscriber { type Data = { listener: 'subscriber-latest'; event: Event; }; type Event = { avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'subscriber'; originalEventName: 'subscriber-latest'; }; } namespace Sponsor { type Data = { listener: 'sponsor-latest'; event: Event; }; type Event = common & (normal | gift | community | spam); type common = { amount: number; name: string; displayName: string; message?: string; providerId?: string; avatar?: string; sender?: string; gifted?: boolean; bulkGifted?: boolean; isCommunityGift?: boolean; _id?: string; sessionTop?: boolean; playedAsCommunityGift?: boolean; type: 'sponsor'; originalEventName: 'sponsor-latest'; }; type normal = { sender?: undefined; gifted?: false; bulkGifted?: false; isCommunityGift?: false; }; type gift = { sender: string; gifted: true; bulkGifted?: false; isCommunityGift?: false; }; type community = { message: string; sender: string; gifted?: false; bulkGifted: true; isCommunityGift?: false; }; type spam = { sender: string; gifted: true; bulkGifted?: false; isCommunityGift: true; }; } interface BaseEvent { provider: 'youtube'; flagged: boolean; channel: string; createdAt: string; _id: string; expiresAt: string; updatedAt: string; activityId: string; sessionEventsCount: number; isMock?: boolean; } namespace Event { type Data = { listener: 'event'; event: Event; }; type Event = Superchat | Subscriber | Sponsor | CommunityGiftedSponsor; interface Superchat extends BaseEvent { type: 'superchat'; data: { amount: string; username: string; message: string; avatar: string; providerId: string; }; } interface Subscriber extends BaseEvent { type: 'subscriber'; data: { avatar: string; displayName: string; username: string; providerId: string; }; } interface Sponsor extends BaseEvent { type: 'sponsor'; data: FirstTimeSponsor | Resubscribe | GiftedSponsor; } type FirstTimeSponsor = { amount: number; username: string; displayName: string; providerId: string; avatar: string; }; type Resubscribe = { amount: number; username: string; displayName: string; providerId: string; avatar: string; }; type GiftedSponsor = { amount: number; username: string; displayName: string; providerId: string; sender: string; gifted: true; avatar: string; }; interface CommunityGiftedSponsor extends BaseEvent { type: 'communityGiftPurchase'; data: { amount: number; username: string; displayName: string; providerId: string; avatar: string; }; } } } declare namespace StreamElements { namespace CustomField { type Types = 'button' | 'number' | 'slider' | 'text' | 'hidden' | 'checkbox' | 'dropdown' | 'colorpicker' | 'googleFont' | 'video-input' | 'image-input' | 'sound-input'; type Schema = { type: Types; label: string; value?: string | number | boolean; group?: string; min?: number | string; max?: number | string; step?: number | string; options?: Record; multiple?: boolean; }; type Value = string | number | boolean | undefined; } type SE_API = { responses: Record; sendMessage: (message: string, data: object) => void; counters: { get: (key: string) => number | null; }; store: { get: (key: string) => Promise; set: (key: string, value: T) => void; }; resumeQueue: () => void; sanitize: (message: string) => string; cheerFilter: (message: string) => string; setField: (key: string, value: string | number | boolean | undefined, reload: boolean) => void; getOverlayStatus: () => { isEditorMode: boolean; muted: boolean; }; events: { emit(event: L, data: Event.EventData['event']): { ok: boolean; }; emit, E extends string>(event: E extends Event.Listener ? never : E, data: T): { ok: boolean; }; broadcast(event: L, data: Event.EventData['event']): { ok: boolean; }; broadcast, E extends string>(event: E extends Event.Listener ? never : E, data: T): { ok: boolean; }; }; }; namespace Event { type onWidgetLoad = { channel: { username: string; /** * The channel's streamelements api token (used to authenticate requests to the SE API) */ apiToken: string; /** * The channel's unique identifier in the SE system */ id: string; /** * The channel's unique identifier from the provider (e.g. Twitch user ID) */ providerId: string; avatar: string; }; currency: { code: string; name: string; symbol: string; }; fieldData: Record; recents: Array; session: { data: StreamElements.Session.Data; settings: { autoReset: boolean; calendar: boolean; resetOnStart: boolean; }; }; overlay: { /** * Whether the overlay is being viewed in the editor mode (in the SE dashboard) or live (on stream) */ isEditorMode: boolean; /** * Whether the overlay is muted or not */ muted: boolean; }; emulated?: boolean; }; type onSessionUpdate = { session: StreamElements.Session.Data; emulated?: boolean; }; namespace Provider { namespace YouTube { type Events = Message | Event | Superchat | Subscriber | Sponsor; type Message = YoutubeEvents.Message.Data; type Event = YoutubeEvents.Event.Data; type Superchat = YoutubeEvents.Superchat.Data; type Subscriber = YoutubeEvents.Subscriber.Data; type Sponsor = YoutubeEvents.Sponsor.Data; type gift = YoutubeEvents.Sponsor.gift; type community = YoutubeEvents.Sponsor.community; type spam = YoutubeEvents.Sponsor.spam; } namespace StreamElements { type Events = Tip | Event | KVStore | EventSkip | EventTest | BotCounter | AlertService; type Tip = StreamElementsEvents.Tip.Data; type Event = StreamElementsEvents.Event.Data; type KVStore = StreamElementsEvents.KVStore.Data; type EventSkip = StreamElementsEvents.EventSkip.Data; type EventTest = StreamElementsEvents.EventTest.Data; type BotCounter = StreamElementsEvents.BotCounter.Data; type AlertService = StreamElementsEvents.AlertService.Data; } namespace Twitch { type Events = Raid | Event | Cheer | Message | Follower | Subscriber | DeleteMessage | DeleteMessages; type SubscriberTier = TwitchEvents.Subscriber.SubscriberTier; type Raid = TwitchEvents.Raid.Data; type Event = TwitchEvents.Event.Data; type Cheer = TwitchEvents.Cheer.Data; type spam = TwitchEvents.Subscriber.spam; type gift = TwitchEvents.Subscriber.gift; type Message = TwitchEvents.Message.Data; type Follower = TwitchEvents.Follower.Data; type Subscriber = TwitchEvents.Subscriber.Data; type community = TwitchEvents.Subscriber.community; type DeleteMessage = TwitchEvents.DeleteMessage.Data; type DeleteMessages = TwitchEvents.DeleteMessages.Data; } namespace Kick { type Events = { listener: 'message'; event: {}; }; } namespace Facebook { type Events = { listener: 'message'; event: {}; }; } } type onEventReceived = (Provider.Twitch.Events | Provider.YouTube.Events | Provider.StreamElements.Events) & { emulated?: boolean; }; type Listener = onEventReceived['listener']; type EventByListener = { [L in Listener]: Extract['event']; }; type EventData = { listener: L; event: EventByListener[L]; emulated?: boolean; }; } namespace Session { type Data = Tip & Host & Raid & Cheer & Merch & Purchase & Follower & Hypetrain & Superchat & Sponsor & Subscriber & CheerPurchase & ChannelPoints & CharityCampaignDonation; namespace Config { type Int = { type: 'int'; min: number; max: number; }; type String = { type: 'string'; options: string[]; }; type Array = { type: 'array'; options: any[]; }; type Date = { type: 'date'; range: number; }; type Recent = { type: 'recent'; amount: number; value: Record; }; type Any = Int | String | Date | Array | Recent | undefined; namespace Available { type Category = Record | undefined>; type Data = Record; } } type Sponsor = { 'sponsor-latest': { amount: string; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'sponsor'; originalEventName: 'sponsor-latest'; }; 'sponsor-session': { count: number; }; 'sponsor-week': { count: number; }; 'sponsor-month': { count: number; }; 'sponsor-goal': { amount: number; }; 'sponsor-total': { count: number; }; 'sponsor-gifted-session': { count: number; }; 'sponsor-gifted-latest': { name: string; amount: number; tier: string; message: string; sender: string; }; 'sponsor-recent': { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'sponsor'; originalEventName: 'sponsor-recent'; }[]; }; type SponsorCommunityGift = { 'community-gift-latest': { amount: number; name: string; tier: string; }; 'communityGiftPurchase-latest': { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; }; }; type Follower = { 'follower-latest': { name: string; }; 'follower-session': { count: number; }; 'follower-week': { count: number; }; 'follower-month': { count: number; }; 'follower-goal': { amount: number; }; 'follower-total': { count: number; }; 'follower-recent': { name: string; createdAt: string; }[]; }; type SubscriptionTier = 'prime' | '1000' | '2000' | '3000'; interface Subscriber { 'subscriber-latest': { name: string; amount: number; tier: SubscriptionTier; message: string; }; 'subscriber-new-latest': { name: string; amount: number; message: string; }; 'subscriber-resub-latest': { name: string; amount: number; message: string; }; 'subscriber-gifted-latest': { name: string; amount: number; message: string; tier: SubscriptionTier; sender: string; }; 'subscriber-session': { count: number; }; 'subscriber-new-session': { count: number; }; 'subscriber-resub-session': { count: number; }; 'subscriber-gifted-session': { count: number; }; 'subscriber-week': { count: number; }; 'subscriber-month': { count: number; }; 'subscriber-goal': { amount: number; }; 'subscriber-total': { count: number; }; 'subscriber-points': { amount: number; }; 'subscriber-alltime-gifter': { name: string; amount: number; }; 'subscriber-recent': { name: string; amount: number; tier: SubscriptionTier; createdAt: string; }[]; } interface Host { 'host-latest': { name: string; amount: number; }; 'host-recent': { name: string; amount: number; createdAt: string; }[]; } interface Raid { 'raid-latest': { name: string; amount: number; }; 'raid-recent': { name: string; amount: number; createdAt: string; }[]; } interface CharityCampaignDonation { 'charityCampaignDonation-latest': { name: string; amount: number; }; 'charityCampaignDonation-session-top-donation': { name: string; amount: number; }; 'charityCampaignDonation-weekly-top-donation': { name: string; amount: number; }; 'charityCampaignDonation-monthly-top-donation': { name: string; amount: number; }; 'charityCampaignDonation-alltime-top-donation': { name: string; amount: number; }; 'charityCampaignDonation-session-top-donator': { name: string; amount: number; }; 'charityCampaignDonation-weekly-top-donator': { name: string; amount: number; }; 'charityCampaignDonation-monthly-top-donator': { name: string; amount: number; }; 'charityCampaignDonation-alltime-top-donator': { name: string; amount: number; }; 'charityCampaignDonation-recent': { name: string; amount: number; createdAt: string; }[]; } interface Cheer { 'cheer-latest': { name: string; amount: number; message: string; }; 'cheer-session-top-donation': { name: string; amount: number; }; 'cheer-session-top-donator': { name: string; amount: number; }; 'cheer-weekly-top-donation': { name: string; amount: number; }; 'cheer-weekly-top-donator': { name: string; amount: number; }; 'cheer-monthly-top-donation': { name: string; amount: number; }; 'cheer-monthly-top-donator': { name: string; amount: number; }; 'cheer-alltime-top-donation': { name: string; amount: number; }; 'cheer-alltime-top-donator': { name: string; amount: number; }; 'cheer-session': { amount: number; }; 'cheer-week': { amount: number; }; 'cheer-month': { amount: number; }; 'cheer-total': { amount: number; }; 'cheer-count': { count: number; }; 'cheer-goal': { amount: number; }; 'cheer-recent': { name: string; amount: number; createdAt: string; }[]; } interface CheerPurchase { 'cheerPurchase-latest': { name: string; amount: number; }; 'cheerPurchase-session-top-donation': { name: string; amount: number; }; 'cheerPurchase-weekly-top-donation': { name: string; amount: number; }; 'cheerPurchase-monthly-top-donation': { name: string; amount: number; }; 'cheerPurchase-alltime-top-donation': { name: string; amount: number; }; 'cheerPurchase-session-top-donator': { name: string; amount: number; }; 'cheerPurchase-weekly-top-donator': { name: string; amount: number; }; 'cheerPurchase-monthly-top-donator': { name: string; amount: number; }; 'cheerPurchase-alltime-top-donator': { name: string; amount: number; }; 'cheerPurchase-recent': { name: string; amount: number; createdAt: string; }[]; } interface Superchat { 'superchat-latest': { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'superchat'; originalEventName: 'superchat-latest'; }; 'superchat-session-top-donation': { name: string; amount: number; _id: string; }; 'superchat-weekly-top-donation': { name: string; amount: number; }; 'superchat-monthly-top-donation': { name: string; amount: number; }; 'superchat-alltime-top-donation': { name: string; amount: number; }; 'superchat-session-top-donator': { name: string; amount: number; }; 'superchat-weekly-top-donator': { name: string; amount: number; }; 'superchat-monthly-top-donator': { name: string; amount: number; }; 'superchat-alltime-top-donator': { name: string; amount: number; }; 'superchat-session': { amount: number; }; 'superchat-week': { amount: number; }; 'superchat-month': { amount: number; }; 'superchat-total': { amount: number; }; 'superchat-count': { count: number; }; 'superchat-goal': { amount: number; }; 'superchat-recent': { amount: number; avatar: string; displayName: string; providerId: string; name: string; _id: string; sessionTop: boolean; type: 'superchat'; originalEventName: 'superchat-latest'; }[]; } interface Hypetrain { 'hypetrain-latest': { name: string; amount: number; active: number; level: any; levelChanged: any; type: any; }; 'hypetrain-level-goal': { amount: number; }; 'hypetrain-level-progress': { amount: number; percent: number; }; 'hypetrain-total': { amount: number; }; 'hypetrain-latest-top-contributors': { name: string; }[]; } interface ChannelPoints { 'channel-points-latest': { name: string; amount: number; message: string; redemption: string; }; } interface Tip { 'tip-latest': { name: string; amount: number; }; 'tip-session-top-donation': { name: string; amount: number; }; 'tip-weekly-top-donation': { name: string; amount: number; }; 'tip-monthly-top-donation': { name: string; amount: number; }; 'tip-alltime-top-donation': { name: string; amount: number; }; 'tip-session-top-donator': { name: string; amount: number; }; 'tip-weekly-top-donator': { name: string; amount: number; }; 'tip-monthly-top-donator': { name: string; amount: number; }; 'tip-alltime-top-donator': { name: string; amount: number; }; 'tip-session': { amount: number; }; 'tip-week': { amount: number; }; 'tip-month': { amount: number; }; 'tip-total': { amount: number; }; 'tip-count': { count: number; }; 'tip-goal': { amount: number; }; 'tip-recent': { name: string; amount: number; createdAt: string; }[]; } interface Merch { 'merch-latest': { name: string; amount: number; items: any[]; }; 'merch-goal-orders': { amount: number; }; 'merch-goal-items': { amount: number; }; 'merch-goal-total': { amount: number; }; 'merch-recent': { name: string; }[]; } interface Purchase { 'purchase-latest': { name: string; amount: number; items: any[]; avatar: string; message: string; }; } } } type Provider$1 = 'twitch' | 'youtube' | 'kick' | 'facebook' | 'streamelements'; type ClientProviderEvents = { streamelements: StreamElements.Event.Provider.StreamElements.Events; twitch: StreamElements.Event.Provider.Twitch.Events; youtube: StreamElements.Event.Provider.YouTube.Events; kick: StreamElements.Event.Provider.Kick.Events; facebook: StreamElements.Event.Provider.Facebook.Events; }; type ClientCustomEventPayload = { provider: TProvider; }; type ClientCustomProviderEvents = Record; type ClientCustomEventsWithoutInternalProviders = Omit; type ValidateCustomProviderEvents = CustomEvents extends Record ? { [K in keyof ClientCustomEventsWithoutInternalProviders & string]: ClientCustomEventsWithoutInternalProviders[K] extends ClientCustomEventPayload ? ClientCustomEventsWithoutInternalProviders[K] : never; } : {}; type ClientAllProviderEvents = ClientProviderEvents & ValidateCustomProviderEvents; type ClientEvents = { [K in keyof ClientAllProviderEvents & string]: { provider: K; data: ClientAllProviderEvents[K]; }; }[keyof ClientAllProviderEvents & string]; type ClientEventTuple = { [K in keyof ClientAllProviderEvents & string]: [ provider: K, event: ClientAllProviderEvents[K] ]; }[keyof ClientAllProviderEvents & string]; declare namespace StreamElementsEvents { namespace Tip { type Data = { listener: 'tip-latest'; event: Event; }; type Event = { amount: number; avatar: string; name: string; displayName: string; providerId: string; _id: string; sessionTop: boolean; type: 'tip'; originalEventName: 'tip-latest'; }; } namespace KVStore { type Data = { listener: 'kvstore:update'; event: Event; }; type Event = { data: { key: `customWidget.${string}`; value: string | number | boolean | Record; }; }; } namespace BotCounter { type Data = { listener: 'bot:counter'; event: Event; }; type Event = { counter: string; value: number; }; } namespace AlertService { type Data = { listener: 'alertService:toggleSound'; event: Event; }; type Event = { muted: boolean; }; } namespace EventSkip { type Data = { listener: 'event:skip'; event: Event; }; type Event = {}; } namespace EventTest { export type Data = { listener: 'event:test'; event: Event; }; export type Event = widgetButton | emulatedEvents | Session; type items = { name: string; price: number; quantity: number; }; type widgetButton = { listener: 'widget-button'; field: string; value: string | number | boolean; }; type EventType = 'follower' | 'subscriber' | 'tip' | 'cheer' | 'raid'; type EventTier = 'prime' | '1000' | '2000' | '3000'; type emulatedEvents = { listener: `${T}-latest`; event: { type: T; name: string; amount: number; count: number; message?: string; gifted?: boolean; bulkGifted?: boolean; sender?: string; subExtension?: boolean; items: items[]; tier: EventTier; month: string; isTest: true; }; }; type Session = SessionCount | SessionTotal | SessionTop | SessionGoal | SessionRecent | SessionPoints; type SessionCount = { listener: `${EventType}-count`; event: { type: EventType; name: string; count: number; items: items[]; tier: EventTier; month: string; isTest: true; }; }; type SessionTotal = { listener: `${EventType}-total`; event: { type: EventType; name: string; amount: number; count: number; items: items[]; tier: EventTier; month: string; isTest: true; }; }; type SessionTop = { listener: `${EventType}-top`; event: { type: EventType; name: string; amount: number; count: number; items: items[]; tier: EventTier; month: string; isTest: true; }; }; type SessionGoal = { listener: `${EventType}-goal`; event: { type: EventType; name: string; amount: number; count: number; items: items[]; tier: EventTier; month: string; isTest: true; }; }; type SessionRecent = { listener: `${EventType}-recent`; event: { event: SessionRecentEvent[]; }; }; type SessionRecentEvent = { type: EventType; name: string; amount: number; count: number; tier: EventTier; isTest: true; }; type SessionPoints = { listener: `${EventType}-points`; event: { type: EventType; name: string; amount: number; count: number; items: items[]; tier: EventTier; month: string; isTest: true; }; }; export {}; } interface BaseEvent { provider: Provider$1; flagged: boolean; channel: string; createdAt: string; _id: string; expiresAt: string; updatedAt: string; activityId: string; sessionEventsCount: number; isMock?: boolean; } namespace Event { type Data = { listener: 'event'; event: Event; }; type Event = Tip; interface Tip extends BaseEvent { type: 'tip'; data: { amount: string; currency: string; username: string; message: string; avatar: string; }; } } } type JSONPrimitive = string | number | boolean | null; type JSONSerializable = JSONPrimitive | JSONSerializable[] | { [k: string]: JSONSerializable | undefined; }; type JSONObject = { [key: string]: JSONSerializable | undefined; }; type RequireAtLeastOne = Pick> & { [K in Keys]-?: Required> & Partial>>; }[Keys]; interface CommandOptions { prefix?: string; name: string; description?: string; arguments?: boolean; run: (this: Client, args: string[], event: CommandEvent) => void; test?: RegExp | ((command: string) => boolean); aliases?: string[]; permissions?: string[] | boolean; admins?: string[]; } type CommandEvent = { provider: 'twitch'; data: StreamElements.Event.Provider.Twitch.Message; } | { provider: 'youtube'; data: StreamElements.Event.Provider.YouTube.Message; } | { provider: 'kick'; data: any; }; declare class Command { prefix: string; name: string; description: string; arguments: boolean; test: RegExp | ((command: string) => boolean); aliases: string[]; permissions?: string[] | boolean; admins: string[]; constructor(options: CommandOptions); run(this: Client | undefined, args: string[], event: CommandEvent): void; verify(nickname: string, roles: string[], args: string[]): boolean; parse(text: string, event: CommandEvent): boolean; remove(): void; static execute(received: CommandEvent): boolean; } /** * EventProvider class for managing event listeners and emitters. * This class allows you to register event listeners, emit events, and manage event subscriptions. * @example * ```typescript * type TestEvents = { * load: [event: { type: 'load' }]; * event: [event: { type: 'event' }]; * }; * * class Test extends EventProvider {} * * const test = new Test(); * test.once('load', (data) => {}); * test.emit('load', { type: 'load' }); * * test.on('event', (data) => {}); * test.emit('event', { type: 'event' }); * ``` */ declare class EventProvider = Record> { /** * Stores registered event listeners. */ private registeredEvents; /** * Emits an event to all registered listeners. * Returns an array of return values from the listeners. * @param eventName The name of the event. * @param args Arguments to pass to the listeners. */ emit(eventName: K, ...args: EventMap[K]): any[]; /** * Registers an event listener. * @param eventName The name of the event. * @param callback The callback function. */ on(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this; /** * Removes a specific event listener. * @param eventName The name of the event. * @param callback The callback function to remove. */ off(eventName: K, callback?: (this: this, ...args: EventMap[K]) => any): this; /** * Registers a listener that is executed only once. * @param eventName The name of the event. * @param callback The callback function. */ once(eventName: K, callback: (this: this, ...args: EventMap[K]) => any): this; /** * Removes all listeners for a specific event. * @param eventName The name of the event. */ removeAllListeners(eventName: K): this; } type UseStorageEvents = { load: [T]; update: [T, from: string]; save: [T]; }; type UseStorageOptions = { /** The unique identifier for the storage instance. */ id?: string; data: T; }; declare class useStorage extends EventProvider> { private SE_API; /** The unique identifier for the storage instance. */ id: string; loaded: boolean; private initial; data: T; constructor(options: UseStorageOptions); /** * Saves the current data to storage. * @param data Data to save (defaults to current) */ private save; /** * Updates the storage data and emits an update event * @param data Data to update (defaults to current) */ update(data?: Partial): void; /** * Adds a value to the storage at the specified path. * @param path Path to add the value to * @param value Value to add */ add

(path: P, value: PathValue): void; /** * Clears all data from the storage. */ clear(): void; on>(eventName: K, callback: (this: useStorage, ...args: UseStorageEvents[K]) => void): this; } declare namespace Alejo { namespace Pronouns { type name = 'hehim' | 'sheher' | 'theythem' | 'shethem' | 'hethem' | 'heshe' | 'xexem' | 'faefaer' | 'vever' | 'aeaer' | 'ziehir' | 'perper' | 'eem' | 'itits'; type display = 'He/Him' | 'She/Her' | 'They/Them' | 'She/They' | 'He/They' | 'He/She' | 'Xe/Xem' | 'Fae/Faer' | 'Ve/Ver' | 'Ae/Aer' | 'Zie/Hir' | 'Per/Per' | 'E/Em' | 'It/Its'; enum map { hehim = "He/Him", sheher = "She/Her", theythem = "They/Them", shethem = "She/They", hethem = "He/They", heshe = "He/She", xexem = "Xe/Xem", faefaer = "Fae/Faer", vever = "Ve/Ver", aeaer = "Ae/Aer", ziehir = "Zie/Hir", perper = "Per/Per", eem = "E/Em", itits = "It/Its" } } function list(): Promise; type user = { id: string; login: string; pronoun_id: Pronouns.name; }; function get(username: string): Promise; } type ClientMapEvents = { load: [event: StreamElements.Event.onWidgetLoad]; action: [action: Button | Command, type: 'created' | 'executed' | 'removed']; session: [session: StreamElements.Session.Data]; event: ClientEventTuple; }; type ClientStorageOptions = { value: T; timestamp: number; expire: number; }; type ClientStorage = { user: Record>; avatar: Record>; pronoun: Record>; emote: Record>; }; type ClientOptions = { id?: string; debug?: boolean | (() => boolean); }; declare class Client extends EventProvider> { id: string; debug: boolean; storage: useStorage; fields: StreamElements.Event.onWidgetLoad['fieldData']; session: StreamElements.Session.Data; loaded: boolean; constructor(options: ClientOptions); actions: { commands: Command[]; buttons: Button[]; }; details: { provider: Provider$1 | 'local'; user: StreamElements.Event.onWidgetLoad['channel']; currency: StreamElements.Event.onWidgetLoad['currency']; overlay: StreamElements.Event.onWidgetLoad['overlay']; }; cache: { /** * Avatar cache duration in minutes. */ avatar: number; /** * Pronoun cache duration in minutes. */ pronoun: number; /** * Emote cache duration in minutes. */ emote: number; }; on>(eventName: K, callback: (this: Client, ...args: ClientMapEvents[K]) => void): this; } interface ButtonOptions { field: string | ((field: string, value: string | boolean | number) => boolean); template?: string; name?: string; value?: string; run: (this: Client | undefined, field: string, value: string | boolean | number) => void; } /** * Represents a button action that can be triggered by custom fields in StreamElements. * The button can be configured with a template and a name, and it will execute a specified function when triggered. * @example * ```javascript * const button = new Button({ * field: (field, value) => field.startsWith('message-') && field.split('-')[1], * template: 'message-{role}', * // name: '[CAP={role}] role message', * name: 'Generate {role} message', * run(field, value) { * console.log(`Button ${field} was clicked with value: ${value}`); * } * }) * * const field = button.generate([{ role: 'broadcaster' }, { role: 'moderator' }]); * // This will create buttons with fields "message-broadcaster" and "message-moderator" and names "Generate broadcaster message" and "Generate moderator message". * // field['message-broadcaster'] => { type: 'button', label: 'Generate broadcaster message' } * // field['message-moderator'] => { type: 'button', label: 'Generate moderator message' } * * // When a custom field with the name "message-broadcaster" or "message-moderator" is triggered, the run function will be called with the field and value. * ``` */ declare class Button { field: ButtonOptions['field']; template: string; name: string; value: string; run: ButtonOptions['run']; constructor(options: ButtonOptions); generate(values: Array>): Record; parse(field: string, value: string | boolean | number): Button; remove(): void; static execute(field: string, value: string | boolean | number): boolean; } interface Theme { color?: string; background?: string; bold?: boolean; italic?: boolean; fontSize?: number; icon?: string; } interface Options { enabled?: boolean; prefix?: string | (() => string); } type LogMethod = (...args: unknown[]) => void; declare class useLogger { enabled: boolean; prefix: string | (() => string); constructor(options?: Options); apply(theme: Theme): LogMethod; private style; group(label: string): void; groupCollapsed(label: string): void; groupEnd(): void; table(data: unknown): void; time(label: string): void; timeEnd(label: string): void; readonly error: LogMethod; readonly warn: LogMethod; readonly success: LogMethod; readonly info: LogMethod; readonly debug: LogMethod; readonly alert: LogMethod; readonly status: LogMethod; readonly received: LogMethod; readonly simple: LogMethod; } type ComfyEvents = { load: [instance: ComfyJSInstance]; error: Parameters; command: Parameters; chat: Parameters; whisper: Parameters; messageDeleted: Parameters; join: Parameters; part: Parameters; hosted: Parameters; raid: Parameters; sub: Parameters; resub: Parameters; subGift: Parameters; subMysteryGift: Parameters; giftSubContinue: Parameters; cheer: Parameters; chatMode: Parameters; reward: Parameters; connected: Parameters; reconnect: Parameters; }; /** * Creates and manages a ComfyJS instance for Twitch chat interaction. */ declare class useComfyJs extends EventProvider { instance: ComfyJSInstance; username: string; password?: string; channels: string[]; isDebug: boolean; private init; emulate: boolean; /** * Initializes a new ComfyJS instance and connects to Twitch chat. * @param options - Configuration options for ComfyJS instance. * @param emulate - Whether to emulate chat messages in the Local module. */ constructor(options: { username: string; password?: string; channels: string[]; isDebug?: boolean; init?: boolean; }, emulate: boolean); /** * Loads the ComfyJS script if not already loaded. * @returns A promise that resolves to the ComfyJS instance. */ private load; /** * Connects event handlers to the ComfyJS instance. */ private connect; } type QueueEvents = { load: []; cancel: []; update: [ queue: QueueItem[], priorityQueue: QueueItem[], history: QueueItem[], timeouts: Array> ]; process: [item: QueueItem, queue: useQueue]; }; type QueueProps = { isoDate: string; isLoop: boolean; isPriority: boolean; isImmediate: boolean; }; type QueueItem = { value: T; } & QueueProps; type QueueProcessor = (this: useQueue, item: QueueItem, queue: useQueue) => Promise | any; type QueueDuration = number | boolean | undefined; interface QueueOptions { /** * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing. */ duration?: QueueDuration | 'client'; /** * Function to process each item in the queue. */ processor: QueueProcessor; } /** * A utility class to manage a queue of items with support for priority, looping, and immediate processing. * @template T - The type of items in the queue. * @extends EventProvider> * @example * ```javascript * const myQueue = new useQueue({ * duration: 1000, * processor: async function (item) { * console.log('Processing item:', item); * }, * }); * * myQueue.enqueue('Item 1'); * myQueue.enqueue('Item 2', { isPriority: true }); * ``` */ declare class useQueue extends EventProvider> { queue: QueueItem[]; priorityQueue: QueueItem[]; history: QueueItem[]; private timeouts; duration: QueueDuration; processor: QueueProcessor; running: boolean; private loaded; private readonly clientWaitRetryDelay; constructor(options: QueueOptions); private waitForClientAndBindLoad; /** * Enqueue an item or multiple items into the queue with optional processing options. * @param value - The item or items to be enqueued. Can be a single value of type T or an array of objects containing the value and options. * @param options - Optional processing options for the item(s) being enqueued. Ignored if an array of items is provided, as each item can have its own options. * @returns The instance of the queue for chaining. * @example * ```javascript * myQueue.enqueue('Single Item', { isPriority: true }); * myQueue.enqueue([ * { value: 'Item 1', options: { isPriority: true } }, * { value: 'Item 2', options: { isLoop: true } } * ]); * ``` */ enqueue(value: T, options?: Partial): this; enqueue(items: { value: T; options?: Partial; }[]): this; private run; private next; /** * Resume processing the queue if it is paused. If the queue is already running, it will be restarted, which can be useful if new items have been added or if you want to reset the processing timer. * If the queue was empty before, it will start processing immediately. * @returns - The instance of the queue for chaining. * @example * ```javascript * myQueue.resume(); * ``` */ resume(): this; /** * Update the queue's state with new values. This can be used to replace the current queue, priority queue, history, or timeouts with new data. If the queue is not currently running and there are items in the queue after the update, it will start processing immediately. * @param save - An object containing the new state for the queue, priority queue, history, and timeouts. Each property is optional, and if not provided, the current state will be retained. * @returns - The instance of the queue for chaining. * @example * ```javascript * myQueue.update({ * queue: newQueueItems, * priorityQueue: newPriorityItems, * history: newHistory, * }); * ``` */ update(save: Partial<{ queue?: QueueItem[]; priorityQueue?: QueueItem[]; history?: QueueItem[]; }>): this; /** * Cancel all pending timeouts and stop the queue from processing further items. This will clear any scheduled processing and prevent any new items from being processed until `resume()` is called again. The current state of the queue, priority queue, and history will be retained, allowing you to resume processing later without losing any data. */ cancel(): void; /** * Check if there are any items in the queue or priority queue. This method returns `true` if there are items waiting to be processed in either the main queue or the priority queue, and `false` if both queues are empty. * @returns - A boolean indicating whether there are items in the queue or priority queue. */ hasItems(): boolean; on>(eventName: K, callback: (this: useQueue, ...args: QueueEvents[K]) => void): this; } declare namespace Data { const avatars: string[]; const badges: Twitch.GlobalBadge[]; const css_color_names: string[]; const items: any[]; const names: string[]; const tiers: string[]; const tts: string[]; const messages: string[]; const normal_messages: string[]; const twitch_messages: string[]; const youtube_messages: string[]; const emotes: (TwitchEmote | BttvEmote | SeventvEmote)[]; const ffz_emotes: { id: string; name: string; platform: string; animated: boolean; urls: { '1': string; '2': string; '4': string; }; }[]; const bttv_emotes: { id: string; name: string; platform: string; animated: boolean; urls: { '1': string; '2': string; '4': string; }; }[]; const seventv_emotes: { id: string; name: string; platform: string; animated: boolean; urls: { '1': string; '2': string; '3': string; '4': string; }; }[]; const twitch_emotes: ({ type: string; name: string; id: string; gif: boolean; animated: boolean; urls: { '1': string; '2': string; '4': string; }; start: number; end: number; } | { type: string; name: string; id: string; gif: boolean; urls: { '1': string; '2': string; '4': string; }; start: number; end: number; animated?: undefined; })[]; const youtube_emotes: { emojiId: string; shortcuts: string[]; searchTerms: string[]; image: { thumbnails: { url: string; width: number; height: number; }[]; accessibility: { accessibilityData: { label: string; }; }; }; isCustomEmoji: boolean; index: number; }[]; } /** * NumberHelper class provides utility methods for working with numbers, including translation to words, balancing within a range, rounding, and generating random numbers. */ declare class NumberHelper { /** * Translate number to words * @param num - Number to translate * @param type - Translation type * @returns - Number in words * @example * ```javascript * const cardinal = translate(42, 'cardinal'); * console.log(cardinal); // "forty-two" * const ordinal = translate(42, 'ordinal'); * console.log(ordinal); // "forty-second" * const suffix = translate(42, 'suffix'); * console.log(suffix); // "42nd" * ``` */ translate(num: number, type?: 'cardinal' | 'ordinal' | 'suffix'): string; /** * Balances a number within a specified range * @param amount - Number to balance * @param min - Minimum value * @param max - Maximum value * @param decimals - Number of decimal places to round to (default is 0) * @returns - Balanced number * @example * ```javascript * const balancedValue = balance(150, 0, 100); * console.log(balancedValue); // 100 * ``` */ balance(amount: number, min?: number, max?: number, decimals?: number): number; /** * Rounds a number to a specified number of decimal places * @param value - Number to round * @param decimals - Number of decimal places (default is 2) * @returns Rounded number * @example * ```javascript * const roundedValue = round(3.14159, 3); * console.log(roundedValue); // 3.142 * const roundedValueDefault = round(3.14159); * console.log(roundedValueDefault); // 3.14 * const roundedValueZero = round(3.14159, 0); * console.log(roundedValueZero); // 3 * ``` */ round(value: number, decimals?: number): number; /** * Generate random number * @param min - Minimum value * @param max - Maximum value * @param float - Number of decimal places (0 for integer) * @returns - Random number * @example * ```javascript * const intNumber = random(1, 10); * console.log(intNumber); // e.g. 7 * * const floatNumber = random(1, 10, 2); * console.log(floatNumber); // e.g. 3.14 * ``` */ random(min: number, max: number, float?: number): number; } interface ScaleOptions { /** * The parent element to use for scaling calculations. If not provided, the element's parent will be used. */ parent?: HTMLElement; /** * The preferred dimension to base the scaling on. Can be 'width', 'height', or 'auto' (default). */ prefer?: 'width' | 'height' | 'auto'; /** * The minimum percentage of the parent size to scale to. Default is 0. */ min?: number; /** * The maximum percentage of the parent size to scale to. Default is 1 (100%). */ max?: number; /** * A callback function that is called after scaling is applied. * @param this - The HTML element being scaled. * @param number - The scale factor applied to the element. * @param element - The HTML element being scaled. * @returns void */ apply?: (this: T, number: number, element: T) => void; } type FitTextOptions = { minFontSize?: number; maxFontSize?: number; parent?: HTMLElement; }; declare class ElementHelper { /** * Merges outer span styles with inner span styles in the provided HTML string. * @param outerStyle - The style string to be applied to the outer span. * @param innerHTML - The inner HTML string which may contain a span with its own styles. * @returns A new HTML string with merged styles applied to a single span. * @example * ```javascript * const result = mergeSpanStyles("color: red; font-weight: bold;", 'Hello World'); * console.log(result); // Output: 'Hello World' * ``` */ mergeSpanStyles(outerStyle: string, innerHTML: string, className?: string): string; /** * Scales an HTML element to fit within its parent element based on specified minimum and maximum scale factors. * @param element - The HTML element to be scaled. * @param min - Minimum scale factor (default is 0). * @param max - Maximum scale factor (default is 1). * @param options - Optional settings for scaling. * @returns - An object containing the new width, height, and scale factor, or void if not applied. * @example * ```javascript * const element = document.getElementById('myElement'); * scale(element, 0.5, 1, { return: false }); * ``` */ scale(element: HTMLElement, min?: number, max?: number, options?: { return: boolean; parent: HTMLElement; base: 'width' | 'height'; }): { width: number; height: number; scale: number; } | void; /** * Scales an HTML element to fit within its parent element based on specified options. * @param element - The HTML element to be scaled. * @param options - Optional settings for scaling. * @returns The scale factor applied to the element. * @example * ```javascript * const element = document.getElementById('myElement'); * const scaleFactor scalev2(element, { * min: 0.5, * max: 1, * prefer: 'width', * apply: (scale, el) => el.style.transform = `scale(${scale})` * }); * console.log(`Element scaled by a factor of ${scaleFactor}`); * ``` */ scalev2(element: T, options?: ScaleOptions): number; /** * Fits the text within the parent element by adjusting the font size. * @param element - The HTML element containing the text to be fitted. * @param compressor - A multiplier to adjust the fitting sensitivity (default is 1). * @param options - Optional settings for fitting text. * @returns The HTML element with adjusted font size. * @example * ```javascript * const element = document.getElementById('myTextElement'); * fitText(element, 1, { minFontSize: 12, maxFontSize: 36 }); * console.log(`Adjusted font size: ${element.style.fontSize}`); * ``` */ fitText(element: HTMLElement, compressor?: number, options?: FitTextOptions): HTMLElement; /** * Wraps formatted HTML text with containers and splits characters into indexed spans. * Adds 'container' class and data-index to all parent elements, and wraps each character in a span with class 'char' and data-index. * @param htmlString - The input HTML string containing formatted text elements (span, strong, em, etc). * @param startIndex - The starting index for the data-index attribute (default is 0). * @param preserveInterElementWhitespace - Whether to preserve whitespace between elements (default is false). * @param options - Optional settings for splitting text, including skipWhitespaceIndex to control index incrementing for whitespace characters. * @returns - A new HTML string with containers and character-level indexing. * @example * ```javascript * const result = splitTextToChars('TesTe bold', 0); * console.log(result); * // Output: 'Te...' * * // Example with skipWhitespaceIndex * const resultSkipWhitespace = splitTextToChars('Hello World', 0, false, { skipWhitespaceIndex: true }); * // The space character will have data-index but won't increment index for subsequent characters * ``` */ splitTextToChars(htmlString: string, startIndex?: number, preserveInterElementWhitespace?: boolean, options?: { /** * If true, skips incrementing the index for whitespace characters (space, newline, tab). * These characters will still have a data-index, but it won't be incremented for subsequent characters. * Default is true. */ skipWhitespaceIndex?: boolean; }): string; /** * Retrieves CSS variables defined in the stylesheets of the document for a given selector, with optional filtering and helper variable exclusion. * @param selector - The CSS selector to search for (default is ':root' to target global variables). * @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. * @param options - Optional settings for retrieving CSS variables, including filterHelpers to exclude common helper variables (those ending with -min, -max, or -step). * @returns - An array of [key, value] pairs representing the CSS variables that match the selector and filter criteria. * @example * ```javascript * // Retrieve all CSS variables defined under :root * const variables = getElementCSSVariables(); * console.log(variables); * // Retrieve CSS variables defined under a specific selector, e.g., .my-class * const classVariables = getElementCSSVariables('.my-class'); * console.log(classVariables); * // Retrieve CSS variables with a custom filter, e.g., only variables that include 'color' in their name * const colorVariables = getElementCSSVariables(':root', ([key]) => key.includes('color')); * console.log(colorVariables); */ getElementCSSVariables(selector?: string, filter?: ([k, v]: [string, string], i: number, array: [string, string][]) => boolean, options?: { filterHelpers?: boolean; }): [string, string][]; /** * Applies CSS styles to an HTML or SVG element, supporting both standard and custom properties, as well as '!important' values. * @param element - The target HTML or SVG element to which the styles will be applied. * @param styles - An object containing CSS property-value pairs. Property names can be in camelCase or kebab-case, and values can include '!important'. * @example * ```javascript * CSS(document.getElementById('myElement'), { * backgroundColor: 'red', * '--custom-var': '10px', * color: 'blue !important', * }); * ``` */ CSS(element: HTMLElement | SVGElement, styles: Partial>): void; /** * Escapes special HTML characters in a string to prevent XSS attacks and ensure safe rendering in HTML contexts. * @param value - The input string that may contain special HTML characters such as &, <, >, ", and '. * @returns A new string with special HTML characters replaced by their corresponding HTML entities. * @example * ```javascript * const unsafeString = ''; * const safeString = escapeHtml(unsafeString); * console.log(safeString); // Output: '<script>alert("XSS")</script>' * ``` */ escapeHtml(value: string): string; /** * Get the relative position of a square * @param dimensions - The square dimensions and positions * @returns All the relative positions * @example * ```js * const positions = relativePositions({ width: 10, height: 10, left: 20, top: 20 }); * // positions.center = { x: 25, y: 25 } * // positions.bottom = { x: 25, y: 30 } * // ... * ``` */ relativePositions({ width, height, left, top, }: { width: number; height: number; left: number; top: number; }): { center: { x: number; y: number; }; top: { x: number; y: number; }; bottom: { x: number; y: number; }; left: { x: number; y: number; }; right: { x: number; y: number; }; 'top-left': { x: number; y: number; }; 'top-right': { x: number; y: number; }; 'bottom-left': { x: number; y: number; }; 'bottom-right': { x: number; y: number; }; }; getRelativePositionToAncestor(element: HTMLElement, ancestor: HTMLElement): { left: number; top: number; width: number; height: number; }; svg: { getDimensionsFromViewBox(svgElement: SVGElement | string): { width: number; height: number; }; }; } type CSSValue = string | number | null | undefined; declare class ObjectHelper { /** * Flattens a nested object into a single-level object with dot-separated keys. * @param obj - The nested object to be flattened. * @param prefix - The prefix to be added to each key (used for recursion). * @returns A flattened object with dot-separated keys. * @example * ```javascript * const nestedObj = { a: { b: 1, c: { d: 2 } }, e: [3, 4] }; * const flatObj = flatten(nestedObj); * console.log(flatObj); * // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' } * ``` */ flatten(obj: Record, stringify?: boolean, prefix?: string): Record; /** * Returns the entries of an object as an array of key-value pairs, with proper typing. * @param obj - The object to retrieve entries from. * @returns An array of key-value pairs from the object, typed as an array of tuples with key and value types. */ entries(obj: Record): [K, V][]; /** * Returns the values of an object as an array, with proper typing. * @param obj - The object to retrieve values from. * @returns An array of values from the object, typed as an array of the value type. */ values(obj: Record): V[]; /** * Returns the keys of an object as an array of strings, with proper typing. * @param obj - The object to retrieve keys from. * @returns An array of keys from the object, typed as an array of strings. */ keys(obj: Record): K[]; /** * Updates a value in a nested object at the specified path, with an option to create missing intermediate objects. * @param obj - The target object to update. * @param path - The path to the property being updated. * @param value - The value to set at the specified path. * @param createMissing - Whether to create missing intermediate objects along the path if they don't exist. * @returns The updated object with the new value set at the specified path. * @example * ```javascript * const obj1 = { a: { b: 1 }, c: 2 }; * updateViaPath(obj1, 'a.d', 9999, false); * console.log(obj1); * // Output: { a: { b: 1, d: 9999 }, c: 2 } * * const obj2 = { a: { b: 1 }, c: 2 }; * updateViaPath(obj2, 'a.e.f', 8888, true); * console.log(obj2); * // Output: { a: { b: 1, e: { f: 8888 } }, c: 2 } * ``` * @returns The updated object with the new value set at the specified path. */ updateViaPath

(obj: T, path: P, value: PathValue, createMissing?: boolean): T; /** * Compares two values for differences, with an option to use JSON stringification for comparison. * @param a - The first value to compare. * @param b - The second value to compare. * @param method - The method to use for comparison, either 'json' for JSON stringification or 'default' for a recursive comparison. * @returns A boolean indicating whether the two values are different based on the specified comparison method. */ isDiff(a: any, b: any, method?: 'json' | 'default'): boolean; } type BadgeOptions = Twitch.tags[] | Twitch.tags | `${Twitch.tags}/${string}` | `${Twitch.tags}/${string}`[]; type TwitchResult = { keys: Twitch.tags[]; badges: Twitch.badge[]; versions: { [K in Twitch.tags]?: string | number; }; amount: { [K in Twitch.tags]?: string | number; }; }; type YouTubeResult = { isVerified: boolean; isChatOwner: boolean; isChatSponsor: boolean; isChatModerator: boolean; }; declare class MessageHelper { /** * Finds emotes in a given text. * @param text - The text to search for emotes. * @param emotes - An array of emotes to search for. Defaults to Local data emotes. * @returns An array of emotes found in the text with their positions. */ findEmotesInText(text: string, emotes?: Emote[]): Emote[]; /** * Replaces emotes in the text with corresponding HTML image tags. * @param text - The text containing emotes. * @param emotes - An array of emotes with their positions in the text. * @returns The text with emotes replaced by HTML image tags. */ replaceEmotesWithHTML(text: string, emotes: Emote[]): string; /** * Checks if the text contains only emotes and whitespace. * @param text - The text to check. * @param emotes - An array of emotes with their positions in the text. * @returns True if the text contains only emotes and whitespace, false otherwise. */ hasOnlyEmotes(text: string, emotes: Emote[]): boolean; /** * Replaces YouTube emotes in the text with corresponding HTML image tags. * @param text - The text containing YouTube emotes. * @param emotes - An array of YouTube emotes. Defaults to Local data YouTube emotes. * @returns The text with YouTube emotes replaced by HTML image tags. */ replaceYoutubeEmotesWithHTML(text: string, emotes?: { emojiId: string; shortcuts: string[]; searchTerms: string[]; image: { thumbnails: { url: string; width: number; height: number; }[]; accessibility: { accessibilityData: { label: string; }; }; }; isCustomEmoji: boolean; index: number; }[]): string; /** * Maps global badge versions to a structured format. * @param globalBadges - An array of Twitch global badges. Defaults to Local data badges. * @returns An array of objects containing badge IDs and their corresponding versions. * @example * ```javascript * const badgeVersions = mapGlobalBadgeVersions(); * console.log(badgeVersions); * // Output: * [ * { * id: 'subscriber', * versions: [ * { type: 'subscriber', version: '1', url: 'https://...', description: 'Subscriber' }, * { type: 'subscriber', version: '2', url: 'https://...', description: '2-Month Subscriber' }, * // ... more versions * ], * }, * { * id: 'bits', * versions: [ * { type: 'bits', version: '100', url: 'https://...', description: 'cheer 100' }, * { type: 'bits', version: '1000', url: 'https://...', description: 'cheer 1000' }, * // ... more versions * ], * }, * // ... more badges * ] * ``` */ mapGlobalBadgeVersions(globalBadges?: Twitch.GlobalBadge[]): Array<{ id: Twitch.tags; versions: Twitch.badge[]; }>; /** * Maps a badge type and variation to the corresponding badge version amount. * @param type - The badge type (e.g., 'subscriber', 'bits', etc.). * @param variation - The badge variation, which can be a number or a string (e.g., 'horde', 'alliance', etc.). * @returns The badge version amount as a string. Returns '0' if no matching badge version is found. * @example * ```javascript * // For subscriber badge with 3 months * mapGlobalBadgeVersionAmount('subscriber', 3); // Returns '3' * // For bits badge with 5000 bits * mapGlobalBadgeVersionAmount('bits', 5000); // Returns the corresponding badge version based on the mapping * // For warcraft badge with 'horde' variation * mapGlobalBadgeVersionAmount('warcraft', 'horde'); // Returns 'horde' * ``` */ mapGlobalBadgeVersionAmount(type: Twitch.tags, variation: string | number): string; badgePriority: Twitch.tags[]; /** * Generates badge data based on the provided badges and platform. * @param badges - The badges to generate. Can be an array or a comma-separated string. * @param provider - The platform provider ('twitch' or 'youtube'). Defaults to 'twitch'. * @returns A promise that resolves to the generated badge data. * @example * ```javascript * // Generate Twitch badges * const twitchBadges = await generateBadges(['broadcaster', 'moderator'], 'twitch'); * // Generate YouTube badges * const youtubeBadges = await generateBadges('sponsor, moderator', 'youtube'); * ``` */ generateBadges(badges: BadgeOptions | undefined, provider: T): Promise; } declare class RandomHelper { /** * Generate random color * @param type - Color format * @returns - Random color in specified format * @example * ```javascript * const hexColor = random.color('hex'); * console.log(hexColor); // e.g. #3e92cc * * const rgbColor = random.color('rgb'); * console.log(rgbColor); // e.g. rgb(62, 146, 204) * ``` */ color(type?: 'hex' | 'hexa' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): string; /** * Generate random number * @param min - Minimum value * @param max - Maximum value * @param float - Number of decimal places (0 for integer) * @returns - Random number * @example * ```javascript * const intNumber = random.number(1, 10); * console.log(intNumber); // e.g. 7 * * const floatNumber = random.number(1, 10, 2); * console.log(floatNumber); // e.g. 3.14 * ``` */ number(min: number, max: number, float?: number): number; /** * Generate random boolean * @param threshold - Threshold between 0 and 1 * @returns - Random boolean * @example * ```javascript * const boolValue = random.boolean(0.7); * console.log(boolValue); // e.g. true (70% chance) * ``` */ boolean(threshold?: number): boolean; /** * Generate random string * @param length - Length of the string * @param chars - Characters to use * @returns - Random string * @example * ```javascript * const randString = random.string(10); // e.g. "aZ3bT9qP1x" * const randHex = random.string(8, 'hex'); // e.g. "4f3c2a1b" * const randNumStr = random.string(6, 'numbers'); // e.g. "839201" * const randLetterStr = random.string(6, 'letters'); // e.g. "aZbTqP" * const randHexUpper = random.string(6, 'hex-upper'); // e.g. "4F3C2A1B" * const randHexLower = random.string(6, 'hex-lower'); // e.g. "4f3c2a1b" * ``` */ string(length: number, chars?: 'numeric' | 'numbers' | 'letters' | 'hex' | 'hex-upper' | 'hex-lower' | string): string; /** * Pick random element from array * @param arr - Array to pick from * @returns - Random element and its index * @example * ```javascript * const [element, index] = random.array(['apple', 'banana', 'cherry']); * console.log(element, index); // e.g. "banana", 1 * ``` */ array(arr: T[]): [value: T, index: number]; /** * Generate random date * @param start - Start date * @param end - End date * @returns - Random date between start and end * @example * ```javascript * const randDate = random.date(new Date(2020, 0, 1), new Date()); * console.log(randDate); // e.g. 2022-05-15T10:30:00.000Z * ``` */ date(start?: Date, end?: Date): Date; /** * Generate ISO date string offset by days * @param daysAgo - Number of days to go back * @returns - ISO date string * @example * ```javascript * const isoDate = random.daysOffset(7); * console.log(isoDate); // e.g. "2024-06-10T14:23:45.678Z" * * const isoDate30 = random.daysOffset(30); * console.log(isoDate30); // e.g. "2024-05-18T09:15:30.123Z" * ``` */ daysOffset(daysAgo: number): string; /** * Generate UUID v4 * @returns - UUID string * @example * ```javascript * const uuid = random.uuid(); * console.log(uuid); // e.g. "3b12f1df-5232-4e3a-9a0c-3f9f1b1b1b1b" * ``` */ uuid(): string; } declare class EventHelper { /** * Parses the provider information from the event detail object. * @param detail - The event detail object received from the StreamElements event. * @returns An object containing the provider and the original event data. */ parseProvider(detail: StreamElements.Event.onEventReceived, overrideProvider?: Provider$1): ClientEvents; } type Modifier = (value: string, param: string | null | undefined, values: { amount?: number; count?: number; }) => string; declare class StringHelper { /** * Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function. * @param string - The input string to perform replacements on. * @param pattern - The pattern to match in the string (can be a string or a regular expression). * @param callback - An asynchronous callback function that takes the matched substring and any captured groups as arguments and returns the replacement string. * @returns A promise that resolves to the modified string with replacements applied. * @example * ```javascript * const result = await string.replace("Hello World", /World/, async (match) => { * return await fetchSomeData(match); // Assume this function fetches data asynchronously * }); * console.log(result); // Output will depend on the fetched data * ``` */ replace(string: string, pattern: string, callback: (match: string, ...groups: string[]) => Promise | string): Promise; /** * Capitalizes the first letter of a given string. * @param string - The input string to be capitalized. * @returns The capitalized string. * @example * ```javascript * const result = string.capitalize("hello world"); * console.log(result); // Output: "Hello world" * ``` */ capitalize(string: string): Capitalize; PRESETS: Record; /** * Composes a template string by replacing placeholders with corresponding values and applying optional modifiers. * @param template - The template string containing placeholders in the format {key} and optional modifiers in the format [MODIFIER:param=value]. * @param values - An object containing key-value pairs to replace the placeholders in the template. * @param options - Optional settings for the composition process. * @returns The composed string with placeholders replaced and modifiers applied. * @example * ```javascript * const { string } = Tixyel.Helper; * * // Basic usage with placeholders and simple modifiers * const template1 = "Hello, {username}! You have {amount} [UPC=messages] and your name is [CAP=name]."; * const values1 = { username: "john_doe", amount: 5, name: "john" }; * const result1 = string.compose(template1, values1); * // "Hello, john_doe! You have 5 MESSAGES and your name is John." * * // Multiple modifiers in a single block (HTML enabled) * const template2 = "[COLOR:#ff0056,BOLD={username}]"; * const values2 = { username: "john_doe" }; * const result2 = string.compose(template2, values2, { html: true }); * // 'john_doe' * * // Conditional rendering with IF (supports ===, >=, &&, ||, !, etc.) * const template3 = "[IF=vip && status === 'live'?VIP Online|Offline]"; * const values3 = { status: 'live', vip: true }; * const result3 = string.compose(template3, values3); * // "VIP Online" * * // Pluralization using amount / count or an explicit key * const template4 = "You have {amount} [PLURAL=message|messages]."; * const values4 = { amount: 1 }; * const values5 = { amount: 3 }; * const result4a = string.compose(template4, values4); // "You have 1 message." * const result4b = string.compose(template4, values5); // "You have 3 messages." * * // Number formatting * const template5 = "Total: [NUMBER:2=amount] {currency}"; * const values6 = { amount: 1234.5, currency: '$' }; * const result5 = string.compose(template5, values6); * // e.g. "Total: 1,234.50 $" (locale dependent) * * // Date and time formatting * const template6 = "Created at: [DATE:iso=createdAt] ([DATE:relative=createdAt])"; * const values7 = { createdAt: new Date('2020-01-02T03:04:05.000Z') }; * const result6 = string.compose(template6, values7); * // e.g. "Created at: 2020-01-02T03:04:05.000Z (Xs ago)" * * // MAP / SWITCH style mapping * const template7 = "Status: [MAP:status=live:Online|offline:Offline|default:Unknown]"; * const values8 = { status: 'offline' }; * const result7 = string.compose(template7, values8); * // "Status: Offline" * * // Escaping HTML * const template8 = "[ESCAPE={message}]"; * const values9 = { message: 'Danger & "HTML"' }; * const result8 = string.compose(template8, values9); * // "<b>Danger & "HTML"</b>" * * // Using global presets * Helper.string.PRESETS['alert'] = 'BOLD,COLOR:#ff0056'; * const template10 = "[PRESET:alert={username}]"; * const values11 = { username: 'john_doe' }; * const result10 = string.compose(template10, values11, { html: true }); * // 'john_doe' * ``` */ compose(template: string, values?: Record, options?: { method?: 'loop' | 'index'; html?: boolean; debug?: boolean; modifiers?: Record; aliases?: Record; }): string; /** * Removes newline characters from a string and replaces them with spaces. * @param string - The input string from which to remove newline characters. * @returns The modified string with newline characters replaced by spaces. * @example * ```javascript * const result = string.removeNewlines("Hello\nWorld\r\nThis is a test."); * console.log(result); // Output: "Hello World This is a test." * ``` */ removeNewlines(string: string): string; removeExtraSpaces(string: string): string; } declare class ColorHelper { /** * Generate opacity hex value * @param opacity - Opacity value from 0 to 100 * @param color - Hex color code * @returns - Hex color code with opacity */ opacity(opacity?: number, color?: string): string; /** * Extract color and opacity from hex code * @param hex - Hex color code * @returns - Object with color and opacity */ extract(hex: string): { color: string; opacity: number; }; /** * Validate color string format * @param str - Color string to validate * @returns Detected color format or false if invalid * @example * ```javascript * const format1 = color.validate("#FF5733"); // "hex" * const format2 = color.validate("rgb(255, 87, 51)"); // "rgb" * const format3 = color.validate("hsl(14, 100%, 60%)"); // "hsl" * const format4 = color.validate("orangered"); // "css-color-name" * const format5 = color.validate("invalid-color"); // false * ``` */ validate(str: string): false | "hex" | "rgb" | "rgba" | "hsl" | "hsla" | "css-color-name"; /** * Convert color to different format * @param str - Color string to convert (e.g. "#FF5733", "rgb(255, 87, 51)") * @param format - Target format * @returns - Converted color string * @example * ```javascript * const hexColor = color.convert("rgb(255, 87, 51)", "hex"); // "#FF5733" * const rgbColor = color.convert("#FF5733", "rgb"); // "rgb(255, 87, 51)" * const hslColor = color.convert("#FF5733", "hsl"); // "hsl(14, 100%, 60%)" * const colorName = color.convert("#FF5733", "css-color-name"); // "orangered" * ``` */ convert(str: string, format: 'hex' | 'rgb' | 'rgba' | 'hsl' | 'hsla' | 'css-color-name'): Promise; } declare class SoundHelper { playing: boolean; audio: AudioContext; /** * Play sound from URL with optional volume and replace parameters * @param url - Sound URL to play * @param volume - Volume level from 0 to 100 (default: 100) * @param replace - If true, replaces currently playing sound (default: false) */ play(url: string, volume?: number, replace?: boolean): void; } declare class FunctionHelper { /** * Apply function with given thisArg and arguments * @param fn - Function to apply * @param thisArg - Value to use as this when calling fn * @param args - Arguments to pass to fn * @returns Result of calling fn with thisArg and args */ apply(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, args: TArgs): TReturn; /** * Call function with given thisArg and arguments * @param fn - Function to call * @param thisArg - Value to use as this when calling fn * @param args - Arguments to pass to fn * @returns Result of calling fn with thisArg and args */ call(fn: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, ...args: TArgs): TReturn; } declare class UtilsHelper { /** * Delays execution for a specified number of milliseconds. * @param ms - The number of milliseconds to delay. * @returns A Promise that resolves after the specified delay. */ delay(ms: M, callback?: () => R): Promise; /** * Returns typed entries of an object. * @param obj - The object to get entries from. * @returns An array of key-value pairs from the object. */ typedEntries(obj: Record | Array): [K, V][]; /** * Returns typed values of an object. * @param obj - The object to get values from. * @returns An array of values from the object. */ typedValues(obj: Record | Array): V[]; /** * Returns typed keys of an object. * @param obj - The object to get keys from. * @returns An array of keys from the object. */ typedKeys(obj: Record | Array): K[]; /** * Compares two dates and returns the difference in multiple time units. * * `total` values are based on raw milliseconds (can be decimal). * `calendar` values use calendar boundaries for full months/years. */ compareDates(date1: Date | string, date2: Date | string): { milliseconds: number; seconds: number; minutes: number; hours: number; days: number; months: number; years: number; absolute: { milliseconds: number; seconds: number; minutes: number; hours: number; days: number; months: number; years: number; }; calendar: { months: number; years: number; }; isFuture: boolean; isPast: boolean; isSameMoment: boolean; }; /** * Selects an item based on weighted probabilities. * @param items - An object where keys are items and values are their weights. * @returns A randomly selected item based on the given probabilities. * @example * ```ts * const utils = new UtilsHelper(); * const result = utils.probability({ * apple: 0.5, * banana: 0.3, * cherry: 0.2, * }); * console.log(result); // 'apple', 'banana', or 'cherry' based on the defined probabilities * ``` */ probability(items: Record): K | undefined; /** * Finds the subscription tier of a user based on various sources of information. * @param data - An object containing userId, name, and broadcasterId to identify the user. * @param session - The current session data which may contain recent subscription information. * @param checkWithAPI - Whether to check the subscription tier with an external API as a last resort. * @returns A promise that resolves to the subscription tier of the user (1, 2, or 3). * @example * ```javascript * const utils = new UtilsHelper(); * const tier = await utils.findSubscriptionTier( * { userId: '12345', name: 'exampleUser', broadcasterId: '67890' }, * sessionData, * true * ); * console.log(tier); // 1, 2, or 3 based on the user's subscription tier * ``` */ findSubscriptionTier({ userId, name, broadcasterId, }: { userId: string; name: string; broadcasterId?: string; }, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<1 | 2 | 3>; /** * Identifies a user based on the received event and session data, returning their ID, name, role, badges, and top status. * @param receivedEvent - The event received from the provider (Twitch or YouTube) containing user information. * @param session - The current session data which may contain recent activity and top user information. * @returns A promise that resolves to an object containing the user's ID, name, role, badges, and top status, or undefined if the user cannot be identified. * @example * ```javascript * const utils = new UtilsHelper(); * const userInfo = await utils.identifyUser(receivedEvent, sessionData); * console.log(userInfo); * // { * // id: '12345', * // name: 'exampleUser', * // role: 'moderator', * // badges: [{ type: 'moderator', version: '1', url: 'https:...', description: 'Moderator' }], * // top: { * // gifter: false, * // tip: { * // session: { donator: false, donation: false }, * // weekly: { donator: false, donation: false }, * // monthly: { donator: false, donation: false }, * // alltime: { donator: false, donation: false }, * // }, * // ... * // } * // } * ``` */ identifyUser(provider: 'twitch', receivedEvent: StreamElements.Event.Provider.Twitch.Message, session: StreamElements.Session.Data): Promise; identifyUser(provider: 'youtube', receivedEvent: StreamElements.Event.Provider.YouTube.Message, session: StreamElements.Session.Data): Promise; getTops(name: string, session: StreamElements.Session.Data): { gifter: boolean; tip: { session: { donator: boolean; donation: boolean; }; weekly: { donator: boolean; donation: boolean; }; monthly: { donator: boolean; donation: boolean; }; alltime: { donator: boolean; donation: boolean; }; }; cheer: { session: { donator: boolean; amount: boolean; }; weekly: { donator: boolean; amount: boolean; }; monthly: { donator: boolean; amount: boolean; }; alltime: { donator: boolean; amount: boolean; }; }; superchat: { session: { donator: boolean; amount: boolean; }; weekly: { donator: boolean; amount: boolean; }; monthly: { donator: boolean; amount: boolean; }; alltime: { donator: boolean; amount: boolean; }; }; }; identifyMessage(provider: 'twitch', receivedEvent: StreamElements.Event.Provider.Twitch.Message, options?: { mapEmote?: (emote: { src: string; alt: string; }) => string; allowedRoles: RequireAtLeastOne[]; }): { username: string; text: string; reply: { login: string; name: string; userId: string; msgId: string; text: string; } | undefined; msgId: string; userId: string; emote: { only: boolean; amount: number; }; }; } type TopType = { gifter: boolean; tip: { session: { donator: boolean; donation: boolean; }; weekly: { donator: boolean; donation: boolean; }; monthly: { donator: boolean; donation: boolean; }; alltime: { donator: boolean; donation: boolean; }; }; cheer: { session: { donator: boolean; amount: boolean; }; weekly: { donator: boolean; amount: boolean; }; monthly: { donator: boolean; amount: boolean; }; alltime: { donator: boolean; amount: boolean; }; }; superchat: { session: { donator: boolean; amount: boolean; }; weekly: { donator: boolean; amount: boolean; }; monthly: { donator: boolean; amount: boolean; }; alltime: { donator: boolean; amount: boolean; }; }; }; type IdentifyTwitchResult = { id: string; name: string; color: string; role: Twitch.tags; tags: Twitch.tags[]; badges: Twitch.badge[]; tier?: 1 | 2 | 3; top: TopType; }; type IdentifyYouTubeResult = { id: string; name: string; role: 'broadcaster' | 'moderator' | 'sponsor' | 'verified' | 'viewer'; badges: unknown[]; top: TopType; }; type Point = { x: number; y: number; }; type AnimOptions = { /** Duration in seconds. Default: `1` */ duration?: number; fps?: number; easing?: (t: number) => number; }; type AnimResult = { x: number[]; y: number[]; }; type QuadraticParams = AnimOptions & { from: Point; to: Point; control: Point; }; type CubicParams = AnimOptions & { from: Point & { control: Point; }; to: Point & { control: Point; }; }; type MultiCubicPoint = Point & { control?: Point; controlIn?: Point; controlOut?: Point; }; type MultiCubicParams = AnimOptions & { points: [MultiCubicPoint, MultiCubicPoint, MultiCubicPoint, ...MultiCubicPoint[]]; }; type CircleParams = AnimOptions & { center: Point; radius: number; from?: number; to?: number; }; type SpiralParams = AnimOptions & { center: Point; radius: { from: number; to: number; }; turns?: number; }; declare class AnimateHelper { /** * Interpolate a number from start to end * @example * ```ts * const value = animate.lerp(0, 100, 0.5); * console.log(value); // 50 * // Clamped between 0 and 1 * const clamped = animate.lerp(0, 100, 1.5); * console.log(clamped); // 100 * const clamped2 = animate.lerp(0, 100, -0.5); * console.log(clamped2); // 0 * const easeIn = animate.lerp(0, 100, (t) => t * t); * console.log(easeIn); // 25 at t=0.5 * const linear = animate.lerp(0, 100, 0.5); * console.log(linear); // 50 at t=0.5 * // Ease-in should be less than linear at t=0.5 * console.log(easeIn < linear); // true * ``` */ lerp(start: number, end: number, t: number): number; /** * Create a quadratic Bezier path between two positions using a control point. * Returns sampled x/y coordinates for the animation timeline. * @example * ```ts * const { x, y } = animate.quadratic({ * from: { x: 0, y: 0 }, * to: { x: 100, y: 0 }, * control: { x: 50, y: 50 }, * duration: 1, * fps: 60, * easing: Motion.easeInOut, * }); * * // Use with Motion.animate * Motion.animate(element, { x, y }, { duration: 1 }); * ``` */ quadratic({ from, to, control, duration, fps, easing, }: QuadraticParams): AnimResult; /** * Create a cubic Bezier path between two positions using two control points. * Returns sampled x/y coordinates for the animation timeline. * @example * ```ts * const { x, y } = animate.cubic({ * from: { x: 0, y: 0, control: { x: 50, y: 100 } }, * to: { x: 200, y: 0, control: { x: 150, y: 100 } }, * duration: 2, * fps: 60, * easing: Motion.easeInOut, * }); * ``` */ cubic({ from, to, duration, fps, easing }: CubicParams): AnimResult; private getMultiCubicOutgoingControl; private getMultiCubicIncomingControl; /** * Create a chained cubic Bezier path using 3 or more points. * First and last points use a single control handle. * Middle points can use separate incoming and outgoing handles. * * Every consecutive pair creates one cubic segment: * `P0 = points[i]`, `P1 = points[i].controlOut`, `P2 = points[i + 1].controlIn`, `P3 = points[i + 1]`. * * For compatibility, `control` is treated as a shared handle when `controlIn` or `controlOut` * are not provided. * @example * ```ts * const { x, y } = animate.multiCubic({ * points: [ * { x: 0, y: 0, control: { x: 20, y: 40 } }, * { * x: 100, * y: 0, * controlIn: { x: 80, y: 60 }, * controlOut: { x: 120, y: -20 }, * }, * { x: 200, y: 50, control: { x: 160, y: 120 } }, * ], * duration: 2, * fps: 60, * easing: Motion.easeInOut, * }); * ``` */ multiCubic({ points, duration, fps, easing }: MultiCubicParams): AnimResult; /** * Create a circular path around a center point. * Angles in degrees. Default: `from: 0`, `to: 360`. * @example * ```ts * const { x, y } = animate.circle({ * center: { x: 100, y: 100 }, * radius: 50, * from: 0, * to: 360, * duration: 3, * fps: 60, * }); * ``` */ circle({ center, radius, from, to, duration, fps, easing, }: CircleParams): AnimResult; /** * Create a spiral path around a center point. * @example * ```ts * const { x, y } = animate.spiral({ * center: { x: 0, y: 0 }, * radius: { from: 10, to: 100 }, * turns: 3, * duration: 2, * fps: 60, * easing: (t) => 1 - (1 - t) * (1 - t), * }); * * // This will create a spiral that starts at radius 10 and expands to radius 100 over 3 turns. * ``` */ spiral({ center, radius, turns, duration, fps, easing, }: SpiralParams): AnimResult; /** * Chain multiple animation paths together sequentially. * @example * ```ts * const path1 = animate.quadratic({ * from: { x: 0, y: 0 }, * to: { x: 100, y: 0 }, * control: { x: 50, y: 50 }, * duration: 1, * fps: 60, * }); * * const path2 = animate.circle({ * center: { x: 100, y: 0 }, * radius: 30, * from: 0, * to: 180, * duration: 1, * fps: 60, * }); * * const combined = animate.chain(path1, path2); * ``` */ chain(...animations: AnimResult[]): AnimResult; /** * Execute multiple animations in sequence with optional delays between them. * Each animation will be sampled and delays will add repeating the last coordinate. * @example * ```ts * const path1 = animate.quadratic({ from: { x: 0, y: 0 }, to: { x: 50, y: 0 }, control: { x: 25, y: 25 }, duration: 0.5, fps: 30 }); * const path2 = animate.quadratic({ from: { x: 50, y: 0 }, to: { x: 100, y: 0 }, control: { x: 75, y: 25 }, duration: 0.5, fps: 30 }); * * // 30 frames delay between animations * const sequenced = animate.sequence([path1, path2], 30); * ``` */ sequence(animations: AnimResult[], delayFrames?: number | number[]): AnimResult; } declare class SEHelper { /** * Assign StreamElements custom field schemas from a given data object, with optional prefixing and grouping * @param data - Object containing StreamElements custom field schemas to assign * @param prefix - Optional string to prefix each field key with * @param assign - Optional object to assign the resulting field schemas to (defaults to a new object) * @param group - Optional string to group the fields under (will use existing group if not provided) * @returns - Object containing the assigned StreamElements custom field schemas * @example * ```javascript * const data = { * 'field1': { type: 'text', label: 'Field 1', value: 'Value 1' }, * 'field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000' }, * 'field3': { type: 'number', label: 'Field 3', value: 10, min: 0, max: 100, step: 1 }, * } * * const fields = assignFields(data, 'prefix-', {}, 'Group 1'); * * console.log(fields); * // Output: * // { * // 'prefix-field1': { type: 'text', label: 'Field 1', value: 'Value 1', group: 'Group 1' }, * // 'prefix-field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000', group: 'Group 1' }, * // 'prefix-field3': { type: 'number', label: 'Field 3', value: 10, min: 0, max: 100, step: 1, group: 'Group 1' }, * // } * ``` */ assignFields(data: Record, prefix?: string, assign?: Record, group?: string): Record | undefined; /** * Check for errors in StreamElements custom fields and throw an error if any are found * @param fields - Object containing StreamElements custom field schemas to check for errors * @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 * @example * ```javascript * const fields = { * 'field1': { type: 'text', label: 'Field 1', value: 'Value 1' }, * 'field2': { type: 'colorpicker', label: 'Field 2', value: '#ff0000' }, * 'field3': { type: 'hidden', label: 'Hidden Field' }, * 'field4': { type: 'button', label: 'Button Field' }, * 'field5': { type: 'text', label: 'Undefined Value Field' }, * } * * checkFieldErrors(fields); * * // Output: * // Error: StreamElements custom fields have errors: field5 (Undefined Value Field) * ``` */ checkFieldErrors(fields: Record): void; /** * Transform CSS variables into StreamElements custom fields * @param data - Array of CSS variable entries (name and value) * @param method - Whether to determine field type based on variable name or value * @param replace - Function to modify the field label based on the variable name * @param subgroup - Function to determine subgrouping of fields based on variable name and value * @returns - Object containing StreamElements custom field schemas * @example * ```javascript * const cssVariables = [ * ['--primary-gradient-color', '#ff0000'], * ['--secondary-gradient-color', '#00ff00'], * ]; * const fields = transformCSSIntoFields( * cssVariables, * 'name', * (x) => x.replace('gradient', '').trim(), * (key, value) => { * if (key.includes('gradient')) return 'Gradients'; * return null; * } * ); * * console.log(fields); * * /* Output: * { * '/Gradients': { * type: 'hidden', * label: 'Gradients', * }, * '--primary-gradient-color': { * type: 'colorpicker', * label: 'Primary color', * value: '#ff0000', * }, * '--secondary-gradient-color': { * type: 'colorpicker', * label: 'Secondary color', * value: '#00ff00', * }, * } * ``` */ transformCSSIntoFields(data: [string, string][], method?: 'name' | 'value', replace?: (name: string) => string, subgroup?: (key: string, value: string) => string | null): Record; /** * Split a long text into multiple StreamElements custom fields with a specified maximum label length, using a key prefix for the field keys * @param keyPrefix - Prefix to use for the field keys (e.g., 'field' will create keys like 'field[0]', 'field[1]', etc.) * @param text - The long text to split into multiple fields * @param maxLabelLength - The maximum length for each field label (default is 31 characters, which is the maximum allowed by StreamElements) * @returns An object containing the generated StreamElements custom field schemas with split labels * @example */ splitFieldLabel(keyPrefix: string, text: string, maxLabelLength?: number): { [k: string]: StreamElements.CustomField.Schema; }; } declare namespace Helper { const animate: AnimateHelper; const number: NumberHelper; const element: ElementHelper; const object: ObjectHelper; const message: MessageHelper; const event: EventHelper; const string: StringHelper; const sound: SoundHelper; const color: ColorHelper; const random: RandomHelper; const fn: FunctionHelper; const utils: UtilsHelper; const streamelements: SEHelper; } declare class Emulator { twitch: { message(data?: Partial<{ name: string; message: string; badges: BadgeOptions; color: string; userId: string; msgId: string; channel: string; time: number; firstMsg: boolean; returningChatter: boolean; reply: { msgId: string; userId: string; login: string; name: string; text: string; }; thread: { msgId: string; name: string; }; }>): void; deleteMessage(msgId: string): void; deleteMessages(userId: string): void; follower(data?: Partial<{ avatar: string; name: string; }>): void; raid(data?: Partial<{ amount: number; avatar: string; name: string; }>): void; cheer(data?: Partial<{ amount: number; avatar: string; name: string; message: string; }>): void; subscriber(data?: Partial<{ tier: "1000" | "2000" | "3000" | "prime"; amount: number; avatar: string; name: string; sender: string; message: string; subType: "default" | "gift" | "community" | "spam"; }> & { subType?: "default" | "gift" | "community" | "spam"; }): void; }; streamelements: { tip(data?: Partial<{ amount: number; avatar: string; name: string; }>): void; }; youtube: { message(data?: Partial<{ name: string; message: string; badges: BadgeOptions; color: string; userId: string; msgId: string; channel: string; time: number; avatar: string; }>): void; subscriber(data?: Partial<{ avatar: string; name: string; }>): void; superchat(data?: Partial<{ amount: number; avatar: string; name: string; }>): void; sponsor(data?: Partial<{ tier: "1000" | "2000" | "3000"; amount: number; avatar: string; name: string; sender: string; message: string; subType: "default" | "gift" | "community" | "spam"; }> & { subType?: "default" | "gift" | "community" | "spam"; }): void; }; kick: {}; facebook: {}; send(listener: T, event: T extends 'onEventReceived' ? StreamElements.Event.onEventReceived : T extends 'onSessionUpdate' ? StreamElements.Event.onSessionUpdate : StreamElements.Event.onWidgetLoad): void; } /** * Simulates the onWidgetLoad event for a widget. * @param fields - The field values to be included in the event. * @param session - The session data to be included in the event. * @param currency - The currency to be used (default is 'USD'). * @returns A Promise that resolves to the simulated onWidgetLoad event data. */ declare function onWidgetLoad(fields: Record, session: StreamElements.Session.Data, currency?: 'BRL' | 'USD' | 'EUR'): Promise; /** * Simulates the onSessionUpdate event for a widget. * @param session - The session data to be included in the event. * @returns A Promise that resolves to the simulated onSessionUpdate event data. */ declare function onSessionUpdate(session?: StreamElements.Session.Data, update?: ClientEvents): Promise; /** * Simulates the onEventReceived event for a widget. * @param provider - The provider of the event (default is 'random'). * @param type - The type of event to simulate (default is 'random'). * @param options - Additional options to customize the event data. * @returns A Promise that resolves to the simulated onEventReceived event data, or null if the event type is not supported. * @example * ```javascript * // Simulate a random event * const randomEvent = await onEventReceived(); * * // Simulate a Twitch message event with custom options * const twitchMessageEvent = await onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' }); * ``` */ declare function onEventReceived(provider?: Provider$1 | 'random', type?: StreamElements.Event.onEventReceived['listener'] | 'random' | 'tip' | 'cheer' | 'follower' | 'raid' | 'subscriber', options?: Record): Promise; declare class Generator { event: { onWidgetLoad: typeof onWidgetLoad; onSessionUpdate: typeof onSessionUpdate; onEventReceived: typeof onEventReceived; }; session: { types: Record; available(): StreamElements.Session.Config.Available.Data; get(startSession?: StreamElements.Session.Data): Promise; }; } type localQueueItem = { listener: 'onEventReceived'; data: StreamElements.Event.onEventReceived; session?: boolean; } | { listener: 'onWidgetLoad'; data: StreamElements.Event.onWidgetLoad; } | { listener: 'onSessionUpdate'; data: StreamElements.Event.onSessionUpdate; }; declare namespace Local { type QueueItem = localQueueItem; const queue: useQueue; const generate: Generator; const emulate: Emulator; function start(fieldsFile?: string[], dataFiles?: string[], session?: StreamElements.Session.Data): Promise; } declare class FakeUser { readonly id: string; readonly name: string; readonly login: string; badges: Twitch.tags[]; isSubscriber: boolean; tier?: StreamElements.Event.Provider.Twitch.SubscriberTier; constructor(id: string, name: string, badges?: Twitch.tags[], isSubscriber?: boolean, tier?: StreamElements.Event.Provider.Twitch.SubscriberTier); } interface FakeUserPoolOptions { id?: string; names?: string[]; badges?: Twitch.tags[]; minimumBadgesPerUser?: number; limits?: { [key in Twitch.tags]?: number; }; fixed?: { [key in Twitch.tags]?: string | string[]; }; incompatible?: { [key in Twitch.tags]?: Twitch.tags | Twitch.tags[]; }; } type FakeUserPoolEvents = { warn: [warning: Error]; }; declare class FakeUserPool extends EventProvider { readonly users: FakeUser[]; readonly id: string; private readonly byId; private readonly byName; private readonly byBadge; private static fixUser; private static getRandomSubTier; constructor(options?: FakeUserPoolOptions); private start; pick(): FakeUser | null; getByName(name: string): FakeUser | null; getById(id: string): FakeUser | null; getByBadge(badge: Twitch.tags): FakeUser[]; getToReply(target: { id?: string; name?: string; }, extend?: Partial): Twitch.Reply | null; buildTwitchMessage(messages?: string[]): Parameters<(typeof Local)['emulate']['twitch']['message']>[0]; buildYouTubeMessage(messages?: string[]): Parameters<(typeof Local)['emulate']['youtube']['message']>[0]; } type MessageMap = Record; type MessageTuple = { [K in keyof T]: [key: K, data: T[K]]; }[keyof T]; type BaseEvents = { load: []; message: MessageTuple; }; type UseCommsOptions = { id?: string; }; type UseCommItem = { nonce: string; key: keyof T; value: T[keyof T]; timestamp: string; }; /** * A module for handling communications between different widgets inside streamelements. * @example * ```ts * type CommsMessages = { * hello: { loaded: boolean }; * update: { value: number }; * reload: {}; * tags: string[]; * } * * const comms = new useComms(); * * comms.on('message', (message, data) => { * switch (message) { * case 'hello': {} * case 'update': {} * case 'reload': {} * case 'tags': {} * } * }) * ``` */ declare class useComms extends EventProvider> { private SE_API; id: string; loaded: boolean; history: Array>; detected: Set; constructor(options?: UseCommsOptions); send(key: K, data: T[K]): Promise; update(history: Array>): void; on>(eventName: K, callback: (this: useComms, ...args: BaseEvents[K]) => void): this; } declare const usedClients: Client[]; declare const usedStorages: Array>; declare const usedComms: Array>; declare const usedCommands: Command[]; declare const usedButtons: Button[]; declare const fakeUserPools: FakeUserPool[]; declare const internals_fakeUserPools: typeof fakeUserPools; declare const internals_usedButtons: typeof usedButtons; declare const internals_usedClients: typeof usedClients; declare const internals_usedCommands: typeof usedCommands; declare const internals_usedComms: typeof usedComms; declare const internals_usedStorages: typeof usedStorages; declare namespace internals { export { internals_fakeUserPools as fakeUserPools, internals_usedButtons as usedButtons, internals_usedClients as usedClients, internals_usedCommands as usedCommands, internals_usedComms as usedComms, internals_usedStorages as usedStorages, }; } declare const main: { SeAPI: Promise; Client: typeof Client; Helper: typeof Helper; Local: typeof Local; Data: typeof Data; logger: useLogger; modules: { EventProvider: typeof EventProvider; useStorage: typeof useStorage; useQueue: typeof useQueue; useLogger: typeof useLogger; useComms: typeof useComms; FakeUserPool: typeof FakeUserPool; }; actions: { Button: typeof Button; Command: typeof Command; }; multistream: { useComfyJs: typeof useComfyJs; }; internal: typeof internals; pronouns: { Alejo: typeof Alejo; }; }; declare global { interface Window { Tixyel: typeof main; ComfyJS?: ComfyJSInstance; } interface WindowEventMap { onWidgetLoad: CustomEvent; onSessionUpdate: CustomEvent; onEventReceived: CustomEvent; } const Tixyel: typeof main; const SE_API: StreamElements.SE_API; } export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage }; export type { BttvEmote, ClientCustomEventPayload, ClientCustomProviderEvents, ClientEventTuple, ClientEvents, ClientProviderEvents, Emoji, Emote, FfzEmote, JSONObject, JSONPrimitive, JSONSerializable, MapNumberValuesToString, NumberAsString, PathValue, Provider$1 as Provider, QueueDuration, QueueItem, QueueOptions, QueueProcessor, QueueProps, RequireAtLeastOne, SeventvEmote, TwitchEmote };