@tixyel/streamelements 7.7.0 → 7.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -2006,6 +2006,62 @@ declare class useLogger {
2006
2006
  readonly simple: LogMethod;
2007
2007
  }
2008
2008
 
2009
+ type ComfyEvents = {
2010
+ load: [instance: ComfyJSInstance];
2011
+ error: Parameters<OnErrorHandler>;
2012
+ command: Parameters<OnCommandHandler>;
2013
+ chat: Parameters<OnChatHandler>;
2014
+ whisper: Parameters<OnWhisperHandler>;
2015
+ messageDeleted: Parameters<OnMessageDeletedHandler>;
2016
+ join: Parameters<OnJoinHandler>;
2017
+ part: Parameters<OnPartHandler>;
2018
+ hosted: Parameters<OnHostedHandler>;
2019
+ raid: Parameters<OnRaidHandler>;
2020
+ sub: Parameters<OnSubHandler>;
2021
+ resub: Parameters<OnResubHandler>;
2022
+ subGift: Parameters<OnSubGiftHandler>;
2023
+ subMysteryGift: Parameters<OnSubMysteryGiftHandler>;
2024
+ giftSubContinue: Parameters<OnGiftSubContinueHandler>;
2025
+ cheer: Parameters<OnCheerHandler>;
2026
+ chatMode: Parameters<OnChatModeHandler>;
2027
+ reward: Parameters<OnRewardHandler>;
2028
+ connected: Parameters<OnConnectedHandler>;
2029
+ reconnect: Parameters<OnReconnectHandler>;
2030
+ };
2031
+ /**
2032
+ * Creates and manages a ComfyJS instance for Twitch chat interaction.
2033
+ */
2034
+ declare class useComfyJs extends EventProvider<ComfyEvents> {
2035
+ instance: ComfyJSInstance;
2036
+ username: string;
2037
+ password?: string;
2038
+ channels: string[];
2039
+ isDebug: boolean;
2040
+ private init;
2041
+ emulate: boolean;
2042
+ /**
2043
+ * Initializes a new ComfyJS instance and connects to Twitch chat.
2044
+ * @param options - Configuration options for ComfyJS instance.
2045
+ * @param emulate - Whether to emulate chat messages in the Local module.
2046
+ */
2047
+ constructor(options: {
2048
+ username: string;
2049
+ password?: string;
2050
+ channels: string[];
2051
+ isDebug?: boolean;
2052
+ init?: boolean;
2053
+ }, emulate: boolean);
2054
+ /**
2055
+ * Loads the ComfyJS script if not already loaded.
2056
+ * @returns A promise that resolves to the ComfyJS instance.
2057
+ */
2058
+ private load;
2059
+ /**
2060
+ * Connects event handlers to the ComfyJS instance.
2061
+ */
2062
+ private connect;
2063
+ }
2064
+
2009
2065
  type QueueEvents<T> = {
2010
2066
  load: [];
2011
2067
  cancel: [];
@@ -2026,7 +2082,7 @@ type QueueProps = {
2026
2082
  type QueueItem<T> = {
2027
2083
  value: T;
2028
2084
  } & QueueProps;
2029
- type QueueProcessor<T> = (this: useQueue<T>, item: T, queue: useQueue<T>) => Promise<any>;
2085
+ type QueueProcessor<T> = (this: useQueue<T>, item: QueueItem<T>, queue: useQueue<T>) => Promise<any> | any;
2030
2086
  type QueueDuration = number | boolean | undefined;
2031
2087
  interface QueueOptions<T> {
2032
2088
  /**
@@ -2060,10 +2116,10 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
2060
2116
  priorityQueue: QueueItem<T>[];
2061
2117
  history: QueueItem<T>[];
2062
2118
  private timeouts;
2063
- running: boolean;
2064
2119
  duration: QueueDuration;
2065
- private loaded;
2066
2120
  processor: QueueProcessor<T>;
2121
+ running: boolean;
2122
+ private loaded;
2067
2123
  private readonly clientWaitRetryDelay;
2068
2124
  constructor(options: QueueOptions<T>);
2069
2125
  private waitForClientAndBindLoad;
@@ -2111,7 +2167,11 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
2111
2167
  * });
2112
2168
  * ```
2113
2169
  */
2114
- update(save: Partial<useQueue<T>>): this;
2170
+ update(save: Partial<{
2171
+ queue?: QueueItem<T>[];
2172
+ priorityQueue?: QueueItem<T>[];
2173
+ history?: QueueItem<T>[];
2174
+ }>): this;
2115
2175
  /**
2116
2176
  * 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.
2117
2177
  */
@@ -2124,62 +2184,6 @@ declare class useQueue<T> extends EventProvider<QueueEvents<T>> {
2124
2184
  on<K extends keyof QueueEvents<T>>(eventName: K, callback: (this: useQueue<T>, ...args: QueueEvents<T>[K]) => void): this;
2125
2185
  }
2126
2186
 
2127
- type ComfyEvents = {
2128
- load: [instance: ComfyJSInstance];
2129
- error: Parameters<OnErrorHandler>;
2130
- command: Parameters<OnCommandHandler>;
2131
- chat: Parameters<OnChatHandler>;
2132
- whisper: Parameters<OnWhisperHandler>;
2133
- messageDeleted: Parameters<OnMessageDeletedHandler>;
2134
- join: Parameters<OnJoinHandler>;
2135
- part: Parameters<OnPartHandler>;
2136
- hosted: Parameters<OnHostedHandler>;
2137
- raid: Parameters<OnRaidHandler>;
2138
- sub: Parameters<OnSubHandler>;
2139
- resub: Parameters<OnResubHandler>;
2140
- subGift: Parameters<OnSubGiftHandler>;
2141
- subMysteryGift: Parameters<OnSubMysteryGiftHandler>;
2142
- giftSubContinue: Parameters<OnGiftSubContinueHandler>;
2143
- cheer: Parameters<OnCheerHandler>;
2144
- chatMode: Parameters<OnChatModeHandler>;
2145
- reward: Parameters<OnRewardHandler>;
2146
- connected: Parameters<OnConnectedHandler>;
2147
- reconnect: Parameters<OnReconnectHandler>;
2148
- };
2149
- /**
2150
- * Creates and manages a ComfyJS instance for Twitch chat interaction.
2151
- */
2152
- declare class useComfyJs extends EventProvider<ComfyEvents> {
2153
- instance: ComfyJSInstance;
2154
- username: string;
2155
- password?: string;
2156
- channels: string[];
2157
- isDebug: boolean;
2158
- private init;
2159
- emulate: boolean;
2160
- /**
2161
- * Initializes a new ComfyJS instance and connects to Twitch chat.
2162
- * @param options - Configuration options for ComfyJS instance.
2163
- * @param emulate - Whether to emulate chat messages in the Local module.
2164
- */
2165
- constructor(options: {
2166
- username: string;
2167
- password?: string;
2168
- channels: string[];
2169
- isDebug?: boolean;
2170
- init?: boolean;
2171
- }, emulate: boolean);
2172
- /**
2173
- * Loads the ComfyJS script if not already loaded.
2174
- * @returns A promise that resolves to the ComfyJS instance.
2175
- */
2176
- private load;
2177
- /**
2178
- * Connects event handlers to the ComfyJS instance.
2179
- */
2180
- private connect;
2181
- }
2182
-
2183
2187
  declare namespace Data {
2184
2188
  const avatars: string[];
2185
2189
  const badges: Twitch.GlobalBadge[];
@@ -2503,6 +2507,18 @@ declare class ElementHelper {
2503
2507
  * ```
2504
2508
  */
2505
2509
  CSS(element: HTMLElement | SVGElement, styles: Partial<Record<keyof CSSStyleProperties | `--${string}`, CSSValue>>): void;
2510
+ /**
2511
+ * Escapes special HTML characters in a string to prevent XSS attacks and ensure safe rendering in HTML contexts.
2512
+ * @param value - The input string that may contain special HTML characters such as &, <, >, ", and '.
2513
+ * @returns A new string with special HTML characters replaced by their corresponding HTML entities.
2514
+ * @example
2515
+ * ```javascript
2516
+ * const unsafeString = '<script>alert("XSS")</script>';
2517
+ * const safeString = escapeHtml(unsafeString);
2518
+ * console.log(safeString); // Output: '&lt;script&gt;alert(&quot;XSS&quot;)&lt;/script&gt;'
2519
+ * ```
2520
+ */
2521
+ escapeHtml(value: string): string;
2506
2522
  }
2507
2523
  type CSSValue = string | number | null | undefined;
2508
2524
 
@@ -3097,7 +3113,7 @@ declare class UtilsHelper {
3097
3113
  userId: string;
3098
3114
  name: string;
3099
3115
  broadcasterId?: string;
3100
- }, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<1 | 2 | 3>;
3116
+ }, session: StreamElements.Session.Data, checkWithAPI?: boolean): Promise<3 | 1 | 2>;
3101
3117
  /**
3102
3118
  * Identifies a user based on the received event and session data, returning their ID, name, role, badges, and top status.
3103
3119
  * @param receivedEvent - The event received from the provider (Twitch or YouTube) containing user information.
@@ -3881,4 +3897,4 @@ declare global {
3881
3897
  }
3882
3898
 
3883
3899
  export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage };
3884
- export type { BttvEmote, ClientCustomEventPayload, ClientCustomProviderEvents, ClientEventTuple, ClientEvents, ClientProviderEvents, Emoji, Emote, FfzEmote, JSONObject, JSONPrimitive, JSONSerializable, MapNumberValuesToString, NumberAsString, PathValue, Provider$1 as Provider, RequireAtLeastOne, SeventvEmote, TwitchEmote };
3900
+ 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 };
package/dist/index.es.js CHANGED
@@ -254,6 +254,16 @@ var e = Object.defineProperty, t = (t, n) => {
254
254
  e.style.setProperty(t, a);
255
255
  }
256
256
  }
257
+ escapeHtml(e) {
258
+ let t = {
259
+ "&": "&amp;",
260
+ "<": "&lt;",
261
+ ">": "&gt;",
262
+ "\"": "&quot;",
263
+ "'": "&#39;"
264
+ };
265
+ return e.replace(/[&<>"']/g, (e) => t[e]);
266
+ }
257
267
  }, i = class {
258
268
  flatten(e, t = !0, n = "") {
259
269
  let r = {};
@@ -10874,7 +10884,7 @@ var H = class {
10874
10884
  }
10875
10885
  }, W = class extends H {
10876
10886
  constructor(e) {
10877
- if (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.running = !1, this.duration = void 0, this.loaded = !1, this.clientWaitRetryDelay = 50, !e.processor || typeof e.processor != "function") throw Error("A valid processor function must be provided to useQueue.");
10887
+ if (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.duration = void 0, this.running = !1, this.loaded = !1, this.clientWaitRetryDelay = 50, !e.processor || typeof e.processor != "function") throw Error("A valid processor function must be provided to useQueue.");
10878
10888
  this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration ?? 0), this.waitForClientAndBindLoad(e.duration);
10879
10889
  }
10880
10890
  waitForClientAndBindLoad(e = this.duration, t) {
@@ -10922,7 +10932,7 @@ var H = class {
10922
10932
  return;
10923
10933
  }
10924
10934
  try {
10925
- await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
10935
+ await this.processor.apply(this, [e, this]), this.emit("process", e, this);
10926
10936
  } catch (e) {
10927
10937
  console.error(`Error during item processing: ${e instanceof Error ? e.message : String(e)}`);
10928
10938
  }
@@ -12544,7 +12554,7 @@ var K = new class {
12544
12554
  }
12545
12555
  }(), q = new W({
12546
12556
  duration: "client",
12547
- processor: async function(e) {
12557
+ processor: async function({ value: e }) {
12548
12558
  if (window.dispatchEvent(new CustomEvent(e.listener, { detail: e.data })), e.listener === "onEventReceived" && e.session) {
12549
12559
  let t = await K.event.onSessionUpdate(N?.[0] ? N[0].session : void 0, B.event.parseProvider(e.data));
12550
12560
  window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: t }));