@tixyel/streamelements 4.2.1 → 4.2.2

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
@@ -1627,7 +1627,7 @@ interface QueueOptions<T> {
1627
1627
  /**
1628
1628
  * Duration between processing each item in milliseconds. Set to `0` or `false` for immediate processing.
1629
1629
  */
1630
- duration: QueueDuration | 'client';
1630
+ duration?: QueueDuration | 'client';
1631
1631
  /**
1632
1632
  * Function to process each item in the queue.
1633
1633
  */
@@ -2020,7 +2020,7 @@ declare namespace Simulation {
2020
2020
  onEventReceived(provider?: Provider$1 | "random", type?: StreamElements.Event.onEventReceived["listener"] | "random" | "tip" | "cheer" | "follower" | "raid" | "subscriber", options?: Record<string, string | number | boolean>): Promise<StreamElements.Event.onEventReceived | null>;
2021
2021
  };
2022
2022
  };
2023
- export const Queue: useQueue<{
2023
+ export const queue: useQueue<{
2024
2024
  listener: "onEventReceived";
2025
2025
  data: StreamElements.Event.onEventReceived;
2026
2026
  session?: boolean;
package/dist/index.es.js CHANGED
@@ -5230,9 +5230,13 @@ class Q extends O {
5230
5230
  loaded = !1;
5231
5231
  processor;
5232
5232
  constructor(e) {
5233
- super(), window.client instanceof J && (this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration), window.client.on("load", () => {
5234
- e.duration === "client" && (this.duration = client.fields.widgetDuration ?? 0), this.emit("load"), this.loaded = !0;
5235
- }));
5233
+ if (super(), !(window.client instanceof J))
5234
+ throw new Error("useQueue can only be instantiated after the Client is initialized.");
5235
+ if (!e.processor || typeof e.processor != "function")
5236
+ throw new Error("A valid processor function must be provided to useQueue.");
5237
+ this.processor = e.processor, e.duration !== "client" && (this.duration = e.duration ?? 0), window.client.on("load", () => {
5238
+ e.duration === "client" && (this.duration = window.client.fields?.widgetDuration ?? 0), this.emit("load"), this.loaded = !0;
5239
+ });
5236
5240
  }
5237
5241
  enqueue(e, a = {}) {
5238
5242
  const o = {
@@ -7071,12 +7075,12 @@ var x;
7071
7075
  }
7072
7076
  }
7073
7077
  }
7074
- }, s.Queue = new Q({
7078
+ }, s.queue = new Q({
7075
7079
  duration: "client",
7076
- async processor(t) {
7077
- if (window.dispatchEvent(new CustomEvent(t.listener, { detail: t.data })), t.listener === "onEventReceived" && t.session) {
7078
- const n = await s.generate.event.onSessionUpdate(client.session, Z(t.data));
7079
- window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: n }));
7080
+ processor: async function(n) {
7081
+ if (window.dispatchEvent(new CustomEvent(n.listener, { detail: n.data })), n.listener === "onEventReceived" && n.session) {
7082
+ const c = await s.generate.event.onSessionUpdate(client.session, Z(n.data));
7083
+ window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: c }));
7080
7084
  }
7081
7085
  }
7082
7086
  }), s.emulate = {
@@ -7161,7 +7165,7 @@ var x;
7161
7165
  send(t, n) {
7162
7166
  switch (t) {
7163
7167
  case "onEventReceived": {
7164
- s.Queue.enqueue({
7168
+ s.queue.enqueue({
7165
7169
  listener: t,
7166
7170
  data: n,
7167
7171
  session: t === "onEventReceived" ? !0 : void 0
@@ -7169,14 +7173,14 @@ var x;
7169
7173
  break;
7170
7174
  }
7171
7175
  case "onSessionUpdate": {
7172
- s.Queue.enqueue({
7176
+ s.queue.enqueue({
7173
7177
  listener: t,
7174
7178
  data: n
7175
7179
  });
7176
7180
  break;
7177
7181
  }
7178
7182
  case "onWidgetLoad": {
7179
- s.Queue.enqueue({
7183
+ s.queue.enqueue({
7180
7184
  listener: t,
7181
7185
  data: n
7182
7186
  });