@tixyel/streamelements 6.4.1 → 6.4.3

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
@@ -2964,7 +2964,7 @@ declare const main: {
2964
2964
  declare global {
2965
2965
  interface Window {
2966
2966
  Tixyel: typeof main;
2967
- client: InstanceType<typeof main.Client>;
2967
+ client: InstanceType<typeof main.Client> | undefined;
2968
2968
  ComfyJS?: ComfyJSInstance;
2969
2969
  }
2970
2970
  interface WindowEventMap {
package/dist/index.es.js CHANGED
@@ -158,7 +158,9 @@ class Z {
158
158
  run(e, t) {
159
159
  }
160
160
  verify(e, t, a) {
161
- return this.arguments === !0 && (!a || !a.length) ? !1 : !!(this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase()) || this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length || Array.isArray(this.permissions) && (this.permissions.some((i) => e.toLowerCase() === i.toLowerCase() || t.map((s) => s.toLowerCase()).includes(i.toLowerCase())) || this.permissions.includes("*")));
161
+ return this.arguments === !0 && (!a || !a.length) ? !1 : !!(this.admins.some((i) => e.toLocaleLowerCase() === i.toLocaleLowerCase()) || this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length || Array.isArray(this.permissions) && (this.permissions.some(
162
+ (i) => e.toLowerCase() === i.toLowerCase() || t.map((s) => s.toLowerCase()).includes(i.toLowerCase())
163
+ ) || this.permissions.includes("*")));
162
164
  }
163
165
  parse(e, t) {
164
166
  if (!(window.client instanceof q)) return !1;
@@ -203,7 +205,10 @@ class Z {
203
205
  });
204
206
  if (a.length && a.every((i) => i instanceof Z))
205
207
  return a.forEach((i) => {
206
- i.parse(t.event.data.text, e), window.client.emit("action", i, "executed"), N.received(`Command executed: ${t.event.data.text} by ${t.event.data.nick || t.event.data.displayName}`, t);
208
+ i.parse(t.event.data.text, e), window?.client?.emit("action", i, "executed"), N.received(
209
+ `Command executed: ${t.event.data.text} by ${t.event.data.nick || t.event.data.displayName}`,
210
+ t
211
+ );
207
212
  }), !0;
208
213
  }
209
214
  } catch {
@@ -5649,7 +5654,7 @@ var w;
5649
5654
  let y = "$", v = "USD";
5650
5655
  if (typeof window < "u")
5651
5656
  try {
5652
- const u = window.client?.details?.currency;
5657
+ const u = window?.client?.details?.currency;
5653
5658
  u?.symbol && (y = String(u.symbol)), u?.code && (v = String(u.code));
5654
5659
  } catch {
5655
5660
  }
@@ -6196,18 +6201,27 @@ class at {
6196
6201
  type: "button",
6197
6202
  label: m
6198
6203
  };
6199
- let c = w.string.compose(String(this.value), { index: s, ...i }, { html: !1 });
6204
+ let c = w.string.compose(
6205
+ String(this.value),
6206
+ { index: s, ...i },
6207
+ { html: !1 }
6208
+ );
6200
6209
  return isNaN(Number(c)) ? c.toLowerCase() === "true" ? c = !0 : c.toLowerCase() === "false" && (c = !1) : c = Number(c), typeof c < "u" && c && (typeof c != "string" || c.length) && (a[n].value = c), a;
6201
6210
  },
6202
6211
  {}
6203
6212
  );
6204
6213
  }
6205
6214
  parse(e, t) {
6206
- var a = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
6215
+ var a = e.replace(
6216
+ typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "",
6217
+ ""
6218
+ ).trim();
6207
6219
  try {
6208
6220
  this.run.apply(window.client, [a.length ? a : e ?? e, t]);
6209
6221
  } catch (i) {
6210
- throw new Error(`Error running button "${this.field}": ${i instanceof Error ? i.message : i}`);
6222
+ throw new Error(
6223
+ `Error running button "${this.field}": ${i instanceof Error ? i.message : i}`
6224
+ );
6211
6225
  }
6212
6226
  return this;
6213
6227
  }
@@ -6224,9 +6238,11 @@ class at {
6224
6238
  if (a.length && a.every((i) => i instanceof at))
6225
6239
  return a.forEach((i) => {
6226
6240
  try {
6227
- i.parse(e, t), window.client.emit("action", i, "executed"), N.received(`Button executed: ${e}${t ? ` with value: ${t}` : ""}`);
6241
+ i.parse(e, t), window?.client?.emit("action", i, "executed"), N.received(`Button executed: ${e}${t ? ` with value: ${t}` : ""}`);
6228
6242
  } catch (s) {
6229
- N.error(`Error executing button "${e}": ${s instanceof Error ? s.message : s}`);
6243
+ N.error(
6244
+ `Error executing button "${e}": ${s instanceof Error ? s.message : s}`
6245
+ );
6230
6246
  }
6231
6247
  }), !0;
6232
6248
  }
@@ -6493,7 +6509,7 @@ class gt extends X {
6493
6509
  return;
6494
6510
  }
6495
6511
  window.client.on("load", () => {
6496
- e === "client" && (this.duration = window.client.fields?.widgetDuration ?? 0), this.emit("load"), this.loaded = !0, t && t();
6512
+ e === "client" && (this.duration = window?.client?.fields?.widgetDuration ?? 0), this.emit("load"), this.loaded = !0, t && t();
6497
6513
  });
6498
6514
  }
