@tixyel/streamelements 7.8.0 → 7.10.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
@@ -1711,7 +1711,7 @@ interface CommandOptions {
1711
1711
  description?: string;
1712
1712
  arguments?: boolean;
1713
1713
  run: (this: Client, args: string[], event: CommandEvent) => void;
1714
- test?: string;
1714
+ test?: RegExp | ((command: string) => boolean);
1715
1715
  aliases?: string[];
1716
1716
  permissions?: string[] | boolean;
1717
1717
  admins?: string[];
@@ -1731,7 +1731,7 @@ declare class Command {
1731
1731
  name: string;
1732
1732
  description: string;
1733
1733
  arguments: boolean;
1734
- test: string | (() => string);
1734
+ test: RegExp | ((command: string) => boolean);
1735
1735
  aliases: string[];
1736
1736
  permissions?: string[] | boolean;
1737
1737
  admins: string[];
@@ -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[];
@@ -3893,4 +3897,4 @@ declare global {
3893
3897
  }
3894
3898
 
3895
3899
  export { Alejo, Button, Command, EventProvider, StreamElements, StreamElementsEvents, Twitch, TwitchEvents, YoutubeEvents, main as default, useComfyJs, useLogger, useQueue, useStorage };
3896
- 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
@@ -10622,7 +10622,7 @@ var oe = class e {
10622
10622
  }
10623
10623
  }, V = class e {
10624
10624
  constructor(e) {
10625
- this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, I.push(this), N.length && N.forEach((e) => {
10625
+ this.prefix = "!", this.arguments = !1, this.test = () => !0, this.aliases = [], this.permissions = void 0, this.admins = [], this.prefix = e.prefix ?? this.prefix, this.name = e.name, this.description = e.description ?? this.description, this.arguments = e.arguments ?? this.arguments, this.run = e.run, this.test = e.test ?? this.test, this.aliases = e.aliases ?? this.aliases, this.permissions = e.permissions ?? this.permissions, this.admins = e.admins ?? this.admins, I.push(this), N.length && N.forEach((e) => {
10626
10626
  e.actions.commands.push(this), e.emit("action", this, "created");
10627
10627
  });
10628
10628
  }
@@ -10637,6 +10637,7 @@ var oe = class e {
10637
10637
  bits: "cheer",
10638
10638
  premium: "prime"
10639
10639
  };
10640
+ if (this.test instanceof RegExp && !this.test.test(e) || typeof this.test == "function" && !this.test(e)) return !1;
10640
10641
  switch (t.provider) {
10641
10642
  case "twitch": {
10642
10643
  let e = t.data;
@@ -10884,7 +10885,7 @@ var H = class {
10884
10885
  }
10885
10886
  }, W = class extends H {
10886
10887
  constructor(e) {
10887
- 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.");
10888
+ 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.");
10888
10889
  this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration ?? 0), this.waitForClientAndBindLoad(e.duration);
10889
10890
  }
10890
10891
  waitForClientAndBindLoad(e = this.duration, t) {
@@ -10932,7 +10933,7 @@ var H = class {
10932
10933
  return;
10933
10934
  }
10934
10935
  try {
10935
- await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
10936
+ await this.processor.apply(this, [e, this]), this.emit("process", e, this);
10936
10937
  } catch (e) {
10937
10938
  console.error(`Error during item processing: ${e instanceof Error ? e.message : String(e)}`);
10938
10939
  }
@@ -12554,7 +12555,7 @@ var K = new class {
12554
12555
  }
12555
12556
  }(), q = new W({
12556
12557
  duration: "client",
12557
- processor: async function(e) {
12558
+ processor: async function({ value: e }) {
12558
12559
  if (window.dispatchEvent(new CustomEvent(e.listener, { detail: e.data })), e.listener === "onEventReceived" && e.session) {
12559
12560
  let t = await K.event.onSessionUpdate(N?.[0] ? N[0].session : void 0, B.event.parseProvider(e.data));
12560
12561
  window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: t }));