@tixyel/streamelements 2.0.0 → 3.0.1
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/README.md +40 -0
- package/dist/index.d.ts +125 -26
- package/dist/index.es.js +696 -539
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +35 -5
package/dist/index.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
class
|
|
1
|
+
class D {
|
|
2
2
|
constructor() {
|
|
3
3
|
this.registeredEvents = {};
|
|
4
4
|
}
|
|
@@ -8,38 +8,38 @@ class N {
|
|
|
8
8
|
* @param eventName The name of the event.
|
|
9
9
|
* @param args Arguments to pass to the listeners.
|
|
10
10
|
*/
|
|
11
|
-
emit(e, ...
|
|
12
|
-
return (this.registeredEvents[e] || []).map((
|
|
11
|
+
emit(e, ...a) {
|
|
12
|
+
return (this.registeredEvents[e] || []).map((n) => n.apply(this, a));
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Registers an event listener.
|
|
16
16
|
* @param eventName The name of the event.
|
|
17
17
|
* @param callback The callback function.
|
|
18
18
|
*/
|
|
19
|
-
on(e,
|
|
20
|
-
if (typeof
|
|
19
|
+
on(e, a) {
|
|
20
|
+
if (typeof a != "function")
|
|
21
21
|
throw new TypeError("Callback must be a function");
|
|
22
|
-
return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(
|
|
22
|
+
return this.registeredEvents[e] || (this.registeredEvents[e] = []), this.registeredEvents[e].push(a), this;
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* Removes a specific event listener.
|
|
26
26
|
* @param eventName The name of the event.
|
|
27
27
|
* @param callback The callback function to remove.
|
|
28
28
|
*/
|
|
29
|
-
off(e,
|
|
30
|
-
const
|
|
31
|
-
return
|
|
29
|
+
off(e, a) {
|
|
30
|
+
const t = this.registeredEvents[e] || [];
|
|
31
|
+
return a ? (this.registeredEvents[e] = t.filter((n) => n !== a), this) : (this.registeredEvents[e] = [], this);
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Registers a listener that is executed only once.
|
|
35
35
|
* @param eventName The name of the event.
|
|
36
36
|
* @param callback The callback function.
|
|
37
37
|
*/
|
|
38
|
-
once(e,
|
|
39
|
-
const
|
|
40
|
-
this.off(e,
|
|
38
|
+
once(e, a) {
|
|
39
|
+
const t = (...n) => {
|
|
40
|
+
this.off(e, t), a.apply(this, n);
|
|
41
41
|
};
|
|
42
|
-
return this.on(e,
|
|
42
|
+
return this.on(e, t), this;
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Removes all listeners for a specific event.
|
|
@@ -49,14 +49,15 @@ class N {
|
|
|
49
49
|
return this.registeredEvents[e] = [], this;
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
var U = [];
|
|
53
|
+
class G extends D {
|
|
53
54
|
constructor(e) {
|
|
54
55
|
if (super(), this.id = "default", this.loaded = !1, this.id = e.id || this.id, this.data = e.data ?? {}, !SE_API || !SE_API.store) throw new Error("SE_API.store is not available");
|
|
55
|
-
SE_API.store.get(this.id).then((
|
|
56
|
-
this.data =
|
|
56
|
+
SE_API.store.get(this.id).then((a) => {
|
|
57
|
+
this.data = a ?? this.data, this.loaded = !0, this.emit("load", this.data), JSON.stringify(this.data) !== JSON.stringify(a) && this.emit("update", this.data);
|
|
57
58
|
}).catch(() => {
|
|
58
59
|
this.loaded = !0, this.emit("load", null);
|
|
59
|
-
});
|
|
60
|
+
}), U.push(this);
|
|
60
61
|
}
|
|
61
62
|
/**
|
|
62
63
|
* Saves the current data to storage.
|
|
@@ -65,21 +66,40 @@ class P extends N {
|
|
|
65
66
|
save(e = this.data) {
|
|
66
67
|
this.loaded && (this.data = e, SE_API.store.set(this.id, this.data), this.emit("save", this.data));
|
|
67
68
|
}
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Updates the storage data and emits an update event if the data has changed.
|
|
71
|
+
* @param data Data to update (defaults to current)
|
|
72
|
+
*/
|
|
73
|
+
update(e = this.data) {
|
|
74
|
+
this.loaded && JSON.stringify(this.data) !== JSON.stringify(e) && (this.data = { ...this.data, ...e }, this.emit("update", this.data));
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Adds a value to the storage at the specified path.
|
|
78
|
+
* @param path Path to add the value to
|
|
79
|
+
* @param value Value to add
|
|
80
|
+
*/
|
|
81
|
+
add(e, a) {
|
|
82
|
+
this.loaded && (G.setByPath(this.data, e, a), this.save(this.data));
|
|
70
83
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
84
|
+
/**
|
|
85
|
+
* Sets a value in the storage at the specified path.
|
|
86
|
+
* @param obj The object to set the value in
|
|
87
|
+
* @param path The path to set the value at
|
|
88
|
+
* @param value The value to set
|
|
89
|
+
* @returns The updated object
|
|
90
|
+
*/
|
|
91
|
+
static setByPath(e, a, t) {
|
|
92
|
+
const n = a.split(".");
|
|
93
|
+
let r = e;
|
|
94
|
+
for (let d = 0; d < n.length - 1; d++)
|
|
95
|
+
(typeof r[n[d]] != "object" || r[n[d]] == null) && (r[n[d]] = {}), r = r[n[d]];
|
|
96
|
+
return r[n[n.length - 1]] = t, r;
|
|
77
97
|
}
|
|
78
|
-
on(e,
|
|
79
|
-
return e === "load" && this.loaded ? (
|
|
98
|
+
on(e, a) {
|
|
99
|
+
return e === "load" && this.loaded ? (a.apply(this, [this.data]), this) : (super.on(e, a), this);
|
|
80
100
|
}
|
|
81
101
|
}
|
|
82
|
-
class
|
|
102
|
+
class E extends D {
|
|
83
103
|
constructor(e) {
|
|
84
104
|
super(), this.id = "default", this.fields = {}, this.loaded = !1, this.actions = {
|
|
85
105
|
commands: [],
|
|
@@ -88,7 +108,7 @@ class I extends N {
|
|
|
88
108
|
avatar: 30,
|
|
89
109
|
pronoun: 30,
|
|
90
110
|
emote: 30
|
|
91
|
-
}, this.id = e.id || this.id,
|
|
111
|
+
}, this.id = e.id || this.id, this.storage = new G({
|
|
92
112
|
id: this.id,
|
|
93
113
|
data: {
|
|
94
114
|
user: {},
|
|
@@ -96,10 +116,10 @@ class I extends N {
|
|
|
96
116
|
pronoun: {},
|
|
97
117
|
emote: {}
|
|
98
118
|
}
|
|
99
|
-
});
|
|
119
|
+
}), window.client = this;
|
|
100
120
|
}
|
|
101
|
-
on(e,
|
|
102
|
-
return e === "load" && this.loaded ? (
|
|
121
|
+
on(e, a) {
|
|
122
|
+
return e === "load" && this.loaded ? (a.apply(this, [
|
|
103
123
|
{
|
|
104
124
|
channel: this.details.user,
|
|
105
125
|
currency: this.details.currency,
|
|
@@ -116,51 +136,51 @@ class I extends N {
|
|
|
116
136
|
overlay: this.details.overlay,
|
|
117
137
|
emulated: !1
|
|
118
138
|
}
|
|
119
|
-
]), this) : (super.on(e,
|
|
139
|
+
]), this) : (super.on(e, a), this);
|
|
120
140
|
}
|
|
121
141
|
}
|
|
122
|
-
var
|
|
123
|
-
function
|
|
124
|
-
const
|
|
125
|
-
return e.forEach((
|
|
126
|
-
const
|
|
127
|
-
let
|
|
128
|
-
for (;
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
/\s/.test(
|
|
142
|
+
var H = /* @__PURE__ */ ((u) => (u.hehim = "He/Him", u.sheher = "She/Her", u.theythem = "They/Them", u.shethem = "She/They", u.hethem = "He/They", u.heshe = "He/She", u.xexem = "Xe/Xem", u.faefaer = "Fae/Faer", u.vever = "Ve/Ver", u.aeaer = "Ae/Aer", u.ziehir = "Zie/Hir", u.perper = "Per/Per", u.eem = "E/Em", u.itits = "It/Its", u))(H || {});
|
|
143
|
+
function N(u, e = j.data.emotes) {
|
|
144
|
+
const a = [];
|
|
145
|
+
return e.forEach((t) => {
|
|
146
|
+
const n = t.name;
|
|
147
|
+
let r = 0, d = 0;
|
|
148
|
+
for (; r < u.length; ) {
|
|
149
|
+
const o = u.indexOf(n, d);
|
|
150
|
+
if (o === -1) break;
|
|
151
|
+
const c = o > 0 ? u[o - 1] : " ", w = o + n.length < u.length ? u[o + n.length] : " ";
|
|
152
|
+
/\s/.test(c) && /\s/.test(w) && a.push({ ...t, start: o, end: o + n.length }), d = o + 1;
|
|
133
153
|
}
|
|
134
|
-
}),
|
|
154
|
+
}), a.sort((t, n) => t.start - n.start);
|
|
135
155
|
}
|
|
136
|
-
function
|
|
156
|
+
function B(u, e) {
|
|
137
157
|
if (!e.length) return u;
|
|
138
|
-
let
|
|
139
|
-
return e.forEach((
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
}),
|
|
158
|
+
let a = "", t = 0;
|
|
159
|
+
return e.forEach((n) => {
|
|
160
|
+
a += u.substring(t, n.start);
|
|
161
|
+
const r = n.urls[4] || n.urls[2] || n.urls[1];
|
|
162
|
+
a += `<img src="${r}" alt="${n.name}" class="emote" style="width: auto; height: 1em; vertical-align: middle;" />`, t = n.end;
|
|
163
|
+
}), a += u.substring(t), a;
|
|
144
164
|
}
|
|
145
|
-
async function
|
|
146
|
-
if (!Array.isArray(u) && typeof u == "string" && (u = u.split(",").map((
|
|
147
|
-
var
|
|
148
|
-
for await (const
|
|
149
|
-
var
|
|
150
|
-
!u.includes(
|
|
165
|
+
async function z(u = [], e = "twitch") {
|
|
166
|
+
if (!Array.isArray(u) && typeof u == "string" && (u = u.split(",").map((d) => d.trim())), !u || !u.length) {
|
|
167
|
+
var a = j.rand.number(1, 3);
|
|
168
|
+
for await (const d of Array.from({ length: a }, () => "")) {
|
|
169
|
+
var t = j.rand.array(Object.keys(j.data.badges))[0];
|
|
170
|
+
!u.includes(t) && Array.isArray(u) ? u.push(t) : u = [t];
|
|
151
171
|
}
|
|
152
172
|
}
|
|
153
|
-
var
|
|
173
|
+
var n;
|
|
154
174
|
switch (e) {
|
|
155
175
|
case "twitch": {
|
|
156
|
-
|
|
157
|
-
keys: Array.from(u).filter((
|
|
158
|
-
badges: Array.from(u).slice(0, 3).map((
|
|
176
|
+
n = {
|
|
177
|
+
keys: Array.from(u).filter((d) => d in j.data.badges),
|
|
178
|
+
badges: Array.from(u).slice(0, 3).map((d) => j.data.badges[d]).filter(Boolean)
|
|
159
179
|
};
|
|
160
180
|
break;
|
|
161
181
|
}
|
|
162
182
|
case "youtube": {
|
|
163
|
-
var
|
|
183
|
+
var r = {
|
|
164
184
|
verified: { isVerified: !1 },
|
|
165
185
|
broadcaster: { isChatOwner: !1 },
|
|
166
186
|
host: { isChatOwner: !1 },
|
|
@@ -168,8 +188,8 @@ async function U(u = [], e = "twitch") {
|
|
|
168
188
|
subscriber: { isChatSponsor: !1 },
|
|
169
189
|
moderator: { isChatModerator: !1 }
|
|
170
190
|
};
|
|
171
|
-
|
|
172
|
-
(
|
|
191
|
+
n = Object.entries(u).reduce(
|
|
192
|
+
(d, [o]) => (o in r && Object.assign(d, r[o]), d),
|
|
173
193
|
{
|
|
174
194
|
isVerified: !1,
|
|
175
195
|
isChatOwner: !1,
|
|
@@ -180,11 +200,11 @@ async function U(u = [], e = "twitch") {
|
|
|
180
200
|
break;
|
|
181
201
|
}
|
|
182
202
|
}
|
|
183
|
-
return
|
|
203
|
+
return n;
|
|
184
204
|
}
|
|
185
|
-
const
|
|
205
|
+
const s = class s {
|
|
186
206
|
static fields(e) {
|
|
187
|
-
const
|
|
207
|
+
const a = {
|
|
188
208
|
from: "main",
|
|
189
209
|
endsWith: [],
|
|
190
210
|
ignore: [],
|
|
@@ -234,128 +254,181 @@ const r = class r {
|
|
|
234
254
|
]
|
|
235
255
|
}
|
|
236
256
|
};
|
|
237
|
-
function
|
|
257
|
+
function t(m) {
|
|
238
258
|
return {
|
|
239
|
-
...
|
|
259
|
+
...a,
|
|
240
260
|
...m,
|
|
241
|
-
endsWith: Array.isArray(m.endsWith) ? m.endsWith :
|
|
242
|
-
ignore: Array.isArray(m.ignore) ? m.ignore :
|
|
243
|
-
replace: { ...
|
|
261
|
+
endsWith: Array.isArray(m.endsWith) ? m.endsWith : a.endsWith,
|
|
262
|
+
ignore: Array.isArray(m.ignore) ? m.ignore : a.ignore,
|
|
263
|
+
replace: { ...a.replace, ...m.replace ?? {} },
|
|
244
264
|
settings: {
|
|
245
|
-
types: Array.isArray(m.settings?.types) ? m.settings.types :
|
|
246
|
-
addons: Array.isArray(m.settings?.addons) ? m.settings.addons :
|
|
247
|
-
transforms: Array.isArray(m.settings?.transforms) ? m.settings.transforms :
|
|
248
|
-
labels: Array.isArray(m.settings?.labels) ? m.settings.labels :
|
|
265
|
+
types: Array.isArray(m.settings?.types) ? m.settings.types : a.settings.types,
|
|
266
|
+
addons: Array.isArray(m.settings?.addons) ? m.settings.addons : a.settings.addons,
|
|
267
|
+
transforms: Array.isArray(m.settings?.transforms) ? m.settings.transforms : a.settings.transforms,
|
|
268
|
+
labels: Array.isArray(m.settings?.labels) ? m.settings.labels : a.settings.labels
|
|
249
269
|
},
|
|
250
|
-
subgroup: m.subgroup ??
|
|
251
|
-
template: m.template ??
|
|
252
|
-
subgroupTemplate: m.subgroupTemplate ??
|
|
253
|
-
from: m.from ??
|
|
270
|
+
subgroup: m.subgroup ?? a.subgroup,
|
|
271
|
+
template: m.template ?? a.template,
|
|
272
|
+
subgroupTemplate: m.subgroupTemplate ?? a.subgroupTemplate,
|
|
273
|
+
from: m.from ?? a.from
|
|
254
274
|
};
|
|
255
275
|
}
|
|
256
|
-
const
|
|
257
|
-
(m, { cssRules:
|
|
258
|
-
|
|
259
|
-
m[
|
|
276
|
+
const n = t(e), d = Array.from(document.styleSheets).filter(({ href: m }) => !m || m.startsWith(window.location.origin)).reduce(
|
|
277
|
+
(m, { cssRules: b }) => (b && Array.from(b).forEach((y) => {
|
|
278
|
+
y instanceof CSSStyleRule && y.selectorText === n.from && Array.from(y.style).some((i) => i.startsWith("--")) && Array.from(y.style).filter((i) => i.startsWith("--")).forEach((i) => {
|
|
279
|
+
m[i] = y.style.getPropertyValue(i).trim();
|
|
260
280
|
});
|
|
261
281
|
}), m),
|
|
262
282
|
{}
|
|
263
|
-
),
|
|
264
|
-
(m, [
|
|
283
|
+
), o = Object.entries(d).filter(([m]) => n.endsWith.some((b) => m.toLowerCase().endsWith(b.toLowerCase()) && !m.includes("-options-"))).filter(([m]) => !n.ignore.some((b) => m.toLowerCase() === b.toLowerCase())).reduce(
|
|
284
|
+
(m, [b, y]) => (m[b.replace("--", "")] = String(n.replace?.[b] ?? y), m),
|
|
265
285
|
{}
|
|
266
286
|
);
|
|
267
|
-
let
|
|
268
|
-
const
|
|
269
|
-
(m, [
|
|
270
|
-
let
|
|
287
|
+
let c = [];
|
|
288
|
+
const w = Object.entries(o).reduce(
|
|
289
|
+
(m, [b, y]) => {
|
|
290
|
+
let i = n.settings.types.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || "text", l = n.settings.transforms.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || ((v) => v), p = {
|
|
271
291
|
type: "text",
|
|
272
|
-
label:
|
|
273
|
-
...
|
|
292
|
+
label: n.settings.labels.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || "",
|
|
293
|
+
...n.settings.addons.find(([v]) => v.some((g) => b.toLowerCase().includes(g)))?.[1] || {}
|
|
274
294
|
};
|
|
275
|
-
["min", "max", "step", "label", "type"].forEach((
|
|
276
|
-
const g =
|
|
277
|
-
g && g.length && (
|
|
295
|
+
["min", "max", "step", "label", "type"].forEach((v) => {
|
|
296
|
+
const g = d[`--${b}-${v}`];
|
|
297
|
+
g && g.length && (p[v] = isNaN(parseFloat(g)) ? String(g).replace(/^['"]|['"]$/g, "") : String(parseFloat(g)));
|
|
278
298
|
});
|
|
279
|
-
let x =
|
|
280
|
-
(
|
|
299
|
+
let x = b.replace(/-(size|color|weight|width|height|gap|duration|radius|amount)$/g, "").replace(/-([a-z])/g, (v, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase().trim(), k = Object.keys(o).filter(
|
|
300
|
+
(v) => v.startsWith(x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1))
|
|
281
301
|
);
|
|
282
|
-
|
|
302
|
+
n.subgroup && !m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] && k.length > 1 && !c.includes(b) && (c.push(...k), m[`${x.replace(/[A-Z]/g, "-$&").replaceAll(" ", "-").toLowerCase().slice(1)}-subgroup`] = {
|
|
283
303
|
type: "hidden",
|
|
284
|
-
label:
|
|
304
|
+
label: n.subgroupTemplate.replaceAll("{key}", s.string.capitalize(x))
|
|
285
305
|
});
|
|
286
|
-
let S =
|
|
287
|
-
|
|
306
|
+
let S = s.string.capitalize(
|
|
307
|
+
b.replace(/-([a-z])/g, (v, g) => g.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
|
|
288
308
|
);
|
|
289
|
-
|
|
290
|
-
const
|
|
291
|
-
const
|
|
292
|
-
(g, [
|
|
293
|
-
const
|
|
294
|
-
return
|
|
295
|
-
|
|
309
|
+
y = l(y) ?? y;
|
|
310
|
+
const M = (() => {
|
|
311
|
+
const v = Object.entries(d).filter(([g]) => g.startsWith(`--${b}-options-`)).reduce(
|
|
312
|
+
(g, [R, A]) => {
|
|
313
|
+
const I = R.replace(`--${b}-options-`, "");
|
|
314
|
+
return I && (g[String(A)] = s.string.capitalize(
|
|
315
|
+
I.replace(/-([a-z])/g, (T, W) => W.toUpperCase()).replace(/[A-Z]/g, " $&").toLowerCase()
|
|
296
316
|
)), g;
|
|
297
317
|
},
|
|
298
318
|
{}
|
|
299
319
|
);
|
|
300
|
-
return Object.keys(
|
|
320
|
+
return Object.keys(v).length ? v : null;
|
|
301
321
|
})();
|
|
302
|
-
return
|
|
303
|
-
[!1, "inherit", "auto", null].includes(g) && (
|
|
304
|
-
}), m[
|
|
305
|
-
type:
|
|
306
|
-
label:
|
|
307
|
-
value:
|
|
308
|
-
min:
|
|
309
|
-
max:
|
|
310
|
-
step:
|
|
311
|
-
options:
|
|
322
|
+
return M && (i = "dropdown", p.options = M, y = String(y)), Object.entries(p).forEach(([v, g]) => {
|
|
323
|
+
[!1, "inherit", "auto", null].includes(g) && (p[v] = y);
|
|
324
|
+
}), m[b] = {
|
|
325
|
+
type: p.type || i,
|
|
326
|
+
label: n.template.toString().replaceAll("{key}", s.string.capitalize(S) + p.label),
|
|
327
|
+
value: y,
|
|
328
|
+
min: p.min,
|
|
329
|
+
max: p.max,
|
|
330
|
+
step: p.step,
|
|
331
|
+
options: p.options
|
|
312
332
|
}, m;
|
|
313
333
|
},
|
|
314
334
|
{}
|
|
315
|
-
),
|
|
316
|
-
(m, [
|
|
317
|
-
const
|
|
318
|
-
return (
|
|
335
|
+
), h = Object.entries(w).reduce(
|
|
336
|
+
(m, [b, y]) => {
|
|
337
|
+
const i = y?.label?.includes("undefined"), l = !["hidden", "button"].includes(y.type) && y.value === void 0;
|
|
338
|
+
return (i || l) && (m[b] = y), m;
|
|
319
339
|
},
|
|
320
340
|
{}
|
|
321
341
|
);
|
|
322
|
-
if (Object.keys(
|
|
323
|
-
throw
|
|
324
|
-
return
|
|
342
|
+
if (Object.keys(h).length)
|
|
343
|
+
throw O.logger.error("Simulation.fields: Detected errors in generated fields:", h), new Error("Error while processing fields");
|
|
344
|
+
return w;
|
|
325
345
|
}
|
|
326
346
|
static async start() {
|
|
327
347
|
const e = {
|
|
328
|
-
fields: ["fields.json", "cf.json", "field.json", "customfields.json"].find((
|
|
348
|
+
fields: ["fields.json", "cf.json", "field.json", "customfields.json"].find((t) => {
|
|
329
349
|
try {
|
|
330
|
-
return new URL("./" +
|
|
350
|
+
return new URL("./" + t, window.location.href), !0;
|
|
331
351
|
} catch {
|
|
332
352
|
return !1;
|
|
333
353
|
}
|
|
334
354
|
}),
|
|
335
|
-
data: ["data.json", "fielddata.json", "fd.json", "DATA.json"].find((
|
|
355
|
+
data: ["data.json", "fielddata.json", "fd.json", "DATA.json"].find((t) => {
|
|
336
356
|
try {
|
|
337
|
-
return new URL("./" +
|
|
357
|
+
return new URL("./" + t, window.location.href), !0;
|
|
338
358
|
} catch {
|
|
339
359
|
return !1;
|
|
340
360
|
}
|
|
341
361
|
})
|
|
342
|
-
},
|
|
362
|
+
}, a = await fetch("./" + (e.data ?? "data.json"), {
|
|
343
363
|
cache: "no-store"
|
|
344
|
-
}).then((
|
|
364
|
+
}).then((t) => t.json()).catch(() => ({}));
|
|
345
365
|
await fetch("./" + (e.fields ?? "fields.json"), {
|
|
346
366
|
cache: "no-store"
|
|
347
|
-
}).then((
|
|
348
|
-
const
|
|
349
|
-
(
|
|
350
|
-
{
|
|
351
|
-
|
|
352
|
-
|
|
367
|
+
}).then((t) => t.json()).then(async (t) => {
|
|
368
|
+
const n = Object.entries(t).filter(([d, { value: o }]) => o != null).reduce(
|
|
369
|
+
(d, [o, { value: c }]) => (a && a[o] !== void 0 && (c = a[o]), d[o] = c, d),
|
|
370
|
+
{
|
|
371
|
+
...a
|
|
372
|
+
}
|
|
373
|
+
), r = await s.generate.event.onWidgetLoad(n, await s.generate.session.get());
|
|
374
|
+
window.dispatchEvent(new CustomEvent("onWidgetLoad", { detail: r }));
|
|
353
375
|
});
|
|
354
376
|
}
|
|
355
377
|
};
|
|
356
|
-
|
|
357
|
-
names: ["
|
|
358
|
-
messages: [
|
|
378
|
+
s.data = {
|
|
379
|
+
names: ["Local", "Tixyel", "Urie_s2", "itzzcatt", "BeniArts", "Cupidiko", "shy_madeit"],
|
|
380
|
+
messages: [
|
|
381
|
+
"Hello everyone!",
|
|
382
|
+
"PogChamp",
|
|
383
|
+
"This stream is amazing!",
|
|
384
|
+
"catJAM catJAM catJAM",
|
|
385
|
+
"LUL that was funny",
|
|
386
|
+
"GG!",
|
|
387
|
+
"First time here, loving it!",
|
|
388
|
+
"DinoDance",
|
|
389
|
+
"Can we get some hype in chat?",
|
|
390
|
+
"TransgenderPride PansexualPride NonbinaryPride",
|
|
391
|
+
"POGGERS",
|
|
392
|
+
"I just followed! PogChamp",
|
|
393
|
+
"Great gameplay btw",
|
|
394
|
+
"LUL LUL LUL",
|
|
395
|
+
"This is so wholesome AngelThump",
|
|
396
|
+
"catJAM vibing",
|
|
397
|
+
"haHAA",
|
|
398
|
+
"Wait what just happened? D:",
|
|
399
|
+
"GlitchCat GlitchCat",
|
|
400
|
+
"Best stream on Twitch right now!",
|
|
401
|
+
"DarkMode gang where you at?",
|
|
402
|
+
"PogChamp PogChamp PogChamp PogChamp",
|
|
403
|
+
"Anyone else eating? DoritosChip",
|
|
404
|
+
"I love this community!",
|
|
405
|
+
"TheIlluminati confirmed",
|
|
406
|
+
"bUrself be yourself!",
|
|
407
|
+
"CookieTime nom nom",
|
|
408
|
+
"imGlitch technical difficulties",
|
|
409
|
+
"This music is fire catJAM",
|
|
410
|
+
"bttvNice",
|
|
411
|
+
"LesbianPride GayPride BisexualPride",
|
|
412
|
+
"SSSsss Minecraft time",
|
|
413
|
+
"PopNemo",
|
|
414
|
+
"Going to bed, good night everyone!",
|
|
415
|
+
"Just got here, what did I miss?",
|
|
416
|
+
":tf: trollface",
|
|
417
|
+
"ariW wave",
|
|
418
|
+
"BroBalt nice one",
|
|
419
|
+
"AsexualPride IntersexPride GenderFluidPride",
|
|
420
|
+
"This chat is moving so fast!",
|
|
421
|
+
"CandianRage",
|
|
422
|
+
"PunchTrees PunchTrees",
|
|
423
|
+
"CiGrip",
|
|
424
|
+
"ConcernDoge hmm",
|
|
425
|
+
"CruW salute",
|
|
426
|
+
"cvHazmat stay safe",
|
|
427
|
+
"DuckerZ quack",
|
|
428
|
+
"BloodTrail hunting time",
|
|
429
|
+
"CatBag kitty!",
|
|
430
|
+
"c! poggers"
|
|
431
|
+
],
|
|
359
432
|
tiers: ["1000", "2000", "3000", "prime"],
|
|
360
433
|
avatars: [
|
|
361
434
|
"https://static-cdn.jtvnw.net/user-default-pictures-uv/13e5fa74-defa-11e9-809c-784f43822e80-profile_image-300x300.png",
|
|
@@ -1115,7 +1188,7 @@ r.data = {
|
|
|
1115
1188
|
description: "VIP"
|
|
1116
1189
|
}
|
|
1117
1190
|
},
|
|
1118
|
-
pronouns:
|
|
1191
|
+
pronouns: H,
|
|
1119
1192
|
tts: [
|
|
1120
1193
|
"Filiz",
|
|
1121
1194
|
"Astrid",
|
|
@@ -1205,21 +1278,21 @@ r.data = {
|
|
|
1205
1278
|
"Hoda",
|
|
1206
1279
|
"Naayf"
|
|
1207
1280
|
]
|
|
1208
|
-
},
|
|
1209
|
-
opacity(e = 100,
|
|
1210
|
-
|
|
1211
|
-
let
|
|
1212
|
-
return
|
|
1281
|
+
}, s.color = {
|
|
1282
|
+
opacity(e = 100, a) {
|
|
1283
|
+
a = a.length > 7 ? a.substring(0, 6) : a, e = e > 1 ? e / 100 : e;
|
|
1284
|
+
let t = Math.round(Math.min(Math.max(e, 0), 1) * 255).toString(16).toLowerCase();
|
|
1285
|
+
return t = t.padStart(2, "0"), a + t;
|
|
1213
1286
|
},
|
|
1214
1287
|
getOpacity(e) {
|
|
1215
1288
|
if (!e.startsWith("#") || e.length <= 7) return { opacity: 100, hex: e };
|
|
1216
|
-
var
|
|
1217
|
-
return { opacity:
|
|
1289
|
+
var a = e.slice(-2), t = parseInt(a, 16) / 255, n = Math.round(t * 100), r = e.length > 7 ? e.slice(0, 7) : e;
|
|
1290
|
+
return { opacity: n, color: r };
|
|
1218
1291
|
},
|
|
1219
1292
|
validate(e) {
|
|
1220
1293
|
if (typeof e != "string" || !e.length) return !1;
|
|
1221
|
-
const
|
|
1222
|
-
return /^#([A-Fa-f0-9]{3}){1,2}$/.test(
|
|
1294
|
+
const a = e.trim();
|
|
1295
|
+
return /^#([A-Fa-f0-9]{3}){1,2}$/.test(a) || /^#([A-Fa-f0-9]{4}|[A-Fa-f0-9]{8})$/.test(a) ? "hex" : /^rgb\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)$/.test(a) ? "rgb" : /^rgba\(\s*(?:\d{1,3}\s*,\s*){3}(?:0|1|0?\.\d+)\s*\)$/.test(a) ? "rgba" : /^hsl\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*\)$/.test(a) ? "hsl" : /^hsla\(\s*\d{1,3}\s*,\s*\d{1,3}%\s*,\s*\d{1,3}%\s*,\s*(?:0|1|0?\.\d+)\s*\)$/.test(a) ? "hsla" : [
|
|
1223
1296
|
"aliceblue",
|
|
1224
1297
|
"antiquewhite",
|
|
1225
1298
|
"aqua",
|
|
@@ -1369,36 +1442,36 @@ r.data = {
|
|
|
1369
1442
|
"yellow",
|
|
1370
1443
|
"yellowgreen",
|
|
1371
1444
|
"transparent"
|
|
1372
|
-
].includes(
|
|
1445
|
+
].includes(a.toLowerCase()) ? "css-color-name" : !1;
|
|
1373
1446
|
}
|
|
1374
|
-
},
|
|
1447
|
+
}, s.rand = {
|
|
1375
1448
|
color(e = "hex") {
|
|
1376
1449
|
switch (e) {
|
|
1377
1450
|
default:
|
|
1378
1451
|
case "hex":
|
|
1379
1452
|
return `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`;
|
|
1380
1453
|
case "hexa": {
|
|
1381
|
-
const
|
|
1382
|
-
return
|
|
1454
|
+
const t = `#${Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")}`, n = Math.floor(Math.random() * 256).toString(16).padStart(2, "0");
|
|
1455
|
+
return t + n;
|
|
1383
1456
|
}
|
|
1384
1457
|
case "rgb": {
|
|
1385
|
-
const
|
|
1386
|
-
return `rgb(${
|
|
1458
|
+
const t = Math.floor(Math.random() * 256), n = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256);
|
|
1459
|
+
return `rgb(${t}, ${n}, ${r})`;
|
|
1387
1460
|
}
|
|
1388
1461
|
case "rgba": {
|
|
1389
|
-
const
|
|
1390
|
-
return `rgba(${
|
|
1462
|
+
const t = Math.floor(Math.random() * 256), n = Math.floor(Math.random() * 256), r = Math.floor(Math.random() * 256), d = Math.random().toFixed(2);
|
|
1463
|
+
return `rgba(${t}, ${n}, ${r}, ${d})`;
|
|
1391
1464
|
}
|
|
1392
1465
|
case "hsl": {
|
|
1393
|
-
const
|
|
1394
|
-
return `hsl(${
|
|
1466
|
+
const t = Math.floor(Math.random() * 361), n = Math.floor(Math.random() * 101), r = Math.floor(Math.random() * 101);
|
|
1467
|
+
return `hsl(${t}, ${n}%, ${r}%)`;
|
|
1395
1468
|
}
|
|
1396
1469
|
case "hsla": {
|
|
1397
|
-
const
|
|
1398
|
-
return `hsla(${
|
|
1470
|
+
const t = Math.floor(Math.random() * 361), n = Math.floor(Math.random() * 101), r = Math.floor(Math.random() * 101), d = Math.random().toFixed(2);
|
|
1471
|
+
return `hsla(${t}, ${n}%, ${r}%, ${d})`;
|
|
1399
1472
|
}
|
|
1400
1473
|
case "css-color-name": {
|
|
1401
|
-
var
|
|
1474
|
+
var a = [
|
|
1402
1475
|
"aliceblue",
|
|
1403
1476
|
"antiquewhite",
|
|
1404
1477
|
"aqua",
|
|
@@ -1549,31 +1622,31 @@ r.data = {
|
|
|
1549
1622
|
"yellowgreen",
|
|
1550
1623
|
"transparent"
|
|
1551
1624
|
];
|
|
1552
|
-
return this.array(
|
|
1625
|
+
return this.array(a)[0];
|
|
1553
1626
|
}
|
|
1554
1627
|
}
|
|
1555
1628
|
},
|
|
1556
|
-
number(e,
|
|
1557
|
-
e >
|
|
1558
|
-
const
|
|
1559
|
-
return
|
|
1629
|
+
number(e, a, t = 0) {
|
|
1630
|
+
e > a && ([e, a] = [a, e]);
|
|
1631
|
+
const n = Math.random() * (a - e) + e;
|
|
1632
|
+
return t ? Number(n.toFixed(t)) : Math.round(n);
|
|
1560
1633
|
},
|
|
1561
1634
|
boolean(e = 0.5) {
|
|
1562
1635
|
return Math.random() > e;
|
|
1563
1636
|
},
|
|
1564
|
-
string(e,
|
|
1565
|
-
let
|
|
1566
|
-
for (let
|
|
1567
|
-
|
|
1568
|
-
return
|
|
1637
|
+
string(e, a = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") {
|
|
1638
|
+
let t = "";
|
|
1639
|
+
for (let n = 0; n < e; n++)
|
|
1640
|
+
t += a.charAt(Math.floor(Math.random() * a.length));
|
|
1641
|
+
return t;
|
|
1569
1642
|
},
|
|
1570
1643
|
array(e) {
|
|
1571
|
-
const
|
|
1572
|
-
return [e[
|
|
1644
|
+
const a = this.number(0, e.length - 1);
|
|
1645
|
+
return [e[a], a];
|
|
1573
1646
|
},
|
|
1574
1647
|
date(e = 365) {
|
|
1575
|
-
const
|
|
1576
|
-
return new Date(
|
|
1648
|
+
const t = Date.now() - this.number(0, e * 24 * 60 * 60 * 1e3);
|
|
1649
|
+
return new Date(t).toISOString();
|
|
1577
1650
|
},
|
|
1578
1651
|
uuid() {
|
|
1579
1652
|
return window.crypto && typeof crypto?.randomUUID == "function" ? crypto.randomUUID() : "10000000-1000-4000-8000-100000000000".replace(
|
|
@@ -1581,7 +1654,7 @@ r.data = {
|
|
|
1581
1654
|
(e) => (+e ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> +e / 4).toString(16)
|
|
1582
1655
|
);
|
|
1583
1656
|
}
|
|
1584
|
-
},
|
|
1657
|
+
}, s.string = {
|
|
1585
1658
|
/**
|
|
1586
1659
|
* Replaces occurrences in a string based on a pattern with the result of an asynchronous callback function.
|
|
1587
1660
|
* @param string - The input string to perform replacements on.
|
|
@@ -1596,14 +1669,14 @@ r.data = {
|
|
|
1596
1669
|
* console.log(result); // Output will depend on the fetched data
|
|
1597
1670
|
* ```
|
|
1598
1671
|
*/
|
|
1599
|
-
async replace(e,
|
|
1600
|
-
const
|
|
1601
|
-
e.replace(
|
|
1602
|
-
const
|
|
1603
|
-
return
|
|
1672
|
+
async replace(e, a, t) {
|
|
1673
|
+
const n = [];
|
|
1674
|
+
e.replace(a, (d, ...o) => {
|
|
1675
|
+
const c = typeof t == "function" ? t(d, ...o) : d;
|
|
1676
|
+
return n.push(Promise.resolve(c)), d;
|
|
1604
1677
|
});
|
|
1605
|
-
const
|
|
1606
|
-
return e.replace(
|
|
1678
|
+
const r = await Promise.all(n);
|
|
1679
|
+
return e.replace(a, () => r.shift() ?? "");
|
|
1607
1680
|
},
|
|
1608
1681
|
/**
|
|
1609
1682
|
* Capitalizes the first letter of a given string.
|
|
@@ -1632,47 +1705,47 @@ r.data = {
|
|
|
1632
1705
|
* console.log(result); // Output: "Hello, john_doe! You have 5 MESSAGES and your name is John."
|
|
1633
1706
|
* ```
|
|
1634
1707
|
*/
|
|
1635
|
-
compose(e,
|
|
1636
|
-
const { mergeSpanStyles:
|
|
1637
|
-
(
|
|
1638
|
-
if (
|
|
1639
|
-
const
|
|
1640
|
-
|
|
1708
|
+
compose(e, a, t = { method: "index", modifiers: {} }) {
|
|
1709
|
+
const { mergeSpanStyles: n } = s.element, r = Object.entries(s.object.flatten(a)).reduce(
|
|
1710
|
+
(i, [l, f]) => {
|
|
1711
|
+
if (i[l] = String(f), ["username", "name", "nick", "nickname", "sender"].some((p) => l === p)) {
|
|
1712
|
+
const p = i?.username || i?.name || i?.nick || i?.nickname || i?.sender;
|
|
1713
|
+
i.username = i.username || p, i.usernameAt = `@${i.username}`, i.name = i.name || p, i.nick = i.nick || p, i.nickname = i.nickname || p, i.sender = i.sender || p, i.senderAt = `@${i.sender}`;
|
|
1641
1714
|
}
|
|
1642
|
-
return ["amount", "count"].some((
|
|
1715
|
+
return ["amount", "count"].some((p) => l === p) && (i.amount = String(o), i.count = String(i?.count || o)), i.currency = i.currency || window.client?.details.currency.symbol || "$", i.currencyCode = i.currencyCode || window.client?.details.currency.code || "USD", i.skip = "<br/>", i.newline = "<br/>", i;
|
|
1643
1716
|
},
|
|
1644
1717
|
{}
|
|
1645
|
-
),
|
|
1718
|
+
), d = {
|
|
1646
1719
|
PLACEHOLDERS: /{([^}]+)}/g,
|
|
1647
1720
|
MODIFIERS: /\[(\w+)(:[^=]+)?=([^\]]+)\]/g
|
|
1648
1721
|
};
|
|
1649
|
-
var
|
|
1650
|
-
const
|
|
1651
|
-
BT1: (
|
|
1652
|
-
BT0: (
|
|
1653
|
-
ST1: (
|
|
1654
|
-
ST0: (
|
|
1655
|
-
UPC: (
|
|
1656
|
-
LOW: (
|
|
1657
|
-
REV: (
|
|
1658
|
-
CAP: (
|
|
1659
|
-
FALLBACK: (
|
|
1660
|
-
COLOR: (
|
|
1661
|
-
WEIGHT: (
|
|
1662
|
-
BOLD: (
|
|
1663
|
-
LIGHT: (
|
|
1664
|
-
STRONG: (
|
|
1665
|
-
ITALIC: (
|
|
1666
|
-
UNDERLINE: (
|
|
1667
|
-
STRIKETHROUGH: (
|
|
1668
|
-
SUB: (
|
|
1669
|
-
SUP: (
|
|
1670
|
-
LARGER: (
|
|
1671
|
-
SMALL: (
|
|
1672
|
-
SHADOW: (
|
|
1673
|
-
SIZE: (
|
|
1674
|
-
...
|
|
1675
|
-
},
|
|
1722
|
+
var o = parseFloat(r?.amount ?? r?.count ?? 0);
|
|
1723
|
+
const c = {
|
|
1724
|
+
BT1: (i) => o > 1 ? i : "",
|
|
1725
|
+
BT0: (i) => o > 0 ? i : "",
|
|
1726
|
+
ST1: (i) => o < 1 ? i : "",
|
|
1727
|
+
ST0: (i) => o < 0 ? i : "",
|
|
1728
|
+
UPC: (i) => i.toUpperCase(),
|
|
1729
|
+
LOW: (i) => i.toLowerCase(),
|
|
1730
|
+
REV: (i) => i.split("").reverse().join(""),
|
|
1731
|
+
CAP: (i) => i.charAt(0).toUpperCase() + i.slice(1).toLowerCase(),
|
|
1732
|
+
FALLBACK: (i, l) => i.length ? i : l ?? i,
|
|
1733
|
+
COLOR: (i, l) => n(l && s.color.validate(l) ? `color: ${l}` : "", i),
|
|
1734
|
+
WEIGHT: (i, l) => n(l && !isNaN(parseInt(l)) ? `font-weight: ${l}` : "", i),
|
|
1735
|
+
BOLD: (i) => n("font-weight: bold", i),
|
|
1736
|
+
LIGHT: (i) => n("font-weight: lighter", i),
|
|
1737
|
+
STRONG: (i) => n("font-weight: bolder", i),
|
|
1738
|
+
ITALIC: (i) => n("font-style: italic", i),
|
|
1739
|
+
UNDERLINE: (i) => n("text-decoration: underline", i),
|
|
1740
|
+
STRIKETHROUGH: (i) => n("text-decoration: line-through", i),
|
|
1741
|
+
SUB: (i) => n("vertical-align: sub", i),
|
|
1742
|
+
SUP: (i) => n("vertical-align: super", i),
|
|
1743
|
+
LARGER: (i) => n("font-size: larger", i),
|
|
1744
|
+
SMALL: (i) => n("font-size: smaller", i),
|
|
1745
|
+
SHADOW: (i, l) => n(`text-shadow: ${l}`, i),
|
|
1746
|
+
SIZE: (i, l) => n(l ? `font-size: ${l}` : "", i),
|
|
1747
|
+
...t.modifiers ?? {}
|
|
1748
|
+
}, w = {
|
|
1676
1749
|
UPC: ["UPPERCASE", "UPPER", "UPP"],
|
|
1677
1750
|
LOW: ["LOWERCASE", "LOWER", "LWC"],
|
|
1678
1751
|
REV: ["REVERSE", "RVS"],
|
|
@@ -1694,59 +1767,59 @@ r.data = {
|
|
|
1694
1767
|
SHADOW: ["SHADOW", "SHD"],
|
|
1695
1768
|
FALLBACK: ["FALLBACK", "FB"]
|
|
1696
1769
|
};
|
|
1697
|
-
function
|
|
1698
|
-
const
|
|
1699
|
-
return
|
|
1770
|
+
function h(i, l, f) {
|
|
1771
|
+
const p = Object.entries(w).find(([k, S]) => S.some((C) => C.toUpperCase() === l.toUpperCase()) ? !0 : k.toUpperCase() === l.toUpperCase()), x = p ? p[0] : l.toUpperCase();
|
|
1772
|
+
return c[x] ? c[x](i, typeof f == "string" ? f.trim() : null, r) : i;
|
|
1700
1773
|
}
|
|
1701
|
-
function m(
|
|
1702
|
-
let
|
|
1703
|
-
for (; (
|
|
1704
|
-
const [
|
|
1705
|
-
|
|
1774
|
+
function m(i) {
|
|
1775
|
+
let l = i, f;
|
|
1776
|
+
for (; (f = d.MODIFIERS.exec(l)) !== null; ) {
|
|
1777
|
+
const [p, x, k, S] = f, C = h(m(S), x, k);
|
|
1778
|
+
l = l.replace(p, C ?? ""), d.MODIFIERS.lastIndex = 0;
|
|
1706
1779
|
}
|
|
1707
|
-
return
|
|
1780
|
+
return l;
|
|
1708
1781
|
}
|
|
1709
|
-
function
|
|
1710
|
-
let
|
|
1711
|
-
const
|
|
1712
|
-
function
|
|
1782
|
+
function b(i) {
|
|
1783
|
+
let l = 0;
|
|
1784
|
+
const f = i.length;
|
|
1785
|
+
function p(k) {
|
|
1713
1786
|
let S = "";
|
|
1714
|
-
for (;
|
|
1715
|
-
if (
|
|
1716
|
-
|
|
1717
|
-
else if (
|
|
1787
|
+
for (; l < f; )
|
|
1788
|
+
if (i[l] === "\\")
|
|
1789
|
+
l + 1 < f ? (S += i[l + 1], l += 2) : l++;
|
|
1790
|
+
else if (i[l] === "[" && (!k || k !== "["))
|
|
1718
1791
|
S += x();
|
|
1719
|
-
else if (k &&
|
|
1720
|
-
|
|
1792
|
+
else if (k && i[l] === k) {
|
|
1793
|
+
l++;
|
|
1721
1794
|
break;
|
|
1722
1795
|
} else
|
|
1723
|
-
S +=
|
|
1796
|
+
S += i[l++];
|
|
1724
1797
|
return S;
|
|
1725
1798
|
}
|
|
1726
1799
|
function x() {
|
|
1727
|
-
|
|
1800
|
+
l++;
|
|
1728
1801
|
let k = "";
|
|
1729
|
-
for (;
|
|
1802
|
+
for (; l < f && /[A-Za-z0-9]/.test(i[l]); ) k += i[l++];
|
|
1730
1803
|
let S = null;
|
|
1731
|
-
if (
|
|
1732
|
-
|
|
1733
|
-
const
|
|
1734
|
-
for (;
|
|
1735
|
-
S =
|
|
1804
|
+
if (i[l] === ":") {
|
|
1805
|
+
l++;
|
|
1806
|
+
const M = l;
|
|
1807
|
+
for (; l < f && i[l] !== "="; ) l++;
|
|
1808
|
+
S = i.slice(M, l);
|
|
1736
1809
|
}
|
|
1737
|
-
|
|
1738
|
-
const
|
|
1739
|
-
return
|
|
1810
|
+
i[l] === "=" && l++;
|
|
1811
|
+
const C = p("]");
|
|
1812
|
+
return h(C, k, S);
|
|
1740
1813
|
}
|
|
1741
|
-
return
|
|
1814
|
+
return p();
|
|
1742
1815
|
}
|
|
1743
|
-
let
|
|
1744
|
-
|
|
1745
|
-
(
|
|
1816
|
+
let y = e.replace(
|
|
1817
|
+
d.PLACEHOLDERS,
|
|
1818
|
+
(i, l) => typeof r[l] == "string" || typeof r[l] == "number" ? String(r[l]) : l ?? l
|
|
1746
1819
|
);
|
|
1747
|
-
return
|
|
1820
|
+
return y = t.method === "loop" ? m(y) : b(y), y;
|
|
1748
1821
|
}
|
|
1749
|
-
},
|
|
1822
|
+
}, s.element = {
|
|
1750
1823
|
/**
|
|
1751
1824
|
* Merges outer span styles with inner span styles in the provided HTML string.
|
|
1752
1825
|
* @param outerStyle - The style string to be applied to the outer span.
|
|
@@ -1758,15 +1831,15 @@ r.data = {
|
|
|
1758
1831
|
* console.log(result); // Output: '<span style="font-size: 14px; color: red; font-weight: bold;">Hello World</span>'
|
|
1759
1832
|
* ```
|
|
1760
1833
|
*/
|
|
1761
|
-
mergeSpanStyles(e,
|
|
1762
|
-
const
|
|
1763
|
-
if (
|
|
1764
|
-
const
|
|
1765
|
-
return `<span style="${[
|
|
1834
|
+
mergeSpanStyles(e, a) {
|
|
1835
|
+
const t = a.match(/^<span style="([^"]*)">(.*)<\/span>$/s);
|
|
1836
|
+
if (t) {
|
|
1837
|
+
const n = t[1], r = t[2];
|
|
1838
|
+
return `<span style="${[n, e].filter(Boolean).join("; ").replace(/\s*;\s*/g, "; ").trim()}">${r}</span>`;
|
|
1766
1839
|
} else
|
|
1767
|
-
return `<span style="${e}">${
|
|
1840
|
+
return `<span style="${e}">${a}</span>`;
|
|
1768
1841
|
}
|
|
1769
|
-
},
|
|
1842
|
+
}, s.object = {
|
|
1770
1843
|
/**
|
|
1771
1844
|
* Flattens a nested object into a single-level object with dot-separated keys.
|
|
1772
1845
|
* @param obj - The nested object to be flattened.
|
|
@@ -1780,48 +1853,48 @@ r.data = {
|
|
|
1780
1853
|
* // Output: { 'a.b': '1', 'a.c.d': '2', 'e:0': '3', 'e:1': '4' }
|
|
1781
1854
|
* ```
|
|
1782
1855
|
*/
|
|
1783
|
-
flatten(e,
|
|
1784
|
-
const
|
|
1785
|
-
for (const
|
|
1786
|
-
if (!Object.prototype.hasOwnProperty.call(e,
|
|
1787
|
-
const
|
|
1788
|
-
if (
|
|
1789
|
-
|
|
1856
|
+
flatten(e, a = "") {
|
|
1857
|
+
const t = {};
|
|
1858
|
+
for (const n in e) {
|
|
1859
|
+
if (!Object.prototype.hasOwnProperty.call(e, n)) continue;
|
|
1860
|
+
const r = e[n], d = a ? `${a}.${n}` : n;
|
|
1861
|
+
if (r == null) {
|
|
1862
|
+
t[d] = String(r);
|
|
1790
1863
|
continue;
|
|
1791
1864
|
}
|
|
1792
|
-
if (
|
|
1793
|
-
|
|
1865
|
+
if (r instanceof Date) {
|
|
1866
|
+
t[d] = r.toISOString();
|
|
1794
1867
|
continue;
|
|
1795
1868
|
}
|
|
1796
|
-
if (
|
|
1797
|
-
|
|
1798
|
-
|
|
1869
|
+
if (r instanceof Map) {
|
|
1870
|
+
r.forEach((o, c) => {
|
|
1871
|
+
t[`${d}.${c}`] = JSON.stringify(o);
|
|
1799
1872
|
});
|
|
1800
1873
|
continue;
|
|
1801
1874
|
}
|
|
1802
|
-
if (Array.isArray(
|
|
1803
|
-
|
|
1804
|
-
const
|
|
1805
|
-
typeof
|
|
1875
|
+
if (Array.isArray(r)) {
|
|
1876
|
+
r.forEach((o, c) => {
|
|
1877
|
+
const w = `${d}:${c}`;
|
|
1878
|
+
typeof o == "object" ? Object.assign(t, this.flatten(o, w)) : t[w] = String(o);
|
|
1806
1879
|
});
|
|
1807
1880
|
continue;
|
|
1808
1881
|
}
|
|
1809
|
-
if (typeof
|
|
1810
|
-
Object.assign(
|
|
1882
|
+
if (typeof r == "object") {
|
|
1883
|
+
Object.assign(t, this.flatten(r, d));
|
|
1811
1884
|
continue;
|
|
1812
1885
|
}
|
|
1813
|
-
|
|
1886
|
+
t[d] = String(r);
|
|
1814
1887
|
}
|
|
1815
|
-
return
|
|
1888
|
+
return t;
|
|
1816
1889
|
}
|
|
1817
|
-
},
|
|
1890
|
+
}, s.generate = {
|
|
1818
1891
|
session: {
|
|
1819
1892
|
types: {
|
|
1820
|
-
name: { type: "string", options:
|
|
1821
|
-
tier: { type: "string", options:
|
|
1822
|
-
message: { type: "string", options:
|
|
1823
|
-
item: { type: "array", options:
|
|
1824
|
-
avatar: { type: "string", options:
|
|
1893
|
+
name: { type: "string", options: s.data.names.filter((e) => e.length) },
|
|
1894
|
+
tier: { type: "string", options: s.data.tiers.filter((e) => e.length) },
|
|
1895
|
+
message: { type: "string", options: s.data.messages.filter((e) => e.length) },
|
|
1896
|
+
item: { type: "array", options: s.data.items },
|
|
1897
|
+
avatar: { type: "string", options: s.data.avatars.filter((e) => e.length) }
|
|
1825
1898
|
},
|
|
1826
1899
|
available() {
|
|
1827
1900
|
const e = this.types;
|
|
@@ -2067,49 +2140,49 @@ r.data = {
|
|
|
2067
2140
|
};
|
|
2068
2141
|
},
|
|
2069
2142
|
async get() {
|
|
2070
|
-
const e = this.available(),
|
|
2071
|
-
const
|
|
2072
|
-
if (!
|
|
2073
|
-
const
|
|
2074
|
-
for (let
|
|
2075
|
-
|
|
2076
|
-
return
|
|
2077
|
-
},
|
|
2078
|
-
const
|
|
2079
|
-
for (const
|
|
2080
|
-
const m =
|
|
2081
|
-
|
|
2143
|
+
const e = this.available(), a = (n) => {
|
|
2144
|
+
const r = (c) => {
|
|
2145
|
+
if (!c || !("amount" in c)) return [];
|
|
2146
|
+
const w = [];
|
|
2147
|
+
for (let h = 0; h < c.amount; h++)
|
|
2148
|
+
w.push(a(c.value));
|
|
2149
|
+
return w.sort((h, m) => new Date(m.createdAt).getTime() - new Date(h.createdAt).getTime());
|
|
2150
|
+
}, d = (c) => {
|
|
2151
|
+
const w = {};
|
|
2152
|
+
for (const h in c) {
|
|
2153
|
+
const m = h.replace("_type", "type");
|
|
2154
|
+
w[m] = a(c[h]);
|
|
2082
2155
|
}
|
|
2083
|
-
return
|
|
2084
|
-
},
|
|
2085
|
-
if (!
|
|
2086
|
-
switch (
|
|
2156
|
+
return w;
|
|
2157
|
+
}, o = (c) => {
|
|
2158
|
+
if (!c) return c;
|
|
2159
|
+
switch (c.type) {
|
|
2087
2160
|
case "int":
|
|
2088
|
-
return
|
|
2161
|
+
return s.rand.number(c.min, c.max);
|
|
2089
2162
|
case "string":
|
|
2090
|
-
return
|
|
2163
|
+
return s.rand.array(c.options)[0];
|
|
2091
2164
|
case "date":
|
|
2092
|
-
return
|
|
2165
|
+
return s.rand.date(c.range);
|
|
2093
2166
|
case "array":
|
|
2094
|
-
return
|
|
2167
|
+
return s.rand.array(c.options)[0];
|
|
2095
2168
|
case "recent":
|
|
2096
|
-
return
|
|
2169
|
+
return r(c);
|
|
2097
2170
|
default:
|
|
2098
|
-
return
|
|
2171
|
+
return c;
|
|
2099
2172
|
}
|
|
2100
2173
|
};
|
|
2101
|
-
return typeof
|
|
2174
|
+
return typeof n != "object" || n === null ? n : "type" in n && typeof n.type == "string" ? o(n) : d(n);
|
|
2102
2175
|
};
|
|
2103
|
-
var
|
|
2104
|
-
(
|
|
2105
|
-
([
|
|
2176
|
+
var t = Object.entries(a(e)).reduce(
|
|
2177
|
+
(n, [r, d]) => (Object.entries(d).forEach(
|
|
2178
|
+
([o, c]) => (
|
|
2106
2179
|
//
|
|
2107
|
-
|
|
2180
|
+
n[`${r}-${o}`] = c
|
|
2108
2181
|
)
|
|
2109
|
-
),
|
|
2182
|
+
), n),
|
|
2110
2183
|
{}
|
|
2111
2184
|
);
|
|
2112
|
-
return
|
|
2185
|
+
return t;
|
|
2113
2186
|
}
|
|
2114
2187
|
},
|
|
2115
2188
|
event: {
|
|
@@ -2120,8 +2193,8 @@ r.data = {
|
|
|
2120
2193
|
* @param currency - The currency to be used (default is 'USD').
|
|
2121
2194
|
* @returns A Promise that resolves to the simulated onWidgetLoad event data.
|
|
2122
2195
|
*/
|
|
2123
|
-
async onWidgetLoad(e,
|
|
2124
|
-
const
|
|
2196
|
+
async onWidgetLoad(e, a, t = "USD") {
|
|
2197
|
+
const n = {
|
|
2125
2198
|
BRL: { code: "BRL", name: "Brazilian Real", symbol: "R$" },
|
|
2126
2199
|
USD: { code: "USD", name: "US Dollar", symbol: "$" },
|
|
2127
2200
|
EUR: { code: "EUR", name: "Euro", symbol: "€" }
|
|
@@ -2134,11 +2207,11 @@ r.data = {
|
|
|
2134
2207
|
providerId: "",
|
|
2135
2208
|
avatar: ""
|
|
2136
2209
|
},
|
|
2137
|
-
currency: t
|
|
2210
|
+
currency: n[t] ?? n.USD,
|
|
2138
2211
|
fieldData: e,
|
|
2139
2212
|
recents: [],
|
|
2140
2213
|
session: {
|
|
2141
|
-
data:
|
|
2214
|
+
data: a,
|
|
2142
2215
|
settings: {
|
|
2143
2216
|
autoReset: !1,
|
|
2144
2217
|
calendar: !1,
|
|
@@ -2158,7 +2231,7 @@ r.data = {
|
|
|
2158
2231
|
* @returns A Promise that resolves to the simulated onSessionUpdate event data.
|
|
2159
2232
|
*/
|
|
2160
2233
|
async onSessionUpdate(e) {
|
|
2161
|
-
return e ??= await
|
|
2234
|
+
return e ??= await s.generate.session.get(), { session: e };
|
|
2162
2235
|
},
|
|
2163
2236
|
/**
|
|
2164
2237
|
* Simulates the onEventReceived event for a widget.
|
|
@@ -2175,8 +2248,8 @@ r.data = {
|
|
|
2175
2248
|
* const twitchMessageEvent = await Simulation.generate.event.onEventReceived('twitch', 'message', { name: 'Streamer', message: 'Hello World!' });
|
|
2176
2249
|
* ```
|
|
2177
2250
|
*/
|
|
2178
|
-
async onEventReceived(e = "random",
|
|
2179
|
-
const
|
|
2251
|
+
async onEventReceived(e = "random", a = "random", t = {}) {
|
|
2252
|
+
const n = {
|
|
2180
2253
|
twitch: ["message", "follower-latest", "cheer-latest", "raid-latest", "subscriber-latest"],
|
|
2181
2254
|
streamelements: ["tip-latest"],
|
|
2182
2255
|
youtube: ["message", "superchat-latest", "subscriber-latest", "sponsor-latest"],
|
|
@@ -2186,52 +2259,52 @@ r.data = {
|
|
|
2186
2259
|
switch (e) {
|
|
2187
2260
|
default:
|
|
2188
2261
|
case "random": {
|
|
2189
|
-
var
|
|
2190
|
-
return this.onEventReceived(
|
|
2262
|
+
var r = s.rand.array(Object.keys(n).filter((v) => n[v].length))[0], d = s.rand.array(n[r])[0];
|
|
2263
|
+
return this.onEventReceived(r, d);
|
|
2191
2264
|
}
|
|
2192
2265
|
case "twitch":
|
|
2193
|
-
switch (
|
|
2266
|
+
switch (a) {
|
|
2194
2267
|
default:
|
|
2195
2268
|
case "random": {
|
|
2196
|
-
var
|
|
2197
|
-
return this.onEventReceived(e,
|
|
2269
|
+
var d = s.rand.array(n[e])[0];
|
|
2270
|
+
return this.onEventReceived(e, d);
|
|
2198
2271
|
}
|
|
2199
2272
|
case "message": {
|
|
2200
|
-
var
|
|
2273
|
+
var o = t?.name ?? s.rand.array(s.data.names.filter((g) => g.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((g) => g.length))[0], w = await z(t?.badges ?? [], e), h = N(c), m = B(c, h), b = t?.color ?? s.rand.color("hex"), y = t?.userId ?? s.rand.number(1e7, 99999999).toString(), i = Date.now();
|
|
2201
2274
|
return {
|
|
2202
2275
|
listener: "message",
|
|
2203
2276
|
event: {
|
|
2204
2277
|
service: e,
|
|
2205
2278
|
data: {
|
|
2206
|
-
time:
|
|
2279
|
+
time: i,
|
|
2207
2280
|
tags: {
|
|
2208
|
-
"badge-info": `${
|
|
2209
|
-
badges:
|
|
2210
|
-
mod:
|
|
2211
|
-
subscriber:
|
|
2212
|
-
turbo:
|
|
2213
|
-
"tmi-sent-ts":
|
|
2214
|
-
"user-id":
|
|
2281
|
+
"badge-info": `${w.keys.map((g) => `${g}/${s.rand.number(1, 5)}`).join(",")}`,
|
|
2282
|
+
badges: w.keys.join("/1,"),
|
|
2283
|
+
mod: w.keys.includes("moderator") ? "1" : "0",
|
|
2284
|
+
subscriber: w.keys.includes("subscriber") ? "1" : "0",
|
|
2285
|
+
turbo: w.keys.includes("turbo") ? "1" : "0",
|
|
2286
|
+
"tmi-sent-ts": i.toString(),
|
|
2287
|
+
"user-id": y,
|
|
2215
2288
|
"user-type": "",
|
|
2216
|
-
color:
|
|
2217
|
-
"display-name":
|
|
2289
|
+
color: b,
|
|
2290
|
+
"display-name": o,
|
|
2218
2291
|
emotes: "",
|
|
2219
|
-
"client-nonce":
|
|
2292
|
+
"client-nonce": s.rand.string(16),
|
|
2220
2293
|
flags: "",
|
|
2221
|
-
id:
|
|
2294
|
+
id: s.rand.uuid(),
|
|
2222
2295
|
"first-msg": "0",
|
|
2223
2296
|
"returning-chatter": "0"
|
|
2224
2297
|
},
|
|
2225
|
-
nick:
|
|
2226
|
-
displayName:
|
|
2227
|
-
displayColor:
|
|
2298
|
+
nick: o.toLowerCase(),
|
|
2299
|
+
displayName: o,
|
|
2300
|
+
displayColor: b,
|
|
2228
2301
|
channel: "local",
|
|
2229
|
-
text:
|
|
2302
|
+
text: c,
|
|
2230
2303
|
isAction: !1,
|
|
2231
|
-
userId:
|
|
2232
|
-
msgId:
|
|
2233
|
-
badges:
|
|
2234
|
-
emotes:
|
|
2304
|
+
userId: y,
|
|
2305
|
+
msgId: s.rand.uuid(),
|
|
2306
|
+
badges: w.badges,
|
|
2307
|
+
emotes: h
|
|
2235
2308
|
},
|
|
2236
2309
|
renderedText: m
|
|
2237
2310
|
}
|
|
@@ -2239,17 +2312,17 @@ r.data = {
|
|
|
2239
2312
|
}
|
|
2240
2313
|
case "cheer":
|
|
2241
2314
|
case "cheer-latest": {
|
|
2242
|
-
var
|
|
2315
|
+
var l = t?.amount ?? s.rand.number(100, 1e4), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((A) => A.length))[0];
|
|
2243
2316
|
return {
|
|
2244
2317
|
listener: "cheer-latest",
|
|
2245
2318
|
event: {
|
|
2246
|
-
amount:
|
|
2247
|
-
avatar:
|
|
2248
|
-
name:
|
|
2249
|
-
displayName:
|
|
2250
|
-
message:
|
|
2319
|
+
amount: l,
|
|
2320
|
+
avatar: f,
|
|
2321
|
+
name: o.toLowerCase(),
|
|
2322
|
+
displayName: o,
|
|
2323
|
+
message: c,
|
|
2251
2324
|
providerId: "",
|
|
2252
|
-
_id:
|
|
2325
|
+
_id: s.rand.uuid(),
|
|
2253
2326
|
sessionTop: !1,
|
|
2254
2327
|
type: "cheer",
|
|
2255
2328
|
originalEventName: "cheer-latest"
|
|
@@ -2258,15 +2331,15 @@ r.data = {
|
|
|
2258
2331
|
}
|
|
2259
2332
|
case "follower":
|
|
2260
2333
|
case "follower-latest": {
|
|
2261
|
-
var
|
|
2334
|
+
var f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
|
|
2262
2335
|
return {
|
|
2263
2336
|
listener: "follower-latest",
|
|
2264
2337
|
event: {
|
|
2265
|
-
avatar:
|
|
2266
|
-
name:
|
|
2267
|
-
displayName:
|
|
2338
|
+
avatar: f,
|
|
2339
|
+
name: o.toLowerCase(),
|
|
2340
|
+
displayName: o,
|
|
2268
2341
|
providerId: "",
|
|
2269
|
-
_id:
|
|
2342
|
+
_id: s.rand.uuid(),
|
|
2270
2343
|
sessionTop: !1,
|
|
2271
2344
|
type: "follower",
|
|
2272
2345
|
originalEventName: "follower-latest"
|
|
@@ -2275,16 +2348,16 @@ r.data = {
|
|
|
2275
2348
|
}
|
|
2276
2349
|
case "raid":
|
|
2277
2350
|
case "raid-latest": {
|
|
2278
|
-
var
|
|
2351
|
+
var l = t?.amount ?? s.rand.number(1, 100), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
|
|
2279
2352
|
return {
|
|
2280
2353
|
listener: "raid-latest",
|
|
2281
2354
|
event: {
|
|
2282
|
-
amount:
|
|
2283
|
-
avatar:
|
|
2284
|
-
name:
|
|
2285
|
-
displayName:
|
|
2355
|
+
amount: l,
|
|
2356
|
+
avatar: f,
|
|
2357
|
+
name: o.toLowerCase(),
|
|
2358
|
+
displayName: o,
|
|
2286
2359
|
providerId: "",
|
|
2287
|
-
_id:
|
|
2360
|
+
_id: s.rand.uuid(),
|
|
2288
2361
|
sessionTop: !1,
|
|
2289
2362
|
type: "raid",
|
|
2290
2363
|
originalEventName: "raid-latest"
|
|
@@ -2293,10 +2366,10 @@ r.data = {
|
|
|
2293
2366
|
}
|
|
2294
2367
|
case "subscriber":
|
|
2295
2368
|
case "subscriber-latest": {
|
|
2296
|
-
var
|
|
2369
|
+
var p = t?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], l = t?.amount ?? s.rand.number(1, 24), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((T) => T.length))[0], x = t?.sender ?? s.rand.array(s.data.names.filter((T) => T.length && T !== o))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((T) => T.length))[0], k = {
|
|
2297
2370
|
default: {
|
|
2298
|
-
avatar:
|
|
2299
|
-
tier:
|
|
2371
|
+
avatar: f,
|
|
2372
|
+
tier: p,
|
|
2300
2373
|
playedAsCommunityGift: !1
|
|
2301
2374
|
},
|
|
2302
2375
|
gift: {
|
|
@@ -2304,7 +2377,7 @@ r.data = {
|
|
|
2304
2377
|
gifted: !0
|
|
2305
2378
|
},
|
|
2306
2379
|
community: {
|
|
2307
|
-
message:
|
|
2380
|
+
message: c,
|
|
2308
2381
|
sender: x,
|
|
2309
2382
|
bulkGifted: !0
|
|
2310
2383
|
},
|
|
@@ -2313,17 +2386,17 @@ r.data = {
|
|
|
2313
2386
|
gifted: !0,
|
|
2314
2387
|
isCommunityGift: !0
|
|
2315
2388
|
}
|
|
2316
|
-
}, S = ["default", "gift", "community", "spam"],
|
|
2317
|
-
return
|
|
2389
|
+
}, S = ["default", "gift", "community", "spam"], C = t?.subType ?? s.rand.array(S)[0];
|
|
2390
|
+
return C = S.includes(C) ? C : "default", {
|
|
2318
2391
|
listener: "subscriber-latest",
|
|
2319
2392
|
event: {
|
|
2320
|
-
amount:
|
|
2321
|
-
name:
|
|
2322
|
-
displayName:
|
|
2393
|
+
amount: l,
|
|
2394
|
+
name: o.toLowerCase(),
|
|
2395
|
+
displayName: o,
|
|
2323
2396
|
providerId: "",
|
|
2324
2397
|
...k.default,
|
|
2325
|
-
...k[
|
|
2326
|
-
_id:
|
|
2398
|
+
...k[C],
|
|
2399
|
+
_id: s.rand.uuid(),
|
|
2327
2400
|
sessionTop: !1,
|
|
2328
2401
|
type: "subscriber",
|
|
2329
2402
|
originalEventName: "subscriber-latest"
|
|
@@ -2334,36 +2407,36 @@ r.data = {
|
|
|
2334
2407
|
return {
|
|
2335
2408
|
listener: "delete-message",
|
|
2336
2409
|
event: {
|
|
2337
|
-
msgId:
|
|
2410
|
+
msgId: t?.id ?? s.rand.uuid()
|
|
2338
2411
|
}
|
|
2339
2412
|
};
|
|
2340
2413
|
case "delete-messages":
|
|
2341
2414
|
return {
|
|
2342
2415
|
listener: "delete-messages",
|
|
2343
2416
|
event: {
|
|
2344
|
-
userId:
|
|
2417
|
+
userId: t?.id ?? s.rand.number(1e7, 99999999).toString()
|
|
2345
2418
|
}
|
|
2346
2419
|
};
|
|
2347
2420
|
}
|
|
2348
2421
|
case "streamelements":
|
|
2349
|
-
switch (
|
|
2422
|
+
switch (a) {
|
|
2350
2423
|
default:
|
|
2351
2424
|
case "random": {
|
|
2352
|
-
var
|
|
2353
|
-
return this.onEventReceived(e,
|
|
2425
|
+
var d = s.rand.array(n[e])[0];
|
|
2426
|
+
return this.onEventReceived(e, d);
|
|
2354
2427
|
}
|
|
2355
2428
|
case "tip":
|
|
2356
2429
|
case "tip-latest": {
|
|
2357
|
-
var
|
|
2430
|
+
var l = t?.amount ?? s.rand.number(100, 4e3), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
|
|
2358
2431
|
return {
|
|
2359
2432
|
listener: "tip-latest",
|
|
2360
2433
|
event: {
|
|
2361
|
-
amount:
|
|
2362
|
-
avatar:
|
|
2363
|
-
name:
|
|
2364
|
-
displayName:
|
|
2434
|
+
amount: l,
|
|
2435
|
+
avatar: f,
|
|
2436
|
+
name: o.toLowerCase(),
|
|
2437
|
+
displayName: o,
|
|
2365
2438
|
providerId: "",
|
|
2366
|
-
_id:
|
|
2439
|
+
_id: s.rand.uuid(),
|
|
2367
2440
|
sessionTop: !1,
|
|
2368
2441
|
type: "tip",
|
|
2369
2442
|
originalEventName: "tip-latest"
|
|
@@ -2375,8 +2448,8 @@ r.data = {
|
|
|
2375
2448
|
listener: "kvstore:update",
|
|
2376
2449
|
event: {
|
|
2377
2450
|
data: {
|
|
2378
|
-
key: `customWidget.${
|
|
2379
|
-
value:
|
|
2451
|
+
key: `customWidget.${t?.key ?? "sampleKey"}`,
|
|
2452
|
+
value: t?.value ?? "sampleValue"
|
|
2380
2453
|
}
|
|
2381
2454
|
}
|
|
2382
2455
|
};
|
|
@@ -2384,17 +2457,19 @@ r.data = {
|
|
|
2384
2457
|
return {
|
|
2385
2458
|
listener: "bot:counter",
|
|
2386
2459
|
event: {
|
|
2387
|
-
counter:
|
|
2388
|
-
value:
|
|
2460
|
+
counter: t?.counter ?? "sampleCounter",
|
|
2461
|
+
value: t?.value ?? s.rand.number(0, 100)
|
|
2389
2462
|
}
|
|
2390
2463
|
};
|
|
2391
2464
|
case "mute":
|
|
2392
2465
|
case "unmute":
|
|
2393
|
-
case "alertService:toggleSound":
|
|
2466
|
+
case "alertService:toggleSound": {
|
|
2467
|
+
var M = t?.muted ?? !client.details.overlay.muted;
|
|
2394
2468
|
return {
|
|
2395
2469
|
listener: "alertService:toggleSound",
|
|
2396
|
-
event: {}
|
|
2470
|
+
event: { muted: M }
|
|
2397
2471
|
};
|
|
2472
|
+
}
|
|
2398
2473
|
case "skip":
|
|
2399
2474
|
case "event:skip":
|
|
2400
2475
|
return {
|
|
@@ -2403,16 +2478,16 @@ r.data = {
|
|
|
2403
2478
|
};
|
|
2404
2479
|
}
|
|
2405
2480
|
case "youtube":
|
|
2406
|
-
switch (
|
|
2481
|
+
switch (a) {
|
|
2407
2482
|
default:
|
|
2408
2483
|
case "random": {
|
|
2409
|
-
var
|
|
2410
|
-
return this.onEventReceived(e,
|
|
2484
|
+
var d = s.rand.array(n[e])[0];
|
|
2485
|
+
return this.onEventReceived(e, d);
|
|
2411
2486
|
}
|
|
2412
2487
|
case "message": {
|
|
2413
|
-
var
|
|
2414
|
-
const
|
|
2415
|
-
var
|
|
2488
|
+
var o = t?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0];
|
|
2489
|
+
const R = await z(t?.badges ?? [], e);
|
|
2490
|
+
var h = N(c), m = B(c, h), b = t?.color ?? s.rand.color("hex"), y = t?.userId ?? s.rand.number(1e7, 99999999).toString(), i = Date.now(), f = t?.avatar ?? s.rand.array(s.data.avatars)[0];
|
|
2416
2491
|
return {
|
|
2417
2492
|
listener: "message",
|
|
2418
2493
|
event: {
|
|
@@ -2427,47 +2502,47 @@ r.data = {
|
|
|
2427
2502
|
authorChannelId: "local",
|
|
2428
2503
|
publishedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2429
2504
|
hasDisplayContent: !0,
|
|
2430
|
-
displayMessage:
|
|
2505
|
+
displayMessage: c,
|
|
2431
2506
|
textMessageDetails: {
|
|
2432
|
-
messageText:
|
|
2507
|
+
messageText: c
|
|
2433
2508
|
}
|
|
2434
2509
|
},
|
|
2435
2510
|
authorDetails: {
|
|
2436
2511
|
channelId: "local",
|
|
2437
2512
|
channelUrl: "",
|
|
2438
|
-
displayName:
|
|
2439
|
-
profileImageUrl:
|
|
2440
|
-
...
|
|
2513
|
+
displayName: o,
|
|
2514
|
+
profileImageUrl: f,
|
|
2515
|
+
...R
|
|
2441
2516
|
},
|
|
2442
|
-
msgId:
|
|
2443
|
-
userId:
|
|
2444
|
-
nick:
|
|
2517
|
+
msgId: s.rand.uuid(),
|
|
2518
|
+
userId: s.rand.uuid(),
|
|
2519
|
+
nick: o.toLowerCase(),
|
|
2445
2520
|
badges: [],
|
|
2446
|
-
displayName:
|
|
2521
|
+
displayName: o,
|
|
2447
2522
|
isAction: !1,
|
|
2448
2523
|
time: Date.now(),
|
|
2449
2524
|
tags: [],
|
|
2450
|
-
displayColor:
|
|
2525
|
+
displayColor: s.rand.color("hex"),
|
|
2451
2526
|
channel: "local",
|
|
2452
|
-
text:
|
|
2453
|
-
avatar:
|
|
2527
|
+
text: c,
|
|
2528
|
+
avatar: f,
|
|
2454
2529
|
emotes: []
|
|
2455
2530
|
},
|
|
2456
|
-
renderedText:
|
|
2531
|
+
renderedText: c
|
|
2457
2532
|
}
|
|
2458
2533
|
};
|
|
2459
2534
|
}
|
|
2460
2535
|
case "subscriber":
|
|
2461
2536
|
case "subscriber-latest": {
|
|
2462
|
-
var
|
|
2537
|
+
var f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((A) => A.length))[0];
|
|
2463
2538
|
return {
|
|
2464
2539
|
listener: "subscriber-latest",
|
|
2465
2540
|
event: {
|
|
2466
|
-
avatar:
|
|
2467
|
-
displayName:
|
|
2468
|
-
name:
|
|
2541
|
+
avatar: f,
|
|
2542
|
+
displayName: o,
|
|
2543
|
+
name: o.toLowerCase(),
|
|
2469
2544
|
providerId: "",
|
|
2470
|
-
_id:
|
|
2545
|
+
_id: s.rand.uuid(),
|
|
2471
2546
|
sessionTop: !1,
|
|
2472
2547
|
type: "subscriber",
|
|
2473
2548
|
originalEventName: "subscriber-latest"
|
|
@@ -2476,16 +2551,16 @@ r.data = {
|
|
|
2476
2551
|
}
|
|
2477
2552
|
case "superchat":
|
|
2478
2553
|
case "superchat-latest": {
|
|
2479
|
-
var
|
|
2554
|
+
var l = t?.amount ?? s.rand.number(100, 4e3), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((I) => I.length))[0];
|
|
2480
2555
|
return {
|
|
2481
2556
|
listener: "superchat-latest",
|
|
2482
2557
|
event: {
|
|
2483
|
-
amount:
|
|
2484
|
-
avatar:
|
|
2485
|
-
name:
|
|
2486
|
-
displayName:
|
|
2558
|
+
amount: l,
|
|
2559
|
+
avatar: f,
|
|
2560
|
+
name: o.toLowerCase(),
|
|
2561
|
+
displayName: o,
|
|
2487
2562
|
providerId: "",
|
|
2488
|
-
_id:
|
|
2563
|
+
_id: s.rand.uuid(),
|
|
2489
2564
|
sessionTop: !1,
|
|
2490
2565
|
type: "superchat",
|
|
2491
2566
|
originalEventName: "superchat-latest"
|
|
@@ -2494,10 +2569,10 @@ r.data = {
|
|
|
2494
2569
|
}
|
|
2495
2570
|
case "sponsor":
|
|
2496
2571
|
case "sponsor-latest": {
|
|
2497
|
-
var
|
|
2572
|
+
var p = t?.tier ?? s.rand.array(["1000", "2000", "3000"])[0], l = t?.amount ?? s.rand.number(1, 24), f = t?.avatar ?? s.rand.array(s.data.avatars)[0], o = t?.name ?? s.rand.array(s.data.names.filter((L) => L.length))[0], x = t?.sender ?? s.rand.array(s.data.names.filter((L) => L.length && L !== o))[0], c = t?.message ?? s.rand.array(s.data.messages.filter((L) => L.length))[0], k = {
|
|
2498
2573
|
default: {
|
|
2499
|
-
avatar:
|
|
2500
|
-
tier:
|
|
2574
|
+
avatar: f,
|
|
2575
|
+
tier: p,
|
|
2501
2576
|
playedAsCommunityGift: !1
|
|
2502
2577
|
},
|
|
2503
2578
|
gift: {
|
|
@@ -2505,7 +2580,7 @@ r.data = {
|
|
|
2505
2580
|
gifted: !0
|
|
2506
2581
|
},
|
|
2507
2582
|
community: {
|
|
2508
|
-
message:
|
|
2583
|
+
message: c,
|
|
2509
2584
|
sender: x,
|
|
2510
2585
|
bulkGifted: !0
|
|
2511
2586
|
},
|
|
@@ -2514,17 +2589,17 @@ r.data = {
|
|
|
2514
2589
|
gifted: !0,
|
|
2515
2590
|
isCommunityGift: !0
|
|
2516
2591
|
}
|
|
2517
|
-
}, S = ["default", "gift", "community", "spam"],
|
|
2518
|
-
return
|
|
2592
|
+
}, S = ["default", "gift", "community", "spam"], C = t?.subType ?? s.rand.array(S)[0];
|
|
2593
|
+
return C = S.includes(C) ? C : "default", {
|
|
2519
2594
|
listener: "sponsor-latest",
|
|
2520
2595
|
event: {
|
|
2521
|
-
amount:
|
|
2522
|
-
name:
|
|
2523
|
-
displayName:
|
|
2596
|
+
amount: l,
|
|
2597
|
+
name: o.toLowerCase(),
|
|
2598
|
+
displayName: o,
|
|
2524
2599
|
providerId: "",
|
|
2525
2600
|
...k.default,
|
|
2526
|
-
...k[
|
|
2527
|
-
_id:
|
|
2601
|
+
...k[C],
|
|
2602
|
+
_id: s.rand.uuid(),
|
|
2528
2603
|
sessionTop: !1,
|
|
2529
2604
|
type: "sponsor",
|
|
2530
2605
|
originalEventName: "sponsor-latest"
|
|
@@ -2536,8 +2611,8 @@ r.data = {
|
|
|
2536
2611
|
}
|
|
2537
2612
|
}
|
|
2538
2613
|
};
|
|
2539
|
-
let
|
|
2540
|
-
class
|
|
2614
|
+
let j = s;
|
|
2615
|
+
class q {
|
|
2541
2616
|
constructor() {
|
|
2542
2617
|
this.themes = [
|
|
2543
2618
|
{
|
|
@@ -2621,42 +2696,48 @@ class W {
|
|
|
2621
2696
|
}, this.simple = () => {
|
|
2622
2697
|
}, this.info = () => {
|
|
2623
2698
|
}, this.themes.forEach((e) => {
|
|
2624
|
-
const
|
|
2625
|
-
e.background && e.background !== "transparent" &&
|
|
2626
|
-
const
|
|
2627
|
-
const
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
...
|
|
2699
|
+
const a = [];
|
|
2700
|
+
e.background && e.background !== "transparent" && a.push(`background-color: ${e.background}`), e.color && a.push(`color: ${e.color}`), e.bold && a.push("font-weight: bold"), e.italic && a.push("font-style: italic"), e.underline && a.push("text-decoration: underline"), e.fontSize && a.push(`font-size: ${e.fontSize}px`);
|
|
2701
|
+
const t = "%c", n = (...r) => {
|
|
2702
|
+
const d = Array.from(r).filter((h) => typeof h == "string" || typeof h == "number"), o = Array.from(r).filter((h) => typeof h != "string" && typeof h != "number"), c = d.length > 0 ? a.join("; ") : null, w = [
|
|
2703
|
+
d.length > 0 ? t + (e.template?.before ?? "") + d.join(" ") + (e.template?.after ?? "") : null,
|
|
2704
|
+
c,
|
|
2705
|
+
...o
|
|
2631
2706
|
].filter(Boolean);
|
|
2632
|
-
return console.log(...
|
|
2707
|
+
return console.log(...w);
|
|
2633
2708
|
};
|
|
2634
|
-
this[e.name] =
|
|
2709
|
+
this[e.name] = n;
|
|
2635
2710
|
});
|
|
2636
2711
|
}
|
|
2637
2712
|
}
|
|
2638
|
-
class
|
|
2713
|
+
class $ {
|
|
2639
2714
|
constructor(e) {
|
|
2640
|
-
this.field = "button", this.template = "button", window.client instanceof
|
|
2715
|
+
this.field = "button", this.template = "button", window.client instanceof E && (this.field = e.field ?? this.field, this.template = e.template ?? this.template, this.run = e.run, window.client.actions.buttons.push(this), window.client.emit("action", this, "created"));
|
|
2641
2716
|
}
|
|
2642
|
-
parse(e,
|
|
2643
|
-
var
|
|
2717
|
+
parse(e, a) {
|
|
2718
|
+
var t = e.replace(typeof this.field == "string" ? this.field : this.template.replace(/\{[^}]*\}/g, "") ?? "", "").trim();
|
|
2644
2719
|
try {
|
|
2645
|
-
this.run.apply(window.client, [
|
|
2646
|
-
} catch (
|
|
2647
|
-
throw new Error(`Error running button "${this.field}": ${
|
|
2720
|
+
this.run.apply(window.client, [t.length ? t : e ?? e, a]);
|
|
2721
|
+
} catch (n) {
|
|
2722
|
+
throw new Error(`Error running button "${this.field}": ${n instanceof Error ? n.message : n}`);
|
|
2648
2723
|
}
|
|
2649
2724
|
return this;
|
|
2650
2725
|
}
|
|
2651
|
-
static execute(e,
|
|
2726
|
+
static execute(e, a) {
|
|
2652
2727
|
try {
|
|
2653
|
-
if (!(window.client instanceof
|
|
2728
|
+
if (!(window.client instanceof E)) return !1;
|
|
2654
2729
|
if (window.client.actions.buttons.length) {
|
|
2655
|
-
const
|
|
2656
|
-
(
|
|
2730
|
+
const t = window.client.actions.buttons.find(
|
|
2731
|
+
(n) => typeof n.field == "string" ? n.field === e : typeof n.field == "function" ? n.field(e, a) : !1
|
|
2657
2732
|
);
|
|
2658
|
-
if (
|
|
2659
|
-
|
|
2733
|
+
if (t && t instanceof $) {
|
|
2734
|
+
try {
|
|
2735
|
+
t.parse(e, a), window.client.emit("action", t, "executed"), O.logger.received(`Button executed: ${e} with value: ${a}`);
|
|
2736
|
+
} catch (n) {
|
|
2737
|
+
O.logger.error(`Error executing button "${e}": ${n instanceof Error ? n.message : n}`);
|
|
2738
|
+
}
|
|
2739
|
+
return !0;
|
|
2740
|
+
}
|
|
2660
2741
|
}
|
|
2661
2742
|
} catch {
|
|
2662
2743
|
return !1;
|
|
@@ -2665,50 +2746,50 @@ class O {
|
|
|
2665
2746
|
}
|
|
2666
2747
|
}
|
|
2667
2748
|
}
|
|
2668
|
-
class
|
|
2749
|
+
class P {
|
|
2669
2750
|
constructor(e) {
|
|
2670
|
-
this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], window.client instanceof
|
|
2751
|
+
this.prefix = "!", this.arguments = !1, this.test = `${this.prefix}${this.name} arg1 arg2`, this.aliases = [], this.permissions = void 0, this.admins = [], window.client instanceof E && (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, window.client.actions.commands.push(this), window.client.emit("action", this, "created"));
|
|
2671
2752
|
}
|
|
2672
|
-
run(e,
|
|
2753
|
+
run(e, a) {
|
|
2673
2754
|
}
|
|
2674
|
-
verify(e,
|
|
2675
|
-
return this.arguments === !0 && (!
|
|
2755
|
+
verify(e, a, t) {
|
|
2756
|
+
return this.arguments === !0 && (!t || !t.length) ? !1 : this.admins.some((n) => e.toLocaleLowerCase() === n.toLocaleLowerCase()) ? !0 : this.permissions === !0 || typeof this.permissions > "u" || Array.isArray(this.permissions) && !this.permissions.length ? !1 : !!(Array.isArray(this.permissions) && this.permissions.some((n) => a.map((r) => r.toLowerCase()).includes(n.toLowerCase())));
|
|
2676
2757
|
}
|
|
2677
|
-
parse(e,
|
|
2678
|
-
if (!(window.client instanceof
|
|
2679
|
-
const
|
|
2680
|
-
var
|
|
2681
|
-
const
|
|
2682
|
-
switch (
|
|
2758
|
+
parse(e, a) {
|
|
2759
|
+
if (!(window.client instanceof E)) return !1;
|
|
2760
|
+
const t = e.replace(this.prefix, "").split(" ").slice(1).map((c) => c.trim());
|
|
2761
|
+
var n = "", r = [];
|
|
2762
|
+
const d = { bits: "cheer", premium: "prime" };
|
|
2763
|
+
switch (a.provider) {
|
|
2683
2764
|
case "twitch": {
|
|
2684
|
-
const
|
|
2685
|
-
|
|
2765
|
+
const c = a.data;
|
|
2766
|
+
n = c.event.data.nick || c.event.data.displayName, c.event.data.tags?.badges && (r = c.event.data.tags.badges.toString().replace(/\/\d+/g, "").split(",").map((h) => h in d ? d[h] : h));
|
|
2686
2767
|
break;
|
|
2687
2768
|
}
|
|
2688
2769
|
case "youtube": {
|
|
2689
|
-
const
|
|
2770
|
+
const c = a.data, w = {
|
|
2690
2771
|
isVerified: "verified",
|
|
2691
2772
|
isChatOwner: "owner",
|
|
2692
2773
|
isChatSponsor: "sponsor",
|
|
2693
2774
|
isChatModerator: "moderator"
|
|
2694
2775
|
};
|
|
2695
|
-
|
|
2776
|
+
n = c.event.data.nick || c.event.data.displayName, r = Object.entries(c.event.data.authorDetails).filter(([h, m]) => h.startsWith("is") && m).map(([h]) => w[h]).filter(Boolean);
|
|
2696
2777
|
break;
|
|
2697
2778
|
}
|
|
2698
2779
|
case "kick":
|
|
2699
2780
|
return !1;
|
|
2700
2781
|
}
|
|
2701
|
-
const
|
|
2702
|
-
return
|
|
2782
|
+
const o = this.verify(n, r, t);
|
|
2783
|
+
return o === !0 && this.run.apply(window.client, [t, a]), o;
|
|
2703
2784
|
}
|
|
2704
2785
|
static execute(e) {
|
|
2705
|
-
if (!(window.client instanceof
|
|
2706
|
-
const
|
|
2786
|
+
if (!(window.client instanceof E)) return !1;
|
|
2787
|
+
const a = e.data;
|
|
2707
2788
|
try {
|
|
2708
|
-
if (window.client.actions.commands.length && window.client.actions.commands.some((
|
|
2709
|
-
const
|
|
2710
|
-
if (
|
|
2711
|
-
return
|
|
2789
|
+
if (window.client.actions.commands.length && window.client.actions.commands.some((t) => a.event.data.text.startsWith(t.prefix))) {
|
|
2790
|
+
const t = window.client.actions.commands.find((n) => a.event.data.text.replace(n.prefix, "").split(" ")[0] === n.name);
|
|
2791
|
+
if (t && t instanceof P)
|
|
2792
|
+
return t.parse(a.event.data.text, e), window.client.emit("action", t, "executed"), O.logger.received(`Command executed: ${a.event.data.text} by ${a.event.data.nick || a.event.data.displayName}`, a), !0;
|
|
2712
2793
|
}
|
|
2713
2794
|
} catch {
|
|
2714
2795
|
return !1;
|
|
@@ -2718,154 +2799,230 @@ class $ {
|
|
|
2718
2799
|
}
|
|
2719
2800
|
}
|
|
2720
2801
|
window.addEventListener("load", () => {
|
|
2721
|
-
window.client instanceof
|
|
2802
|
+
window.client instanceof E && j.start();
|
|
2722
2803
|
});
|
|
2723
2804
|
window.addEventListener("onWidgetLoad", async (u) => {
|
|
2724
2805
|
const { detail: e } = u;
|
|
2725
|
-
if (window.client instanceof
|
|
2726
|
-
const
|
|
2727
|
-
|
|
2728
|
-
...
|
|
2806
|
+
if (window.client instanceof E) {
|
|
2807
|
+
const a = window.client;
|
|
2808
|
+
a.fields = e.fieldData, a.session = e.session.data, a.details = {
|
|
2809
|
+
...a.details,
|
|
2729
2810
|
user: e.channel,
|
|
2730
2811
|
currency: e.currency,
|
|
2731
2812
|
overlay: e.overlay
|
|
2732
|
-
}, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((
|
|
2733
|
-
if (
|
|
2734
|
-
return
|
|
2735
|
-
|
|
2813
|
+
}, e.channel.id && !e.emulated ? await fetch(`https://api.streamelements.com/kappa/v2/channels/${e.channel.id}/`).then((t) => t.json()).then((t) => {
|
|
2814
|
+
if (t.provider)
|
|
2815
|
+
return a.details.provider = t.provider, t.provider;
|
|
2816
|
+
a.details.provider = "local";
|
|
2736
2817
|
}).catch(() => {
|
|
2737
|
-
|
|
2738
|
-
}) :
|
|
2739
|
-
|
|
2818
|
+
a.details.provider = "local";
|
|
2819
|
+
}) : a.details.provider = "local", a.emit("load", e), a.loaded = !0, a.storage.on("load", () => {
|
|
2820
|
+
a.storage.add(`avatar.${e.channel.providerId.toLowerCase()}`, {
|
|
2740
2821
|
value: e.channel.avatar,
|
|
2741
2822
|
timestamp: Date.now(),
|
|
2742
|
-
expire: Date.now() +
|
|
2823
|
+
expire: Date.now() + a.cache.avatar * 60 * 60 * 1e3
|
|
2743
2824
|
});
|
|
2744
2825
|
});
|
|
2745
2826
|
}
|
|
2746
2827
|
});
|
|
2747
2828
|
window.addEventListener("onSessionUpdate", (u) => {
|
|
2748
2829
|
const { detail: e } = u;
|
|
2749
|
-
if (window.client instanceof
|
|
2750
|
-
const
|
|
2751
|
-
|
|
2830
|
+
if (window.client instanceof E) {
|
|
2831
|
+
const a = window.client;
|
|
2832
|
+
a.session = e.session, a.emit("session", e.session);
|
|
2752
2833
|
}
|
|
2753
2834
|
});
|
|
2754
2835
|
window.addEventListener("onEventReceived", ({ detail: u }) => {
|
|
2755
|
-
if (window.client instanceof
|
|
2836
|
+
if (window.client instanceof E) {
|
|
2756
2837
|
var e = (
|
|
2757
2838
|
// @ts-ignore
|
|
2758
2839
|
u.event?.provider || u.event?.service || u.event?.data?.provider || window.client.details.provider
|
|
2759
2840
|
);
|
|
2760
|
-
["kvstore:update", "bot:counter", "alertService:toggleSound", "event:skip", "tip-latest", "event:test"].some((
|
|
2761
|
-
const
|
|
2762
|
-
switch (
|
|
2841
|
+
["kvstore:update", "bot:counter", "alertService:toggleSound", "event:skip", "tip-latest", "event:test"].some((r) => r === u.listener) && (e = "streamelements");
|
|
2842
|
+
const n = { provider: e, data: u };
|
|
2843
|
+
switch (n.provider) {
|
|
2763
2844
|
case "streamelements": {
|
|
2764
|
-
const
|
|
2765
|
-
switch (
|
|
2845
|
+
const r = n.data;
|
|
2846
|
+
switch (r.listener) {
|
|
2766
2847
|
case "tip-latest": {
|
|
2767
|
-
|
|
2848
|
+
r.event;
|
|
2768
2849
|
break;
|
|
2769
2850
|
}
|
|
2770
2851
|
case "event:skip": {
|
|
2771
|
-
|
|
2852
|
+
r.event;
|
|
2772
2853
|
break;
|
|
2773
2854
|
}
|
|
2774
2855
|
case "event:test": {
|
|
2775
|
-
switch (
|
|
2856
|
+
switch (r.event.listener) {
|
|
2776
2857
|
case "widget-button": {
|
|
2777
|
-
const d =
|
|
2778
|
-
|
|
2858
|
+
const d = r.event;
|
|
2859
|
+
$.execute(d.field, d.value);
|
|
2779
2860
|
break;
|
|
2780
2861
|
}
|
|
2781
2862
|
case "subscriber-latest": {
|
|
2782
|
-
|
|
2863
|
+
r.event;
|
|
2783
2864
|
break;
|
|
2784
2865
|
}
|
|
2785
2866
|
}
|
|
2786
2867
|
break;
|
|
2787
2868
|
}
|
|
2788
2869
|
case "kvstore:update": {
|
|
2789
|
-
|
|
2870
|
+
const d = r.event;
|
|
2871
|
+
if (U.length) {
|
|
2872
|
+
var a = U.find((o) => o.id === d.data.key.replace("customWidget.", ""));
|
|
2873
|
+
a && a.update(d.data.value);
|
|
2874
|
+
}
|
|
2790
2875
|
break;
|
|
2791
2876
|
}
|
|
2792
2877
|
case "bot:counter": {
|
|
2793
|
-
|
|
2878
|
+
r.event;
|
|
2794
2879
|
break;
|
|
2795
2880
|
}
|
|
2796
2881
|
case "alertService:toggleSound": {
|
|
2797
|
-
|
|
2882
|
+
const d = r.event;
|
|
2883
|
+
client.details.overlay.muted = !!d.muted;
|
|
2798
2884
|
break;
|
|
2799
2885
|
}
|
|
2800
2886
|
}
|
|
2801
2887
|
break;
|
|
2802
2888
|
}
|
|
2803
2889
|
case "twitch": {
|
|
2804
|
-
const
|
|
2805
|
-
switch (
|
|
2890
|
+
const r = n.data;
|
|
2891
|
+
switch (r.listener) {
|
|
2806
2892
|
case "delete-message": {
|
|
2807
|
-
|
|
2893
|
+
r.event;
|
|
2808
2894
|
break;
|
|
2809
2895
|
}
|
|
2810
2896
|
case "delete-messages": {
|
|
2811
|
-
|
|
2897
|
+
r.event;
|
|
2812
2898
|
break;
|
|
2813
2899
|
}
|
|
2814
2900
|
case "message": {
|
|
2815
|
-
|
|
2901
|
+
r.event;
|
|
2816
2902
|
break;
|
|
2817
2903
|
}
|
|
2818
2904
|
case "follower-latest": {
|
|
2819
|
-
|
|
2905
|
+
r.event;
|
|
2820
2906
|
break;
|
|
2821
2907
|
}
|
|
2822
2908
|
case "cheer-latest": {
|
|
2823
|
-
|
|
2909
|
+
r.event;
|
|
2824
2910
|
break;
|
|
2825
2911
|
}
|
|
2826
2912
|
case "subscriber-latest": {
|
|
2827
|
-
(!
|
|
2913
|
+
(!r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && r.event.isCommunityGift || !r.event.gifted && r.event.bulkGifted && !r.event.isCommunityGift) && r.event;
|
|
2828
2914
|
break;
|
|
2829
2915
|
}
|
|
2830
2916
|
case "raid-latest": {
|
|
2831
|
-
|
|
2917
|
+
r.event;
|
|
2832
2918
|
break;
|
|
2833
2919
|
}
|
|
2834
2920
|
}
|
|
2835
2921
|
break;
|
|
2836
2922
|
}
|
|
2837
2923
|
case "youtube": {
|
|
2838
|
-
const
|
|
2839
|
-
switch (
|
|
2924
|
+
const r = n.data;
|
|
2925
|
+
switch (r.listener) {
|
|
2840
2926
|
case "message": {
|
|
2841
|
-
|
|
2927
|
+
r.event, P.execute({ provider: "youtube", data: r });
|
|
2842
2928
|
break;
|
|
2843
2929
|
}
|
|
2844
2930
|
case "subscriber-latest": {
|
|
2845
|
-
|
|
2931
|
+
r.event;
|
|
2846
2932
|
break;
|
|
2847
2933
|
}
|
|
2848
2934
|
case "sponsor-latest": {
|
|
2849
|
-
|
|
2935
|
+
r.event, (!r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && !r.event.isCommunityGift || r.event.gifted && !r.event.bulkGifted && r.event.isCommunityGift || !r.event.gifted && r.event.bulkGifted && !r.event.isCommunityGift) && r.event;
|
|
2850
2936
|
break;
|
|
2851
2937
|
}
|
|
2852
2938
|
case "superchat-latest": {
|
|
2853
|
-
|
|
2939
|
+
r.event;
|
|
2854
2940
|
break;
|
|
2855
2941
|
}
|
|
2856
2942
|
}
|
|
2857
2943
|
break;
|
|
2858
2944
|
}
|
|
2945
|
+
case "kick": {
|
|
2946
|
+
n.data;
|
|
2947
|
+
break;
|
|
2948
|
+
}
|
|
2949
|
+
case "facebook": {
|
|
2950
|
+
n.data;
|
|
2951
|
+
break;
|
|
2952
|
+
}
|
|
2859
2953
|
}
|
|
2954
|
+
window.client.emit("event", n);
|
|
2860
2955
|
}
|
|
2861
2956
|
});
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2957
|
+
class V extends D {
|
|
2958
|
+
constructor(e) {
|
|
2959
|
+
window.client instanceof E && (super(), this.queue = [], this.priorityQueue = [], this.history = [], this.timeouts = [], this.running = !1, this.duration = void 0, this.loaded = !1, this.duration = e.duration, this.processor = e.processor, window.client.on("load", () => {
|
|
2960
|
+
this.emit("load"), this.loaded = !0;
|
|
2961
|
+
}));
|
|
2962
|
+
}
|
|
2963
|
+
enqueue(e, a = {}) {
|
|
2964
|
+
const t = {
|
|
2965
|
+
isoDate: (/* @__PURE__ */ new Date()).toISOString(),
|
|
2966
|
+
isLoop: a?.isLoop ?? !1,
|
|
2967
|
+
isPriority: a?.isPriority ?? !1,
|
|
2968
|
+
isImmediate: a?.isImmediate ?? !1,
|
|
2969
|
+
value: e
|
|
2970
|
+
}, n = this.hasItems();
|
|
2971
|
+
return t.isPriority && t.isImmediate ? (this.cancel(), this.priorityQueue.unshift(t)) : (t.isPriority ? this.priorityQueue : this.queue).push(t), this.running === !1 && n === !1 && this.run(), this.emit("update", this.queue, this.priorityQueue, this.history, this.timeouts), this;
|
|
2972
|
+
}
|
|
2973
|
+
async run() {
|
|
2974
|
+
if (!this.hasItems()) {
|
|
2975
|
+
this.running = !1;
|
|
2976
|
+
return;
|
|
2977
|
+
}
|
|
2978
|
+
this.running = !0, await this.next(), typeof this.duration == "number" && this.duration > 0 ? this.timeouts.push(setTimeout(() => this.run(), this.duration)) : (this.duration === 0 || this.duration === !1) && this.run();
|
|
2979
|
+
}
|
|
2980
|
+
async next() {
|
|
2981
|
+
const e = this.priorityQueue.length > 0 ? this.priorityQueue.shift() : this.queue.shift();
|
|
2982
|
+
if (!e) {
|
|
2983
|
+
this.running = !1;
|
|
2984
|
+
return;
|
|
2985
|
+
}
|
|
2986
|
+
try {
|
|
2987
|
+
await this.processor.apply(this, [e.value, this]), this.emit("process", e, this);
|
|
2988
|
+
} catch (t) {
|
|
2989
|
+
O.logger.error(`Error during item processing: ${t instanceof Error ? t.message : String(t)}`);
|
|
2990
|
+
}
|
|
2991
|
+
this.history.push(e);
|
|
2992
|
+
const a = e.isPriority ? this.priorityQueue : this.queue;
|
|
2993
|
+
e.isLoop && a.push(e);
|
|
2994
|
+
}
|
|
2995
|
+
resume() {
|
|
2996
|
+
return this.cancel(), this.hasItems() && this.run(), this;
|
|
2997
|
+
}
|
|
2998
|
+
update(e) {
|
|
2999
|
+
return this.queue = e.queue ?? this.queue, this.priorityQueue = e.priorityQueue ?? this.priorityQueue, this.history = e.history ?? this.history, this.hasItems() && this.running === !1 && window.client?.on("load", () => this.run()), this;
|
|
3000
|
+
}
|
|
3001
|
+
cancel() {
|
|
3002
|
+
this.timeouts.forEach((e) => clearTimeout(e)), this.timeouts = [], this.running = !1, this.emit("cancel");
|
|
3003
|
+
}
|
|
3004
|
+
hasItems() {
|
|
3005
|
+
return this.queue.length > 0 || this.priorityQueue.length > 0;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
const O = {
|
|
3009
|
+
Client: E,
|
|
3010
|
+
Simulation: j,
|
|
3011
|
+
logger: new q(),
|
|
3012
|
+
utils: {
|
|
3013
|
+
findEmotesInText: N,
|
|
3014
|
+
replaceEmotesWithHTML: B
|
|
3015
|
+
},
|
|
3016
|
+
modules: {
|
|
3017
|
+
Button: $,
|
|
3018
|
+
Command: P,
|
|
3019
|
+
EventProvider: D,
|
|
3020
|
+
useStorage: G,
|
|
3021
|
+
useQueue: V
|
|
3022
|
+
}
|
|
2866
3023
|
};
|
|
2867
|
-
typeof window < "u" && (window.Tixyel =
|
|
3024
|
+
typeof window < "u" && (window.Tixyel = O);
|
|
2868
3025
|
export {
|
|
2869
|
-
|
|
3026
|
+
O as Tixyel
|
|
2870
3027
|
};
|
|
2871
3028
|
//# sourceMappingURL=index.es.js.map
|