6499
6515
  enqueue(e, t = {}) {
@@ -6584,9 +6600,9 @@ var G;
6584
6600
  l.queue = new gt({
6585
6601
  duration: "client",
6586
6602
  processor: async function(a) {
6587
- if (window.dispatchEvent(new CustomEvent(a.listener, { detail: a.data })), a.listener === "onEventReceived" && a.session && client instanceof q && client && client?.session) {
6603
+ if (window.dispatchEvent(new CustomEvent(a.listener, { detail: a.data })), a.listener === "onEventReceived" && a.session) {
6588
6604
  const i = await l.generate.event.onSessionUpdate(
6589
- client.session,
6605
+ window?.client && window?.client instanceof q ? window.client.session : void 0,
6590
6606
  w.event.parseProvider(a.data)
6591
6607
  );
6592
6608
  window.dispatchEvent(new CustomEvent("onSessionUpdate", { detail: i }));
@@ -7252,7 +7268,7 @@ var G;
7252
7268
  var c = i?.name ?? w.random.array(A.names.filter((H) => H.length))[0], b = i?.message ?? w.random.array(A.messages.filter((H) => H.length))[0], p = await w.message.generateBadges(
7253
7269
  i?.badges ?? [],
7254
7270
  t
7255
- ), o = w.message.findEmotesInText(b), h = w.message.replaceEmotesWithHTML(b, o), f = i?.color ?? w.random.color("hex"), d = i?.userId ?? w.random.number(1e7, 99999999).toString(), g = i?.msgId ?? w.random.uuid(), y = i?.time ?? Date.now(), v = i?.channel ?? client?.details?.user?.username ?? "local";
7271
+ ), o = w.message.findEmotesInText(b), h = w.message.replaceEmotesWithHTML(b, o), f = i?.color ?? w.random.color("hex"), d = i?.userId ?? w.random.number(1e7, 99999999).toString(), g = i?.msgId ?? w.random.uuid(), y = i?.time ?? Date.now(), v = i?.channel ?? window?.client?.details?.user?.username ?? "local";
7256
7272
  return {
7257
7273
  listener: "message",
7258
7274
  event: {
@@ -7477,7 +7493,7 @@ var G;
7477
7493
  case "mute":
7478
7494
  case "unmute":
7479
7495
  case "alertService:toggleSound": {
7480
- var J = i?.muted ?? client?.details?.overlay?.muted ?? !1;
7496
+ var J = i?.muted ?? window?.client?.details?.overlay?.muted ?? !1;
7481
7497
  return {
7482
7498
  listener: "alertService:toggleSound",
7483
7499
  event: {
@@ -7514,7 +7530,7 @@ var G;
7514
7530
  i?.badges ?? [],
7515
7531
  t
7516
7532
  );
7517
- var o = w.message.findEmotesInText(b), h = w.message.replaceEmotesWithHTML(b, o), f = i?.color ?? w.random.color("hex"), d = i?.userId ?? w.random.number(1e7, 99999999).toString(), g = i?.msgId ?? w.random.uuid(), y = i?.time ?? Date.now(), x = i?.avatar ?? w.random.array(A.avatars)[0], v = i?.channel ?? client?.details?.user?.username ?? "local";
7533
+ var o = w.message.findEmotesInText(b), h = w.message.replaceEmotesWithHTML(b, o), f = i?.color ?? w.random.color("hex"), d = i?.userId ?? w.random.number(1e7, 99999999).toString(), g = i?.msgId ?? w.random.uuid(), y = i?.time ?? Date.now(), x = i?.avatar ?? w.random.array(A.avatars)[0], v = i?.channel ?? window?.client?.details?.user?.username ?? "local";
7518
7534
  return {
7519
7535
  listener: "message",
7520
7536
  event: {
@@ -7899,7 +7915,7 @@ var ot;
7899
7915
  l.list = t;
7900
7916
  async function a(i) {
7901
7917
  if (!i) throw new Error("Username is required to fetch Alejo data.");
7902
- if (i = i.toLowerCase(), !client) {
7918
+ if (i = i.toLowerCase(), !window?.client) {
7903
7919
  try {
7904
7920
  const s = await fetch(`https://pronouns.alejo.io/api/users/${i}`).then((n) => n.json()).then(([n]) => n);
7905
7921
  if (s)
@@ -7911,16 +7927,16 @@ var ot;
7911
7927
  }
7912
7928
  return;
7913
7929
  }
7914
- if (i in client.storage.data.pronoun && client.storage.data.pronoun[i].expire > Date.now())
7915
- return client.storage.data.pronoun[i].value;
7930
+ if (i in window?.client?.storage.data.pronoun && window?.client?.storage.data.pronoun[i].expire > Date.now())
7931
+ return window?.client?.storage.data.pronoun[i].value;
7916
7932
  try {
7917
7933
  const s = await fetch(`https://pronouns.alejo.io/api/users/${i}`).then((n) => n.json()).then(([n]) => n);
7918
7934
  if (s)
7919
- return client.storage.add(`pronoun.${i}`, {
7935
+ return window?.client?.storage.add(`pronoun.${i}`, {
7920
7936
  value: s.pronoun_id,
7921
7937
  timestamp: Date.now(),
7922
- expire: Date.now() + client.cache.pronoun * 60 * 1e3
7923
- }), client.storage.data.pronoun[i].value ?? s.pronoun_id;
7938
+ expire: Date.now() + window?.client?.cache.pronoun * 60 * 1e3
7939
+ }), window?.client?.storage.data.pronoun[i].value ?? s.pronoun_id;
7924
7940
  } catch (s) {
7925
7941
  throw new Error(
7926
7942
  `Failed to fetch pronoun data for user "${i}": ${s instanceof Error ? s.message : s}`