@vunex/support-chat 1.0.2 → 1.0.5
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.
|
@@ -1,2905 +1,255 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
/*!
|
|
13
|
-
* pinia v2.3.1
|
|
14
|
-
* (c) 2025 Eduardo San Martin Morote
|
|
15
|
-
* @license MIT
|
|
16
|
-
*/
|
|
17
|
-
let Q;
|
|
18
|
-
const he = (s) => Q = s, Vt = process.env.NODE_ENV !== "production" ? Symbol("pinia") : (
|
|
19
|
-
/* istanbul ignore next */
|
|
20
|
-
Symbol()
|
|
21
|
-
);
|
|
22
|
-
function $(s) {
|
|
23
|
-
return s && typeof s == "object" && Object.prototype.toString.call(s) === "[object Object]" && typeof s.toJSON != "function";
|
|
24
|
-
}
|
|
25
|
-
var te;
|
|
26
|
-
(function(s) {
|
|
27
|
-
s.direct = "direct", s.patchObject = "patch object", s.patchFunction = "patch function";
|
|
28
|
-
})(te || (te = {}));
|
|
29
|
-
const Z = typeof window < "u";
|
|
30
|
-
function it(s, e) {
|
|
31
|
-
for (const t in e) {
|
|
32
|
-
const n = e[t];
|
|
33
|
-
if (!(t in s))
|
|
34
|
-
continue;
|
|
35
|
-
const r = s[t];
|
|
36
|
-
$(r) && $(n) && !se(n) && !Pe(n) ? s[t] = it(r, n) : s[t] = n;
|
|
37
|
-
}
|
|
38
|
-
return s;
|
|
39
|
-
}
|
|
40
|
-
const ot = () => {
|
|
41
|
-
};
|
|
42
|
-
function je(s, e, t, n = ot) {
|
|
43
|
-
s.push(e);
|
|
44
|
-
const r = () => {
|
|
45
|
-
const i = s.indexOf(e);
|
|
46
|
-
i > -1 && (s.splice(i, 1), n());
|
|
47
|
-
};
|
|
48
|
-
return !t && Rt() && At(r), r;
|
|
49
|
-
}
|
|
50
|
-
function H(s, ...e) {
|
|
51
|
-
s.slice().forEach((t) => {
|
|
52
|
-
t(...e);
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
const Ut = (s) => s(), Ke = Symbol(), me = Symbol();
|
|
56
|
-
function Ne(s, e) {
|
|
57
|
-
s instanceof Map && e instanceof Map ? e.forEach((t, n) => s.set(n, t)) : s instanceof Set && e instanceof Set && e.forEach(s.add, s);
|
|
58
|
-
for (const t in e) {
|
|
59
|
-
if (!e.hasOwnProperty(t))
|
|
60
|
-
continue;
|
|
61
|
-
const n = e[t], r = s[t];
|
|
62
|
-
$(r) && $(n) && s.hasOwnProperty(t) && !se(n) && !Pe(n) ? s[t] = Ne(r, n) : s[t] = n;
|
|
63
|
-
}
|
|
64
|
-
return s;
|
|
65
|
-
}
|
|
66
|
-
const Mt = process.env.NODE_ENV !== "production" ? Symbol("pinia:skipHydration") : (
|
|
67
|
-
/* istanbul ignore next */
|
|
68
|
-
Symbol()
|
|
69
|
-
);
|
|
70
|
-
function qt(s) {
|
|
71
|
-
return !$(s) || !s.hasOwnProperty(Mt);
|
|
72
|
-
}
|
|
73
|
-
const { assign: B } = Object;
|
|
74
|
-
function Ye(s) {
|
|
75
|
-
return !!(se(s) && s.effect);
|
|
76
|
-
}
|
|
77
|
-
function Xe(s, e, t, n) {
|
|
78
|
-
const { state: r, actions: i, getters: c } = e, l = t.state.value[s];
|
|
79
|
-
let h;
|
|
80
|
-
function f() {
|
|
81
|
-
!l && (process.env.NODE_ENV === "production" || !n) && (t.state.value[s] = r ? r() : {});
|
|
82
|
-
const p = process.env.NODE_ENV !== "production" && n ? (
|
|
83
|
-
// use ref() to unwrap refs inside state TODO: check if this is still necessary
|
|
84
|
-
Fe(b(r ? r() : {}).value)
|
|
85
|
-
) : Fe(t.state.value[s]);
|
|
86
|
-
return B(p, i, Object.keys(c || {}).reduce((g, w) => (process.env.NODE_ENV !== "production" && w in p && console.warn(`[🍍]: A getter cannot have the same name as another state property. Rename one of them. Found with "${w}" in store "${s}".`), g[w] = J(De(() => {
|
|
87
|
-
he(t);
|
|
88
|
-
const T = t._s.get(s);
|
|
89
|
-
return c[w].call(T, T);
|
|
90
|
-
})), g), {}));
|
|
91
|
-
}
|
|
92
|
-
return h = Oe(s, f, e, t, n, !0), h;
|
|
93
|
-
}
|
|
94
|
-
function Oe(s, e, t = {}, n, r, i) {
|
|
95
|
-
let c;
|
|
96
|
-
const l = B({ actions: {} }, t);
|
|
97
|
-
if (process.env.NODE_ENV !== "production" && !n._e.active)
|
|
98
|
-
throw new Error("Pinia destroyed");
|
|
99
|
-
const h = { deep: !0 };
|
|
100
|
-
process.env.NODE_ENV !== "production" && (h.onTrigger = (o) => {
|
|
101
|
-
f ? T = o : f == !1 && !d._hotUpdating && (Array.isArray(T) ? T.push(o) : console.error("🍍 debuggerEvents should be an array. This is most likely an internal Pinia bug."));
|
|
102
|
-
});
|
|
103
|
-
let f, p, g = [], w = [], T;
|
|
104
|
-
const x = n.state.value[s];
|
|
105
|
-
!i && !x && (process.env.NODE_ENV === "production" || !r) && (n.state.value[s] = {});
|
|
106
|
-
const F = b({});
|
|
107
|
-
let z;
|
|
108
|
-
function j(o) {
|
|
109
|
-
let a;
|
|
110
|
-
f = p = !1, process.env.NODE_ENV !== "production" && (T = []), typeof o == "function" ? (o(n.state.value[s]), a = {
|
|
111
|
-
type: te.patchFunction,
|
|
112
|
-
storeId: s,
|
|
113
|
-
events: T
|
|
114
|
-
}) : (Ne(n.state.value[s], o), a = {
|
|
115
|
-
type: te.patchObject,
|
|
116
|
-
payload: o,
|
|
117
|
-
storeId: s,
|
|
118
|
-
events: T
|
|
119
|
-
});
|
|
120
|
-
const m = z = Symbol();
|
|
121
|
-
be().then(() => {
|
|
122
|
-
z === m && (f = !0);
|
|
123
|
-
}), p = !0, H(g, a, n.state.value[s]);
|
|
124
|
-
}
|
|
125
|
-
const q = i ? function() {
|
|
126
|
-
const { state: a } = t, m = a ? a() : {};
|
|
127
|
-
this.$patch((R) => {
|
|
128
|
-
B(R, m);
|
|
129
|
-
});
|
|
130
|
-
} : (
|
|
131
|
-
/* istanbul ignore next */
|
|
132
|
-
process.env.NODE_ENV !== "production" ? () => {
|
|
133
|
-
throw new Error(`🍍: Store "${s}" is built using the setup syntax and does not implement $reset().`);
|
|
134
|
-
} : ot
|
|
135
|
-
);
|
|
136
|
-
function ne() {
|
|
137
|
-
c.stop(), g = [], w = [], n._s.delete(s);
|
|
138
|
-
}
|
|
139
|
-
const k = (o, a = "") => {
|
|
140
|
-
if (Ke in o)
|
|
141
|
-
return o[me] = a, o;
|
|
142
|
-
const m = function() {
|
|
143
|
-
he(n);
|
|
144
|
-
const R = Array.from(arguments), Y = [], pe = [];
|
|
145
|
-
function Et(A) {
|
|
146
|
-
Y.push(A);
|
|
147
|
-
}
|
|
148
|
-
function kt(A) {
|
|
149
|
-
pe.push(A);
|
|
150
|
-
}
|
|
151
|
-
H(w, {
|
|
152
|
-
args: R,
|
|
153
|
-
name: m[me],
|
|
154
|
-
store: d,
|
|
155
|
-
after: Et,
|
|
156
|
-
onError: kt
|
|
157
|
-
});
|
|
158
|
-
let X;
|
|
159
|
-
try {
|
|
160
|
-
X = o.apply(this && this.$id === s ? this : d, R);
|
|
161
|
-
} catch (A) {
|
|
162
|
-
throw H(pe, A), A;
|
|
163
|
-
}
|
|
164
|
-
return X instanceof Promise ? X.then((A) => (H(Y, A), A)).catch((A) => (H(pe, A), Promise.reject(A))) : (H(Y, X), X);
|
|
165
|
-
};
|
|
166
|
-
return m[Ke] = !0, m[me] = a, m;
|
|
167
|
-
}, _ = /* @__PURE__ */ J({
|
|
168
|
-
actions: {},
|
|
169
|
-
getters: {},
|
|
170
|
-
state: [],
|
|
171
|
-
hotState: F
|
|
172
|
-
}), S = {
|
|
173
|
-
_p: n,
|
|
174
|
-
// _s: scope,
|
|
175
|
-
$id: s,
|
|
176
|
-
$onAction: je.bind(null, w),
|
|
177
|
-
$patch: j,
|
|
178
|
-
$reset: q,
|
|
179
|
-
$subscribe(o, a = {}) {
|
|
180
|
-
const m = je(g, o, a.detached, () => R()), R = c.run(() => tt(() => n.state.value[s], (Y) => {
|
|
181
|
-
(a.flush === "sync" ? p : f) && o({
|
|
182
|
-
storeId: s,
|
|
183
|
-
type: te.direct,
|
|
184
|
-
events: T
|
|
185
|
-
}, Y);
|
|
186
|
-
}, B({}, h, a)));
|
|
187
|
-
return m;
|
|
188
|
-
},
|
|
189
|
-
$dispose: ne
|
|
190
|
-
}, d = Ot(process.env.NODE_ENV !== "production" || process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Z ? B(
|
|
191
|
-
{
|
|
192
|
-
_hmrPayload: _,
|
|
193
|
-
_customProperties: J(/* @__PURE__ */ new Set())
|
|
194
|
-
// devtools custom properties
|
|
195
|
-
},
|
|
196
|
-
S
|
|
197
|
-
// must be added later
|
|
198
|
-
// setupStore
|
|
199
|
-
) : S);
|
|
200
|
-
n._s.set(s, d);
|
|
201
|
-
const y = (n._a && n._a.runWithContext || Ut)(() => n._e.run(() => (c = Tt()).run(() => e({ action: k }))));
|
|
202
|
-
for (const o in y) {
|
|
203
|
-
const a = y[o];
|
|
204
|
-
if (se(a) && !Ye(a) || Pe(a))
|
|
205
|
-
process.env.NODE_ENV !== "production" && r ? re(F.value, o, ge(y, o)) : i || (x && qt(a) && (se(a) ? a.value = x[o] : Ne(a, x[o])), n.state.value[s][o] = a), process.env.NODE_ENV !== "production" && _.state.push(o);
|
|
206
|
-
else if (typeof a == "function") {
|
|
207
|
-
const m = process.env.NODE_ENV !== "production" && r ? a : k(a, o);
|
|
208
|
-
y[o] = m, process.env.NODE_ENV !== "production" && (_.actions[o] = a), l.actions[o] = a;
|
|
209
|
-
} else process.env.NODE_ENV !== "production" && Ye(a) && (_.getters[o] = i ? (
|
|
210
|
-
// @ts-expect-error
|
|
211
|
-
t.getters[o]
|
|
212
|
-
) : a, Z && (y._getters || // @ts-expect-error: same
|
|
213
|
-
(y._getters = J([]))).push(o));
|
|
214
|
-
}
|
|
215
|
-
if (B(d, y), B(xt(d), y), Object.defineProperty(d, "$state", {
|
|
216
|
-
get: () => process.env.NODE_ENV !== "production" && r ? F.value : n.state.value[s],
|
|
217
|
-
set: (o) => {
|
|
218
|
-
if (process.env.NODE_ENV !== "production" && r)
|
|
219
|
-
throw new Error("cannot set hotState");
|
|
220
|
-
j((a) => {
|
|
221
|
-
B(a, o);
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
}), process.env.NODE_ENV !== "production" && (d._hotUpdate = J((o) => {
|
|
225
|
-
d._hotUpdating = !0, o._hmrPayload.state.forEach((a) => {
|
|
226
|
-
if (a in d.$state) {
|
|
227
|
-
const m = o.$state[a], R = d.$state[a];
|
|
228
|
-
typeof m == "object" && $(m) && $(R) ? it(m, R) : o.$state[a] = R;
|
|
229
|
-
}
|
|
230
|
-
re(d, a, ge(o.$state, a));
|
|
231
|
-
}), Object.keys(d.$state).forEach((a) => {
|
|
232
|
-
a in o.$state || ye(d, a);
|
|
233
|
-
}), f = !1, p = !1, n.state.value[s] = ge(o._hmrPayload, "hotState"), p = !0, be().then(() => {
|
|
234
|
-
f = !0;
|
|
235
|
-
});
|
|
236
|
-
for (const a in o._hmrPayload.actions) {
|
|
237
|
-
const m = o[a];
|
|
238
|
-
re(d, a, k(m, a));
|
|
239
|
-
}
|
|
240
|
-
for (const a in o._hmrPayload.getters) {
|
|
241
|
-
const m = o._hmrPayload.getters[a], R = i ? (
|
|
242
|
-
// special handling of options api
|
|
243
|
-
De(() => (he(n), m.call(d, d)))
|
|
244
|
-
) : m;
|
|
245
|
-
re(d, a, R);
|
|
246
|
-
}
|
|
247
|
-
Object.keys(d._hmrPayload.getters).forEach((a) => {
|
|
248
|
-
a in o._hmrPayload.getters || ye(d, a);
|
|
249
|
-
}), Object.keys(d._hmrPayload.actions).forEach((a) => {
|
|
250
|
-
a in o._hmrPayload.actions || ye(d, a);
|
|
251
|
-
}), d._hmrPayload = o._hmrPayload, d._getters = o._getters, d._hotUpdating = !1;
|
|
252
|
-
})), process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Z) {
|
|
253
|
-
const o = {
|
|
254
|
-
writable: !0,
|
|
255
|
-
configurable: !0,
|
|
256
|
-
// avoid warning on devtools trying to display this property
|
|
257
|
-
enumerable: !1
|
|
258
|
-
};
|
|
259
|
-
["_p", "_hmrPayload", "_getters", "_customProperties"].forEach((a) => {
|
|
260
|
-
Object.defineProperty(d, a, B({ value: d[a] }, o));
|
|
261
|
-
});
|
|
262
|
-
}
|
|
263
|
-
return n._p.forEach((o) => {
|
|
264
|
-
if (process.env.NODE_ENV !== "production" && process.env.NODE_ENV !== "test" && Z) {
|
|
265
|
-
const a = c.run(() => o({
|
|
266
|
-
store: d,
|
|
267
|
-
app: n._a,
|
|
268
|
-
pinia: n,
|
|
269
|
-
options: l
|
|
270
|
-
}));
|
|
271
|
-
Object.keys(a || {}).forEach((m) => d._customProperties.add(m)), B(d, a);
|
|
272
|
-
} else
|
|
273
|
-
B(d, c.run(() => o({
|
|
274
|
-
store: d,
|
|
275
|
-
app: n._a,
|
|
276
|
-
pinia: n,
|
|
277
|
-
options: l
|
|
278
|
-
})));
|
|
279
|
-
}), process.env.NODE_ENV !== "production" && d.$state && typeof d.$state == "object" && typeof d.$state.constructor == "function" && !d.$state.constructor.toString().includes("[native code]") && console.warn(`[🍍]: The "state" must be a plain object. It cannot be
|
|
280
|
-
state: () => new MyClass()
|
|
281
|
-
Found in store "${d.$id}".`), x && i && t.hydrate && t.hydrate(d.$state, x), f = !0, p = !0, d;
|
|
282
|
-
}
|
|
283
|
-
/*! #__NO_SIDE_EFFECTS__ */
|
|
284
|
-
// @__NO_SIDE_EFFECTS__
|
|
285
|
-
function $t(s, e, t) {
|
|
286
|
-
let n, r;
|
|
287
|
-
const i = typeof e == "function";
|
|
288
|
-
n = s, r = i ? t : e;
|
|
289
|
-
function c(l, h) {
|
|
290
|
-
const f = St();
|
|
291
|
-
if (l = // in test mode, ignore the argument provided as we can always retrieve a
|
|
292
|
-
// pinia instance with getActivePinia()
|
|
293
|
-
(process.env.NODE_ENV === "test" && Q && Q._testing ? null : l) || (f ? Ct(Vt, null) : null), l && he(l), process.env.NODE_ENV !== "production" && !Q)
|
|
294
|
-
throw new Error(`[🍍]: "getActivePinia()" was called but there was no active Pinia. Are you trying to use a store before calling "app.use(pinia)"?
|
|
295
|
-
See https://pinia.vuejs.org/core-concepts/outside-component-usage.html for help.
|
|
296
|
-
This will fail in production.`);
|
|
297
|
-
l = Q, l._s.has(n) || (i ? Oe(n, e, r, l) : Xe(n, r, l), process.env.NODE_ENV !== "production" && (c._pinia = l));
|
|
298
|
-
const p = l._s.get(n);
|
|
299
|
-
if (process.env.NODE_ENV !== "production" && h) {
|
|
300
|
-
const g = "__hot:" + n, w = i ? Oe(g, e, r, l, !0) : Xe(g, B({}, r), l, !0);
|
|
301
|
-
h._hotUpdate(w), delete l.state.value[g], l._s.delete(g);
|
|
302
|
-
}
|
|
303
|
-
if (process.env.NODE_ENV !== "production" && Z) {
|
|
304
|
-
const g = Nt();
|
|
305
|
-
if (g && g.proxy && // avoid adding stores that are just built for hot module replacement
|
|
306
|
-
!h) {
|
|
307
|
-
const w = g.proxy, T = "_pStores" in w ? w._pStores : w._pStores = {};
|
|
308
|
-
T[n] = p;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
return p;
|
|
312
|
-
}
|
|
313
|
-
return c.$id = n, c;
|
|
314
|
-
}
|
|
315
|
-
const I = /* @__PURE__ */ Object.create(null);
|
|
316
|
-
I.open = "0";
|
|
317
|
-
I.close = "1";
|
|
318
|
-
I.ping = "2";
|
|
319
|
-
I.pong = "3";
|
|
320
|
-
I.message = "4";
|
|
321
|
-
I.upgrade = "5";
|
|
322
|
-
I.noop = "6";
|
|
323
|
-
const ae = /* @__PURE__ */ Object.create(null);
|
|
324
|
-
Object.keys(I).forEach((s) => {
|
|
325
|
-
ae[I[s]] = s;
|
|
326
|
-
});
|
|
327
|
-
const Te = { type: "error", data: "parser error" }, at = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ct = typeof ArrayBuffer == "function", lt = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s && s.buffer instanceof ArrayBuffer, Ve = ({ type: s, data: e }, t, n) => at && e instanceof Blob ? t ? n(e) : Ge(e, n) : ct && (e instanceof ArrayBuffer || lt(e)) ? t ? n(e) : Ge(new Blob([e]), n) : n(I[s] + (e || "")), Ge = (s, e) => {
|
|
328
|
-
const t = new FileReader();
|
|
329
|
-
return t.onload = function() {
|
|
330
|
-
const n = t.result.split(",")[1];
|
|
331
|
-
e("b" + (n || ""));
|
|
332
|
-
}, t.readAsDataURL(s);
|
|
333
|
-
};
|
|
334
|
-
function Je(s) {
|
|
335
|
-
return s instanceof Uint8Array ? s : s instanceof ArrayBuffer ? new Uint8Array(s) : new Uint8Array(s.buffer, s.byteOffset, s.byteLength);
|
|
336
|
-
}
|
|
337
|
-
let ve;
|
|
338
|
-
function Ft(s, e) {
|
|
339
|
-
if (at && s.data instanceof Blob)
|
|
340
|
-
return s.data.arrayBuffer().then(Je).then(e);
|
|
341
|
-
if (ct && (s.data instanceof ArrayBuffer || lt(s.data)))
|
|
342
|
-
return e(Je(s.data));
|
|
343
|
-
Ve(s, !1, (t) => {
|
|
344
|
-
ve || (ve = new TextEncoder()), e(ve.encode(t));
|
|
345
|
-
});
|
|
346
|
-
}
|
|
347
|
-
const Qe = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", ee = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
348
|
-
for (let s = 0; s < Qe.length; s++)
|
|
349
|
-
ee[Qe.charCodeAt(s)] = s;
|
|
350
|
-
const Ht = (s) => {
|
|
351
|
-
let e = s.length * 0.75, t = s.length, n, r = 0, i, c, l, h;
|
|
352
|
-
s[s.length - 1] === "=" && (e--, s[s.length - 2] === "=" && e--);
|
|
353
|
-
const f = new ArrayBuffer(e), p = new Uint8Array(f);
|
|
354
|
-
for (n = 0; n < t; n += 4)
|
|
355
|
-
i = ee[s.charCodeAt(n)], c = ee[s.charCodeAt(n + 1)], l = ee[s.charCodeAt(n + 2)], h = ee[s.charCodeAt(n + 3)], p[r++] = i << 2 | c >> 4, p[r++] = (c & 15) << 4 | l >> 2, p[r++] = (l & 3) << 6 | h & 63;
|
|
356
|
-
return f;
|
|
357
|
-
}, Wt = typeof ArrayBuffer == "function", Ue = (s, e) => {
|
|
358
|
-
if (typeof s != "string")
|
|
359
|
-
return {
|
|
360
|
-
type: "message",
|
|
361
|
-
data: ut(s, e)
|
|
362
|
-
};
|
|
363
|
-
const t = s.charAt(0);
|
|
364
|
-
return t === "b" ? {
|
|
365
|
-
type: "message",
|
|
366
|
-
data: zt(s.substring(1), e)
|
|
367
|
-
} : ae[t] ? s.length > 1 ? {
|
|
368
|
-
type: ae[t],
|
|
369
|
-
data: s.substring(1)
|
|
370
|
-
} : {
|
|
371
|
-
type: ae[t]
|
|
372
|
-
} : Te;
|
|
373
|
-
}, zt = (s, e) => {
|
|
374
|
-
if (Wt) {
|
|
375
|
-
const t = Ht(s);
|
|
376
|
-
return ut(t, e);
|
|
377
|
-
} else
|
|
378
|
-
return { base64: !0, data: s };
|
|
379
|
-
}, ut = (s, e) => {
|
|
380
|
-
switch (e) {
|
|
381
|
-
case "blob":
|
|
382
|
-
return s instanceof Blob ? s : new Blob([s]);
|
|
383
|
-
case "arraybuffer":
|
|
384
|
-
default:
|
|
385
|
-
return s instanceof ArrayBuffer ? s : s.buffer;
|
|
386
|
-
}
|
|
387
|
-
}, ht = "", jt = (s, e) => {
|
|
388
|
-
const t = s.length, n = new Array(t);
|
|
389
|
-
let r = 0;
|
|
390
|
-
s.forEach((i, c) => {
|
|
391
|
-
Ve(i, !1, (l) => {
|
|
392
|
-
n[c] = l, ++r === t && e(n.join(ht));
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
}, Kt = (s, e) => {
|
|
396
|
-
const t = s.split(ht), n = [];
|
|
397
|
-
for (let r = 0; r < t.length; r++) {
|
|
398
|
-
const i = Ue(t[r], e);
|
|
399
|
-
if (n.push(i), i.type === "error")
|
|
400
|
-
break;
|
|
401
|
-
}
|
|
402
|
-
return n;
|
|
403
|
-
};
|
|
404
|
-
function Yt() {
|
|
405
|
-
return new TransformStream({
|
|
406
|
-
transform(s, e) {
|
|
407
|
-
Ft(s, (t) => {
|
|
408
|
-
const n = t.length;
|
|
409
|
-
let r;
|
|
410
|
-
if (n < 126)
|
|
411
|
-
r = new Uint8Array(1), new DataView(r.buffer).setUint8(0, n);
|
|
412
|
-
else if (n < 65536) {
|
|
413
|
-
r = new Uint8Array(3);
|
|
414
|
-
const i = new DataView(r.buffer);
|
|
415
|
-
i.setUint8(0, 126), i.setUint16(1, n);
|
|
416
|
-
} else {
|
|
417
|
-
r = new Uint8Array(9);
|
|
418
|
-
const i = new DataView(r.buffer);
|
|
419
|
-
i.setUint8(0, 127), i.setBigUint64(1, BigInt(n));
|
|
420
|
-
}
|
|
421
|
-
s.data && typeof s.data != "string" && (r[0] |= 128), e.enqueue(r), e.enqueue(t);
|
|
422
|
-
});
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
}
|
|
426
|
-
let _e;
|
|
427
|
-
function ie(s) {
|
|
428
|
-
return s.reduce((e, t) => e + t.length, 0);
|
|
429
|
-
}
|
|
430
|
-
function oe(s, e) {
|
|
431
|
-
if (s[0].length === e)
|
|
432
|
-
return s.shift();
|
|
433
|
-
const t = new Uint8Array(e);
|
|
434
|
-
let n = 0;
|
|
435
|
-
for (let r = 0; r < e; r++)
|
|
436
|
-
t[r] = s[0][n++], n === s[0].length && (s.shift(), n = 0);
|
|
437
|
-
return s.length && n < s[0].length && (s[0] = s[0].slice(n)), t;
|
|
438
|
-
}
|
|
439
|
-
function Xt(s, e) {
|
|
440
|
-
_e || (_e = new TextDecoder());
|
|
441
|
-
const t = [];
|
|
442
|
-
let n = 0, r = -1, i = !1;
|
|
443
|
-
return new TransformStream({
|
|
444
|
-
transform(c, l) {
|
|
445
|
-
for (t.push(c); ; ) {
|
|
446
|
-
if (n === 0) {
|
|
447
|
-
if (ie(t) < 1)
|
|
448
|
-
break;
|
|
449
|
-
const h = oe(t, 1);
|
|
450
|
-
i = (h[0] & 128) === 128, r = h[0] & 127, r < 126 ? n = 3 : r === 126 ? n = 1 : n = 2;
|
|
451
|
-
} else if (n === 1) {
|
|
452
|
-
if (ie(t) < 2)
|
|
453
|
-
break;
|
|
454
|
-
const h = oe(t, 2);
|
|
455
|
-
r = new DataView(h.buffer, h.byteOffset, h.length).getUint16(0), n = 3;
|
|
456
|
-
} else if (n === 2) {
|
|
457
|
-
if (ie(t) < 8)
|
|
458
|
-
break;
|
|
459
|
-
const h = oe(t, 8), f = new DataView(h.buffer, h.byteOffset, h.length), p = f.getUint32(0);
|
|
460
|
-
if (p > Math.pow(2, 21) - 1) {
|
|
461
|
-
l.enqueue(Te);
|
|
462
|
-
break;
|
|
463
|
-
}
|
|
464
|
-
r = p * Math.pow(2, 32) + f.getUint32(4), n = 3;
|
|
465
|
-
} else {
|
|
466
|
-
if (ie(t) < r)
|
|
467
|
-
break;
|
|
468
|
-
const h = oe(t, r);
|
|
469
|
-
l.enqueue(Ue(i ? h : _e.decode(h), e)), n = 0;
|
|
470
|
-
}
|
|
471
|
-
if (r === 0 || r > s) {
|
|
472
|
-
l.enqueue(Te);
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
}
|
|
477
|
-
});
|
|
478
|
-
}
|
|
479
|
-
const ft = 4;
|
|
480
|
-
function E(s) {
|
|
481
|
-
if (s) return Gt(s);
|
|
482
|
-
}
|
|
483
|
-
function Gt(s) {
|
|
484
|
-
for (var e in E.prototype)
|
|
485
|
-
s[e] = E.prototype[e];
|
|
486
|
-
return s;
|
|
487
|
-
}
|
|
488
|
-
E.prototype.on = E.prototype.addEventListener = function(s, e) {
|
|
489
|
-
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + s] = this._callbacks["$" + s] || []).push(e), this;
|
|
490
|
-
};
|
|
491
|
-
E.prototype.once = function(s, e) {
|
|
492
|
-
function t() {
|
|
493
|
-
this.off(s, t), e.apply(this, arguments);
|
|
494
|
-
}
|
|
495
|
-
return t.fn = e, this.on(s, t), this;
|
|
496
|
-
};
|
|
497
|
-
E.prototype.off = E.prototype.removeListener = E.prototype.removeAllListeners = E.prototype.removeEventListener = function(s, e) {
|
|
498
|
-
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
499
|
-
return this._callbacks = {}, this;
|
|
500
|
-
var t = this._callbacks["$" + s];
|
|
501
|
-
if (!t) return this;
|
|
502
|
-
if (arguments.length == 1)
|
|
503
|
-
return delete this._callbacks["$" + s], this;
|
|
504
|
-
for (var n, r = 0; r < t.length; r++)
|
|
505
|
-
if (n = t[r], n === e || n.fn === e) {
|
|
506
|
-
t.splice(r, 1);
|
|
507
|
-
break;
|
|
508
|
-
}
|
|
509
|
-
return t.length === 0 && delete this._callbacks["$" + s], this;
|
|
510
|
-
};
|
|
511
|
-
E.prototype.emit = function(s) {
|
|
512
|
-
this._callbacks = this._callbacks || {};
|
|
513
|
-
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + s], n = 1; n < arguments.length; n++)
|
|
514
|
-
e[n - 1] = arguments[n];
|
|
515
|
-
if (t) {
|
|
516
|
-
t = t.slice(0);
|
|
517
|
-
for (var n = 0, r = t.length; n < r; ++n)
|
|
518
|
-
t[n].apply(this, e);
|
|
519
|
-
}
|
|
520
|
-
return this;
|
|
521
|
-
};
|
|
522
|
-
E.prototype.emitReserved = E.prototype.emit;
|
|
523
|
-
E.prototype.listeners = function(s) {
|
|
524
|
-
return this._callbacks = this._callbacks || {}, this._callbacks["$" + s] || [];
|
|
525
|
-
};
|
|
526
|
-
E.prototype.hasListeners = function(s) {
|
|
527
|
-
return !!this.listeners(s).length;
|
|
528
|
-
};
|
|
529
|
-
const fe = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), L = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Jt = "arraybuffer";
|
|
530
|
-
function dt(s, ...e) {
|
|
531
|
-
return e.reduce((t, n) => (s.hasOwnProperty(n) && (t[n] = s[n]), t), {});
|
|
532
|
-
}
|
|
533
|
-
const Qt = L.setTimeout, Zt = L.clearTimeout;
|
|
534
|
-
function de(s, e) {
|
|
535
|
-
e.useNativeTimers ? (s.setTimeoutFn = Qt.bind(L), s.clearTimeoutFn = Zt.bind(L)) : (s.setTimeoutFn = L.setTimeout.bind(L), s.clearTimeoutFn = L.clearTimeout.bind(L));
|
|
536
|
-
}
|
|
537
|
-
const es = 1.33;
|
|
538
|
-
function ts(s) {
|
|
539
|
-
return typeof s == "string" ? ss(s) : Math.ceil((s.byteLength || s.size) * es);
|
|
540
|
-
}
|
|
541
|
-
function ss(s) {
|
|
542
|
-
let e = 0, t = 0;
|
|
543
|
-
for (let n = 0, r = s.length; n < r; n++)
|
|
544
|
-
e = s.charCodeAt(n), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (n++, t += 4);
|
|
545
|
-
return t;
|
|
546
|
-
}
|
|
547
|
-
function pt() {
|
|
548
|
-
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
549
|
-
}
|
|
550
|
-
function ns(s) {
|
|
551
|
-
let e = "";
|
|
552
|
-
for (let t in s)
|
|
553
|
-
s.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(s[t]));
|
|
554
|
-
return e;
|
|
555
|
-
}
|
|
556
|
-
function rs(s) {
|
|
557
|
-
let e = {}, t = s.split("&");
|
|
558
|
-
for (let n = 0, r = t.length; n < r; n++) {
|
|
559
|
-
let i = t[n].split("=");
|
|
560
|
-
e[decodeURIComponent(i[0])] = decodeURIComponent(i[1]);
|
|
561
|
-
}
|
|
562
|
-
return e;
|
|
563
|
-
}
|
|
564
|
-
class is extends Error {
|
|
565
|
-
constructor(e, t, n) {
|
|
566
|
-
super(e), this.description = t, this.context = n, this.type = "TransportError";
|
|
567
|
-
}
|
|
568
|
-
}
|
|
569
|
-
class Me extends E {
|
|
570
|
-
/**
|
|
571
|
-
* Transport abstract constructor.
|
|
572
|
-
*
|
|
573
|
-
* @param {Object} opts - options
|
|
574
|
-
* @protected
|
|
575
|
-
*/
|
|
576
|
-
constructor(e) {
|
|
577
|
-
super(), this.writable = !1, de(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
578
|
-
}
|
|
579
|
-
/**
|
|
580
|
-
* Emits an error.
|
|
581
|
-
*
|
|
582
|
-
* @param {String} reason
|
|
583
|
-
* @param description
|
|
584
|
-
* @param context - the error context
|
|
585
|
-
* @return {Transport} for chaining
|
|
586
|
-
* @protected
|
|
587
|
-
*/
|
|
588
|
-
onError(e, t, n) {
|
|
589
|
-
return super.emitReserved("error", new is(e, t, n)), this;
|
|
590
|
-
}
|
|
591
|
-
/**
|
|
592
|
-
* Opens the transport.
|
|
593
|
-
*/
|
|
594
|
-
open() {
|
|
595
|
-
return this.readyState = "opening", this.doOpen(), this;
|
|
596
|
-
}
|
|
597
|
-
/**
|
|
598
|
-
* Closes the transport.
|
|
599
|
-
*/
|
|
600
|
-
close() {
|
|
601
|
-
return (this.readyState === "opening" || this.readyState === "open") && (this.doClose(), this.onClose()), this;
|
|
602
|
-
}
|
|
603
|
-
/**
|
|
604
|
-
* Sends multiple packets.
|
|
605
|
-
*
|
|
606
|
-
* @param {Array} packets
|
|
607
|
-
*/
|
|
608
|
-
send(e) {
|
|
609
|
-
this.readyState === "open" && this.write(e);
|
|
610
|
-
}
|
|
611
|
-
/**
|
|
612
|
-
* Called upon open
|
|
613
|
-
*
|
|
614
|
-
* @protected
|
|
615
|
-
*/
|
|
616
|
-
onOpen() {
|
|
617
|
-
this.readyState = "open", this.writable = !0, super.emitReserved("open");
|
|
618
|
-
}
|
|
619
|
-
/**
|
|
620
|
-
* Called with data.
|
|
621
|
-
*
|
|
622
|
-
* @param {String} data
|
|
623
|
-
* @protected
|
|
624
|
-
*/
|
|
625
|
-
onData(e) {
|
|
626
|
-
const t = Ue(e, this.socket.binaryType);
|
|
627
|
-
this.onPacket(t);
|
|
628
|
-
}
|
|
629
|
-
/**
|
|
630
|
-
* Called with a decoded packet.
|
|
631
|
-
*
|
|
632
|
-
* @protected
|
|
633
|
-
*/
|
|
634
|
-
onPacket(e) {
|
|
635
|
-
super.emitReserved("packet", e);
|
|
636
|
-
}
|
|
637
|
-
/**
|
|
638
|
-
* Called upon close.
|
|
639
|
-
*
|
|
640
|
-
* @protected
|
|
641
|
-
*/
|
|
642
|
-
onClose(e) {
|
|
643
|
-
this.readyState = "closed", super.emitReserved("close", e);
|
|
644
|
-
}
|
|
645
|
-
/**
|
|
646
|
-
* Pauses the transport, in order not to lose packets during an upgrade.
|
|
647
|
-
*
|
|
648
|
-
* @param onPause
|
|
649
|
-
*/
|
|
650
|
-
pause(e) {
|
|
651
|
-
}
|
|
652
|
-
createUri(e, t = {}) {
|
|
653
|
-
return e + "://" + this._hostname() + this._port() + this.opts.path + this._query(t);
|
|
654
|
-
}
|
|
655
|
-
_hostname() {
|
|
656
|
-
const e = this.opts.hostname;
|
|
657
|
-
return e.indexOf(":") === -1 ? e : "[" + e + "]";
|
|
658
|
-
}
|
|
659
|
-
_port() {
|
|
660
|
-
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
661
|
-
}
|
|
662
|
-
_query(e) {
|
|
663
|
-
const t = ns(e);
|
|
664
|
-
return t.length ? "?" + t : "";
|
|
665
|
-
}
|
|
666
|
-
}
|
|
667
|
-
class os extends Me {
|
|
668
|
-
constructor() {
|
|
669
|
-
super(...arguments), this._polling = !1;
|
|
670
|
-
}
|
|
671
|
-
get name() {
|
|
672
|
-
return "polling";
|
|
673
|
-
}
|
|
674
|
-
/**
|
|
675
|
-
* Opens the socket (triggers polling). We write a PING message to determine
|
|
676
|
-
* when the transport is open.
|
|
677
|
-
*
|
|
678
|
-
* @protected
|
|
679
|
-
*/
|
|
680
|
-
doOpen() {
|
|
681
|
-
this._poll();
|
|
682
|
-
}
|
|
683
|
-
/**
|
|
684
|
-
* Pauses polling.
|
|
685
|
-
*
|
|
686
|
-
* @param {Function} onPause - callback upon buffers are flushed and transport is paused
|
|
687
|
-
* @package
|
|
688
|
-
*/
|
|
689
|
-
pause(e) {
|
|
690
|
-
this.readyState = "pausing";
|
|
691
|
-
const t = () => {
|
|
692
|
-
this.readyState = "paused", e();
|
|
693
|
-
};
|
|
694
|
-
if (this._polling || !this.writable) {
|
|
695
|
-
let n = 0;
|
|
696
|
-
this._polling && (n++, this.once("pollComplete", function() {
|
|
697
|
-
--n || t();
|
|
698
|
-
})), this.writable || (n++, this.once("drain", function() {
|
|
699
|
-
--n || t();
|
|
700
|
-
}));
|
|
701
|
-
} else
|
|
702
|
-
t();
|
|
703
|
-
}
|
|
704
|
-
/**
|
|
705
|
-
* Starts polling cycle.
|
|
706
|
-
*
|
|
707
|
-
* @private
|
|
708
|
-
*/
|
|
709
|
-
_poll() {
|
|
710
|
-
this._polling = !0, this.doPoll(), this.emitReserved("poll");
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* Overloads onData to detect payloads.
|
|
714
|
-
*
|
|
715
|
-
* @protected
|
|
716
|
-
*/
|
|
717
|
-
onData(e) {
|
|
718
|
-
const t = (n) => {
|
|
719
|
-
if (this.readyState === "opening" && n.type === "open" && this.onOpen(), n.type === "close")
|
|
720
|
-
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
721
|
-
this.onPacket(n);
|
|
722
|
-
};
|
|
723
|
-
Kt(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* For polling, send a close packet.
|
|
727
|
-
*
|
|
728
|
-
* @protected
|
|
729
|
-
*/
|
|
730
|
-
doClose() {
|
|
731
|
-
const e = () => {
|
|
732
|
-
this.write([{ type: "close" }]);
|
|
733
|
-
};
|
|
734
|
-
this.readyState === "open" ? e() : this.once("open", e);
|
|
735
|
-
}
|
|
736
|
-
/**
|
|
737
|
-
* Writes a packets payload.
|
|
738
|
-
*
|
|
739
|
-
* @param {Array} packets - data packets
|
|
740
|
-
* @protected
|
|
741
|
-
*/
|
|
742
|
-
write(e) {
|
|
743
|
-
this.writable = !1, jt(e, (t) => {
|
|
744
|
-
this.doWrite(t, () => {
|
|
745
|
-
this.writable = !0, this.emitReserved("drain");
|
|
746
|
-
});
|
|
747
|
-
});
|
|
748
|
-
}
|
|
749
|
-
/**
|
|
750
|
-
* Generates uri for connection.
|
|
751
|
-
*
|
|
752
|
-
* @private
|
|
753
|
-
*/
|
|
754
|
-
uri() {
|
|
755
|
-
const e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
756
|
-
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = pt()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
let gt = !1;
|
|
760
|
-
try {
|
|
761
|
-
gt = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
762
|
-
} catch {
|
|
763
|
-
}
|
|
764
|
-
const as = gt;
|
|
765
|
-
function cs() {
|
|
766
|
-
}
|
|
767
|
-
class ls extends os {
|
|
768
|
-
/**
|
|
769
|
-
* XHR Polling constructor.
|
|
770
|
-
*
|
|
771
|
-
* @param {Object} opts
|
|
772
|
-
* @package
|
|
773
|
-
*/
|
|
774
|
-
constructor(e) {
|
|
775
|
-
if (super(e), typeof location < "u") {
|
|
776
|
-
const t = location.protocol === "https:";
|
|
777
|
-
let n = location.port;
|
|
778
|
-
n || (n = t ? "443" : "80"), this.xd = typeof location < "u" && e.hostname !== location.hostname || n !== e.port;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
/**
|
|
782
|
-
* Sends data.
|
|
783
|
-
*
|
|
784
|
-
* @param {String} data to send.
|
|
785
|
-
* @param {Function} called upon flush.
|
|
786
|
-
* @private
|
|
787
|
-
*/
|
|
788
|
-
doWrite(e, t) {
|
|
789
|
-
const n = this.request({
|
|
790
|
-
method: "POST",
|
|
791
|
-
data: e
|
|
792
|
-
});
|
|
793
|
-
n.on("success", t), n.on("error", (r, i) => {
|
|
794
|
-
this.onError("xhr post error", r, i);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
/**
|
|
798
|
-
* Starts a poll cycle.
|
|
799
|
-
*
|
|
800
|
-
* @private
|
|
801
|
-
*/
|
|
802
|
-
doPoll() {
|
|
803
|
-
const e = this.request();
|
|
804
|
-
e.on("data", this.onData.bind(this)), e.on("error", (t, n) => {
|
|
805
|
-
this.onError("xhr poll error", t, n);
|
|
806
|
-
}), this.pollXhr = e;
|
|
807
|
-
}
|
|
808
|
-
}
|
|
809
|
-
class D extends E {
|
|
810
|
-
/**
|
|
811
|
-
* Request constructor
|
|
812
|
-
*
|
|
813
|
-
* @param {Object} options
|
|
814
|
-
* @package
|
|
815
|
-
*/
|
|
816
|
-
constructor(e, t, n) {
|
|
817
|
-
super(), this.createRequest = e, de(this, n), this._opts = n, this._method = n.method || "GET", this._uri = t, this._data = n.data !== void 0 ? n.data : null, this._create();
|
|
818
|
-
}
|
|
819
|
-
/**
|
|
820
|
-
* Creates the XHR object and sends the request.
|
|
821
|
-
*
|
|
822
|
-
* @private
|
|
823
|
-
*/
|
|
824
|
-
_create() {
|
|
825
|
-
var e;
|
|
826
|
-
const t = dt(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
827
|
-
t.xdomain = !!this._opts.xd;
|
|
828
|
-
const n = this._xhr = this.createRequest(t);
|
|
829
|
-
try {
|
|
830
|
-
n.open(this._method, this._uri, !0);
|
|
831
|
-
try {
|
|
832
|
-
if (this._opts.extraHeaders) {
|
|
833
|
-
n.setDisableHeaderCheck && n.setDisableHeaderCheck(!0);
|
|
834
|
-
for (let r in this._opts.extraHeaders)
|
|
835
|
-
this._opts.extraHeaders.hasOwnProperty(r) && n.setRequestHeader(r, this._opts.extraHeaders[r]);
|
|
836
|
-
}
|
|
837
|
-
} catch {
|
|
838
|
-
}
|
|
839
|
-
if (this._method === "POST")
|
|
840
|
-
try {
|
|
841
|
-
n.setRequestHeader("Content-type", "text/plain;charset=UTF-8");
|
|
842
|
-
} catch {
|
|
843
|
-
}
|
|
844
|
-
try {
|
|
845
|
-
n.setRequestHeader("Accept", "*/*");
|
|
846
|
-
} catch {
|
|
847
|
-
}
|
|
848
|
-
(e = this._opts.cookieJar) === null || e === void 0 || e.addCookies(n), "withCredentials" in n && (n.withCredentials = this._opts.withCredentials), this._opts.requestTimeout && (n.timeout = this._opts.requestTimeout), n.onreadystatechange = () => {
|
|
849
|
-
var r;
|
|
850
|
-
n.readyState === 3 && ((r = this._opts.cookieJar) === null || r === void 0 || r.parseCookies(
|
|
851
|
-
// @ts-ignore
|
|
852
|
-
n.getResponseHeader("set-cookie")
|
|
853
|
-
)), n.readyState === 4 && (n.status === 200 || n.status === 1223 ? this._onLoad() : this.setTimeoutFn(() => {
|
|
854
|
-
this._onError(typeof n.status == "number" ? n.status : 0);
|
|
855
|
-
}, 0));
|
|
856
|
-
}, n.send(this._data);
|
|
857
|
-
} catch (r) {
|
|
858
|
-
this.setTimeoutFn(() => {
|
|
859
|
-
this._onError(r);
|
|
860
|
-
}, 0);
|
|
861
|
-
return;
|
|
862
|
-
}
|
|
863
|
-
typeof document < "u" && (this._index = D.requestsCount++, D.requests[this._index] = this);
|
|
864
|
-
}
|
|
865
|
-
/**
|
|
866
|
-
* Called upon error.
|
|
867
|
-
*
|
|
868
|
-
* @private
|
|
869
|
-
*/
|
|
870
|
-
_onError(e) {
|
|
871
|
-
this.emitReserved("error", e, this._xhr), this._cleanup(!0);
|
|
872
|
-
}
|
|
873
|
-
/**
|
|
874
|
-
* Cleans up house.
|
|
875
|
-
*
|
|
876
|
-
* @private
|
|
877
|
-
*/
|
|
878
|
-
_cleanup(e) {
|
|
879
|
-
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
880
|
-
if (this._xhr.onreadystatechange = cs, e)
|
|
881
|
-
try {
|
|
882
|
-
this._xhr.abort();
|
|
883
|
-
} catch {
|
|
884
|
-
}
|
|
885
|
-
typeof document < "u" && delete D.requests[this._index], this._xhr = null;
|
|
886
|
-
}
|
|
887
|
-
}
|
|
888
|
-
/**
|
|
889
|
-
* Called upon load.
|
|
890
|
-
*
|
|
891
|
-
* @private
|
|
892
|
-
*/
|
|
893
|
-
_onLoad() {
|
|
894
|
-
const e = this._xhr.responseText;
|
|
895
|
-
e !== null && (this.emitReserved("data", e), this.emitReserved("success"), this._cleanup());
|
|
896
|
-
}
|
|
897
|
-
/**
|
|
898
|
-
* Aborts the request.
|
|
899
|
-
*
|
|
900
|
-
* @package
|
|
901
|
-
*/
|
|
902
|
-
abort() {
|
|
903
|
-
this._cleanup();
|
|
904
|
-
}
|
|
905
|
-
}
|
|
906
|
-
D.requestsCount = 0;
|
|
907
|
-
D.requests = {};
|
|
908
|
-
if (typeof document < "u") {
|
|
909
|
-
if (typeof attachEvent == "function")
|
|
910
|
-
attachEvent("onunload", Ze);
|
|
911
|
-
else if (typeof addEventListener == "function") {
|
|
912
|
-
const s = "onpagehide" in L ? "pagehide" : "unload";
|
|
913
|
-
addEventListener(s, Ze, !1);
|
|
914
|
-
}
|
|
915
|
-
}
|
|
916
|
-
function Ze() {
|
|
917
|
-
for (let s in D.requests)
|
|
918
|
-
D.requests.hasOwnProperty(s) && D.requests[s].abort();
|
|
919
|
-
}
|
|
920
|
-
const us = (function() {
|
|
921
|
-
const s = yt({
|
|
922
|
-
xdomain: !1
|
|
923
|
-
});
|
|
924
|
-
return s && s.responseType !== null;
|
|
925
|
-
})();
|
|
926
|
-
class hs extends ls {
|
|
927
|
-
constructor(e) {
|
|
928
|
-
super(e);
|
|
929
|
-
const t = e && e.forceBase64;
|
|
930
|
-
this.supportsBinary = us && !t;
|
|
931
|
-
}
|
|
932
|
-
request(e = {}) {
|
|
933
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new D(yt, this.uri(), e);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
function yt(s) {
|
|
937
|
-
const e = s.xdomain;
|
|
938
|
-
try {
|
|
939
|
-
if (typeof XMLHttpRequest < "u" && (!e || as))
|
|
940
|
-
return new XMLHttpRequest();
|
|
941
|
-
} catch {
|
|
942
|
-
}
|
|
943
|
-
if (!e)
|
|
944
|
-
try {
|
|
945
|
-
return new L[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
946
|
-
} catch {
|
|
947
|
-
}
|
|
948
|
-
}
|
|
949
|
-
const mt = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
950
|
-
class fs extends Me {
|
|
951
|
-
get name() {
|
|
952
|
-
return "websocket";
|
|
953
|
-
}
|
|
954
|
-
doOpen() {
|
|
955
|
-
const e = this.uri(), t = this.opts.protocols, n = mt ? {} : dt(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
956
|
-
this.opts.extraHeaders && (n.headers = this.opts.extraHeaders);
|
|
957
|
-
try {
|
|
958
|
-
this.ws = this.createSocket(e, t, n);
|
|
959
|
-
} catch (r) {
|
|
960
|
-
return this.emitReserved("error", r);
|
|
961
|
-
}
|
|
962
|
-
this.ws.binaryType = this.socket.binaryType, this.addEventListeners();
|
|
963
|
-
}
|
|
964
|
-
/**
|
|
965
|
-
* Adds event listeners to the socket
|
|
966
|
-
*
|
|
967
|
-
* @private
|
|
968
|
-
*/
|
|
969
|
-
addEventListeners() {
|
|
970
|
-
this.ws.onopen = () => {
|
|
971
|
-
this.opts.autoUnref && this.ws._socket.unref(), this.onOpen();
|
|
972
|
-
}, this.ws.onclose = (e) => this.onClose({
|
|
973
|
-
description: "websocket connection closed",
|
|
974
|
-
context: e
|
|
975
|
-
}), this.ws.onmessage = (e) => this.onData(e.data), this.ws.onerror = (e) => this.onError("websocket error", e);
|
|
976
|
-
}
|
|
977
|
-
write(e) {
|
|
978
|
-
this.writable = !1;
|
|
979
|
-
for (let t = 0; t < e.length; t++) {
|
|
980
|
-
const n = e[t], r = t === e.length - 1;
|
|
981
|
-
Ve(n, this.supportsBinary, (i) => {
|
|
982
|
-
try {
|
|
983
|
-
this.doWrite(n, i);
|
|
984
|
-
} catch {
|
|
985
|
-
}
|
|
986
|
-
r && fe(() => {
|
|
987
|
-
this.writable = !0, this.emitReserved("drain");
|
|
988
|
-
}, this.setTimeoutFn);
|
|
989
|
-
});
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
doClose() {
|
|
993
|
-
typeof this.ws < "u" && (this.ws.onerror = () => {
|
|
994
|
-
}, this.ws.close(), this.ws = null);
|
|
995
|
-
}
|
|
996
|
-
/**
|
|
997
|
-
* Generates uri for connection.
|
|
998
|
-
*
|
|
999
|
-
* @private
|
|
1000
|
-
*/
|
|
1001
|
-
uri() {
|
|
1002
|
-
const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
1003
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] = pt()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
const we = L.WebSocket || L.MozWebSocket;
|
|
1007
|
-
class ds extends fs {
|
|
1008
|
-
createSocket(e, t, n) {
|
|
1009
|
-
return mt ? new we(e, t, n) : t ? new we(e, t) : new we(e);
|
|
1010
|
-
}
|
|
1011
|
-
doWrite(e, t) {
|
|
1012
|
-
this.ws.send(t);
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
class ps extends Me {
|
|
1016
|
-
get name() {
|
|
1017
|
-
return "webtransport";
|
|
1018
|
-
}
|
|
1019
|
-
doOpen() {
|
|
1020
|
-
try {
|
|
1021
|
-
this._transport = new WebTransport(this.createUri("https"), this.opts.transportOptions[this.name]);
|
|
1022
|
-
} catch (e) {
|
|
1023
|
-
return this.emitReserved("error", e);
|
|
1024
|
-
}
|
|
1025
|
-
this._transport.closed.then(() => {
|
|
1026
|
-
this.onClose();
|
|
1027
|
-
}).catch((e) => {
|
|
1028
|
-
this.onError("webtransport error", e);
|
|
1029
|
-
}), this._transport.ready.then(() => {
|
|
1030
|
-
this._transport.createBidirectionalStream().then((e) => {
|
|
1031
|
-
const t = Xt(Number.MAX_SAFE_INTEGER, this.socket.binaryType), n = e.readable.pipeThrough(t).getReader(), r = Yt();
|
|
1032
|
-
r.readable.pipeTo(e.writable), this._writer = r.writable.getWriter();
|
|
1033
|
-
const i = () => {
|
|
1034
|
-
n.read().then(({ done: l, value: h }) => {
|
|
1035
|
-
l || (this.onPacket(h), i());
|
|
1036
|
-
}).catch((l) => {
|
|
1037
|
-
});
|
|
1038
|
-
};
|
|
1039
|
-
i();
|
|
1040
|
-
const c = { type: "open" };
|
|
1041
|
-
this.query.sid && (c.data = `{"sid":"${this.query.sid}"}`), this._writer.write(c).then(() => this.onOpen());
|
|
1042
|
-
});
|
|
1043
|
-
});
|
|
1044
|
-
}
|
|
1045
|
-
write(e) {
|
|
1046
|
-
this.writable = !1;
|
|
1047
|
-
for (let t = 0; t < e.length; t++) {
|
|
1048
|
-
const n = e[t], r = t === e.length - 1;
|
|
1049
|
-
this._writer.write(n).then(() => {
|
|
1050
|
-
r && fe(() => {
|
|
1051
|
-
this.writable = !0, this.emitReserved("drain");
|
|
1052
|
-
}, this.setTimeoutFn);
|
|
1053
|
-
});
|
|
1054
|
-
}
|
|
1055
|
-
}
|
|
1056
|
-
doClose() {
|
|
1057
|
-
var e;
|
|
1058
|
-
(e = this._transport) === null || e === void 0 || e.close();
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
const gs = {
|
|
1062
|
-
websocket: ds,
|
|
1063
|
-
webtransport: ps,
|
|
1064
|
-
polling: hs
|
|
1065
|
-
}, ys = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, ms = [
|
|
1066
|
-
"source",
|
|
1067
|
-
"protocol",
|
|
1068
|
-
"authority",
|
|
1069
|
-
"userInfo",
|
|
1070
|
-
"user",
|
|
1071
|
-
"password",
|
|
1072
|
-
"host",
|
|
1073
|
-
"port",
|
|
1074
|
-
"relative",
|
|
1075
|
-
"path",
|
|
1076
|
-
"directory",
|
|
1077
|
-
"file",
|
|
1078
|
-
"query",
|
|
1079
|
-
"anchor"
|
|
1080
|
-
];
|
|
1081
|
-
function xe(s) {
|
|
1082
|
-
if (s.length > 8e3)
|
|
1083
|
-
throw "URI too long";
|
|
1084
|
-
const e = s, t = s.indexOf("["), n = s.indexOf("]");
|
|
1085
|
-
t != -1 && n != -1 && (s = s.substring(0, t) + s.substring(t, n).replace(/:/g, ";") + s.substring(n, s.length));
|
|
1086
|
-
let r = ys.exec(s || ""), i = {}, c = 14;
|
|
1087
|
-
for (; c--; )
|
|
1088
|
-
i[ms[c]] = r[c] || "";
|
|
1089
|
-
return t != -1 && n != -1 && (i.source = e, i.host = i.host.substring(1, i.host.length - 1).replace(/;/g, ":"), i.authority = i.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), i.ipv6uri = !0), i.pathNames = vs(i, i.path), i.queryKey = _s(i, i.query), i;
|
|
1090
|
-
}
|
|
1091
|
-
function vs(s, e) {
|
|
1092
|
-
const t = /\/{2,9}/g, n = e.replace(t, "/").split("/");
|
|
1093
|
-
return (e.slice(0, 1) == "/" || e.length === 0) && n.splice(0, 1), e.slice(-1) == "/" && n.splice(n.length - 1, 1), n;
|
|
1094
|
-
}
|
|
1095
|
-
function _s(s, e) {
|
|
1096
|
-
const t = {};
|
|
1097
|
-
return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(n, r, i) {
|
|
1098
|
-
r && (t[r] = i);
|
|
1099
|
-
}), t;
|
|
1100
|
-
}
|
|
1101
|
-
const Re = typeof addEventListener == "function" && typeof removeEventListener == "function", ce = [];
|
|
1102
|
-
Re && addEventListener("offline", () => {
|
|
1103
|
-
ce.forEach((s) => s());
|
|
1104
|
-
}, !1);
|
|
1105
|
-
class M extends E {
|
|
1106
|
-
/**
|
|
1107
|
-
* Socket constructor.
|
|
1108
|
-
*
|
|
1109
|
-
* @param {String|Object} uri - uri or options
|
|
1110
|
-
* @param {Object} opts - options
|
|
1111
|
-
*/
|
|
1112
|
-
constructor(e, t) {
|
|
1113
|
-
if (super(), this.binaryType = Jt, this.writeBuffer = [], this._prevBufferLen = 0, this._pingInterval = -1, this._pingTimeout = -1, this._maxPayload = -1, this._pingTimeoutTime = 1 / 0, e && typeof e == "object" && (t = e, e = null), e) {
|
|
1114
|
-
const n = xe(e);
|
|
1115
|
-
t.hostname = n.host, t.secure = n.protocol === "https" || n.protocol === "wss", t.port = n.port, n.query && (t.query = n.query);
|
|
1116
|
-
} else t.host && (t.hostname = xe(t.host).host);
|
|
1117
|
-
de(this, t), this.secure = t.secure != null ? t.secure : typeof location < "u" && location.protocol === "https:", t.hostname && !t.port && (t.port = this.secure ? "443" : "80"), this.hostname = t.hostname || (typeof location < "u" ? location.hostname : "localhost"), this.port = t.port || (typeof location < "u" && location.port ? location.port : this.secure ? "443" : "80"), this.transports = [], this._transportsByName = {}, t.transports.forEach((n) => {
|
|
1118
|
-
const r = n.prototype.name;
|
|
1119
|
-
this.transports.push(r), this._transportsByName[r] = n;
|
|
1120
|
-
}), this.opts = Object.assign({
|
|
1121
|
-
path: "/engine.io",
|
|
1122
|
-
agent: !1,
|
|
1123
|
-
withCredentials: !1,
|
|
1124
|
-
upgrade: !0,
|
|
1125
|
-
timestampParam: "t",
|
|
1126
|
-
rememberUpgrade: !1,
|
|
1127
|
-
addTrailingSlash: !0,
|
|
1128
|
-
rejectUnauthorized: !0,
|
|
1129
|
-
perMessageDeflate: {
|
|
1130
|
-
threshold: 1024
|
|
1131
|
-
},
|
|
1132
|
-
transportOptions: {},
|
|
1133
|
-
closeOnBeforeunload: !1
|
|
1134
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = rs(this.opts.query)), Re && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
1135
|
-
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
1136
|
-
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
1137
|
-
this._onClose("transport close", {
|
|
1138
|
-
description: "network connection lost"
|
|
1139
|
-
});
|
|
1140
|
-
}, ce.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
1141
|
-
}
|
|
1142
|
-
/**
|
|
1143
|
-
* Creates transport of the given type.
|
|
1144
|
-
*
|
|
1145
|
-
* @param {String} name - transport name
|
|
1146
|
-
* @return {Transport}
|
|
1147
|
-
* @private
|
|
1148
|
-
*/
|
|
1149
|
-
createTransport(e) {
|
|
1150
|
-
const t = Object.assign({}, this.opts.query);
|
|
1151
|
-
t.EIO = ft, t.transport = e, this.id && (t.sid = this.id);
|
|
1152
|
-
const n = Object.assign({}, this.opts, {
|
|
1153
|
-
query: t,
|
|
1154
|
-
socket: this,
|
|
1155
|
-
hostname: this.hostname,
|
|
1156
|
-
secure: this.secure,
|
|
1157
|
-
port: this.port
|
|
1158
|
-
}, this.opts.transportOptions[e]);
|
|
1159
|
-
return new this._transportsByName[e](n);
|
|
1160
|
-
}
|
|
1161
|
-
/**
|
|
1162
|
-
* Initializes transport to use and starts probe.
|
|
1163
|
-
*
|
|
1164
|
-
* @private
|
|
1165
|
-
*/
|
|
1166
|
-
_open() {
|
|
1167
|
-
if (this.transports.length === 0) {
|
|
1168
|
-
this.setTimeoutFn(() => {
|
|
1169
|
-
this.emitReserved("error", "No transports available");
|
|
1170
|
-
}, 0);
|
|
1171
|
-
return;
|
|
1172
|
-
}
|
|
1173
|
-
const e = this.opts.rememberUpgrade && M.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
1174
|
-
this.readyState = "opening";
|
|
1175
|
-
const t = this.createTransport(e);
|
|
1176
|
-
t.open(), this.setTransport(t);
|
|
1177
|
-
}
|
|
1178
|
-
/**
|
|
1179
|
-
* Sets the current transport. Disables the existing one (if any).
|
|
1180
|
-
*
|
|
1181
|
-
* @private
|
|
1182
|
-
*/
|
|
1183
|
-
setTransport(e) {
|
|
1184
|
-
this.transport && this.transport.removeAllListeners(), this.transport = e, e.on("drain", this._onDrain.bind(this)).on("packet", this._onPacket.bind(this)).on("error", this._onError.bind(this)).on("close", (t) => this._onClose("transport close", t));
|
|
1185
|
-
}
|
|
1186
|
-
/**
|
|
1187
|
-
* Called when connection is deemed open.
|
|
1188
|
-
*
|
|
1189
|
-
* @private
|
|
1190
|
-
*/
|
|
1191
|
-
onOpen() {
|
|
1192
|
-
this.readyState = "open", M.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
1193
|
-
}
|
|
1194
|
-
/**
|
|
1195
|
-
* Handles a packet.
|
|
1196
|
-
*
|
|
1197
|
-
* @private
|
|
1198
|
-
*/
|
|
1199
|
-
_onPacket(e) {
|
|
1200
|
-
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing")
|
|
1201
|
-
switch (this.emitReserved("packet", e), this.emitReserved("heartbeat"), e.type) {
|
|
1202
|
-
case "open":
|
|
1203
|
-
this.onHandshake(JSON.parse(e.data));
|
|
1204
|
-
break;
|
|
1205
|
-
case "ping":
|
|
1206
|
-
this._sendPacket("pong"), this.emitReserved("ping"), this.emitReserved("pong"), this._resetPingTimeout();
|
|
1207
|
-
break;
|
|
1208
|
-
case "error":
|
|
1209
|
-
const t = new Error("server error");
|
|
1210
|
-
t.code = e.data, this._onError(t);
|
|
1211
|
-
break;
|
|
1212
|
-
case "message":
|
|
1213
|
-
this.emitReserved("data", e.data), this.emitReserved("message", e.data);
|
|
1214
|
-
break;
|
|
1215
|
-
}
|
|
1216
|
-
}
|
|
1217
|
-
/**
|
|
1218
|
-
* Called upon handshake completion.
|
|
1219
|
-
*
|
|
1220
|
-
* @param {Object} data - handshake obj
|
|
1221
|
-
* @private
|
|
1222
|
-
*/
|
|
1223
|
-
onHandshake(e) {
|
|
1224
|
-
this.emitReserved("handshake", e), this.id = e.sid, this.transport.query.sid = e.sid, this._pingInterval = e.pingInterval, this._pingTimeout = e.pingTimeout, this._maxPayload = e.maxPayload, this.onOpen(), this.readyState !== "closed" && this._resetPingTimeout();
|
|
1225
|
-
}
|
|
1226
|
-
/**
|
|
1227
|
-
* Sets and resets ping timeout timer based on server pings.
|
|
1228
|
-
*
|
|
1229
|
-
* @private
|
|
1230
|
-
*/
|
|
1231
|
-
_resetPingTimeout() {
|
|
1232
|
-
this.clearTimeoutFn(this._pingTimeoutTimer);
|
|
1233
|
-
const e = this._pingInterval + this._pingTimeout;
|
|
1234
|
-
this._pingTimeoutTime = Date.now() + e, this._pingTimeoutTimer = this.setTimeoutFn(() => {
|
|
1235
|
-
this._onClose("ping timeout");
|
|
1236
|
-
}, e), this.opts.autoUnref && this._pingTimeoutTimer.unref();
|
|
1237
|
-
}
|
|
1238
|
-
/**
|
|
1239
|
-
* Called on `drain` event
|
|
1240
|
-
*
|
|
1241
|
-
* @private
|
|
1242
|
-
*/
|
|
1243
|
-
_onDrain() {
|
|
1244
|
-
this.writeBuffer.splice(0, this._prevBufferLen), this._prevBufferLen = 0, this.writeBuffer.length === 0 ? this.emitReserved("drain") : this.flush();
|
|
1245
|
-
}
|
|
1246
|
-
/**
|
|
1247
|
-
* Flush write buffers.
|
|
1248
|
-
*
|
|
1249
|
-
* @private
|
|
1250
|
-
*/
|
|
1251
|
-
flush() {
|
|
1252
|
-
if (this.readyState !== "closed" && this.transport.writable && !this.upgrading && this.writeBuffer.length) {
|
|
1253
|
-
const e = this._getWritablePackets();
|
|
1254
|
-
this.transport.send(e), this._prevBufferLen = e.length, this.emitReserved("flush");
|
|
1255
|
-
}
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Ensure the encoded size of the writeBuffer is below the maxPayload value sent by the server (only for HTTP
|
|
1259
|
-
* long-polling)
|
|
1260
|
-
*
|
|
1261
|
-
* @private
|
|
1262
|
-
*/
|
|
1263
|
-
_getWritablePackets() {
|
|
1264
|
-
if (!(this._maxPayload && this.transport.name === "polling" && this.writeBuffer.length > 1))
|
|
1265
|
-
return this.writeBuffer;
|
|
1266
|
-
let t = 1;
|
|
1267
|
-
for (let n = 0; n < this.writeBuffer.length; n++) {
|
|
1268
|
-
const r = this.writeBuffer[n].data;
|
|
1269
|
-
if (r && (t += ts(r)), n > 0 && t > this._maxPayload)
|
|
1270
|
-
return this.writeBuffer.slice(0, n);
|
|
1271
|
-
t += 2;
|
|
1272
|
-
}
|
|
1273
|
-
return this.writeBuffer;
|
|
1274
|
-
}
|
|
1275
|
-
/**
|
|
1276
|
-
* Checks whether the heartbeat timer has expired but the socket has not yet been notified.
|
|
1277
|
-
*
|
|
1278
|
-
* Note: this method is private for now because it does not really fit the WebSocket API, but if we put it in the
|
|
1279
|
-
* `write()` method then the message would not be buffered by the Socket.IO client.
|
|
1280
|
-
*
|
|
1281
|
-
* @return {boolean}
|
|
1282
|
-
* @private
|
|
1283
|
-
*/
|
|
1284
|
-
/* private */
|
|
1285
|
-
_hasPingExpired() {
|
|
1286
|
-
if (!this._pingTimeoutTime)
|
|
1287
|
-
return !0;
|
|
1288
|
-
const e = Date.now() > this._pingTimeoutTime;
|
|
1289
|
-
return e && (this._pingTimeoutTime = 0, fe(() => {
|
|
1290
|
-
this._onClose("ping timeout");
|
|
1291
|
-
}, this.setTimeoutFn)), e;
|
|
1292
|
-
}
|
|
1293
|
-
/**
|
|
1294
|
-
* Sends a message.
|
|
1295
|
-
*
|
|
1296
|
-
* @param {String} msg - message.
|
|
1297
|
-
* @param {Object} options.
|
|
1298
|
-
* @param {Function} fn - callback function.
|
|
1299
|
-
* @return {Socket} for chaining.
|
|
1300
|
-
*/
|
|
1301
|
-
write(e, t, n) {
|
|
1302
|
-
return this._sendPacket("message", e, t, n), this;
|
|
1303
|
-
}
|
|
1304
|
-
/**
|
|
1305
|
-
* Sends a message. Alias of {@link Socket#write}.
|
|
1306
|
-
*
|
|
1307
|
-
* @param {String} msg - message.
|
|
1308
|
-
* @param {Object} options.
|
|
1309
|
-
* @param {Function} fn - callback function.
|
|
1310
|
-
* @return {Socket} for chaining.
|
|
1311
|
-
*/
|
|
1312
|
-
send(e, t, n) {
|
|
1313
|
-
return this._sendPacket("message", e, t, n), this;
|
|
1314
|
-
}
|
|
1315
|
-
/**
|
|
1316
|
-
* Sends a packet.
|
|
1317
|
-
*
|
|
1318
|
-
* @param {String} type: packet type.
|
|
1319
|
-
* @param {String} data.
|
|
1320
|
-
* @param {Object} options.
|
|
1321
|
-
* @param {Function} fn - callback function.
|
|
1322
|
-
* @private
|
|
1323
|
-
*/
|
|
1324
|
-
_sendPacket(e, t, n, r) {
|
|
1325
|
-
if (typeof t == "function" && (r = t, t = void 0), typeof n == "function" && (r = n, n = null), this.readyState === "closing" || this.readyState === "closed")
|
|
1326
|
-
return;
|
|
1327
|
-
n = n || {}, n.compress = n.compress !== !1;
|
|
1328
|
-
const i = {
|
|
1329
|
-
type: e,
|
|
1330
|
-
data: t,
|
|
1331
|
-
options: n
|
|
1332
|
-
};
|
|
1333
|
-
this.emitReserved("packetCreate", i), this.writeBuffer.push(i), r && this.once("flush", r), this.flush();
|
|
1334
|
-
}
|
|
1335
|
-
/**
|
|
1336
|
-
* Closes the connection.
|
|
1337
|
-
*/
|
|
1338
|
-
close() {
|
|
1339
|
-
const e = () => {
|
|
1340
|
-
this._onClose("forced close"), this.transport.close();
|
|
1341
|
-
}, t = () => {
|
|
1342
|
-
this.off("upgrade", t), this.off("upgradeError", t), e();
|
|
1343
|
-
}, n = () => {
|
|
1344
|
-
this.once("upgrade", t), this.once("upgradeError", t);
|
|
1345
|
-
};
|
|
1346
|
-
return (this.readyState === "opening" || this.readyState === "open") && (this.readyState = "closing", this.writeBuffer.length ? this.once("drain", () => {
|
|
1347
|
-
this.upgrading ? n() : e();
|
|
1348
|
-
}) : this.upgrading ? n() : e()), this;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Called upon transport error
|
|
1352
|
-
*
|
|
1353
|
-
* @private
|
|
1354
|
-
*/
|
|
1355
|
-
_onError(e) {
|
|
1356
|
-
if (M.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1357
|
-
return this.transports.shift(), this._open();
|
|
1358
|
-
this.emitReserved("error", e), this._onClose("transport error", e);
|
|
1359
|
-
}
|
|
1360
|
-
/**
|
|
1361
|
-
* Called upon transport close.
|
|
1362
|
-
*
|
|
1363
|
-
* @private
|
|
1364
|
-
*/
|
|
1365
|
-
_onClose(e, t) {
|
|
1366
|
-
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
1367
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), Re && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1368
|
-
const n = ce.indexOf(this._offlineEventListener);
|
|
1369
|
-
n !== -1 && ce.splice(n, 1);
|
|
1370
|
-
}
|
|
1371
|
-
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1372
|
-
}
|
|
1373
|
-
}
|
|
1374
|
-
}
|
|
1375
|
-
M.protocol = ft;
|
|
1376
|
-
class ws extends M {
|
|
1377
|
-
constructor() {
|
|
1378
|
-
super(...arguments), this._upgrades = [];
|
|
1379
|
-
}
|
|
1380
|
-
onOpen() {
|
|
1381
|
-
if (super.onOpen(), this.readyState === "open" && this.opts.upgrade)
|
|
1382
|
-
for (let e = 0; e < this._upgrades.length; e++)
|
|
1383
|
-
this._probe(this._upgrades[e]);
|
|
1384
|
-
}
|
|
1385
|
-
/**
|
|
1386
|
-
* Probes a transport.
|
|
1387
|
-
*
|
|
1388
|
-
* @param {String} name - transport name
|
|
1389
|
-
* @private
|
|
1390
|
-
*/
|
|
1391
|
-
_probe(e) {
|
|
1392
|
-
let t = this.createTransport(e), n = !1;
|
|
1393
|
-
M.priorWebsocketSuccess = !1;
|
|
1394
|
-
const r = () => {
|
|
1395
|
-
n || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (g) => {
|
|
1396
|
-
if (!n)
|
|
1397
|
-
if (g.type === "pong" && g.data === "probe") {
|
|
1398
|
-
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
|
|
1399
|
-
return;
|
|
1400
|
-
M.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1401
|
-
n || this.readyState !== "closed" && (p(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1402
|
-
});
|
|
1403
|
-
} else {
|
|
1404
|
-
const w = new Error("probe error");
|
|
1405
|
-
w.transport = t.name, this.emitReserved("upgradeError", w);
|
|
1406
|
-
}
|
|
1407
|
-
}));
|
|
1408
|
-
};
|
|
1409
|
-
function i() {
|
|
1410
|
-
n || (n = !0, p(), t.close(), t = null);
|
|
1411
|
-
}
|
|
1412
|
-
const c = (g) => {
|
|
1413
|
-
const w = new Error("probe error: " + g);
|
|
1414
|
-
w.transport = t.name, i(), this.emitReserved("upgradeError", w);
|
|
1415
|
-
};
|
|
1416
|
-
function l() {
|
|
1417
|
-
c("transport closed");
|
|
1418
|
-
}
|
|
1419
|
-
function h() {
|
|
1420
|
-
c("socket closed");
|
|
1421
|
-
}
|
|
1422
|
-
function f(g) {
|
|
1423
|
-
t && g.name !== t.name && i();
|
|
1424
|
-
}
|
|
1425
|
-
const p = () => {
|
|
1426
|
-
t.removeListener("open", r), t.removeListener("error", c), t.removeListener("close", l), this.off("close", h), this.off("upgrading", f);
|
|
1427
|
-
};
|
|
1428
|
-
t.once("open", r), t.once("error", c), t.once("close", l), this.once("close", h), this.once("upgrading", f), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1429
|
-
n || t.open();
|
|
1430
|
-
}, 200) : t.open();
|
|
1431
|
-
}
|
|
1432
|
-
onHandshake(e) {
|
|
1433
|
-
this._upgrades = this._filterUpgrades(e.upgrades), super.onHandshake(e);
|
|
1434
|
-
}
|
|
1435
|
-
/**
|
|
1436
|
-
* Filters upgrades, returning only those matching client transports.
|
|
1437
|
-
*
|
|
1438
|
-
* @param {Array} upgrades - server upgrades
|
|
1439
|
-
* @private
|
|
1440
|
-
*/
|
|
1441
|
-
_filterUpgrades(e) {
|
|
1442
|
-
const t = [];
|
|
1443
|
-
for (let n = 0; n < e.length; n++)
|
|
1444
|
-
~this.transports.indexOf(e[n]) && t.push(e[n]);
|
|
1445
|
-
return t;
|
|
1446
|
-
}
|
|
1447
|
-
}
|
|
1448
|
-
let bs = class extends ws {
|
|
1449
|
-
constructor(e, t = {}) {
|
|
1450
|
-
const n = typeof e == "object" ? e : t;
|
|
1451
|
-
(!n.transports || n.transports && typeof n.transports[0] == "string") && (n.transports = (n.transports || ["polling", "websocket", "webtransport"]).map((r) => gs[r]).filter((r) => !!r)), super(e, n);
|
|
1452
|
-
}
|
|
1453
|
-
};
|
|
1454
|
-
function Es(s, e = "", t) {
|
|
1455
|
-
let n = s;
|
|
1456
|
-
t = t || typeof location < "u" && location, s == null && (s = t.protocol + "//" + t.host), typeof s == "string" && (s.charAt(0) === "/" && (s.charAt(1) === "/" ? s = t.protocol + s : s = t.host + s), /^(https?|wss?):\/\//.test(s) || (typeof t < "u" ? s = t.protocol + "//" + s : s = "https://" + s), n = xe(s)), n.port || (/^(http|ws)$/.test(n.protocol) ? n.port = "80" : /^(http|ws)s$/.test(n.protocol) && (n.port = "443")), n.path = n.path || "/";
|
|
1457
|
-
const i = n.host.indexOf(":") !== -1 ? "[" + n.host + "]" : n.host;
|
|
1458
|
-
return n.id = n.protocol + "://" + i + ":" + n.port + e, n.href = n.protocol + "://" + i + (t && t.port === n.port ? "" : ":" + n.port), n;
|
|
1459
|
-
}
|
|
1460
|
-
const ks = typeof ArrayBuffer == "function", Ss = (s) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(s) : s.buffer instanceof ArrayBuffer, vt = Object.prototype.toString, Cs = typeof Blob == "function" || typeof Blob < "u" && vt.call(Blob) === "[object BlobConstructor]", Ns = typeof File == "function" || typeof File < "u" && vt.call(File) === "[object FileConstructor]";
|
|
1461
|
-
function qe(s) {
|
|
1462
|
-
return ks && (s instanceof ArrayBuffer || Ss(s)) || Cs && s instanceof Blob || Ns && s instanceof File;
|
|
1463
|
-
}
|
|
1464
|
-
function le(s, e) {
|
|
1465
|
-
if (!s || typeof s != "object")
|
|
1466
|
-
return !1;
|
|
1467
|
-
if (Array.isArray(s)) {
|
|
1468
|
-
for (let t = 0, n = s.length; t < n; t++)
|
|
1469
|
-
if (le(s[t]))
|
|
1470
|
-
return !0;
|
|
1471
|
-
return !1;
|
|
1472
|
-
}
|
|
1473
|
-
if (qe(s))
|
|
1474
|
-
return !0;
|
|
1475
|
-
if (s.toJSON && typeof s.toJSON == "function" && arguments.length === 1)
|
|
1476
|
-
return le(s.toJSON(), !0);
|
|
1477
|
-
for (const t in s)
|
|
1478
|
-
if (Object.prototype.hasOwnProperty.call(s, t) && le(s[t]))
|
|
1479
|
-
return !0;
|
|
1480
|
-
return !1;
|
|
1481
|
-
}
|
|
1482
|
-
function Os(s) {
|
|
1483
|
-
const e = [], t = s.data, n = s;
|
|
1484
|
-
return n.data = Ae(t, e), n.attachments = e.length, { packet: n, buffers: e };
|
|
1485
|
-
}
|
|
1486
|
-
function Ae(s, e) {
|
|
1487
|
-
if (!s)
|
|
1488
|
-
return s;
|
|
1489
|
-
if (qe(s)) {
|
|
1490
|
-
const t = { _placeholder: !0, num: e.length };
|
|
1491
|
-
return e.push(s), t;
|
|
1492
|
-
} else if (Array.isArray(s)) {
|
|
1493
|
-
const t = new Array(s.length);
|
|
1494
|
-
for (let n = 0; n < s.length; n++)
|
|
1495
|
-
t[n] = Ae(s[n], e);
|
|
1496
|
-
return t;
|
|
1497
|
-
} else if (typeof s == "object" && !(s instanceof Date)) {
|
|
1498
|
-
const t = {};
|
|
1499
|
-
for (const n in s)
|
|
1500
|
-
Object.prototype.hasOwnProperty.call(s, n) && (t[n] = Ae(s[n], e));
|
|
1501
|
-
return t;
|
|
1502
|
-
}
|
|
1503
|
-
return s;
|
|
1504
|
-
}
|
|
1505
|
-
function Ts(s, e) {
|
|
1506
|
-
return s.data = Be(s.data, e), delete s.attachments, s;
|
|
1507
|
-
}
|
|
1508
|
-
function Be(s, e) {
|
|
1509
|
-
if (!s)
|
|
1510
|
-
return s;
|
|
1511
|
-
if (s && s._placeholder === !0) {
|
|
1512
|
-
if (typeof s.num == "number" && s.num >= 0 && s.num < e.length)
|
|
1513
|
-
return e[s.num];
|
|
1514
|
-
throw new Error("illegal attachments");
|
|
1515
|
-
} else if (Array.isArray(s))
|
|
1516
|
-
for (let t = 0; t < s.length; t++)
|
|
1517
|
-
s[t] = Be(s[t], e);
|
|
1518
|
-
else if (typeof s == "object")
|
|
1519
|
-
for (const t in s)
|
|
1520
|
-
Object.prototype.hasOwnProperty.call(s, t) && (s[t] = Be(s[t], e));
|
|
1521
|
-
return s;
|
|
1522
|
-
}
|
|
1523
|
-
const xs = [
|
|
1524
|
-
"connect",
|
|
1525
|
-
// used on the client side
|
|
1526
|
-
"connect_error",
|
|
1527
|
-
// used on the client side
|
|
1528
|
-
"disconnect",
|
|
1529
|
-
// used on both sides
|
|
1530
|
-
"disconnecting",
|
|
1531
|
-
// used on the server side
|
|
1532
|
-
"newListener",
|
|
1533
|
-
// used by the Node.js EventEmitter
|
|
1534
|
-
"removeListener"
|
|
1535
|
-
// used by the Node.js EventEmitter
|
|
1536
|
-
];
|
|
1537
|
-
var v;
|
|
1538
|
-
(function(s) {
|
|
1539
|
-
s[s.CONNECT = 0] = "CONNECT", s[s.DISCONNECT = 1] = "DISCONNECT", s[s.EVENT = 2] = "EVENT", s[s.ACK = 3] = "ACK", s[s.CONNECT_ERROR = 4] = "CONNECT_ERROR", s[s.BINARY_EVENT = 5] = "BINARY_EVENT", s[s.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1540
|
-
})(v || (v = {}));
|
|
1541
|
-
class Rs {
|
|
1542
|
-
/**
|
|
1543
|
-
* Encoder constructor
|
|
1544
|
-
*
|
|
1545
|
-
* @param {function} replacer - custom replacer to pass down to JSON.parse
|
|
1546
|
-
*/
|
|
1547
|
-
constructor(e) {
|
|
1548
|
-
this.replacer = e;
|
|
1549
|
-
}
|
|
1550
|
-
/**
|
|
1551
|
-
* Encode a packet as a single string if non-binary, or as a
|
|
1552
|
-
* buffer sequence, depending on packet type.
|
|
1553
|
-
*
|
|
1554
|
-
* @param {Object} obj - packet object
|
|
1555
|
-
*/
|
|
1556
|
-
encode(e) {
|
|
1557
|
-
return (e.type === v.EVENT || e.type === v.ACK) && le(e) ? this.encodeAsBinary({
|
|
1558
|
-
type: e.type === v.EVENT ? v.BINARY_EVENT : v.BINARY_ACK,
|
|
1559
|
-
nsp: e.nsp,
|
|
1560
|
-
data: e.data,
|
|
1561
|
-
id: e.id
|
|
1562
|
-
}) : [this.encodeAsString(e)];
|
|
1563
|
-
}
|
|
1564
|
-
/**
|
|
1565
|
-
* Encode packet as string.
|
|
1566
|
-
*/
|
|
1567
|
-
encodeAsString(e) {
|
|
1568
|
-
let t = "" + e.type;
|
|
1569
|
-
return (e.type === v.BINARY_EVENT || e.type === v.BINARY_ACK) && (t += e.attachments + "-"), e.nsp && e.nsp !== "/" && (t += e.nsp + ","), e.id != null && (t += e.id), e.data != null && (t += JSON.stringify(e.data, this.replacer)), t;
|
|
1570
|
-
}
|
|
1571
|
-
/**
|
|
1572
|
-
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
1573
|
-
* deconstructing packet into object with placeholders and
|
|
1574
|
-
* a list of buffers.
|
|
1575
|
-
*/
|
|
1576
|
-
encodeAsBinary(e) {
|
|
1577
|
-
const t = Os(e), n = this.encodeAsString(t.packet), r = t.buffers;
|
|
1578
|
-
return r.unshift(n), r;
|
|
1579
|
-
}
|
|
1580
|
-
}
|
|
1581
|
-
class $e extends E {
|
|
1582
|
-
/**
|
|
1583
|
-
* Decoder constructor
|
|
1584
|
-
*
|
|
1585
|
-
* @param {function} reviver - custom reviver to pass down to JSON.stringify
|
|
1586
|
-
*/
|
|
1587
|
-
constructor(e) {
|
|
1588
|
-
super(), this.reviver = e;
|
|
1589
|
-
}
|
|
1590
|
-
/**
|
|
1591
|
-
* Decodes an encoded packet string into packet JSON.
|
|
1592
|
-
*
|
|
1593
|
-
* @param {String} obj - encoded packet
|
|
1594
|
-
*/
|
|
1595
|
-
add(e) {
|
|
1596
|
-
let t;
|
|
1597
|
-
if (typeof e == "string") {
|
|
1598
|
-
if (this.reconstructor)
|
|
1599
|
-
throw new Error("got plaintext data when reconstructing a packet");
|
|
1600
|
-
t = this.decodeString(e);
|
|
1601
|
-
const n = t.type === v.BINARY_EVENT;
|
|
1602
|
-
n || t.type === v.BINARY_ACK ? (t.type = n ? v.EVENT : v.ACK, this.reconstructor = new As(t), t.attachments === 0 && super.emitReserved("decoded", t)) : super.emitReserved("decoded", t);
|
|
1603
|
-
} else if (qe(e) || e.base64)
|
|
1604
|
-
if (this.reconstructor)
|
|
1605
|
-
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
1606
|
-
else
|
|
1607
|
-
throw new Error("got binary data when not reconstructing a packet");
|
|
1608
|
-
else
|
|
1609
|
-
throw new Error("Unknown type: " + e);
|
|
1610
|
-
}
|
|
1611
|
-
/**
|
|
1612
|
-
* Decode a packet String (JSON data)
|
|
1613
|
-
*
|
|
1614
|
-
* @param {String} str
|
|
1615
|
-
* @return {Object} packet
|
|
1616
|
-
*/
|
|
1617
|
-
decodeString(e) {
|
|
1618
|
-
let t = 0;
|
|
1619
|
-
const n = {
|
|
1620
|
-
type: Number(e.charAt(0))
|
|
1621
|
-
};
|
|
1622
|
-
if (v[n.type] === void 0)
|
|
1623
|
-
throw new Error("unknown packet type " + n.type);
|
|
1624
|
-
if (n.type === v.BINARY_EVENT || n.type === v.BINARY_ACK) {
|
|
1625
|
-
const i = t + 1;
|
|
1626
|
-
for (; e.charAt(++t) !== "-" && t != e.length; )
|
|
1627
|
-
;
|
|
1628
|
-
const c = e.substring(i, t);
|
|
1629
|
-
if (c != Number(c) || e.charAt(t) !== "-")
|
|
1630
|
-
throw new Error("Illegal attachments");
|
|
1631
|
-
n.attachments = Number(c);
|
|
1632
|
-
}
|
|
1633
|
-
if (e.charAt(t + 1) === "/") {
|
|
1634
|
-
const i = t + 1;
|
|
1635
|
-
for (; ++t && !(e.charAt(t) === "," || t === e.length); )
|
|
1636
|
-
;
|
|
1637
|
-
n.nsp = e.substring(i, t);
|
|
1638
|
-
} else
|
|
1639
|
-
n.nsp = "/";
|
|
1640
|
-
const r = e.charAt(t + 1);
|
|
1641
|
-
if (r !== "" && Number(r) == r) {
|
|
1642
|
-
const i = t + 1;
|
|
1643
|
-
for (; ++t; ) {
|
|
1644
|
-
const c = e.charAt(t);
|
|
1645
|
-
if (c == null || Number(c) != c) {
|
|
1646
|
-
--t;
|
|
1647
|
-
break;
|
|
1648
|
-
}
|
|
1649
|
-
if (t === e.length)
|
|
1650
|
-
break;
|
|
1651
|
-
}
|
|
1652
|
-
n.id = Number(e.substring(i, t + 1));
|
|
1653
|
-
}
|
|
1654
|
-
if (e.charAt(++t)) {
|
|
1655
|
-
const i = this.tryParse(e.substr(t));
|
|
1656
|
-
if ($e.isPayloadValid(n.type, i))
|
|
1657
|
-
n.data = i;
|
|
1658
|
-
else
|
|
1659
|
-
throw new Error("invalid payload");
|
|
1660
|
-
}
|
|
1661
|
-
return n;
|
|
1662
|
-
}
|
|
1663
|
-
tryParse(e) {
|
|
1664
|
-
try {
|
|
1665
|
-
return JSON.parse(e, this.reviver);
|
|
1666
|
-
} catch {
|
|
1667
|
-
return !1;
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
static isPayloadValid(e, t) {
|
|
1671
|
-
switch (e) {
|
|
1672
|
-
case v.CONNECT:
|
|
1673
|
-
return et(t);
|
|
1674
|
-
case v.DISCONNECT:
|
|
1675
|
-
return t === void 0;
|
|
1676
|
-
case v.CONNECT_ERROR:
|
|
1677
|
-
return typeof t == "string" || et(t);
|
|
1678
|
-
case v.EVENT:
|
|
1679
|
-
case v.BINARY_EVENT:
|
|
1680
|
-
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && xs.indexOf(t[0]) === -1);
|
|
1681
|
-
case v.ACK:
|
|
1682
|
-
case v.BINARY_ACK:
|
|
1683
|
-
return Array.isArray(t);
|
|
1684
|
-
}
|
|
1685
|
-
}
|
|
1686
|
-
/**
|
|
1687
|
-
* Deallocates a parser's resources
|
|
1688
|
-
*/
|
|
1689
|
-
destroy() {
|
|
1690
|
-
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1691
|
-
}
|
|
1692
|
-
}
|
|
1693
|
-
class As {
|
|
1694
|
-
constructor(e) {
|
|
1695
|
-
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1696
|
-
}
|
|
1697
|
-
/**
|
|
1698
|
-
* Method to be called when binary data received from connection
|
|
1699
|
-
* after a BINARY_EVENT packet.
|
|
1700
|
-
*
|
|
1701
|
-
* @param {Buffer | ArrayBuffer} binData - the raw binary data received
|
|
1702
|
-
* @return {null | Object} returns null if more binary data is expected or
|
|
1703
|
-
* a reconstructed packet object if all buffers have been received.
|
|
1704
|
-
*/
|
|
1705
|
-
takeBinaryData(e) {
|
|
1706
|
-
if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
|
|
1707
|
-
const t = Ts(this.reconPack, this.buffers);
|
|
1708
|
-
return this.finishedReconstruction(), t;
|
|
1709
|
-
}
|
|
1710
|
-
return null;
|
|
1711
|
-
}
|
|
1712
|
-
/**
|
|
1713
|
-
* Cleans up binary packet reconstruction variables.
|
|
1714
|
-
*/
|
|
1715
|
-
finishedReconstruction() {
|
|
1716
|
-
this.reconPack = null, this.buffers = [];
|
|
1717
|
-
}
|
|
1718
|
-
}
|
|
1719
|
-
function et(s) {
|
|
1720
|
-
return Object.prototype.toString.call(s) === "[object Object]";
|
|
1721
|
-
}
|
|
1722
|
-
const Bs = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1723
|
-
__proto__: null,
|
|
1724
|
-
Decoder: $e,
|
|
1725
|
-
Encoder: Rs,
|
|
1726
|
-
get PacketType() {
|
|
1727
|
-
return v;
|
|
1728
|
-
}
|
|
1729
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
1730
|
-
function P(s, e, t) {
|
|
1731
|
-
return s.on(e, t), function() {
|
|
1732
|
-
s.off(e, t);
|
|
1733
|
-
};
|
|
1734
|
-
}
|
|
1735
|
-
const Ls = Object.freeze({
|
|
1736
|
-
connect: 1,
|
|
1737
|
-
connect_error: 1,
|
|
1738
|
-
disconnect: 1,
|
|
1739
|
-
disconnecting: 1,
|
|
1740
|
-
// EventEmitter reserved events: https://nodejs.org/api/events.html#events_event_newlistener
|
|
1741
|
-
newListener: 1,
|
|
1742
|
-
removeListener: 1
|
|
1743
|
-
});
|
|
1744
|
-
class _t extends E {
|
|
1745
|
-
/**
|
|
1746
|
-
* `Socket` constructor.
|
|
1747
|
-
*/
|
|
1748
|
-
constructor(e, t, n) {
|
|
1749
|
-
super(), this.connected = !1, this.recovered = !1, this.receiveBuffer = [], this.sendBuffer = [], this._queue = [], this._queueSeq = 0, this.ids = 0, this.acks = {}, this.flags = {}, this.io = e, this.nsp = t, n && n.auth && (this.auth = n.auth), this._opts = Object.assign({}, n), this.io._autoConnect && this.open();
|
|
1750
|
-
}
|
|
1751
|
-
/**
|
|
1752
|
-
* Whether the socket is currently disconnected
|
|
1753
|
-
*
|
|
1754
|
-
* @example
|
|
1755
|
-
* const socket = io();
|
|
1756
|
-
*
|
|
1757
|
-
* socket.on("connect", () => {
|
|
1758
|
-
* console.log(socket.disconnected); // false
|
|
1759
|
-
* });
|
|
1760
|
-
*
|
|
1761
|
-
* socket.on("disconnect", () => {
|
|
1762
|
-
* console.log(socket.disconnected); // true
|
|
1763
|
-
* });
|
|
1764
|
-
*/
|
|
1765
|
-
get disconnected() {
|
|
1766
|
-
return !this.connected;
|
|
1767
|
-
}
|
|
1768
|
-
/**
|
|
1769
|
-
* Subscribe to open, close and packet events
|
|
1770
|
-
*
|
|
1771
|
-
* @private
|
|
1772
|
-
*/
|
|
1773
|
-
subEvents() {
|
|
1774
|
-
if (this.subs)
|
|
1775
|
-
return;
|
|
1776
|
-
const e = this.io;
|
|
1777
|
-
this.subs = [
|
|
1778
|
-
P(e, "open", this.onopen.bind(this)),
|
|
1779
|
-
P(e, "packet", this.onpacket.bind(this)),
|
|
1780
|
-
P(e, "error", this.onerror.bind(this)),
|
|
1781
|
-
P(e, "close", this.onclose.bind(this))
|
|
1782
|
-
];
|
|
1783
|
-
}
|
|
1784
|
-
/**
|
|
1785
|
-
* Whether the Socket will try to reconnect when its Manager connects or reconnects.
|
|
1786
|
-
*
|
|
1787
|
-
* @example
|
|
1788
|
-
* const socket = io();
|
|
1789
|
-
*
|
|
1790
|
-
* console.log(socket.active); // true
|
|
1791
|
-
*
|
|
1792
|
-
* socket.on("disconnect", (reason) => {
|
|
1793
|
-
* if (reason === "io server disconnect") {
|
|
1794
|
-
* // the disconnection was initiated by the server, you need to manually reconnect
|
|
1795
|
-
* console.log(socket.active); // false
|
|
1796
|
-
* }
|
|
1797
|
-
* // else the socket will automatically try to reconnect
|
|
1798
|
-
* console.log(socket.active); // true
|
|
1799
|
-
* });
|
|
1800
|
-
*/
|
|
1801
|
-
get active() {
|
|
1802
|
-
return !!this.subs;
|
|
1803
|
-
}
|
|
1804
|
-
/**
|
|
1805
|
-
* "Opens" the socket.
|
|
1806
|
-
*
|
|
1807
|
-
* @example
|
|
1808
|
-
* const socket = io({
|
|
1809
|
-
* autoConnect: false
|
|
1810
|
-
* });
|
|
1811
|
-
*
|
|
1812
|
-
* socket.connect();
|
|
1813
|
-
*/
|
|
1814
|
-
connect() {
|
|
1815
|
-
return this.connected ? this : (this.subEvents(), this.io._reconnecting || this.io.open(), this.io._readyState === "open" && this.onopen(), this);
|
|
1816
|
-
}
|
|
1817
|
-
/**
|
|
1818
|
-
* Alias for {@link connect()}.
|
|
1819
|
-
*/
|
|
1820
|
-
open() {
|
|
1821
|
-
return this.connect();
|
|
1822
|
-
}
|
|
1823
|
-
/**
|
|
1824
|
-
* Sends a `message` event.
|
|
1825
|
-
*
|
|
1826
|
-
* This method mimics the WebSocket.send() method.
|
|
1827
|
-
*
|
|
1828
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/send
|
|
1829
|
-
*
|
|
1830
|
-
* @example
|
|
1831
|
-
* socket.send("hello");
|
|
1832
|
-
*
|
|
1833
|
-
* // this is equivalent to
|
|
1834
|
-
* socket.emit("message", "hello");
|
|
1835
|
-
*
|
|
1836
|
-
* @return self
|
|
1837
|
-
*/
|
|
1838
|
-
send(...e) {
|
|
1839
|
-
return e.unshift("message"), this.emit.apply(this, e), this;
|
|
1840
|
-
}
|
|
1841
|
-
/**
|
|
1842
|
-
* Override `emit`.
|
|
1843
|
-
* If the event is in `events`, it's emitted normally.
|
|
1844
|
-
*
|
|
1845
|
-
* @example
|
|
1846
|
-
* socket.emit("hello", "world");
|
|
1847
|
-
*
|
|
1848
|
-
* // all serializable datastructures are supported (no need to call JSON.stringify)
|
|
1849
|
-
* socket.emit("hello", 1, "2", { 3: ["4"], 5: Uint8Array.from([6]) });
|
|
1850
|
-
*
|
|
1851
|
-
* // with an acknowledgement from the server
|
|
1852
|
-
* socket.emit("hello", "world", (val) => {
|
|
1853
|
-
* // ...
|
|
1854
|
-
* });
|
|
1855
|
-
*
|
|
1856
|
-
* @return self
|
|
1857
|
-
*/
|
|
1858
|
-
emit(e, ...t) {
|
|
1859
|
-
var n, r, i;
|
|
1860
|
-
if (Ls.hasOwnProperty(e))
|
|
1861
|
-
throw new Error('"' + e.toString() + '" is a reserved event name');
|
|
1862
|
-
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1863
|
-
return this._addToQueue(t), this;
|
|
1864
|
-
const c = {
|
|
1865
|
-
type: v.EVENT,
|
|
1866
|
-
data: t
|
|
1867
|
-
};
|
|
1868
|
-
if (c.options = {}, c.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
1869
|
-
const p = this.ids++, g = t.pop();
|
|
1870
|
-
this._registerAckCallback(p, g), c.id = p;
|
|
1871
|
-
}
|
|
1872
|
-
const l = (r = (n = this.io.engine) === null || n === void 0 ? void 0 : n.transport) === null || r === void 0 ? void 0 : r.writable, h = this.connected && !(!((i = this.io.engine) === null || i === void 0) && i._hasPingExpired());
|
|
1873
|
-
return this.flags.volatile && !l || (h ? (this.notifyOutgoingListeners(c), this.packet(c)) : this.sendBuffer.push(c)), this.flags = {}, this;
|
|
1874
|
-
}
|
|
1875
|
-
/**
|
|
1876
|
-
* @private
|
|
1877
|
-
*/
|
|
1878
|
-
_registerAckCallback(e, t) {
|
|
1879
|
-
var n;
|
|
1880
|
-
const r = (n = this.flags.timeout) !== null && n !== void 0 ? n : this._opts.ackTimeout;
|
|
1881
|
-
if (r === void 0) {
|
|
1882
|
-
this.acks[e] = t;
|
|
1883
|
-
return;
|
|
1884
|
-
}
|
|
1885
|
-
const i = this.io.setTimeoutFn(() => {
|
|
1886
|
-
delete this.acks[e];
|
|
1887
|
-
for (let l = 0; l < this.sendBuffer.length; l++)
|
|
1888
|
-
this.sendBuffer[l].id === e && this.sendBuffer.splice(l, 1);
|
|
1889
|
-
t.call(this, new Error("operation has timed out"));
|
|
1890
|
-
}, r), c = (...l) => {
|
|
1891
|
-
this.io.clearTimeoutFn(i), t.apply(this, l);
|
|
1892
|
-
};
|
|
1893
|
-
c.withError = !0, this.acks[e] = c;
|
|
1894
|
-
}
|
|
1895
|
-
/**
|
|
1896
|
-
* Emits an event and waits for an acknowledgement
|
|
1897
|
-
*
|
|
1898
|
-
* @example
|
|
1899
|
-
* // without timeout
|
|
1900
|
-
* const response = await socket.emitWithAck("hello", "world");
|
|
1901
|
-
*
|
|
1902
|
-
* // with a specific timeout
|
|
1903
|
-
* try {
|
|
1904
|
-
* const response = await socket.timeout(1000).emitWithAck("hello", "world");
|
|
1905
|
-
* } catch (err) {
|
|
1906
|
-
* // the server did not acknowledge the event in the given delay
|
|
1907
|
-
* }
|
|
1908
|
-
*
|
|
1909
|
-
* @return a Promise that will be fulfilled when the server acknowledges the event
|
|
1910
|
-
*/
|
|
1911
|
-
emitWithAck(e, ...t) {
|
|
1912
|
-
return new Promise((n, r) => {
|
|
1913
|
-
const i = (c, l) => c ? r(c) : n(l);
|
|
1914
|
-
i.withError = !0, t.push(i), this.emit(e, ...t);
|
|
1915
|
-
});
|
|
1916
|
-
}
|
|
1917
|
-
/**
|
|
1918
|
-
* Add the packet to the queue.
|
|
1919
|
-
* @param args
|
|
1920
|
-
* @private
|
|
1921
|
-
*/
|
|
1922
|
-
_addToQueue(e) {
|
|
1923
|
-
let t;
|
|
1924
|
-
typeof e[e.length - 1] == "function" && (t = e.pop());
|
|
1925
|
-
const n = {
|
|
1926
|
-
id: this._queueSeq++,
|
|
1927
|
-
tryCount: 0,
|
|
1928
|
-
pending: !1,
|
|
1929
|
-
args: e,
|
|
1930
|
-
flags: Object.assign({ fromQueue: !0 }, this.flags)
|
|
1931
|
-
};
|
|
1932
|
-
e.push((r, ...i) => (this._queue[0], r !== null ? n.tryCount > this._opts.retries && (this._queue.shift(), t && t(r)) : (this._queue.shift(), t && t(null, ...i)), n.pending = !1, this._drainQueue())), this._queue.push(n), this._drainQueue();
|
|
1933
|
-
}
|
|
1934
|
-
/**
|
|
1935
|
-
* Send the first packet of the queue, and wait for an acknowledgement from the server.
|
|
1936
|
-
* @param force - whether to resend a packet that has not been acknowledged yet
|
|
1937
|
-
*
|
|
1938
|
-
* @private
|
|
1939
|
-
*/
|
|
1940
|
-
_drainQueue(e = !1) {
|
|
1941
|
-
if (!this.connected || this._queue.length === 0)
|
|
1942
|
-
return;
|
|
1943
|
-
const t = this._queue[0];
|
|
1944
|
-
t.pending && !e || (t.pending = !0, t.tryCount++, this.flags = t.flags, this.emit.apply(this, t.args));
|
|
1945
|
-
}
|
|
1946
|
-
/**
|
|
1947
|
-
* Sends a packet.
|
|
1948
|
-
*
|
|
1949
|
-
* @param packet
|
|
1950
|
-
* @private
|
|
1951
|
-
*/
|
|
1952
|
-
packet(e) {
|
|
1953
|
-
e.nsp = this.nsp, this.io._packet(e);
|
|
1954
|
-
}
|
|
1955
|
-
/**
|
|
1956
|
-
* Called upon engine `open`.
|
|
1957
|
-
*
|
|
1958
|
-
* @private
|
|
1959
|
-
*/
|
|
1960
|
-
onopen() {
|
|
1961
|
-
typeof this.auth == "function" ? this.auth((e) => {
|
|
1962
|
-
this._sendConnectPacket(e);
|
|
1963
|
-
}) : this._sendConnectPacket(this.auth);
|
|
1964
|
-
}
|
|
1965
|
-
/**
|
|
1966
|
-
* Sends a CONNECT packet to initiate the Socket.IO session.
|
|
1967
|
-
*
|
|
1968
|
-
* @param data
|
|
1969
|
-
* @private
|
|
1970
|
-
*/
|
|
1971
|
-
_sendConnectPacket(e) {
|
|
1972
|
-
this.packet({
|
|
1973
|
-
type: v.CONNECT,
|
|
1974
|
-
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
|
|
1975
|
-
});
|
|
1976
|
-
}
|
|
1977
|
-
/**
|
|
1978
|
-
* Called upon engine or manager `error`.
|
|
1979
|
-
*
|
|
1980
|
-
* @param err
|
|
1981
|
-
* @private
|
|
1982
|
-
*/
|
|
1983
|
-
onerror(e) {
|
|
1984
|
-
this.connected || this.emitReserved("connect_error", e);
|
|
1985
|
-
}
|
|
1986
|
-
/**
|
|
1987
|
-
* Called upon engine `close`.
|
|
1988
|
-
*
|
|
1989
|
-
* @param reason
|
|
1990
|
-
* @param description
|
|
1991
|
-
* @private
|
|
1992
|
-
*/
|
|
1993
|
-
onclose(e, t) {
|
|
1994
|
-
this.connected = !1, delete this.id, this.emitReserved("disconnect", e, t), this._clearAcks();
|
|
1995
|
-
}
|
|
1996
|
-
/**
|
|
1997
|
-
* Clears the acknowledgement handlers upon disconnection, since the client will never receive an acknowledgement from
|
|
1998
|
-
* the server.
|
|
1999
|
-
*
|
|
2000
|
-
* @private
|
|
2001
|
-
*/
|
|
2002
|
-
_clearAcks() {
|
|
2003
|
-
Object.keys(this.acks).forEach((e) => {
|
|
2004
|
-
if (!this.sendBuffer.some((n) => String(n.id) === e)) {
|
|
2005
|
-
const n = this.acks[e];
|
|
2006
|
-
delete this.acks[e], n.withError && n.call(this, new Error("socket has been disconnected"));
|
|
2007
|
-
}
|
|
2008
|
-
});
|
|
2009
|
-
}
|
|
2010
|
-
/**
|
|
2011
|
-
* Called with socket packet.
|
|
2012
|
-
*
|
|
2013
|
-
* @param packet
|
|
2014
|
-
* @private
|
|
2015
|
-
*/
|
|
2016
|
-
onpacket(e) {
|
|
2017
|
-
if (e.nsp === this.nsp)
|
|
2018
|
-
switch (e.type) {
|
|
2019
|
-
case v.CONNECT:
|
|
2020
|
-
e.data && e.data.sid ? this.onconnect(e.data.sid, e.data.pid) : this.emitReserved("connect_error", new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));
|
|
2021
|
-
break;
|
|
2022
|
-
case v.EVENT:
|
|
2023
|
-
case v.BINARY_EVENT:
|
|
2024
|
-
this.onevent(e);
|
|
2025
|
-
break;
|
|
2026
|
-
case v.ACK:
|
|
2027
|
-
case v.BINARY_ACK:
|
|
2028
|
-
this.onack(e);
|
|
2029
|
-
break;
|
|
2030
|
-
case v.DISCONNECT:
|
|
2031
|
-
this.ondisconnect();
|
|
2032
|
-
break;
|
|
2033
|
-
case v.CONNECT_ERROR:
|
|
2034
|
-
this.destroy();
|
|
2035
|
-
const n = new Error(e.data.message);
|
|
2036
|
-
n.data = e.data.data, this.emitReserved("connect_error", n);
|
|
2037
|
-
break;
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
/**
|
|
2041
|
-
* Called upon a server event.
|
|
2042
|
-
*
|
|
2043
|
-
* @param packet
|
|
2044
|
-
* @private
|
|
2045
|
-
*/
|
|
2046
|
-
onevent(e) {
|
|
2047
|
-
const t = e.data || [];
|
|
2048
|
-
e.id != null && t.push(this.ack(e.id)), this.connected ? this.emitEvent(t) : this.receiveBuffer.push(Object.freeze(t));
|
|
2049
|
-
}
|
|
2050
|
-
emitEvent(e) {
|
|
2051
|
-
if (this._anyListeners && this._anyListeners.length) {
|
|
2052
|
-
const t = this._anyListeners.slice();
|
|
2053
|
-
for (const n of t)
|
|
2054
|
-
n.apply(this, e);
|
|
2055
|
-
}
|
|
2056
|
-
super.emit.apply(this, e), this._pid && e.length && typeof e[e.length - 1] == "string" && (this._lastOffset = e[e.length - 1]);
|
|
2057
|
-
}
|
|
2058
|
-
/**
|
|
2059
|
-
* Produces an ack callback to emit with an event.
|
|
2060
|
-
*
|
|
2061
|
-
* @private
|
|
2062
|
-
*/
|
|
2063
|
-
ack(e) {
|
|
2064
|
-
const t = this;
|
|
2065
|
-
let n = !1;
|
|
2066
|
-
return function(...r) {
|
|
2067
|
-
n || (n = !0, t.packet({
|
|
2068
|
-
type: v.ACK,
|
|
2069
|
-
id: e,
|
|
2070
|
-
data: r
|
|
2071
|
-
}));
|
|
2072
|
-
};
|
|
2073
|
-
}
|
|
2074
|
-
/**
|
|
2075
|
-
* Called upon a server acknowledgement.
|
|
2076
|
-
*
|
|
2077
|
-
* @param packet
|
|
2078
|
-
* @private
|
|
2079
|
-
*/
|
|
2080
|
-
onack(e) {
|
|
2081
|
-
const t = this.acks[e.id];
|
|
2082
|
-
typeof t == "function" && (delete this.acks[e.id], t.withError && e.data.unshift(null), t.apply(this, e.data));
|
|
2083
|
-
}
|
|
2084
|
-
/**
|
|
2085
|
-
* Called upon server connect.
|
|
2086
|
-
*
|
|
2087
|
-
* @private
|
|
2088
|
-
*/
|
|
2089
|
-
onconnect(e, t) {
|
|
2090
|
-
this.id = e, this.recovered = t && this._pid === t, this._pid = t, this.connected = !0, this.emitBuffered(), this._drainQueue(!0), this.emitReserved("connect");
|
|
2091
|
-
}
|
|
2092
|
-
/**
|
|
2093
|
-
* Emit buffered events (received and emitted).
|
|
2094
|
-
*
|
|
2095
|
-
* @private
|
|
2096
|
-
*/
|
|
2097
|
-
emitBuffered() {
|
|
2098
|
-
this.receiveBuffer.forEach((e) => this.emitEvent(e)), this.receiveBuffer = [], this.sendBuffer.forEach((e) => {
|
|
2099
|
-
this.notifyOutgoingListeners(e), this.packet(e);
|
|
2100
|
-
}), this.sendBuffer = [];
|
|
2101
|
-
}
|
|
2102
|
-
/**
|
|
2103
|
-
* Called upon server disconnect.
|
|
2104
|
-
*
|
|
2105
|
-
* @private
|
|
2106
|
-
*/
|
|
2107
|
-
ondisconnect() {
|
|
2108
|
-
this.destroy(), this.onclose("io server disconnect");
|
|
2109
|
-
}
|
|
2110
|
-
/**
|
|
2111
|
-
* Called upon forced client/server side disconnections,
|
|
2112
|
-
* this method ensures the manager stops tracking us and
|
|
2113
|
-
* that reconnections don't get triggered for this.
|
|
2114
|
-
*
|
|
2115
|
-
* @private
|
|
2116
|
-
*/
|
|
2117
|
-
destroy() {
|
|
2118
|
-
this.subs && (this.subs.forEach((e) => e()), this.subs = void 0), this.io._destroy(this);
|
|
2119
|
-
}
|
|
2120
|
-
/**
|
|
2121
|
-
* Disconnects the socket manually. In that case, the socket will not try to reconnect.
|
|
2122
|
-
*
|
|
2123
|
-
* If this is the last active Socket instance of the {@link Manager}, the low-level connection will be closed.
|
|
2124
|
-
*
|
|
2125
|
-
* @example
|
|
2126
|
-
* const socket = io();
|
|
2127
|
-
*
|
|
2128
|
-
* socket.on("disconnect", (reason) => {
|
|
2129
|
-
* // console.log(reason); prints "io client disconnect"
|
|
2130
|
-
* });
|
|
2131
|
-
*
|
|
2132
|
-
* socket.disconnect();
|
|
2133
|
-
*
|
|
2134
|
-
* @return self
|
|
2135
|
-
*/
|
|
2136
|
-
disconnect() {
|
|
2137
|
-
return this.connected && this.packet({ type: v.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
2138
|
-
}
|
|
2139
|
-
/**
|
|
2140
|
-
* Alias for {@link disconnect()}.
|
|
2141
|
-
*
|
|
2142
|
-
* @return self
|
|
2143
|
-
*/
|
|
2144
|
-
close() {
|
|
2145
|
-
return this.disconnect();
|
|
2146
|
-
}
|
|
2147
|
-
/**
|
|
2148
|
-
* Sets the compress flag.
|
|
2149
|
-
*
|
|
2150
|
-
* @example
|
|
2151
|
-
* socket.compress(false).emit("hello");
|
|
2152
|
-
*
|
|
2153
|
-
* @param compress - if `true`, compresses the sending data
|
|
2154
|
-
* @return self
|
|
2155
|
-
*/
|
|
2156
|
-
compress(e) {
|
|
2157
|
-
return this.flags.compress = e, this;
|
|
2158
|
-
}
|
|
2159
|
-
/**
|
|
2160
|
-
* Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not
|
|
2161
|
-
* ready to send messages.
|
|
2162
|
-
*
|
|
2163
|
-
* @example
|
|
2164
|
-
* socket.volatile.emit("hello"); // the server may or may not receive it
|
|
2165
|
-
*
|
|
2166
|
-
* @returns self
|
|
2167
|
-
*/
|
|
2168
|
-
get volatile() {
|
|
2169
|
-
return this.flags.volatile = !0, this;
|
|
2170
|
-
}
|
|
2171
|
-
/**
|
|
2172
|
-
* Sets a modifier for a subsequent event emission that the callback will be called with an error when the
|
|
2173
|
-
* given number of milliseconds have elapsed without an acknowledgement from the server:
|
|
2174
|
-
*
|
|
2175
|
-
* @example
|
|
2176
|
-
* socket.timeout(5000).emit("my-event", (err) => {
|
|
2177
|
-
* if (err) {
|
|
2178
|
-
* // the server did not acknowledge the event in the given delay
|
|
2179
|
-
* }
|
|
2180
|
-
* });
|
|
2181
|
-
*
|
|
2182
|
-
* @returns self
|
|
2183
|
-
*/
|
|
2184
|
-
timeout(e) {
|
|
2185
|
-
return this.flags.timeout = e, this;
|
|
2186
|
-
}
|
|
2187
|
-
/**
|
|
2188
|
-
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2189
|
-
* callback.
|
|
2190
|
-
*
|
|
2191
|
-
* @example
|
|
2192
|
-
* socket.onAny((event, ...args) => {
|
|
2193
|
-
* console.log(`got ${event}`);
|
|
2194
|
-
* });
|
|
2195
|
-
*
|
|
2196
|
-
* @param listener
|
|
2197
|
-
*/
|
|
2198
|
-
onAny(e) {
|
|
2199
|
-
return this._anyListeners = this._anyListeners || [], this._anyListeners.push(e), this;
|
|
2200
|
-
}
|
|
2201
|
-
/**
|
|
2202
|
-
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2203
|
-
* callback. The listener is added to the beginning of the listeners array.
|
|
2204
|
-
*
|
|
2205
|
-
* @example
|
|
2206
|
-
* socket.prependAny((event, ...args) => {
|
|
2207
|
-
* console.log(`got event ${event}`);
|
|
2208
|
-
* });
|
|
2209
|
-
*
|
|
2210
|
-
* @param listener
|
|
2211
|
-
*/
|
|
2212
|
-
prependAny(e) {
|
|
2213
|
-
return this._anyListeners = this._anyListeners || [], this._anyListeners.unshift(e), this;
|
|
2214
|
-
}
|
|
2215
|
-
/**
|
|
2216
|
-
* Removes the listener that will be fired when any event is emitted.
|
|
2217
|
-
*
|
|
2218
|
-
* @example
|
|
2219
|
-
* const catchAllListener = (event, ...args) => {
|
|
2220
|
-
* console.log(`got event ${event}`);
|
|
2221
|
-
* }
|
|
2222
|
-
*
|
|
2223
|
-
* socket.onAny(catchAllListener);
|
|
2224
|
-
*
|
|
2225
|
-
* // remove a specific listener
|
|
2226
|
-
* socket.offAny(catchAllListener);
|
|
2227
|
-
*
|
|
2228
|
-
* // or remove all listeners
|
|
2229
|
-
* socket.offAny();
|
|
2230
|
-
*
|
|
2231
|
-
* @param listener
|
|
2232
|
-
*/
|
|
2233
|
-
offAny(e) {
|
|
2234
|
-
if (!this._anyListeners)
|
|
2235
|
-
return this;
|
|
2236
|
-
if (e) {
|
|
2237
|
-
const t = this._anyListeners;
|
|
2238
|
-
for (let n = 0; n < t.length; n++)
|
|
2239
|
-
if (e === t[n])
|
|
2240
|
-
return t.splice(n, 1), this;
|
|
2241
|
-
} else
|
|
2242
|
-
this._anyListeners = [];
|
|
2243
|
-
return this;
|
|
2244
|
-
}
|
|
2245
|
-
/**
|
|
2246
|
-
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
2247
|
-
* e.g. to remove listeners.
|
|
2248
|
-
*/
|
|
2249
|
-
listenersAny() {
|
|
2250
|
-
return this._anyListeners || [];
|
|
2251
|
-
}
|
|
2252
|
-
/**
|
|
2253
|
-
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2254
|
-
* callback.
|
|
2255
|
-
*
|
|
2256
|
-
* Note: acknowledgements sent to the server are not included.
|
|
2257
|
-
*
|
|
2258
|
-
* @example
|
|
2259
|
-
* socket.onAnyOutgoing((event, ...args) => {
|
|
2260
|
-
* console.log(`sent event ${event}`);
|
|
2261
|
-
* });
|
|
2262
|
-
*
|
|
2263
|
-
* @param listener
|
|
2264
|
-
*/
|
|
2265
|
-
onAnyOutgoing(e) {
|
|
2266
|
-
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.push(e), this;
|
|
2267
|
-
}
|
|
2268
|
-
/**
|
|
2269
|
-
* Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the
|
|
2270
|
-
* callback. The listener is added to the beginning of the listeners array.
|
|
2271
|
-
*
|
|
2272
|
-
* Note: acknowledgements sent to the server are not included.
|
|
2273
|
-
*
|
|
2274
|
-
* @example
|
|
2275
|
-
* socket.prependAnyOutgoing((event, ...args) => {
|
|
2276
|
-
* console.log(`sent event ${event}`);
|
|
2277
|
-
* });
|
|
2278
|
-
*
|
|
2279
|
-
* @param listener
|
|
2280
|
-
*/
|
|
2281
|
-
prependAnyOutgoing(e) {
|
|
2282
|
-
return this._anyOutgoingListeners = this._anyOutgoingListeners || [], this._anyOutgoingListeners.unshift(e), this;
|
|
2283
|
-
}
|
|
2284
|
-
/**
|
|
2285
|
-
* Removes the listener that will be fired when any event is emitted.
|
|
2286
|
-
*
|
|
2287
|
-
* @example
|
|
2288
|
-
* const catchAllListener = (event, ...args) => {
|
|
2289
|
-
* console.log(`sent event ${event}`);
|
|
2290
|
-
* }
|
|
2291
|
-
*
|
|
2292
|
-
* socket.onAnyOutgoing(catchAllListener);
|
|
2293
|
-
*
|
|
2294
|
-
* // remove a specific listener
|
|
2295
|
-
* socket.offAnyOutgoing(catchAllListener);
|
|
2296
|
-
*
|
|
2297
|
-
* // or remove all listeners
|
|
2298
|
-
* socket.offAnyOutgoing();
|
|
2299
|
-
*
|
|
2300
|
-
* @param [listener] - the catch-all listener (optional)
|
|
2301
|
-
*/
|
|
2302
|
-
offAnyOutgoing(e) {
|
|
2303
|
-
if (!this._anyOutgoingListeners)
|
|
2304
|
-
return this;
|
|
2305
|
-
if (e) {
|
|
2306
|
-
const t = this._anyOutgoingListeners;
|
|
2307
|
-
for (let n = 0; n < t.length; n++)
|
|
2308
|
-
if (e === t[n])
|
|
2309
|
-
return t.splice(n, 1), this;
|
|
2310
|
-
} else
|
|
2311
|
-
this._anyOutgoingListeners = [];
|
|
2312
|
-
return this;
|
|
2313
|
-
}
|
|
2314
|
-
/**
|
|
2315
|
-
* Returns an array of listeners that are listening for any event that is specified. This array can be manipulated,
|
|
2316
|
-
* e.g. to remove listeners.
|
|
2317
|
-
*/
|
|
2318
|
-
listenersAnyOutgoing() {
|
|
2319
|
-
return this._anyOutgoingListeners || [];
|
|
2320
|
-
}
|
|
2321
|
-
/**
|
|
2322
|
-
* Notify the listeners for each packet sent
|
|
2323
|
-
*
|
|
2324
|
-
* @param packet
|
|
2325
|
-
*
|
|
2326
|
-
* @private
|
|
2327
|
-
*/
|
|
2328
|
-
notifyOutgoingListeners(e) {
|
|
2329
|
-
if (this._anyOutgoingListeners && this._anyOutgoingListeners.length) {
|
|
2330
|
-
const t = this._anyOutgoingListeners.slice();
|
|
2331
|
-
for (const n of t)
|
|
2332
|
-
n.apply(this, e.data);
|
|
2333
|
-
}
|
|
2334
|
-
}
|
|
2335
|
-
}
|
|
2336
|
-
function W(s) {
|
|
2337
|
-
s = s || {}, this.ms = s.min || 100, this.max = s.max || 1e4, this.factor = s.factor || 2, this.jitter = s.jitter > 0 && s.jitter <= 1 ? s.jitter : 0, this.attempts = 0;
|
|
2338
|
-
}
|
|
2339
|
-
W.prototype.duration = function() {
|
|
2340
|
-
var s = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2341
|
-
if (this.jitter) {
|
|
2342
|
-
var e = Math.random(), t = Math.floor(e * this.jitter * s);
|
|
2343
|
-
s = (Math.floor(e * 10) & 1) == 0 ? s - t : s + t;
|
|
2344
|
-
}
|
|
2345
|
-
return Math.min(s, this.max) | 0;
|
|
2346
|
-
};
|
|
2347
|
-
W.prototype.reset = function() {
|
|
2348
|
-
this.attempts = 0;
|
|
2349
|
-
};
|
|
2350
|
-
W.prototype.setMin = function(s) {
|
|
2351
|
-
this.ms = s;
|
|
2352
|
-
};
|
|
2353
|
-
W.prototype.setMax = function(s) {
|
|
2354
|
-
this.max = s;
|
|
2355
|
-
};
|
|
2356
|
-
W.prototype.setJitter = function(s) {
|
|
2357
|
-
this.jitter = s;
|
|
2358
|
-
};
|
|
2359
|
-
class Le extends E {
|
|
2360
|
-
constructor(e, t) {
|
|
2361
|
-
var n;
|
|
2362
|
-
super(), this.nsps = {}, this.subs = [], e && typeof e == "object" && (t = e, e = void 0), t = t || {}, t.path = t.path || "/socket.io", this.opts = t, de(this, t), this.reconnection(t.reconnection !== !1), this.reconnectionAttempts(t.reconnectionAttempts || 1 / 0), this.reconnectionDelay(t.reconnectionDelay || 1e3), this.reconnectionDelayMax(t.reconnectionDelayMax || 5e3), this.randomizationFactor((n = t.randomizationFactor) !== null && n !== void 0 ? n : 0.5), this.backoff = new W({
|
|
2363
|
-
min: this.reconnectionDelay(),
|
|
2364
|
-
max: this.reconnectionDelayMax(),
|
|
2365
|
-
jitter: this.randomizationFactor()
|
|
2366
|
-
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2367
|
-
const r = t.parser || Bs;
|
|
2368
|
-
this.encoder = new r.Encoder(), this.decoder = new r.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2369
|
-
}
|
|
2370
|
-
reconnection(e) {
|
|
2371
|
-
return arguments.length ? (this._reconnection = !!e, e || (this.skipReconnect = !0), this) : this._reconnection;
|
|
2372
|
-
}
|
|
2373
|
-
reconnectionAttempts(e) {
|
|
2374
|
-
return e === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = e, this);
|
|
2375
|
-
}
|
|
2376
|
-
reconnectionDelay(e) {
|
|
2377
|
-
var t;
|
|
2378
|
-
return e === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = e, (t = this.backoff) === null || t === void 0 || t.setMin(e), this);
|
|
2379
|
-
}
|
|
2380
|
-
randomizationFactor(e) {
|
|
2381
|
-
var t;
|
|
2382
|
-
return e === void 0 ? this._randomizationFactor : (this._randomizationFactor = e, (t = this.backoff) === null || t === void 0 || t.setJitter(e), this);
|
|
2383
|
-
}
|
|
2384
|
-
reconnectionDelayMax(e) {
|
|
2385
|
-
var t;
|
|
2386
|
-
return e === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = e, (t = this.backoff) === null || t === void 0 || t.setMax(e), this);
|
|
2387
|
-
}
|
|
2388
|
-
timeout(e) {
|
|
2389
|
-
return arguments.length ? (this._timeout = e, this) : this._timeout;
|
|
2390
|
-
}
|
|
2391
|
-
/**
|
|
2392
|
-
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
2393
|
-
* started reconnecting yet
|
|
2394
|
-
*
|
|
2395
|
-
* @private
|
|
2396
|
-
*/
|
|
2397
|
-
maybeReconnectOnOpen() {
|
|
2398
|
-
!this._reconnecting && this._reconnection && this.backoff.attempts === 0 && this.reconnect();
|
|
2399
|
-
}
|
|
2400
|
-
/**
|
|
2401
|
-
* Sets the current transport `socket`.
|
|
2402
|
-
*
|
|
2403
|
-
* @param {Function} fn - optional, callback
|
|
2404
|
-
* @return self
|
|
2405
|
-
* @public
|
|
2406
|
-
*/
|
|
2407
|
-
open(e) {
|
|
2408
|
-
if (~this._readyState.indexOf("open"))
|
|
2409
|
-
return this;
|
|
2410
|
-
this.engine = new bs(this.uri, this.opts);
|
|
2411
|
-
const t = this.engine, n = this;
|
|
2412
|
-
this._readyState = "opening", this.skipReconnect = !1;
|
|
2413
|
-
const r = P(t, "open", function() {
|
|
2414
|
-
n.onopen(), e && e();
|
|
2415
|
-
}), i = (l) => {
|
|
2416
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error", l), e ? e(l) : this.maybeReconnectOnOpen();
|
|
2417
|
-
}, c = P(t, "error", i);
|
|
2418
|
-
if (this._timeout !== !1) {
|
|
2419
|
-
const l = this._timeout, h = this.setTimeoutFn(() => {
|
|
2420
|
-
r(), i(new Error("timeout")), t.close();
|
|
2421
|
-
}, l);
|
|
2422
|
-
this.opts.autoUnref && h.unref(), this.subs.push(() => {
|
|
2423
|
-
this.clearTimeoutFn(h);
|
|
2424
|
-
});
|
|
2425
|
-
}
|
|
2426
|
-
return this.subs.push(r), this.subs.push(c), this;
|
|
2427
|
-
}
|
|
2428
|
-
/**
|
|
2429
|
-
* Alias for open()
|
|
2430
|
-
*
|
|
2431
|
-
* @return self
|
|
2432
|
-
* @public
|
|
2433
|
-
*/
|
|
2434
|
-
connect(e) {
|
|
2435
|
-
return this.open(e);
|
|
2436
|
-
}
|
|
2437
|
-
/**
|
|
2438
|
-
* Called upon transport open.
|
|
2439
|
-
*
|
|
2440
|
-
* @private
|
|
2441
|
-
*/
|
|
2442
|
-
onopen() {
|
|
2443
|
-
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2444
|
-
const e = this.engine;
|
|
2445
|
-
this.subs.push(
|
|
2446
|
-
P(e, "ping", this.onping.bind(this)),
|
|
2447
|
-
P(e, "data", this.ondata.bind(this)),
|
|
2448
|
-
P(e, "error", this.onerror.bind(this)),
|
|
2449
|
-
P(e, "close", this.onclose.bind(this)),
|
|
2450
|
-
// @ts-ignore
|
|
2451
|
-
P(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2452
|
-
);
|
|
2453
|
-
}
|
|
2454
|
-
/**
|
|
2455
|
-
* Called upon a ping.
|
|
2456
|
-
*
|
|
2457
|
-
* @private
|
|
2458
|
-
*/
|
|
2459
|
-
onping() {
|
|
2460
|
-
this.emitReserved("ping");
|
|
2461
|
-
}
|
|
2462
|
-
/**
|
|
2463
|
-
* Called with data.
|
|
2464
|
-
*
|
|
2465
|
-
* @private
|
|
2466
|
-
*/
|
|
2467
|
-
ondata(e) {
|
|
2468
|
-
try {
|
|
2469
|
-
this.decoder.add(e);
|
|
2470
|
-
} catch (t) {
|
|
2471
|
-
this.onclose("parse error", t);
|
|
2472
|
-
}
|
|
2473
|
-
}
|
|
2474
|
-
/**
|
|
2475
|
-
* Called when parser fully decodes a packet.
|
|
2476
|
-
*
|
|
2477
|
-
* @private
|
|
2478
|
-
*/
|
|
2479
|
-
ondecoded(e) {
|
|
2480
|
-
fe(() => {
|
|
2481
|
-
this.emitReserved("packet", e);
|
|
2482
|
-
}, this.setTimeoutFn);
|
|
2483
|
-
}
|
|
2484
|
-
/**
|
|
2485
|
-
* Called upon socket error.
|
|
2486
|
-
*
|
|
2487
|
-
* @private
|
|
2488
|
-
*/
|
|
2489
|
-
onerror(e) {
|
|
2490
|
-
this.emitReserved("error", e);
|
|
2491
|
-
}
|
|
2492
|
-
/**
|
|
2493
|
-
* Creates a new socket for the given `nsp`.
|
|
2494
|
-
*
|
|
2495
|
-
* @return {Socket}
|
|
2496
|
-
* @public
|
|
2497
|
-
*/
|
|
2498
|
-
socket(e, t) {
|
|
2499
|
-
let n = this.nsps[e];
|
|
2500
|
-
return n ? this._autoConnect && !n.active && n.connect() : (n = new _t(this, e, t), this.nsps[e] = n), n;
|
|
2501
|
-
}
|
|
2502
|
-
/**
|
|
2503
|
-
* Called upon a socket close.
|
|
2504
|
-
*
|
|
2505
|
-
* @param socket
|
|
2506
|
-
* @private
|
|
2507
|
-
*/
|
|
2508
|
-
_destroy(e) {
|
|
2509
|
-
const t = Object.keys(this.nsps);
|
|
2510
|
-
for (const n of t)
|
|
2511
|
-
if (this.nsps[n].active)
|
|
2512
|
-
return;
|
|
2513
|
-
this._close();
|
|
2514
|
-
}
|
|
2515
|
-
/**
|
|
2516
|
-
* Writes a packet.
|
|
2517
|
-
*
|
|
2518
|
-
* @param packet
|
|
2519
|
-
* @private
|
|
2520
|
-
*/
|
|
2521
|
-
_packet(e) {
|
|
2522
|
-
const t = this.encoder.encode(e);
|
|
2523
|
-
for (let n = 0; n < t.length; n++)
|
|
2524
|
-
this.engine.write(t[n], e.options);
|
|
2525
|
-
}
|
|
2526
|
-
/**
|
|
2527
|
-
* Clean up transport subscriptions and packet buffer.
|
|
2528
|
-
*
|
|
2529
|
-
* @private
|
|
2530
|
-
*/
|
|
2531
|
-
cleanup() {
|
|
2532
|
-
this.subs.forEach((e) => e()), this.subs.length = 0, this.decoder.destroy();
|
|
2533
|
-
}
|
|
2534
|
-
/**
|
|
2535
|
-
* Close the current socket.
|
|
2536
|
-
*
|
|
2537
|
-
* @private
|
|
2538
|
-
*/
|
|
2539
|
-
_close() {
|
|
2540
|
-
this.skipReconnect = !0, this._reconnecting = !1, this.onclose("forced close");
|
|
2541
|
-
}
|
|
2542
|
-
/**
|
|
2543
|
-
* Alias for close()
|
|
2544
|
-
*
|
|
2545
|
-
* @private
|
|
2546
|
-
*/
|
|
2547
|
-
disconnect() {
|
|
2548
|
-
return this._close();
|
|
2549
|
-
}
|
|
2550
|
-
/**
|
|
2551
|
-
* Called when:
|
|
2552
|
-
*
|
|
2553
|
-
* - the low-level engine is closed
|
|
2554
|
-
* - the parser encountered a badly formatted packet
|
|
2555
|
-
* - all sockets are disconnected
|
|
2556
|
-
*
|
|
2557
|
-
* @private
|
|
2558
|
-
*/
|
|
2559
|
-
onclose(e, t) {
|
|
2560
|
-
var n;
|
|
2561
|
-
this.cleanup(), (n = this.engine) === null || n === void 0 || n.close(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
|
|
2562
|
-
}
|
|
2563
|
-
/**
|
|
2564
|
-
* Attempt a reconnection.
|
|
2565
|
-
*
|
|
2566
|
-
* @private
|
|
2567
|
-
*/
|
|
2568
|
-
reconnect() {
|
|
2569
|
-
if (this._reconnecting || this.skipReconnect)
|
|
2570
|
-
return this;
|
|
2571
|
-
const e = this;
|
|
2572
|
-
if (this.backoff.attempts >= this._reconnectionAttempts)
|
|
2573
|
-
this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
|
|
2574
|
-
else {
|
|
2575
|
-
const t = this.backoff.duration();
|
|
2576
|
-
this._reconnecting = !0;
|
|
2577
|
-
const n = this.setTimeoutFn(() => {
|
|
2578
|
-
e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((r) => {
|
|
2579
|
-
r ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", r)) : e.onreconnect();
|
|
2580
|
-
}));
|
|
2581
|
-
}, t);
|
|
2582
|
-
this.opts.autoUnref && n.unref(), this.subs.push(() => {
|
|
2583
|
-
this.clearTimeoutFn(n);
|
|
2584
|
-
});
|
|
2585
|
-
}
|
|
2586
|
-
}
|
|
2587
|
-
/**
|
|
2588
|
-
* Called upon successful reconnect.
|
|
2589
|
-
*
|
|
2590
|
-
* @private
|
|
2591
|
-
*/
|
|
2592
|
-
onreconnect() {
|
|
2593
|
-
const e = this.backoff.attempts;
|
|
2594
|
-
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
2595
|
-
}
|
|
2596
|
-
}
|
|
2597
|
-
const G = {};
|
|
2598
|
-
function ue(s, e) {
|
|
2599
|
-
typeof s == "object" && (e = s, s = void 0), e = e || {};
|
|
2600
|
-
const t = Es(s, e.path || "/socket.io"), n = t.source, r = t.id, i = t.path, c = G[r] && i in G[r].nsps, l = e.forceNew || e["force new connection"] || e.multiplex === !1 || c;
|
|
2601
|
-
let h;
|
|
2602
|
-
return l ? h = new Le(n, e) : (G[r] || (G[r] = new Le(n, e)), h = G[r]), t.query && !e.query && (e.query = t.queryKey), h.socket(t.path, e);
|
|
2603
|
-
}
|
|
2604
|
-
Object.assign(ue, {
|
|
2605
|
-
Manager: Le,
|
|
2606
|
-
Socket: _t,
|
|
2607
|
-
io: ue,
|
|
2608
|
-
connect: ue
|
|
2609
|
-
});
|
|
2610
|
-
const wt = /* @__PURE__ */ $t("gigSupportChat", () => {
|
|
2611
|
-
const s = b(null), e = b([]), t = b(!1), n = b(!1), r = b(0), i = b(""), c = b([]), l = b(!1), h = b(null), f = b(null), p = (k) => {
|
|
2612
|
-
f.value = k;
|
|
2613
|
-
}, g = () => {
|
|
2614
|
-
var k;
|
|
2615
|
-
(k = s.value) != null && k.connected || !f.value || (s.value = ue(f.value.apiUrl, {
|
|
2616
|
-
path: f.value.path || "/ws",
|
|
1
|
+
import { ref as c, defineComponent as B, computed as Y, openBlock as f, createElementBlock as w, normalizeClass as L, createElementVNode as s, createTextVNode as O, toDisplayString as R, createCommentVNode as $, onMounted as N, onUnmounted as V, normalizeStyle as A, createStaticVNode as P, withModifiers as D, Fragment as j, renderList as F, createBlock as K, withDirectives as q, withKeys as J, vModelText as Q, nextTick as Z, createVNode as _, Transition as ee, withCtx as te, unref as k } from "vue";
|
|
2
|
+
import { defineStore as se } from "pinia";
|
|
3
|
+
import { io as ne } from "socket.io-client";
|
|
4
|
+
const ie = se("gigSupportChat", () => {
|
|
5
|
+
const e = c(null), v = c([]), t = c(!1), g = c(!1), i = c(0), l = c(""), r = c([]), u = c(!1), p = c(null), o = c(null), b = (d) => {
|
|
6
|
+
o.value = d;
|
|
7
|
+
}, I = () => {
|
|
8
|
+
var d;
|
|
9
|
+
(d = e.value) != null && d.connected || !o.value || (e.value = ne(o.value.apiUrl, {
|
|
10
|
+
path: o.value.path || "/ws",
|
|
2617
11
|
transports: ["websocket", "polling"],
|
|
2618
12
|
auth: {
|
|
2619
|
-
apiKey:
|
|
2620
|
-
uuid:
|
|
2621
|
-
metaUser:
|
|
13
|
+
apiKey: o.value.apiKey,
|
|
14
|
+
uuid: o.value.uuid,
|
|
15
|
+
metaUser: o.value.metaUser
|
|
2622
16
|
}
|
|
2623
|
-
}),
|
|
17
|
+
}), e.value.on("connect", () => {
|
|
2624
18
|
console.log("[GigSupportChat] Connected"), t.value = !0;
|
|
2625
|
-
}),
|
|
2626
|
-
console.log("[GigSupportChat] Registered as:",
|
|
2627
|
-
}),
|
|
19
|
+
}), e.value.on("connected", (n) => {
|
|
20
|
+
console.log("[GigSupportChat] Registered as:", n.userId), l.value = n.userId, M();
|
|
21
|
+
}), e.value.on("disconnect", () => {
|
|
2628
22
|
console.log("[GigSupportChat] Disconnected"), t.value = !1;
|
|
2629
|
-
}),
|
|
2630
|
-
|
|
2631
|
-
}),
|
|
2632
|
-
|
|
2633
|
-
}),
|
|
2634
|
-
|
|
2635
|
-
}),
|
|
2636
|
-
console.error("[GigSupportChat] Socket error:",
|
|
23
|
+
}), e.value.on("new_message", (n) => {
|
|
24
|
+
n.status === "SUCCESS" && (v.value.find((m) => m.id === n.message.id) || (v.value.push(n.message), g.value || i.value++));
|
|
25
|
+
}), e.value.on("message_sent", (n) => {
|
|
26
|
+
n.status === "SUCCESS" && (v.value.find((m) => m.id === n.message.id) || v.value.push(n.message));
|
|
27
|
+
}), e.value.on("history", (n) => {
|
|
28
|
+
n.status === "SUCCESS" && (v.value = n.messages);
|
|
29
|
+
}), e.value.on("error", (n) => {
|
|
30
|
+
console.error("[GigSupportChat] Socket error:", n);
|
|
2637
31
|
}));
|
|
2638
|
-
},
|
|
2639
|
-
|
|
2640
|
-
},
|
|
2641
|
-
var
|
|
2642
|
-
!
|
|
2643
|
-
userId:
|
|
2644
|
-
text:
|
|
2645
|
-
replyToMessageId: (
|
|
2646
|
-
metaUser: (
|
|
2647
|
-
}),
|
|
2648
|
-
},
|
|
2649
|
-
!
|
|
2650
|
-
userId:
|
|
32
|
+
}, C = () => {
|
|
33
|
+
e.value && (e.value.disconnect(), e.value = null), t.value = !1, v.value = [], i.value = 0, l.value = "";
|
|
34
|
+
}, S = (d) => {
|
|
35
|
+
var n, m;
|
|
36
|
+
!e.value || !t.value || (e.value.emit("send_message", {
|
|
37
|
+
userId: l.value,
|
|
38
|
+
text: d,
|
|
39
|
+
replyToMessageId: (n = p.value) == null ? void 0 : n.id,
|
|
40
|
+
metaUser: (m = o.value) == null ? void 0 : m.metaUser
|
|
41
|
+
}), p.value = null);
|
|
42
|
+
}, M = () => {
|
|
43
|
+
!e.value || !l.value || e.value.emit("get_history", {
|
|
44
|
+
userId: l.value,
|
|
2651
45
|
limit: 50,
|
|
2652
46
|
offset: 0
|
|
2653
47
|
});
|
|
2654
48
|
};
|
|
2655
49
|
return {
|
|
2656
|
-
messages:
|
|
50
|
+
messages: v,
|
|
2657
51
|
isConnected: t,
|
|
2658
|
-
isWidgetOpen:
|
|
2659
|
-
unreadCount:
|
|
2660
|
-
currentUserId:
|
|
2661
|
-
stickers:
|
|
2662
|
-
isLoadingStickers:
|
|
2663
|
-
replyingToMessage:
|
|
2664
|
-
init:
|
|
2665
|
-
connect:
|
|
2666
|
-
disconnect:
|
|
2667
|
-
sendMessage:
|
|
2668
|
-
sendSticker: (
|
|
2669
|
-
var
|
|
2670
|
-
!
|
|
2671
|
-
userId:
|
|
2672
|
-
stickerId:
|
|
52
|
+
isWidgetOpen: g,
|
|
53
|
+
unreadCount: i,
|
|
54
|
+
currentUserId: l,
|
|
55
|
+
stickers: r,
|
|
56
|
+
isLoadingStickers: u,
|
|
57
|
+
replyingToMessage: p,
|
|
58
|
+
init: b,
|
|
59
|
+
connect: I,
|
|
60
|
+
disconnect: C,
|
|
61
|
+
sendMessage: S,
|
|
62
|
+
sendSticker: (d) => {
|
|
63
|
+
var n, m;
|
|
64
|
+
!e.value || !t.value || (e.value.emit("send_message", {
|
|
65
|
+
userId: l.value,
|
|
66
|
+
stickerId: d,
|
|
2673
67
|
messageType: "sticker",
|
|
2674
|
-
replyToMessageId: (
|
|
2675
|
-
metaUser: (
|
|
2676
|
-
}),
|
|
68
|
+
replyToMessageId: (n = p.value) == null ? void 0 : n.id,
|
|
69
|
+
metaUser: (m = o.value) == null ? void 0 : m.metaUser
|
|
70
|
+
}), p.value = null);
|
|
2677
71
|
},
|
|
2678
72
|
fetchStickers: async () => {
|
|
2679
|
-
var
|
|
2680
|
-
if ((
|
|
2681
|
-
|
|
73
|
+
var d;
|
|
74
|
+
if ((d = o.value) != null && d.apiUrl) {
|
|
75
|
+
u.value = !0;
|
|
2682
76
|
try {
|
|
2683
|
-
const
|
|
77
|
+
const m = await (await fetch(`${o.value.apiUrl}/api/v1.0/stickers?activeOnly=true`, {
|
|
2684
78
|
headers: {
|
|
2685
|
-
"x-api-key":
|
|
79
|
+
"x-api-key": o.value.apiKey || ""
|
|
2686
80
|
}
|
|
2687
81
|
})).json();
|
|
2688
|
-
|
|
2689
|
-
} catch (
|
|
2690
|
-
console.error("[GigSupportChat] Error fetching stickers:",
|
|
82
|
+
m.status === "SUCCESS" && (r.value = m.content);
|
|
83
|
+
} catch (n) {
|
|
84
|
+
console.error("[GigSupportChat] Error fetching stickers:", n);
|
|
2691
85
|
} finally {
|
|
2692
|
-
|
|
86
|
+
u.value = !1;
|
|
2693
87
|
}
|
|
2694
88
|
}
|
|
2695
89
|
},
|
|
2696
90
|
toggleWidget: () => {
|
|
2697
|
-
|
|
91
|
+
g.value = !g.value, g.value && (i.value = 0);
|
|
2698
92
|
},
|
|
2699
|
-
loadHistory:
|
|
2700
|
-
startReply: (
|
|
2701
|
-
|
|
93
|
+
loadHistory: M,
|
|
94
|
+
startReply: (d) => {
|
|
95
|
+
p.value = d;
|
|
2702
96
|
},
|
|
2703
97
|
cancelReply: () => {
|
|
2704
|
-
|
|
98
|
+
p.value = null;
|
|
2705
99
|
}
|
|
2706
100
|
};
|
|
2707
|
-
}),
|
|
101
|
+
}), ae = ["data-message-id"], oe = {
|
|
2708
102
|
key: 0,
|
|
2709
103
|
class: "gig-message-author"
|
|
2710
|
-
},
|
|
104
|
+
}, le = ["src", "alt"], re = ["innerHTML"], ue = { class: "gig-message-time" }, ge = /* @__PURE__ */ B({
|
|
2711
105
|
__name: "ChatMessage",
|
|
2712
106
|
props: {
|
|
2713
107
|
message: {},
|
|
2714
108
|
currentUserId: {}
|
|
2715
109
|
},
|
|
2716
110
|
emits: ["reply", "scroll-to"],
|
|
2717
|
-
setup(
|
|
2718
|
-
const
|
|
2719
|
-
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
return h.replace(f, (p) => `<a href="${p.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'")}" target="_blank" rel="noopener noreferrer">${p}</a>`);
|
|
111
|
+
setup(e) {
|
|
112
|
+
const v = e, t = Y(() => v.message.userId === v.currentUserId), g = (r) => r ? new Date(r).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) : "", i = (r) => {
|
|
113
|
+
const u = r.trim().split(/\s+/);
|
|
114
|
+
return u.length >= 2 ? `${u[0]} ${u[1][0]}.` : r;
|
|
115
|
+
}, l = (r) => {
|
|
116
|
+
if (!r) return "";
|
|
117
|
+
const u = r.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), p = /(https?:\/\/[^\s]+)/g;
|
|
118
|
+
return u.replace(p, (o) => `<a href="${o}" target="_blank" style="color: inherit; text-decoration: underline;">${o}</a>`);
|
|
2726
119
|
};
|
|
2727
|
-
return (
|
|
2728
|
-
class:
|
|
2729
|
-
"data-message-id":
|
|
120
|
+
return (r, u) => (f(), w("div", {
|
|
121
|
+
class: L(["gig-message-row", t.value ? "sent" : "received"]),
|
|
122
|
+
"data-message-id": e.message.id
|
|
2730
123
|
}, [
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
u("span", Is, V(r(s.message.userName || "Support")), 1)
|
|
2734
|
-
])),
|
|
2735
|
-
u("div", {
|
|
2736
|
-
class: Ee(["gig-message-bubble", s.message.messageType === "sticker" ? "is-sticker" : ""])
|
|
124
|
+
s("div", {
|
|
125
|
+
class: L(["gig-message-bubble", { "is-sticker": e.message.messageType === "sticker" }])
|
|
2737
126
|
}, [
|
|
2738
|
-
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
|
|
2743
|
-
u("div", Vs, V(s.message.replyToMessage.userId === s.currentUserId ? "Вы" : r(s.message.replyToMessage.userName || "Support")), 1),
|
|
2744
|
-
u("div", Us, V(s.message.replyToMessage.messageType === "sticker" ? "[Стикер]" : s.message.replyToMessage.text), 1)
|
|
2745
|
-
])) : U("", !0),
|
|
2746
|
-
s.message.messageType === "sticker" && s.message.sticker ? (C(), O("img", {
|
|
127
|
+
t.value ? $("", !0) : (f(), w("div", oe, [
|
|
128
|
+
u[1] || (u[1] = s("div", { class: "gig-author-avatar" }, "GP", -1)),
|
|
129
|
+
O(" " + R(i(e.message.userName || "Support")), 1)
|
|
130
|
+
])),
|
|
131
|
+
e.message.replyToMessageId ? (f(), w("div", {
|
|
2747
132
|
key: 1,
|
|
2748
|
-
|
|
2749
|
-
|
|
2750
|
-
|
|
2751
|
-
|
|
133
|
+
class: "gig-message-reply-preview",
|
|
134
|
+
onClick: u[0] || (u[0] = (p) => r.$emit("scroll-to", e.message.replyToMessageId))
|
|
135
|
+
})) : $("", !0),
|
|
136
|
+
e.message.messageType === "sticker" && e.message.sticker ? (f(), w("img", {
|
|
2752
137
|
key: 2,
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
onClick: l[1] || (l[1] = (h) => c.$emit("reply", s.message))
|
|
2762
|
-
}, [...l[3] || (l[3] = [
|
|
2763
|
-
u("svg", {
|
|
2764
|
-
viewBox: "0 0 24 24",
|
|
2765
|
-
width: "14",
|
|
2766
|
-
height: "14",
|
|
2767
|
-
fill: "none",
|
|
2768
|
-
stroke: "currentColor",
|
|
2769
|
-
"stroke-width": "2"
|
|
2770
|
-
}, [
|
|
2771
|
-
u("polyline", { points: "9 17 4 12 9 7" }),
|
|
2772
|
-
u("path", { d: "M20 18v-2a4 4 0 0 0-4-4H4" })
|
|
2773
|
-
], -1)
|
|
2774
|
-
])])
|
|
138
|
+
src: `data:${e.message.sticker.mimeType || "image/png"};base64,${e.message.sticker.base64}`,
|
|
139
|
+
class: "gig-sticker-img",
|
|
140
|
+
alt: e.message.sticker.name
|
|
141
|
+
}, null, 8, le)) : (f(), w("div", {
|
|
142
|
+
key: 3,
|
|
143
|
+
innerHTML: l(e.message.text || "")
|
|
144
|
+
}, null, 8, re)),
|
|
145
|
+
s("div", ue, R(g(e.message.createdAt)), 1)
|
|
2775
146
|
], 2)
|
|
2776
|
-
], 10,
|
|
147
|
+
], 10, ae));
|
|
2777
148
|
}
|
|
2778
|
-
}),
|
|
2779
|
-
const t =
|
|
2780
|
-
for (const [
|
|
2781
|
-
t[
|
|
149
|
+
}), ce = (e, v) => {
|
|
150
|
+
const t = e.__vccOpts || e;
|
|
151
|
+
for (const [g, i] of v)
|
|
152
|
+
t[g] = i;
|
|
2782
153
|
return t;
|
|
2783
|
-
},
|
|
2784
|
-
key: 0,
|
|
2785
|
-
class: "gig-empty-state"
|
|
2786
|
-
}, Xs = {
|
|
2787
|
-
key: 0,
|
|
2788
|
-
class: "gig-sticker-picker"
|
|
2789
|
-
}, Gs = { class: "gig-picker-header" }, Js = { class: "gig-sticker-grid" }, Qs = {
|
|
154
|
+
}, de = /* @__PURE__ */ ce(ge, [["__scopeId", "data-v-ca90faac"]]), ve = {
|
|
2790
155
|
key: 0,
|
|
2791
|
-
|
|
2792
|
-
},
|
|
2793
|
-
|
|
2794
|
-
|
|
2795
|
-
|
|
156
|
+
style: { "text-align": "center", color: "#94a3b8", "padding-top": "40px" }
|
|
157
|
+
}, me = { class: "gig-input-area" }, pe = { class: "gig-input-box" }, he = ["onKeydown"], fe = ["disabled"], ye = {
|
|
158
|
+
viewBox: "0 0 24 24",
|
|
159
|
+
width: "18",
|
|
160
|
+
height: "18",
|
|
161
|
+
fill: "none",
|
|
162
|
+
stroke: "currentColor",
|
|
163
|
+
"stroke-width": "2",
|
|
164
|
+
style: { transform: "rotate(45deg)", "margin-bottom": "2px" }
|
|
165
|
+
}, we = /* @__PURE__ */ B({
|
|
2796
166
|
__name: "ChatWindow",
|
|
2797
167
|
props: {
|
|
2798
168
|
messages: {},
|
|
2799
|
-
isConnected: { type: Boolean },
|
|
2800
169
|
currentUserId: {}
|
|
2801
170
|
},
|
|
2802
|
-
emits: ["close"],
|
|
2803
|
-
setup(
|
|
2804
|
-
const t =
|
|
2805
|
-
|
|
2806
|
-
}
|
|
2807
|
-
|
|
2808
|
-
|
|
2809
|
-
|
|
2810
|
-
},
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
if (!f.value) return;
|
|
2824
|
-
const o = p.value.x - y.clientX, a = p.value.y - y.clientY;
|
|
2825
|
-
if (f.value === "left" || f.value === "corner") {
|
|
2826
|
-
const m = p.value.w + o;
|
|
2827
|
-
m > 320 && m < 800 && (l.value.width = m);
|
|
171
|
+
emits: ["close", "send"],
|
|
172
|
+
setup(e, { emit: v }) {
|
|
173
|
+
const t = v, g = c(""), i = c(null), l = c(null), r = c({ x: 32, y: 112 }), u = c({ width: 440, height: 600 }), p = c(!1), o = c(null), b = c(!1), I = () => {
|
|
174
|
+
b.value = !b.value;
|
|
175
|
+
};
|
|
176
|
+
let C = 0, S = 0, M = 0, z = 0, U = 0, T = 0;
|
|
177
|
+
const G = (h) => {
|
|
178
|
+
h.button === 0 && (p.value = !0, C = h.clientX, S = h.clientY, U = r.value.x, T = r.value.y, window.addEventListener("mousemove", E), window.addEventListener("mouseup", m));
|
|
179
|
+
}, E = (h) => {
|
|
180
|
+
p.value && (r.value = {
|
|
181
|
+
x: U - (h.clientX - C),
|
|
182
|
+
y: T - (h.clientY - S)
|
|
183
|
+
});
|
|
184
|
+
}, d = (h, a) => {
|
|
185
|
+
h.preventDefault(), o.value = a, C = h.clientX, S = h.clientY, M = u.value.width, z = u.value.height, U = r.value.x, T = r.value.y, window.addEventListener("mousemove", n), window.addEventListener("mouseup", m);
|
|
186
|
+
}, n = (h) => {
|
|
187
|
+
if (!o.value) return;
|
|
188
|
+
const a = C - h.clientX, y = S - h.clientY;
|
|
189
|
+
if (o.value === "left" || o.value === "corner") {
|
|
190
|
+
const x = M + a;
|
|
191
|
+
x > 320 && x < 800 && (u.value.width = x);
|
|
2828
192
|
}
|
|
2829
|
-
if (
|
|
2830
|
-
const
|
|
2831
|
-
|
|
193
|
+
if (o.value === "top" || o.value === "corner") {
|
|
194
|
+
const x = z + y;
|
|
195
|
+
x > 400 && x < 900 && (u.value.height = x);
|
|
2832
196
|
}
|
|
2833
|
-
},
|
|
2834
|
-
|
|
197
|
+
}, m = () => {
|
|
198
|
+
p.value = !1, o.value = null, window.removeEventListener("mousemove", E), window.removeEventListener("mousemove", n);
|
|
199
|
+
}, H = () => {
|
|
200
|
+
g.value.trim() && (t("send", g.value), g.value = "", l.value && (l.value.style.height = "auto"), W());
|
|
201
|
+
}, X = () => {
|
|
202
|
+
l.value && (l.value.style.height = "auto", l.value.style.height = Math.min(l.value.scrollHeight, 120) + "px");
|
|
203
|
+
}, W = async () => {
|
|
204
|
+
await Z(), i.value && (i.value.scrollTop = i.value.scrollHeight);
|
|
2835
205
|
};
|
|
2836
|
-
return
|
|
206
|
+
return N(W), V(m), (h, a) => (f(), w("div", {
|
|
2837
207
|
class: "gig-chat-window",
|
|
2838
|
-
style:
|
|
2839
|
-
width:
|
|
2840
|
-
height:
|
|
2841
|
-
bottom:
|
|
2842
|
-
right:
|
|
2843
|
-
cursor:
|
|
208
|
+
style: A({
|
|
209
|
+
width: u.value.width + "px",
|
|
210
|
+
height: u.value.height + "px",
|
|
211
|
+
bottom: r.value.y + "px",
|
|
212
|
+
right: r.value.x + "px",
|
|
213
|
+
cursor: p.value ? "grabbing" : "auto"
|
|
2844
214
|
})
|
|
2845
215
|
}, [
|
|
2846
|
-
|
|
2847
|
-
class: "gig-
|
|
2848
|
-
onMousedown:
|
|
216
|
+
s("div", {
|
|
217
|
+
class: "gig-resizer gig-resizer-l",
|
|
218
|
+
onMousedown: a[0] || (a[0] = (y) => d(y, "left"))
|
|
2849
219
|
}, null, 32),
|
|
2850
|
-
|
|
2851
|
-
class: "gig-
|
|
2852
|
-
onMousedown:
|
|
220
|
+
s("div", {
|
|
221
|
+
class: "gig-resizer gig-resizer-t",
|
|
222
|
+
onMousedown: a[1] || (a[1] = (y) => d(y, "top"))
|
|
2853
223
|
}, null, 32),
|
|
2854
|
-
|
|
2855
|
-
class: "gig-
|
|
2856
|
-
onMousedown:
|
|
224
|
+
s("div", {
|
|
225
|
+
class: "gig-resizer gig-resizer-tl",
|
|
226
|
+
onMousedown: a[2] || (a[2] = (y) => d(y, "corner"))
|
|
2857
227
|
}, null, 32),
|
|
2858
|
-
|
|
228
|
+
s("div", {
|
|
2859
229
|
class: "gig-chat-header",
|
|
2860
|
-
onMousedown:
|
|
230
|
+
onMousedown: G
|
|
2861
231
|
}, [
|
|
2862
|
-
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
fill: "none",
|
|
2870
|
-
stroke: "currentColor",
|
|
2871
|
-
"stroke-width": "2"
|
|
2872
|
-
}, [
|
|
2873
|
-
u("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
2874
|
-
])
|
|
2875
|
-
], -1)),
|
|
2876
|
-
u("div", null, [
|
|
2877
|
-
o[10] || (o[10] = u("h3", null, "Поддержка", -1)),
|
|
2878
|
-
u("div", js, [
|
|
2879
|
-
o[9] || (o[9] = u("span", { class: "gig-status-pulse" }, null, -1)),
|
|
2880
|
-
u("span", Ks, V(s.isConnected ? "В сети" : "Подключение..."), 1)
|
|
2881
|
-
])
|
|
2882
|
-
])
|
|
2883
|
-
]),
|
|
2884
|
-
u("button", {
|
|
2885
|
-
onClick: o[3] || (o[3] = He((a) => y.$emit("close"), ["stop"])),
|
|
2886
|
-
class: "gig-close-btn"
|
|
2887
|
-
}, [...o[12] || (o[12] = [
|
|
2888
|
-
u("svg", {
|
|
232
|
+
a[6] || (a[6] = P('<div class="gig-header-left"><div class="gig-header-icon"><svg viewBox="0 0 24 24" width="22" height="22" stroke="currentColor" fill="none" stroke-width="2"><path d="M3 18v-6a9 9 0 0 1 18 0v6"></path><path d="M21 19a2 2 0 0 1-2 2h-1a2 2 0 0 1-2-2v-3a2 2 0 0 1 2-2h3zM3 19a2 2 0 0 0 2 2h1a2 2 0 0 0 2-2v-3a2 2 0 0 0-2-2H3z"></path></svg></div><div><h3 class="gig-header-title">Чат поддержки</h3><div class="gig-header-status"><div class="gig-status-dot"></div><span>Мы онлайн!</span></div></div></div>', 1)),
|
|
233
|
+
s("button", {
|
|
234
|
+
class: "gig-btn-icon",
|
|
235
|
+
onClick: a[3] || (a[3] = D((y) => h.$emit("close"), ["stop"])),
|
|
236
|
+
style: { opacity: "0.8" }
|
|
237
|
+
}, [...a[5] || (a[5] = [
|
|
238
|
+
s("svg", {
|
|
2889
239
|
viewBox: "0 0 24 24",
|
|
2890
|
-
width: "
|
|
2891
|
-
height: "
|
|
2892
|
-
fill: "none",
|
|
240
|
+
width: "22",
|
|
241
|
+
height: "22",
|
|
2893
242
|
stroke: "currentColor",
|
|
2894
|
-
|
|
243
|
+
fill: "none",
|
|
244
|
+
"stroke-width": "2.5"
|
|
2895
245
|
}, [
|
|
2896
|
-
|
|
246
|
+
s("line", {
|
|
2897
247
|
x1: "18",
|
|
2898
248
|
y1: "6",
|
|
2899
249
|
x2: "6",
|
|
2900
250
|
y2: "18"
|
|
2901
251
|
}),
|
|
2902
|
-
|
|
252
|
+
s("line", {
|
|
2903
253
|
x1: "6",
|
|
2904
254
|
y1: "6",
|
|
2905
255
|
x2: "18",
|
|
@@ -2908,101 +258,25 @@ const wt = /* @__PURE__ */ $t("gigSupportChat", () => {
|
|
|
2908
258
|
], -1)
|
|
2909
259
|
])])
|
|
2910
260
|
], 32),
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
261
|
+
s("div", {
|
|
262
|
+
ref_key: "messagesArea",
|
|
263
|
+
ref: i,
|
|
264
|
+
class: "gig-messages-area"
|
|
2915
265
|
}, [
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
height: "40",
|
|
2922
|
-
fill: "none",
|
|
2923
|
-
stroke: "currentColor",
|
|
2924
|
-
"stroke-width": "1.5"
|
|
2925
|
-
}, [
|
|
2926
|
-
u("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" })
|
|
2927
|
-
])
|
|
2928
|
-
], -1),
|
|
2929
|
-
u("p", null, "Чем мы можем вам помочь?", -1)
|
|
2930
|
-
])])) : U("", !0),
|
|
2931
|
-
(C(!0), O(We, null, ze(s.messages, (a) => (C(), rt(Ws, {
|
|
2932
|
-
key: a.id,
|
|
2933
|
-
message: a,
|
|
2934
|
-
"current-user-id": s.currentUserId,
|
|
2935
|
-
onReply: o[4] || (o[4] = (m) => N(n).startReply(m)),
|
|
2936
|
-
onScrollTo: ne
|
|
266
|
+
e.messages.length === 0 ? (f(), w("div", ve, " Здесь будет история переписки ")) : $("", !0),
|
|
267
|
+
(f(!0), w(j, null, F(e.messages, (y) => (f(), K(de, {
|
|
268
|
+
key: y.id,
|
|
269
|
+
message: y,
|
|
270
|
+
"current-user-id": e.currentUserId
|
|
2937
271
|
}, null, 8, ["message", "current-user-id"]))), 128))
|
|
2938
272
|
], 512),
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
class: "gig-picker-close"
|
|
2947
|
-
}, "×")
|
|
2948
|
-
]),
|
|
2949
|
-
u("div", Js, [
|
|
2950
|
-
N(n).isLoadingStickers ? (C(), O("div", Qs, "...")) : U("", !0),
|
|
2951
|
-
(C(!0), O(We, null, ze(N(n).stickers, (a) => (C(), O("div", {
|
|
2952
|
-
key: a.id,
|
|
2953
|
-
class: "gig-sticker-item",
|
|
2954
|
-
onClick: (m) => T(a.id)
|
|
2955
|
-
}, [
|
|
2956
|
-
u("img", {
|
|
2957
|
-
src: `data:${a.mimeType || "image/png"};base64,${a.base64}`,
|
|
2958
|
-
alt: a.name
|
|
2959
|
-
}, null, 8, en)
|
|
2960
|
-
], 8, Zs))), 128))
|
|
2961
|
-
])
|
|
2962
|
-
])) : U("", !0)
|
|
2963
|
-
]),
|
|
2964
|
-
_: 1
|
|
2965
|
-
}),
|
|
2966
|
-
ke(Se, { name: "gig-fade" }, {
|
|
2967
|
-
default: Ce(() => [
|
|
2968
|
-
N(n).replyingToMessage ? (C(), O("div", tn, [
|
|
2969
|
-
o[16] || (o[16] = u("div", { class: "gig-reply-line" }, null, -1)),
|
|
2970
|
-
u("div", sn, [
|
|
2971
|
-
u("div", nn, "Ответ " + V(F(N(n).replyingToMessage)), 1),
|
|
2972
|
-
u("div", rn, V(z(N(n).replyingToMessage)), 1)
|
|
2973
|
-
]),
|
|
2974
|
-
u("button", {
|
|
2975
|
-
onClick: o[6] || (o[6] = (a) => N(n).cancelReply()),
|
|
2976
|
-
class: "gig-reply-close"
|
|
2977
|
-
}, "×")
|
|
2978
|
-
])) : U("", !0)
|
|
2979
|
-
]),
|
|
2980
|
-
_: 1
|
|
2981
|
-
}),
|
|
2982
|
-
u("div", on, [
|
|
2983
|
-
u("div", an, [
|
|
2984
|
-
u("button", {
|
|
2985
|
-
class: Ee(["gig-sticker-toggle", { active: g.value }]),
|
|
2986
|
-
onClick: w
|
|
2987
|
-
}, [...o[17] || (o[17] = [
|
|
2988
|
-
Lt('<svg viewBox="0 0 24 24" width="20" height="20" fill="none" stroke="currentColor" stroke-width="2" data-v-4a6ac4c2><circle cx="12" cy="12" r="10" data-v-4a6ac4c2></circle><path d="M8 14s1.5 2 4 2 4-2 4-2" data-v-4a6ac4c2></path><line x1="9" y1="9" x2="9.01" y2="9" data-v-4a6ac4c2></line><line x1="15" y1="9" x2="15.01" y2="9" data-v-4a6ac4c2></line></svg>', 1)
|
|
2989
|
-
])], 2),
|
|
2990
|
-
Pt(u("textarea", {
|
|
2991
|
-
"onUpdate:modelValue": o[7] || (o[7] = (a) => r.value = a),
|
|
2992
|
-
onKeydown: Dt(He(x, ["exact", "prevent"]), ["enter"]),
|
|
2993
|
-
placeholder: "Введите сообщение...",
|
|
2994
|
-
class: "gig-chat-input",
|
|
2995
|
-
rows: "1",
|
|
2996
|
-
onFocus: o[8] || (o[8] = (a) => g.value = !1)
|
|
2997
|
-
}, null, 40, cn), [
|
|
2998
|
-
[It, r.value]
|
|
2999
|
-
]),
|
|
3000
|
-
u("button", {
|
|
3001
|
-
onClick: x,
|
|
3002
|
-
class: "gig-send-btn",
|
|
3003
|
-
disabled: !r.value.trim()
|
|
3004
|
-
}, [...o[18] || (o[18] = [
|
|
3005
|
-
u("svg", {
|
|
273
|
+
s("div", me, [
|
|
274
|
+
s("div", pe, [
|
|
275
|
+
s("div", {
|
|
276
|
+
class: "gig-input-star",
|
|
277
|
+
onClick: I
|
|
278
|
+
}, [...a[7] || (a[7] = [
|
|
279
|
+
s("svg", {
|
|
3006
280
|
viewBox: "0 0 24 24",
|
|
3007
281
|
width: "20",
|
|
3008
282
|
height: "20",
|
|
@@ -3010,26 +284,43 @@ const wt = /* @__PURE__ */ $t("gigSupportChat", () => {
|
|
|
3010
284
|
stroke: "currentColor",
|
|
3011
285
|
"stroke-width": "2"
|
|
3012
286
|
}, [
|
|
3013
|
-
|
|
3014
|
-
x1: "22",
|
|
3015
|
-
y1: "2",
|
|
3016
|
-
x2: "11",
|
|
3017
|
-
y2: "13"
|
|
3018
|
-
}),
|
|
3019
|
-
u("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
|
|
287
|
+
s("polygon", { points: "12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" })
|
|
3020
288
|
], -1)
|
|
3021
|
-
])],
|
|
289
|
+
])]),
|
|
290
|
+
q(s("textarea", {
|
|
291
|
+
ref_key: "textareaRef",
|
|
292
|
+
ref: l,
|
|
293
|
+
"onUpdate:modelValue": a[4] || (a[4] = (y) => g.value = y),
|
|
294
|
+
placeholder: "Напишите сообщение...",
|
|
295
|
+
class: "gig-textarea",
|
|
296
|
+
rows: "1",
|
|
297
|
+
onKeydown: J(D(H, ["exact", "prevent"]), ["enter"]),
|
|
298
|
+
onInput: X
|
|
299
|
+
}, null, 40, he), [
|
|
300
|
+
[Q, g.value]
|
|
301
|
+
]),
|
|
302
|
+
s("button", {
|
|
303
|
+
class: L(["gig-send-btn", { active: g.value.trim() }]),
|
|
304
|
+
disabled: !g.value.trim(),
|
|
305
|
+
onClick: H
|
|
306
|
+
}, [
|
|
307
|
+
(f(), w("svg", ye, [...a[8] || (a[8] = [
|
|
308
|
+
s("path", { d: "M22 2L11 13M22 2l-7 20-4-9-9-4 20-7z" }, null, -1)
|
|
309
|
+
])]))
|
|
310
|
+
], 10, fe)
|
|
3022
311
|
]),
|
|
3023
|
-
|
|
3024
|
-
|
|
312
|
+
a[9] || (a[9] = s("div", { class: "gig-footer" }, [
|
|
313
|
+
s("div", { class: "gig-footer-line" }),
|
|
314
|
+
s("span", { class: "gig-footer-text" }, "Работает на GigSupport"),
|
|
315
|
+
s("div", { class: "gig-footer-line" })
|
|
3025
316
|
], -1))
|
|
3026
317
|
])
|
|
3027
318
|
], 4));
|
|
3028
319
|
}
|
|
3029
|
-
}),
|
|
320
|
+
}), ke = { class: "gig-chat-wrapper" }, xe = {
|
|
3030
321
|
key: 0,
|
|
3031
322
|
class: "gig-chat-badge"
|
|
3032
|
-
},
|
|
323
|
+
}, Ce = {
|
|
3033
324
|
key: 1,
|
|
3034
325
|
viewBox: "0 0 24 24",
|
|
3035
326
|
width: "32",
|
|
@@ -3037,7 +328,7 @@ const wt = /* @__PURE__ */ $t("gigSupportChat", () => {
|
|
|
3037
328
|
fill: "none",
|
|
3038
329
|
stroke: "white",
|
|
3039
330
|
"stroke-width": "2"
|
|
3040
|
-
},
|
|
331
|
+
}, Se = {
|
|
3041
332
|
key: 2,
|
|
3042
333
|
viewBox: "0 0 24 24",
|
|
3043
334
|
width: "32",
|
|
@@ -3045,62 +336,62 @@ const wt = /* @__PURE__ */ $t("gigSupportChat", () => {
|
|
|
3045
336
|
fill: "none",
|
|
3046
337
|
stroke: "white",
|
|
3047
338
|
"stroke-width": "2"
|
|
3048
|
-
},
|
|
339
|
+
}, Me = /* @__PURE__ */ B({
|
|
3049
340
|
__name: "GigSupportChat",
|
|
3050
341
|
props: {
|
|
3051
342
|
config: {}
|
|
3052
343
|
},
|
|
3053
|
-
setup(
|
|
3054
|
-
const
|
|
3055
|
-
return
|
|
3056
|
-
t.init(
|
|
3057
|
-
}),
|
|
344
|
+
setup(e) {
|
|
345
|
+
const v = e, t = ie();
|
|
346
|
+
return N(() => {
|
|
347
|
+
t.init(v.config), t.connect();
|
|
348
|
+
}), V(() => {
|
|
3058
349
|
t.disconnect();
|
|
3059
|
-
}), (
|
|
3060
|
-
|
|
3061
|
-
default:
|
|
3062
|
-
|
|
350
|
+
}), (g, i) => (f(), w("div", ke, [
|
|
351
|
+
_(ee, { name: "gig-fade" }, {
|
|
352
|
+
default: te(() => [
|
|
353
|
+
k(t).isWidgetOpen ? (f(), K(we, {
|
|
3063
354
|
key: 0,
|
|
3064
|
-
messages:
|
|
3065
|
-
"is-connected":
|
|
3066
|
-
"current-user-id":
|
|
3067
|
-
onSend:
|
|
3068
|
-
onClose:
|
|
3069
|
-
}, null, 8, ["messages", "is-connected", "current-user-id"])) :
|
|
355
|
+
messages: k(t).messages,
|
|
356
|
+
"is-connected": k(t).isConnected,
|
|
357
|
+
"current-user-id": k(t).currentUserId,
|
|
358
|
+
onSend: i[0] || (i[0] = (l) => k(t).sendMessage(l)),
|
|
359
|
+
onClose: i[1] || (i[1] = (l) => k(t).toggleWidget())
|
|
360
|
+
}, null, 8, ["messages", "is-connected", "current-user-id"])) : $("", !0)
|
|
3070
361
|
]),
|
|
3071
362
|
_: 1
|
|
3072
363
|
}),
|
|
3073
|
-
|
|
364
|
+
s("button", {
|
|
3074
365
|
class: "gig-chat-trigger",
|
|
3075
|
-
onClick:
|
|
366
|
+
onClick: i[2] || (i[2] = (l) => k(t).toggleWidget())
|
|
3076
367
|
}, [
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
368
|
+
k(t).unreadCount > 0 ? (f(), w("div", xe, R(k(t).unreadCount), 1)) : $("", !0),
|
|
369
|
+
k(t).isWidgetOpen ? (f(), w("svg", Se, [...i[4] || (i[4] = [
|
|
370
|
+
s("line", {
|
|
3080
371
|
x1: "18",
|
|
3081
372
|
y1: "6",
|
|
3082
373
|
x2: "6",
|
|
3083
374
|
y2: "18"
|
|
3084
375
|
}, null, -1),
|
|
3085
|
-
|
|
376
|
+
s("line", {
|
|
3086
377
|
x1: "6",
|
|
3087
378
|
y1: "6",
|
|
3088
379
|
x2: "18",
|
|
3089
380
|
y2: "18"
|
|
3090
381
|
}, null, -1)
|
|
3091
|
-
])])) : (
|
|
3092
|
-
|
|
382
|
+
])])) : (f(), w("svg", Ce, [...i[3] || (i[3] = [
|
|
383
|
+
s("path", { d: "M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z" }, null, -1)
|
|
3093
384
|
])]))
|
|
3094
385
|
])
|
|
3095
386
|
]));
|
|
3096
387
|
}
|
|
3097
|
-
}),
|
|
3098
|
-
install: (
|
|
3099
|
-
|
|
388
|
+
}), Te = {
|
|
389
|
+
install: (e) => {
|
|
390
|
+
e.component("GigSupportChat", Me);
|
|
3100
391
|
}
|
|
3101
392
|
};
|
|
3102
393
|
export {
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
394
|
+
Me as GigSupportChat,
|
|
395
|
+
Te as default,
|
|
396
|
+
ie as useSupportChat
|
|
3106
397
|
};
|