@variamosple/variamos-components 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -42
- package/dist/Common/Events.d.ts +3 -2
- package/dist/Common/Events.js +18 -11
- package/dist/Common/fieldOf.d.ts +2 -0
- package/dist/Common/fieldOf.js +7 -0
- package/dist/Common/isAllowedFor.d.ts +7 -0
- package/dist/Common/isAllowedFor.js +9 -0
- package/dist/Components/AuthWrapper/addressWithoutToken.d.ts +9 -0
- package/dist/Components/AuthWrapper/addressWithoutToken.js +7 -0
- package/dist/Components/AuthWrapper/index.js +18 -17
- package/dist/Components/ConfirmationModal/index.js +3 -3
- package/dist/Components/Footer/index.js +1 -1
- package/dist/Components/Header/BugFormModal.d.ts +2 -0
- package/dist/Components/Header/BugFormModal.js +39 -37
- package/dist/Components/Header/HeaderOptions.js +80 -86
- package/dist/Components/Header/MenuItem.js +24 -34
- package/dist/Components/Header/SubHeader.js +17 -29
- package/dist/Components/Header/index.js +25 -13
- package/dist/Components/Header/submitBugReport.d.ts +15 -0
- package/dist/Components/Header/submitBugReport.js +23 -0
- package/dist/Components/NotAuthorized/index.js +1 -1
- package/dist/Components/Notifications/NotificationBell.js +10 -10
- package/dist/Components/Notifications/NotificationCard.d.ts +9 -0
- package/dist/Components/Notifications/NotificationCard.js +81 -0
- package/dist/Components/Notifications/NotificationDrawer.js +139 -191
- package/dist/Components/Notifications/NotificationSettings.js +32 -28
- package/dist/Components/Notifications/mutedEventTypes.js +9 -9
- package/dist/Components/Notifications/notificationText.d.ts +7 -0
- package/dist/Components/Notifications/notificationText.js +38 -0
- package/dist/Components/Paginator/index.js +22 -22
- package/dist/Components/ProtectedRoute/index.js +18 -18
- package/dist/Components/index.d.ts +1 -1
- package/dist/Components/index.js +10 -10
- package/dist/Context/AnalyticsContext.d.ts +2 -2
- package/dist/Context/AnalyticsContext.js +15 -15
- package/dist/Context/MenuContext.js +39 -47
- package/dist/Context/NotificationContext.d.ts +2 -14
- package/dist/Context/NotificationContext.js +393 -458
- package/dist/Context/SessionContext.js +74 -81
- package/dist/Context/index.d.ts +1 -1
- package/dist/Context/index.js +11 -11
- package/dist/Context/notificationAccessToken.js +13 -13
- package/dist/Context/notificationApi.d.ts +43 -0
- package/dist/Context/notificationApi.js +83 -0
- package/dist/Context/useNotificationState.d.ts +35 -0
- package/dist/Context/useNotificationState.js +92 -0
- package/dist/Hooks/useDebouncedValue.js +20 -16
- package/dist/Hooks/usePaginatedQuery.js +14 -20
- package/dist/Hooks/useQuery.js +6 -6
- package/dist/Model/ResponseModel.d.ts +2 -2
- package/dist/Model/ResponseModel.js +9 -4
- package/dist/main.js +21 -21
- package/package.json +22 -15
|
@@ -1,72 +1,74 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { createContext as
|
|
3
|
-
import { createAccessTokenProvider as
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
1
|
+
import { jsx as ve } from "react/jsx-runtime";
|
|
2
|
+
import { createContext as Ee, useMemo as P, useEffect as ke, useContext as Te } from "react";
|
|
3
|
+
import { createAccessTokenProvider as Ae, accessTokenUrl as Oe } from "./notificationAccessToken.js";
|
|
4
|
+
import { createNotificationApi as Re, notificationItemOf as Ce } from "./notificationApi.js";
|
|
5
|
+
import { useSession as Se } from "./SessionContext.js";
|
|
6
|
+
import { useNotificationList as Be, useNotificationChanges as Ne, useNotificationPreferences as xe } from "./useNotificationState.js";
|
|
7
|
+
const _ = /* @__PURE__ */ Object.create(null);
|
|
8
|
+
_.open = "0";
|
|
9
|
+
_.close = "1";
|
|
10
|
+
_.ping = "2";
|
|
11
|
+
_.pong = "3";
|
|
12
|
+
_.message = "4";
|
|
13
|
+
_.upgrade = "5";
|
|
14
|
+
_.noop = "6";
|
|
15
|
+
const O = /* @__PURE__ */ Object.create(null);
|
|
16
|
+
Object.keys(_).forEach((n) => {
|
|
17
|
+
O[_[n]] = n;
|
|
16
18
|
});
|
|
17
|
-
const
|
|
19
|
+
const F = { type: "error", data: "parser error" }, oe = typeof Blob == "function" || typeof Blob < "u" && Object.prototype.toString.call(Blob) === "[object BlobConstructor]", ce = typeof ArrayBuffer == "function", ae = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n && n.buffer instanceof ArrayBuffer, K = ({ type: n, data: e }, t, s) => oe && e instanceof Blob ? t ? s(e) : te(e, s) : ce && (e instanceof ArrayBuffer || ae(e)) ? t ? s(e) : te(new Blob([e]), s) : s(_[n] + (e || "")), te = (n, e) => {
|
|
18
20
|
const t = new FileReader();
|
|
19
21
|
return t.onload = function() {
|
|
20
22
|
const s = t.result.split(",")[1];
|
|
21
23
|
e("b" + (s || ""));
|
|
22
24
|
}, t.readAsDataURL(n);
|
|
23
25
|
};
|
|
24
|
-
function
|
|
26
|
+
function se(n) {
|
|
25
27
|
return n instanceof Uint8Array ? n : n instanceof ArrayBuffer ? new Uint8Array(n) : new Uint8Array(n.buffer, n.byteOffset, n.byteLength);
|
|
26
28
|
}
|
|
27
|
-
let
|
|
28
|
-
function
|
|
29
|
-
if (
|
|
30
|
-
return n.data.arrayBuffer().then(
|
|
31
|
-
if (ce && (n.data instanceof ArrayBuffer ||
|
|
32
|
-
return e(
|
|
33
|
-
|
|
34
|
-
|
|
29
|
+
let q;
|
|
30
|
+
function Le(n, e) {
|
|
31
|
+
if (oe && n.data instanceof Blob)
|
|
32
|
+
return n.data.arrayBuffer().then(se).then(e);
|
|
33
|
+
if (ce && (n.data instanceof ArrayBuffer || ae(n.data)))
|
|
34
|
+
return e(se(n.data));
|
|
35
|
+
K(n, !1, (t) => {
|
|
36
|
+
q || (q = new TextEncoder()), e(q.encode(t));
|
|
35
37
|
});
|
|
36
38
|
}
|
|
37
|
-
const
|
|
38
|
-
for (let n = 0; n <
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
let e = n.length * 0.75, t = n.length, s, i = 0, r, o,
|
|
39
|
+
const ne = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/", k = typeof Uint8Array > "u" ? [] : new Uint8Array(256);
|
|
40
|
+
for (let n = 0; n < ne.length; n++)
|
|
41
|
+
k[ne.charCodeAt(n)] = n;
|
|
42
|
+
const Pe = (n) => {
|
|
43
|
+
let e = n.length * 0.75, t = n.length, s, i = 0, r, o, c, h;
|
|
42
44
|
n[n.length - 1] === "=" && (e--, n[n.length - 2] === "=" && e--);
|
|
43
|
-
const
|
|
45
|
+
const l = new ArrayBuffer(e), f = new Uint8Array(l);
|
|
44
46
|
for (s = 0; s < t; s += 4)
|
|
45
|
-
r =
|
|
46
|
-
return
|
|
47
|
-
},
|
|
47
|
+
r = k[n.charCodeAt(s)], o = k[n.charCodeAt(s + 1)], c = k[n.charCodeAt(s + 2)], h = k[n.charCodeAt(s + 3)], f[i++] = r << 2 | o >> 4, f[i++] = (o & 15) << 4 | c >> 2, f[i++] = (c & 3) << 6 | h & 63;
|
|
48
|
+
return l;
|
|
49
|
+
}, qe = typeof ArrayBuffer == "function", W = (n, e) => {
|
|
48
50
|
if (typeof n != "string")
|
|
49
51
|
return {
|
|
50
52
|
type: "message",
|
|
51
|
-
data:
|
|
53
|
+
data: he(n, e)
|
|
52
54
|
};
|
|
53
55
|
const t = n.charAt(0);
|
|
54
56
|
return t === "b" ? {
|
|
55
57
|
type: "message",
|
|
56
|
-
data:
|
|
57
|
-
} :
|
|
58
|
-
type:
|
|
58
|
+
data: Ie(n.substring(1), e)
|
|
59
|
+
} : O[t] ? n.length > 1 ? {
|
|
60
|
+
type: O[t],
|
|
59
61
|
data: n.substring(1)
|
|
60
62
|
} : {
|
|
61
|
-
type:
|
|
62
|
-
} :
|
|
63
|
-
},
|
|
64
|
-
if (
|
|
65
|
-
const t =
|
|
66
|
-
return
|
|
63
|
+
type: O[t]
|
|
64
|
+
} : F;
|
|
65
|
+
}, Ie = (n, e) => {
|
|
66
|
+
if (qe) {
|
|
67
|
+
const t = Pe(n);
|
|
68
|
+
return he(t, e);
|
|
67
69
|
} else
|
|
68
70
|
return { base64: !0, data: n };
|
|
69
|
-
},
|
|
71
|
+
}, he = (n, e) => {
|
|
70
72
|
switch (e) {
|
|
71
73
|
case "blob":
|
|
72
74
|
return n instanceof Blob ? n : new Blob([n]);
|
|
@@ -74,27 +76,27 @@ const De = (n) => {
|
|
|
74
76
|
default:
|
|
75
77
|
return n instanceof ArrayBuffer ? n : n.buffer;
|
|
76
78
|
}
|
|
77
|
-
}, ue = "",
|
|
79
|
+
}, ue = "", De = (n, e) => {
|
|
78
80
|
const t = n.length, s = new Array(t);
|
|
79
81
|
let i = 0;
|
|
80
82
|
n.forEach((r, o) => {
|
|
81
|
-
|
|
82
|
-
s[o] =
|
|
83
|
+
K(r, !1, (c) => {
|
|
84
|
+
s[o] = c, ++i === t && e(s.join(ue));
|
|
83
85
|
});
|
|
84
86
|
});
|
|
85
|
-
},
|
|
87
|
+
}, Fe = (n, e) => {
|
|
86
88
|
const t = n.split(ue), s = [];
|
|
87
89
|
for (let i = 0; i < t.length; i++) {
|
|
88
|
-
const r =
|
|
90
|
+
const r = W(t[i], e);
|
|
89
91
|
if (s.push(r), r.type === "error")
|
|
90
92
|
break;
|
|
91
93
|
}
|
|
92
94
|
return s;
|
|
93
95
|
};
|
|
94
|
-
function
|
|
96
|
+
function Ue() {
|
|
95
97
|
return new TransformStream({
|
|
96
98
|
transform(n, e) {
|
|
97
|
-
|
|
99
|
+
Le(n, (t) => {
|
|
98
100
|
const s = t.length;
|
|
99
101
|
let i;
|
|
100
102
|
if (s < 126)
|
|
@@ -113,11 +115,11 @@ function $e() {
|
|
|
113
115
|
}
|
|
114
116
|
});
|
|
115
117
|
}
|
|
116
|
-
let
|
|
117
|
-
function
|
|
118
|
+
let I;
|
|
119
|
+
function T(n) {
|
|
118
120
|
return n.reduce((e, t) => e + t.length, 0);
|
|
119
121
|
}
|
|
120
|
-
function
|
|
122
|
+
function A(n, e) {
|
|
121
123
|
if (n[0].length === e)
|
|
122
124
|
return n.shift();
|
|
123
125
|
const t = new Uint8Array(e);
|
|
@@ -126,65 +128,65 @@ function x(n, e) {
|
|
|
126
128
|
t[i] = n[0][s++], s === n[0].length && (n.shift(), s = 0);
|
|
127
129
|
return n.length && s < n[0].length && (n[0] = n[0].slice(s)), t;
|
|
128
130
|
}
|
|
129
|
-
function
|
|
130
|
-
|
|
131
|
+
function Ve(n, e) {
|
|
132
|
+
I || (I = new TextDecoder());
|
|
131
133
|
const t = [];
|
|
132
134
|
let s = 0, i = -1, r = !1;
|
|
133
135
|
return new TransformStream({
|
|
134
|
-
transform(o,
|
|
136
|
+
transform(o, c) {
|
|
135
137
|
for (t.push(o); ; ) {
|
|
136
138
|
if (s === 0) {
|
|
137
|
-
if (
|
|
139
|
+
if (T(t) < 1)
|
|
138
140
|
break;
|
|
139
|
-
const
|
|
140
|
-
r = (
|
|
141
|
+
const h = A(t, 1);
|
|
142
|
+
r = (h[0] & 128) === 128, i = h[0] & 127, i < 126 ? s = 3 : i === 126 ? s = 1 : s = 2;
|
|
141
143
|
} else if (s === 1) {
|
|
142
|
-
if (
|
|
144
|
+
if (T(t) < 2)
|
|
143
145
|
break;
|
|
144
|
-
const
|
|
145
|
-
i = new DataView(
|
|
146
|
+
const h = A(t, 2);
|
|
147
|
+
i = new DataView(h.buffer, h.byteOffset, h.length).getUint16(0), s = 3;
|
|
146
148
|
} else if (s === 2) {
|
|
147
|
-
if (
|
|
149
|
+
if (T(t) < 8)
|
|
148
150
|
break;
|
|
149
|
-
const
|
|
150
|
-
if (
|
|
151
|
-
|
|
151
|
+
const h = A(t, 8), l = new DataView(h.buffer, h.byteOffset, h.length), f = l.getUint32(0);
|
|
152
|
+
if (f > Math.pow(2, 21) - 1) {
|
|
153
|
+
c.enqueue(F);
|
|
152
154
|
break;
|
|
153
155
|
}
|
|
154
|
-
i =
|
|
156
|
+
i = f * Math.pow(2, 32) + l.getUint32(4), s = 3;
|
|
155
157
|
} else {
|
|
156
|
-
if (
|
|
158
|
+
if (T(t) < i)
|
|
157
159
|
break;
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
+
const h = A(t, i);
|
|
161
|
+
c.enqueue(W(r ? h : I.decode(h), e)), s = 0;
|
|
160
162
|
}
|
|
161
163
|
if (i === 0 || i > n) {
|
|
162
|
-
|
|
164
|
+
c.enqueue(F);
|
|
163
165
|
break;
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
168
|
}
|
|
167
169
|
});
|
|
168
170
|
}
|
|
169
|
-
const
|
|
170
|
-
function
|
|
171
|
-
if (n) return
|
|
171
|
+
const fe = 4;
|
|
172
|
+
function u(n) {
|
|
173
|
+
if (n) return Me(n);
|
|
172
174
|
}
|
|
173
|
-
function
|
|
174
|
-
for (var e in
|
|
175
|
-
n[e] =
|
|
175
|
+
function Me(n) {
|
|
176
|
+
for (var e in u.prototype)
|
|
177
|
+
n[e] = u.prototype[e];
|
|
176
178
|
return n;
|
|
177
179
|
}
|
|
178
|
-
|
|
180
|
+
u.prototype.on = u.prototype.addEventListener = function(n, e) {
|
|
179
181
|
return this._callbacks = this._callbacks || {}, (this._callbacks["$" + n] = this._callbacks["$" + n] || []).push(e), this;
|
|
180
182
|
};
|
|
181
|
-
|
|
183
|
+
u.prototype.once = function(n, e) {
|
|
182
184
|
function t() {
|
|
183
185
|
this.off(n, t), e.apply(this, arguments);
|
|
184
186
|
}
|
|
185
187
|
return t.fn = e, this.on(n, t), this;
|
|
186
188
|
};
|
|
187
|
-
|
|
189
|
+
u.prototype.off = u.prototype.removeListener = u.prototype.removeAllListeners = u.prototype.removeEventListener = function(n, e) {
|
|
188
190
|
if (this._callbacks = this._callbacks || {}, arguments.length == 0)
|
|
189
191
|
return this._callbacks = {}, this;
|
|
190
192
|
var t = this._callbacks["$" + n];
|
|
@@ -198,7 +200,7 @@ l.prototype.off = l.prototype.removeListener = l.prototype.removeAllListeners =
|
|
|
198
200
|
}
|
|
199
201
|
return t.length === 0 && delete this._callbacks["$" + n], this;
|
|
200
202
|
};
|
|
201
|
-
|
|
203
|
+
u.prototype.emit = function(n) {
|
|
202
204
|
this._callbacks = this._callbacks || {};
|
|
203
205
|
for (var e = new Array(arguments.length - 1), t = this._callbacks["$" + n], s = 1; s < arguments.length; s++)
|
|
204
206
|
e[s - 1] = arguments[s];
|
|
@@ -209,41 +211,41 @@ l.prototype.emit = function(n) {
|
|
|
209
211
|
}
|
|
210
212
|
return this;
|
|
211
213
|
};
|
|
212
|
-
|
|
213
|
-
|
|
214
|
+
u.prototype.emitReserved = u.prototype.emit;
|
|
215
|
+
u.prototype.listeners = function(n) {
|
|
214
216
|
return this._callbacks = this._callbacks || {}, this._callbacks["$" + n] || [];
|
|
215
217
|
};
|
|
216
|
-
|
|
218
|
+
u.prototype.hasListeners = function(n) {
|
|
217
219
|
return !!this.listeners(n).length;
|
|
218
220
|
};
|
|
219
|
-
const
|
|
220
|
-
function
|
|
221
|
+
const N = typeof Promise == "function" && typeof Promise.resolve == "function" ? (e) => Promise.resolve().then(e) : (e, t) => t(e, 0), p = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), He = "arraybuffer";
|
|
222
|
+
function le(n, ...e) {
|
|
221
223
|
return e.reduce((t, s) => (n.hasOwnProperty(s) && (t[s] = n[s]), t), {});
|
|
222
224
|
}
|
|
223
|
-
const
|
|
224
|
-
function
|
|
225
|
-
e.useNativeTimers ? (n.setTimeoutFn =
|
|
225
|
+
const Ke = p.setTimeout, We = p.clearTimeout;
|
|
226
|
+
function x(n, e) {
|
|
227
|
+
e.useNativeTimers ? (n.setTimeoutFn = Ke.bind(p), n.clearTimeoutFn = We.bind(p)) : (n.setTimeoutFn = p.setTimeout.bind(p), n.clearTimeoutFn = p.clearTimeout.bind(p));
|
|
226
228
|
}
|
|
227
|
-
const
|
|
228
|
-
function
|
|
229
|
-
return typeof n == "string" ?
|
|
229
|
+
const $e = 1.33;
|
|
230
|
+
function Ye(n) {
|
|
231
|
+
return typeof n == "string" ? ze(n) : Math.ceil((n.byteLength || n.size) * $e);
|
|
230
232
|
}
|
|
231
|
-
function
|
|
233
|
+
function ze(n) {
|
|
232
234
|
let e = 0, t = 0;
|
|
233
235
|
for (let s = 0, i = n.length; s < i; s++)
|
|
234
236
|
e = n.charCodeAt(s), e < 128 ? t += 1 : e < 2048 ? t += 2 : e < 55296 || e >= 57344 ? t += 3 : (s++, t += 4);
|
|
235
237
|
return t;
|
|
236
238
|
}
|
|
237
|
-
function
|
|
239
|
+
function pe() {
|
|
238
240
|
return Date.now().toString(36).substring(3) + Math.random().toString(36).substring(2, 5);
|
|
239
241
|
}
|
|
240
|
-
function
|
|
242
|
+
function Je(n) {
|
|
241
243
|
let e = "";
|
|
242
244
|
for (let t in n)
|
|
243
245
|
n.hasOwnProperty(t) && (e.length && (e += "&"), e += encodeURIComponent(t) + "=" + encodeURIComponent(n[t]));
|
|
244
246
|
return e;
|
|
245
247
|
}
|
|
246
|
-
function
|
|
248
|
+
function Xe(n) {
|
|
247
249
|
let e = {}, t = n.split("&");
|
|
248
250
|
for (let s = 0, i = t.length; s < i; s++) {
|
|
249
251
|
let r = t[s].split("=");
|
|
@@ -251,12 +253,12 @@ function Ge(n) {
|
|
|
251
253
|
}
|
|
252
254
|
return e;
|
|
253
255
|
}
|
|
254
|
-
class
|
|
256
|
+
class Qe extends Error {
|
|
255
257
|
constructor(e, t, s) {
|
|
256
258
|
super(e), this.description = t, this.context = s, this.type = "TransportError";
|
|
257
259
|
}
|
|
258
260
|
}
|
|
259
|
-
class
|
|
261
|
+
class $ extends u {
|
|
260
262
|
/**
|
|
261
263
|
* Transport abstract constructor.
|
|
262
264
|
*
|
|
@@ -264,7 +266,7 @@ class X extends l {
|
|
|
264
266
|
* @protected
|
|
265
267
|
*/
|
|
266
268
|
constructor(e) {
|
|
267
|
-
super(), this.writable = !1,
|
|
269
|
+
super(), this.writable = !1, x(this, e), this.opts = e, this.query = e.query, this.socket = e.socket, this.supportsBinary = !e.forceBase64;
|
|
268
270
|
}
|
|
269
271
|
/**
|
|
270
272
|
* Emits an error.
|
|
@@ -276,7 +278,7 @@ class X extends l {
|
|
|
276
278
|
* @protected
|
|
277
279
|
*/
|
|
278
280
|
onError(e, t, s) {
|
|
279
|
-
return super.emitReserved("error", new
|
|
281
|
+
return super.emitReserved("error", new Qe(e, t, s)), this;
|
|
280
282
|
}
|
|
281
283
|
/**
|
|
282
284
|
* Opens the transport.
|
|
@@ -313,7 +315,7 @@ class X extends l {
|
|
|
313
315
|
* @protected
|
|
314
316
|
*/
|
|
315
317
|
onData(e) {
|
|
316
|
-
const t =
|
|
318
|
+
const t = W(e, this.socket.binaryType);
|
|
317
319
|
this.onPacket(t);
|
|
318
320
|
}
|
|
319
321
|
/**
|
|
@@ -350,11 +352,11 @@ class X extends l {
|
|
|
350
352
|
return this.opts.port && (this.opts.secure && Number(this.opts.port) !== 443 || !this.opts.secure && Number(this.opts.port) !== 80) ? ":" + this.opts.port : "";
|
|
351
353
|
}
|
|
352
354
|
_query(e) {
|
|
353
|
-
const t =
|
|
355
|
+
const t = Je(e);
|
|
354
356
|
return t.length ? "?" + t : "";
|
|
355
357
|
}
|
|
356
358
|
}
|
|
357
|
-
class
|
|
359
|
+
class je extends $ {
|
|
358
360
|
constructor() {
|
|
359
361
|
super(...arguments), this._polling = !1;
|
|
360
362
|
}
|
|
@@ -410,7 +412,7 @@ class et extends X {
|
|
|
410
412
|
return this.onClose({ description: "transport closed by the server" }), !1;
|
|
411
413
|
this.onPacket(s);
|
|
412
414
|
};
|
|
413
|
-
|
|
415
|
+
Fe(e, this.socket.binaryType).forEach(t), this.readyState !== "closed" && (this._polling = !1, this.emitReserved("pollComplete"), this.readyState === "open" && this._poll());
|
|
414
416
|
}
|
|
415
417
|
/**
|
|
416
418
|
* For polling, send a close packet.
|
|
@@ -430,7 +432,7 @@ class et extends X {
|
|
|
430
432
|
* @protected
|
|
431
433
|
*/
|
|
432
434
|
write(e) {
|
|
433
|
-
this.writable = !1,
|
|
435
|
+
this.writable = !1, De(e, (t) => {
|
|
434
436
|
this.doWrite(t, () => {
|
|
435
437
|
this.writable = !0, this.emitReserved("drain");
|
|
436
438
|
});
|
|
@@ -443,18 +445,18 @@ class et extends X {
|
|
|
443
445
|
*/
|
|
444
446
|
uri() {
|
|
445
447
|
const e = this.opts.secure ? "https" : "http", t = this.query || {};
|
|
446
|
-
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] =
|
|
448
|
+
return this.opts.timestampRequests !== !1 && (t[this.opts.timestampParam] = pe()), !this.supportsBinary && !t.sid && (t.b64 = 1), this.createUri(e, t);
|
|
447
449
|
}
|
|
448
450
|
}
|
|
449
|
-
let
|
|
451
|
+
let de = !1;
|
|
450
452
|
try {
|
|
451
|
-
|
|
453
|
+
de = typeof XMLHttpRequest < "u" && "withCredentials" in new XMLHttpRequest();
|
|
452
454
|
} catch {
|
|
453
455
|
}
|
|
454
|
-
const
|
|
455
|
-
function
|
|
456
|
+
const Ge = de;
|
|
457
|
+
function Ze() {
|
|
456
458
|
}
|
|
457
|
-
class
|
|
459
|
+
class et extends je {
|
|
458
460
|
/**
|
|
459
461
|
* XHR Polling constructor.
|
|
460
462
|
*
|
|
@@ -496,7 +498,7 @@ class nt extends et {
|
|
|
496
498
|
}), this.pollXhr = e;
|
|
497
499
|
}
|
|
498
500
|
}
|
|
499
|
-
class
|
|
501
|
+
class g extends u {
|
|
500
502
|
/**
|
|
501
503
|
* Request constructor
|
|
502
504
|
*
|
|
@@ -504,7 +506,7 @@ class b extends l {
|
|
|
504
506
|
* @package
|
|
505
507
|
*/
|
|
506
508
|
constructor(e, t, s) {
|
|
507
|
-
super(), this.createRequest = e,
|
|
509
|
+
super(), this.createRequest = e, x(this, s), this._opts = s, this._method = s.method || "GET", this._uri = t, this._data = s.data !== void 0 ? s.data : null, this._create();
|
|
508
510
|
}
|
|
509
511
|
/**
|
|
510
512
|
* Creates the XHR object and sends the request.
|
|
@@ -513,7 +515,7 @@ class b extends l {
|
|
|
513
515
|
*/
|
|
514
516
|
_create() {
|
|
515
517
|
var e;
|
|
516
|
-
const t =
|
|
518
|
+
const t = le(this._opts, "agent", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "autoUnref");
|
|
517
519
|
t.xdomain = !!this._opts.xd;
|
|
518
520
|
const s = this._xhr = this.createRequest(t);
|
|
519
521
|
try {
|
|
@@ -550,7 +552,7 @@ class b extends l {
|
|
|
550
552
|
}, 0);
|
|
551
553
|
return;
|
|
552
554
|
}
|
|
553
|
-
typeof document < "u" && (this._index =
|
|
555
|
+
typeof document < "u" && (this._index = g.requestsCount++, g.requests[this._index] = this);
|
|
554
556
|
}
|
|
555
557
|
/**
|
|
556
558
|
* Called upon error.
|
|
@@ -567,12 +569,12 @@ class b extends l {
|
|
|
567
569
|
*/
|
|
568
570
|
_cleanup(e) {
|
|
569
571
|
if (!(typeof this._xhr > "u" || this._xhr === null)) {
|
|
570
|
-
if (this._xhr.onreadystatechange =
|
|
572
|
+
if (this._xhr.onreadystatechange = Ze, e)
|
|
571
573
|
try {
|
|
572
574
|
this._xhr.abort();
|
|
573
575
|
} catch {
|
|
574
576
|
}
|
|
575
|
-
typeof document < "u" && delete
|
|
577
|
+
typeof document < "u" && delete g.requests[this._index], this._xhr = null;
|
|
576
578
|
}
|
|
577
579
|
}
|
|
578
580
|
/**
|
|
@@ -593,56 +595,56 @@ class b extends l {
|
|
|
593
595
|
this._cleanup();
|
|
594
596
|
}
|
|
595
597
|
}
|
|
596
|
-
|
|
597
|
-
|
|
598
|
+
g.requestsCount = 0;
|
|
599
|
+
g.requests = {};
|
|
598
600
|
if (typeof document < "u") {
|
|
599
601
|
if (typeof attachEvent == "function")
|
|
600
|
-
attachEvent("onunload",
|
|
602
|
+
attachEvent("onunload", ie);
|
|
601
603
|
else if (typeof addEventListener == "function") {
|
|
602
|
-
const n = "onpagehide" in
|
|
603
|
-
addEventListener(n,
|
|
604
|
+
const n = "onpagehide" in p ? "pagehide" : "unload";
|
|
605
|
+
addEventListener(n, ie, !1);
|
|
604
606
|
}
|
|
605
607
|
}
|
|
606
|
-
function
|
|
607
|
-
for (let n in
|
|
608
|
-
|
|
608
|
+
function ie() {
|
|
609
|
+
for (let n in g.requests)
|
|
610
|
+
g.requests.hasOwnProperty(n) && g.requests[n].abort();
|
|
609
611
|
}
|
|
610
|
-
const
|
|
611
|
-
const n =
|
|
612
|
+
const tt = (function() {
|
|
613
|
+
const n = ye({
|
|
612
614
|
xdomain: !1
|
|
613
615
|
});
|
|
614
616
|
return n && n.responseType !== null;
|
|
615
617
|
})();
|
|
616
|
-
class
|
|
618
|
+
class st extends et {
|
|
617
619
|
constructor(e) {
|
|
618
620
|
super(e);
|
|
619
621
|
const t = e && e.forceBase64;
|
|
620
|
-
this.supportsBinary =
|
|
622
|
+
this.supportsBinary = tt && !t;
|
|
621
623
|
}
|
|
622
624
|
request(e = {}) {
|
|
623
|
-
return Object.assign(e, { xd: this.xd }, this.opts), new
|
|
625
|
+
return Object.assign(e, { xd: this.xd }, this.opts), new g(ye, this.uri(), e);
|
|
624
626
|
}
|
|
625
627
|
}
|
|
626
|
-
function
|
|
628
|
+
function ye(n) {
|
|
627
629
|
const e = n.xdomain;
|
|
628
630
|
try {
|
|
629
|
-
if (typeof XMLHttpRequest < "u" && (!e ||
|
|
631
|
+
if (typeof XMLHttpRequest < "u" && (!e || Ge))
|
|
630
632
|
return new XMLHttpRequest();
|
|
631
633
|
} catch {
|
|
632
634
|
}
|
|
633
635
|
if (!e)
|
|
634
636
|
try {
|
|
635
|
-
return new
|
|
637
|
+
return new p[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
636
638
|
} catch {
|
|
637
639
|
}
|
|
638
640
|
}
|
|
639
|
-
const
|
|
640
|
-
class
|
|
641
|
+
const me = typeof navigator < "u" && typeof navigator.product == "string" && navigator.product.toLowerCase() === "reactnative";
|
|
642
|
+
class nt extends $ {
|
|
641
643
|
get name() {
|
|
642
644
|
return "websocket";
|
|
643
645
|
}
|
|
644
646
|
doOpen() {
|
|
645
|
-
const e = this.uri(), t = this.opts.protocols, s =
|
|
647
|
+
const e = this.uri(), t = this.opts.protocols, s = me ? {} : le(this.opts, "agent", "perMessageDeflate", "pfx", "key", "passphrase", "cert", "ca", "ciphers", "rejectUnauthorized", "localAddress", "protocolVersion", "origin", "maxPayload", "family", "checkServerIdentity");
|
|
646
648
|
this.opts.extraHeaders && (s.headers = this.opts.extraHeaders);
|
|
647
649
|
try {
|
|
648
650
|
this.ws = this.createSocket(e, t, s);
|
|
@@ -668,12 +670,12 @@ class ot extends X {
|
|
|
668
670
|
this.writable = !1;
|
|
669
671
|
for (let t = 0; t < e.length; t++) {
|
|
670
672
|
const s = e[t], i = t === e.length - 1;
|
|
671
|
-
|
|
673
|
+
K(s, this.supportsBinary, (r) => {
|
|
672
674
|
try {
|
|
673
675
|
this.doWrite(s, r);
|
|
674
676
|
} catch {
|
|
675
677
|
}
|
|
676
|
-
i &&
|
|
678
|
+
i && N(() => {
|
|
677
679
|
this.writable = !0, this.emitReserved("drain");
|
|
678
680
|
}, this.setTimeoutFn);
|
|
679
681
|
});
|
|
@@ -690,19 +692,19 @@ class ot extends X {
|
|
|
690
692
|
*/
|
|
691
693
|
uri() {
|
|
692
694
|
const e = this.opts.secure ? "wss" : "ws", t = this.query || {};
|
|
693
|
-
return this.opts.timestampRequests && (t[this.opts.timestampParam] =
|
|
695
|
+
return this.opts.timestampRequests && (t[this.opts.timestampParam] = pe()), this.supportsBinary || (t.b64 = 1), this.createUri(e, t);
|
|
694
696
|
}
|
|
695
697
|
}
|
|
696
|
-
const
|
|
697
|
-
class
|
|
698
|
+
const D = p.WebSocket || p.MozWebSocket;
|
|
699
|
+
class it extends nt {
|
|
698
700
|
createSocket(e, t, s) {
|
|
699
|
-
return
|
|
701
|
+
return me ? new D(e, t, s) : t ? new D(e, t) : new D(e);
|
|
700
702
|
}
|
|
701
703
|
doWrite(e, t) {
|
|
702
704
|
this.ws.send(t);
|
|
703
705
|
}
|
|
704
706
|
}
|
|
705
|
-
class
|
|
707
|
+
class rt extends $ {
|
|
706
708
|
get name() {
|
|
707
709
|
return "webtransport";
|
|
708
710
|
}
|
|
@@ -718,12 +720,12 @@ class ct extends X {
|
|
|
718
720
|
this.onError("webtransport error", e);
|
|
719
721
|
}), this._transport.ready.then(() => {
|
|
720
722
|
this._transport.createBidirectionalStream().then((e) => {
|
|
721
|
-
const t =
|
|
723
|
+
const t = Ve(Number.MAX_SAFE_INTEGER, this.socket.binaryType), s = e.readable.pipeThrough(t).getReader(), i = Ue();
|
|
722
724
|
i.readable.pipeTo(e.writable), this._writer = i.writable.getWriter();
|
|
723
725
|
const r = () => {
|
|
724
|
-
s.read().then(({ done:
|
|
725
|
-
|
|
726
|
-
}).catch((
|
|
726
|
+
s.read().then(({ done: c, value: h }) => {
|
|
727
|
+
c || (this.onPacket(h), r());
|
|
728
|
+
}).catch((c) => {
|
|
727
729
|
});
|
|
728
730
|
};
|
|
729
731
|
r();
|
|
@@ -737,7 +739,7 @@ class ct extends X {
|
|
|
737
739
|
for (let t = 0; t < e.length; t++) {
|
|
738
740
|
const s = e[t], i = t === e.length - 1;
|
|
739
741
|
this._writer.write(s).then(() => {
|
|
740
|
-
i &&
|
|
742
|
+
i && N(() => {
|
|
741
743
|
this.writable = !0, this.emitReserved("drain");
|
|
742
744
|
}, this.setTimeoutFn);
|
|
743
745
|
});
|
|
@@ -748,11 +750,11 @@ class ct extends X {
|
|
|
748
750
|
(e = this._transport) === null || e === void 0 || e.close();
|
|
749
751
|
}
|
|
750
752
|
}
|
|
751
|
-
const
|
|
752
|
-
websocket:
|
|
753
|
-
webtransport:
|
|
754
|
-
polling:
|
|
755
|
-
},
|
|
753
|
+
const ot = {
|
|
754
|
+
websocket: it,
|
|
755
|
+
webtransport: rt,
|
|
756
|
+
polling: st
|
|
757
|
+
}, ct = /^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/, at = [
|
|
756
758
|
"source",
|
|
757
759
|
"protocol",
|
|
758
760
|
"authority",
|
|
@@ -768,31 +770,31 @@ const ht = {
|
|
|
768
770
|
"query",
|
|
769
771
|
"anchor"
|
|
770
772
|
];
|
|
771
|
-
function
|
|
773
|
+
function U(n) {
|
|
772
774
|
if (n.length > 8e3)
|
|
773
775
|
throw "URI too long";
|
|
774
776
|
const e = n, t = n.indexOf("["), s = n.indexOf("]");
|
|
775
777
|
t != -1 && s != -1 && (n = n.substring(0, t) + n.substring(t, s).replace(/:/g, ";") + n.substring(s, n.length));
|
|
776
|
-
let i =
|
|
778
|
+
let i = ct.exec(n || ""), r = {}, o = 14;
|
|
777
779
|
for (; o--; )
|
|
778
|
-
r[
|
|
779
|
-
return t != -1 && s != -1 && (r.source = e, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames =
|
|
780
|
+
r[at[o]] = i[o] || "";
|
|
781
|
+
return t != -1 && s != -1 && (r.source = e, r.host = r.host.substring(1, r.host.length - 1).replace(/;/g, ":"), r.authority = r.authority.replace("[", "").replace("]", "").replace(/;/g, ":"), r.ipv6uri = !0), r.pathNames = ht(r, r.path), r.queryKey = ut(r, r.query), r;
|
|
780
782
|
}
|
|
781
|
-
function
|
|
783
|
+
function ht(n, e) {
|
|
782
784
|
const t = /\/{2,9}/g, s = e.replace(t, "/").split("/");
|
|
783
785
|
return (e.slice(0, 1) == "/" || e.length === 0) && s.splice(0, 1), e.slice(-1) == "/" && s.splice(s.length - 1, 1), s;
|
|
784
786
|
}
|
|
785
|
-
function
|
|
787
|
+
function ut(n, e) {
|
|
786
788
|
const t = {};
|
|
787
789
|
return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g, function(s, i, r) {
|
|
788
790
|
i && (t[i] = r);
|
|
789
791
|
}), t;
|
|
790
792
|
}
|
|
791
|
-
const
|
|
792
|
-
|
|
793
|
-
|
|
793
|
+
const V = typeof addEventListener == "function" && typeof removeEventListener == "function", R = [];
|
|
794
|
+
V && addEventListener("offline", () => {
|
|
795
|
+
R.forEach((n) => n());
|
|
794
796
|
}, !1);
|
|
795
|
-
class
|
|
797
|
+
class w extends u {
|
|
796
798
|
/**
|
|
797
799
|
* Socket constructor.
|
|
798
800
|
*
|
|
@@ -800,11 +802,11 @@ class T extends l {
|
|
|
800
802
|
* @param {Object} opts - options
|
|
801
803
|
*/
|
|
802
804
|
constructor(e, t) {
|
|
803
|
-
if (super(), this.binaryType =
|
|
804
|
-
const s =
|
|
805
|
+
if (super(), this.binaryType = He, 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) {
|
|
806
|
+
const s = U(e);
|
|
805
807
|
t.hostname = s.host, t.secure = s.protocol === "https" || s.protocol === "wss", t.port = s.port, s.query && (t.query = s.query);
|
|
806
|
-
} else t.host && (t.hostname =
|
|
807
|
-
|
|
808
|
+
} else t.host && (t.hostname = U(t.host).host);
|
|
809
|
+
x(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((s) => {
|
|
808
810
|
const i = s.prototype.name;
|
|
809
811
|
this.transports.push(i), this._transportsByName[i] = s;
|
|
810
812
|
}), this.opts = Object.assign({
|
|
@@ -821,13 +823,13 @@ class T extends l {
|
|
|
821
823
|
},
|
|
822
824
|
transportOptions: {},
|
|
823
825
|
closeOnBeforeunload: !1
|
|
824
|
-
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query =
|
|
826
|
+
}, t), this.opts.path = this.opts.path.replace(/\/$/, "") + (this.opts.addTrailingSlash ? "/" : ""), typeof this.opts.query == "string" && (this.opts.query = Xe(this.opts.query)), V && (this.opts.closeOnBeforeunload && (this._beforeunloadEventListener = () => {
|
|
825
827
|
this.transport && (this.transport.removeAllListeners(), this.transport.close());
|
|
826
828
|
}, addEventListener("beforeunload", this._beforeunloadEventListener, !1)), this.hostname !== "localhost" && (this._offlineEventListener = () => {
|
|
827
829
|
this._onClose("transport close", {
|
|
828
830
|
description: "network connection lost"
|
|
829
831
|
});
|
|
830
|
-
},
|
|
832
|
+
}, R.push(this._offlineEventListener))), this.opts.withCredentials && (this._cookieJar = void 0), this._open();
|
|
831
833
|
}
|
|
832
834
|
/**
|
|
833
835
|
* Creates transport of the given type.
|
|
@@ -838,7 +840,7 @@ class T extends l {
|
|
|
838
840
|
*/
|
|
839
841
|
createTransport(e) {
|
|
840
842
|
const t = Object.assign({}, this.opts.query);
|
|
841
|
-
t.EIO =
|
|
843
|
+
t.EIO = fe, t.transport = e, this.id && (t.sid = this.id);
|
|
842
844
|
const s = Object.assign({}, this.opts, {
|
|
843
845
|
query: t,
|
|
844
846
|
socket: this,
|
|
@@ -860,7 +862,7 @@ class T extends l {
|
|
|
860
862
|
}, 0);
|
|
861
863
|
return;
|
|
862
864
|
}
|
|
863
|
-
const e = this.opts.rememberUpgrade &&
|
|
865
|
+
const e = this.opts.rememberUpgrade && w.priorWebsocketSuccess && this.transports.indexOf("websocket") !== -1 ? "websocket" : this.transports[0];
|
|
864
866
|
this.readyState = "opening";
|
|
865
867
|
const t = this.createTransport(e);
|
|
866
868
|
t.open(), this.setTransport(t);
|
|
@@ -879,7 +881,7 @@ class T extends l {
|
|
|
879
881
|
* @private
|
|
880
882
|
*/
|
|
881
883
|
onOpen() {
|
|
882
|
-
this.readyState = "open",
|
|
884
|
+
this.readyState = "open", w.priorWebsocketSuccess = this.transport.name === "websocket", this.emitReserved("open"), this.flush();
|
|
883
885
|
}
|
|
884
886
|
/**
|
|
885
887
|
* Handles a packet.
|
|
@@ -956,7 +958,7 @@ class T extends l {
|
|
|
956
958
|
let t = 1;
|
|
957
959
|
for (let s = 0; s < this.writeBuffer.length; s++) {
|
|
958
960
|
const i = this.writeBuffer[s].data;
|
|
959
|
-
if (i && (t +=
|
|
961
|
+
if (i && (t += Ye(i)), s > 0 && t > this._maxPayload)
|
|
960
962
|
return this.writeBuffer.slice(0, s);
|
|
961
963
|
t += 2;
|
|
962
964
|
}
|
|
@@ -976,7 +978,7 @@ class T extends l {
|
|
|
976
978
|
if (!this._pingTimeoutTime)
|
|
977
979
|
return !0;
|
|
978
980
|
const e = Date.now() > this._pingTimeoutTime;
|
|
979
|
-
return e && (this._pingTimeoutTime = 0,
|
|
981
|
+
return e && (this._pingTimeoutTime = 0, N(() => {
|
|
980
982
|
this._onClose("ping timeout");
|
|
981
983
|
}, this.setTimeoutFn)), e;
|
|
982
984
|
}
|
|
@@ -1043,7 +1045,7 @@ class T extends l {
|
|
|
1043
1045
|
* @private
|
|
1044
1046
|
*/
|
|
1045
1047
|
_onError(e) {
|
|
1046
|
-
if (
|
|
1048
|
+
if (w.priorWebsocketSuccess = !1, this.opts.tryAllTransports && this.transports.length > 1 && this.readyState === "opening")
|
|
1047
1049
|
return this.transports.shift(), this._open();
|
|
1048
1050
|
this.emitReserved("error", e), this._onClose("transport error", e);
|
|
1049
1051
|
}
|
|
@@ -1054,16 +1056,16 @@ class T extends l {
|
|
|
1054
1056
|
*/
|
|
1055
1057
|
_onClose(e, t) {
|
|
1056
1058
|
if (this.readyState === "opening" || this.readyState === "open" || this.readyState === "closing") {
|
|
1057
|
-
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(),
|
|
1058
|
-
const s =
|
|
1059
|
-
s !== -1 &&
|
|
1059
|
+
if (this.clearTimeoutFn(this._pingTimeoutTimer), this.transport.removeAllListeners("close"), this.transport.close(), this.transport.removeAllListeners(), V && (this._beforeunloadEventListener && removeEventListener("beforeunload", this._beforeunloadEventListener, !1), this._offlineEventListener)) {
|
|
1060
|
+
const s = R.indexOf(this._offlineEventListener);
|
|
1061
|
+
s !== -1 && R.splice(s, 1);
|
|
1060
1062
|
}
|
|
1061
1063
|
this.readyState = "closed", this.id = null, this.emitReserved("close", e, t), this.writeBuffer = [], this._prevBufferLen = 0;
|
|
1062
1064
|
}
|
|
1063
1065
|
}
|
|
1064
1066
|
}
|
|
1065
|
-
|
|
1066
|
-
class
|
|
1067
|
+
w.protocol = fe;
|
|
1068
|
+
class ft extends w {
|
|
1067
1069
|
constructor() {
|
|
1068
1070
|
super(...arguments), this._upgrades = [];
|
|
1069
1071
|
}
|
|
@@ -1080,42 +1082,42 @@ class dt extends T {
|
|
|
1080
1082
|
*/
|
|
1081
1083
|
_probe(e) {
|
|
1082
1084
|
let t = this.createTransport(e), s = !1;
|
|
1083
|
-
|
|
1085
|
+
w.priorWebsocketSuccess = !1;
|
|
1084
1086
|
const i = () => {
|
|
1085
|
-
s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (
|
|
1087
|
+
s || (t.send([{ type: "ping", data: "probe" }]), t.once("packet", (d) => {
|
|
1086
1088
|
if (!s)
|
|
1087
|
-
if (
|
|
1089
|
+
if (d.type === "pong" && d.data === "probe") {
|
|
1088
1090
|
if (this.upgrading = !0, this.emitReserved("upgrading", t), !t)
|
|
1089
1091
|
return;
|
|
1090
|
-
|
|
1091
|
-
s || this.readyState !== "closed" && (
|
|
1092
|
+
w.priorWebsocketSuccess = t.name === "websocket", this.transport.pause(() => {
|
|
1093
|
+
s || this.readyState !== "closed" && (f(), this.setTransport(t), t.send([{ type: "upgrade" }]), this.emitReserved("upgrade", t), t = null, this.upgrading = !1, this.flush());
|
|
1092
1094
|
});
|
|
1093
1095
|
} else {
|
|
1094
|
-
const
|
|
1095
|
-
|
|
1096
|
+
const m = new Error("probe error");
|
|
1097
|
+
m.transport = t.name, this.emitReserved("upgradeError", m);
|
|
1096
1098
|
}
|
|
1097
1099
|
}));
|
|
1098
1100
|
};
|
|
1099
1101
|
function r() {
|
|
1100
|
-
s || (s = !0,
|
|
1102
|
+
s || (s = !0, f(), t.close(), t = null);
|
|
1101
1103
|
}
|
|
1102
|
-
const o = (
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1104
|
+
const o = (d) => {
|
|
1105
|
+
const m = new Error("probe error: " + d);
|
|
1106
|
+
m.transport = t.name, r(), this.emitReserved("upgradeError", m);
|
|
1105
1107
|
};
|
|
1106
|
-
function
|
|
1108
|
+
function c() {
|
|
1107
1109
|
o("transport closed");
|
|
1108
1110
|
}
|
|
1109
|
-
function
|
|
1111
|
+
function h() {
|
|
1110
1112
|
o("socket closed");
|
|
1111
1113
|
}
|
|
1112
|
-
function
|
|
1113
|
-
t &&
|
|
1114
|
+
function l(d) {
|
|
1115
|
+
t && d.name !== t.name && r();
|
|
1114
1116
|
}
|
|
1115
|
-
const
|
|
1116
|
-
t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close",
|
|
1117
|
+
const f = () => {
|
|
1118
|
+
t.removeListener("open", i), t.removeListener("error", o), t.removeListener("close", c), this.off("close", h), this.off("upgrading", l);
|
|
1117
1119
|
};
|
|
1118
|
-
t.once("open", i), t.once("error", o), t.once("close",
|
|
1120
|
+
t.once("open", i), t.once("error", o), t.once("close", c), this.once("close", h), this.once("upgrading", l), this._upgrades.indexOf("webtransport") !== -1 && e !== "webtransport" ? this.setTimeoutFn(() => {
|
|
1119
1121
|
s || t.open();
|
|
1120
1122
|
}, 200) : t.open();
|
|
1121
1123
|
}
|
|
@@ -1135,69 +1137,69 @@ class dt extends T {
|
|
|
1135
1137
|
return t;
|
|
1136
1138
|
}
|
|
1137
1139
|
}
|
|
1138
|
-
let
|
|
1140
|
+
let lt = class extends ft {
|
|
1139
1141
|
constructor(e, t = {}) {
|
|
1140
1142
|
const s = typeof e == "object", i = s ? { ...e } : { ...t };
|
|
1141
|
-
(!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) =>
|
|
1143
|
+
(!i.transports || i.transports && typeof i.transports[0] == "string") && (i.transports = (i.transports || ["polling", "websocket", "webtransport"]).map((r) => ot[r]).filter((r) => !!r)), super(s ? i : e, i);
|
|
1142
1144
|
}
|
|
1143
1145
|
};
|
|
1144
|
-
function
|
|
1146
|
+
function pt(n, e = "", t) {
|
|
1145
1147
|
let s = n;
|
|
1146
|
-
t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s =
|
|
1148
|
+
t = t || typeof location < "u" && location, n == null && (n = t.protocol + "//" + t.host), typeof n == "string" && (n.charAt(0) === "/" && (n.charAt(1) === "/" ? n = t.protocol + n : n = t.host + n), /^(https?|wss?):\/\//.test(n) || (typeof t < "u" ? n = t.protocol + "//" + n : n = "https://" + n), s = U(n)), s.port || (/^(http|ws)$/.test(s.protocol) ? s.port = "80" : /^(http|ws)s$/.test(s.protocol) && (s.port = "443")), s.path = s.path || "/";
|
|
1147
1149
|
const r = s.host.indexOf(":") !== -1 ? "[" + s.host + "]" : s.host;
|
|
1148
1150
|
return s.id = s.protocol + "://" + r + ":" + s.port + e, s.href = s.protocol + "://" + r + (t && t.port === s.port ? "" : ":" + s.port), s;
|
|
1149
1151
|
}
|
|
1150
|
-
const
|
|
1151
|
-
function
|
|
1152
|
-
return
|
|
1152
|
+
const dt = typeof ArrayBuffer == "function", yt = (n) => typeof ArrayBuffer.isView == "function" ? ArrayBuffer.isView(n) : n.buffer instanceof ArrayBuffer, ge = Object.prototype.toString, mt = typeof Blob == "function" || typeof Blob < "u" && ge.call(Blob) === "[object BlobConstructor]", gt = typeof File == "function" || typeof File < "u" && ge.call(File) === "[object FileConstructor]";
|
|
1153
|
+
function Y(n) {
|
|
1154
|
+
return dt && (n instanceof ArrayBuffer || yt(n)) || mt && n instanceof Blob || gt && n instanceof File;
|
|
1153
1155
|
}
|
|
1154
|
-
function
|
|
1156
|
+
function C(n, e) {
|
|
1155
1157
|
if (!n || typeof n != "object")
|
|
1156
1158
|
return !1;
|
|
1157
1159
|
if (Array.isArray(n)) {
|
|
1158
1160
|
for (let t = 0, s = n.length; t < s; t++)
|
|
1159
|
-
if (
|
|
1161
|
+
if (C(n[t]))
|
|
1160
1162
|
return !0;
|
|
1161
1163
|
return !1;
|
|
1162
1164
|
}
|
|
1163
|
-
if (
|
|
1165
|
+
if (Y(n))
|
|
1164
1166
|
return !0;
|
|
1165
1167
|
if (n.toJSON && typeof n.toJSON == "function" && arguments.length === 1)
|
|
1166
|
-
return
|
|
1168
|
+
return C(n.toJSON(), !0);
|
|
1167
1169
|
for (const t in n)
|
|
1168
|
-
if (Object.prototype.hasOwnProperty.call(n, t) &&
|
|
1170
|
+
if (Object.prototype.hasOwnProperty.call(n, t) && C(n[t]))
|
|
1169
1171
|
return !0;
|
|
1170
1172
|
return !1;
|
|
1171
1173
|
}
|
|
1172
|
-
function
|
|
1174
|
+
function _t(n) {
|
|
1173
1175
|
const e = [], t = n.data, s = n;
|
|
1174
|
-
return s.data =
|
|
1176
|
+
return s.data = S(t, e), s.attachments = e.length, { packet: s, buffers: e };
|
|
1175
1177
|
}
|
|
1176
|
-
function
|
|
1178
|
+
function S(n, e, t) {
|
|
1177
1179
|
if (!n)
|
|
1178
1180
|
return n;
|
|
1179
|
-
if (
|
|
1181
|
+
if (Y(n)) {
|
|
1180
1182
|
const s = { _placeholder: !0, num: e.length };
|
|
1181
1183
|
return e.push(n), s;
|
|
1182
1184
|
} else if (Array.isArray(n)) {
|
|
1183
1185
|
const s = new Array(n.length);
|
|
1184
1186
|
for (let i = 0; i < n.length; i++)
|
|
1185
|
-
s[i] =
|
|
1187
|
+
s[i] = S(n[i], e);
|
|
1186
1188
|
return s;
|
|
1187
1189
|
} else if (typeof n == "object" && !(n instanceof Date)) {
|
|
1188
1190
|
if (n.toJSON && typeof n.toJSON == "function" && !t)
|
|
1189
|
-
return
|
|
1191
|
+
return S(n.toJSON(), e, !0);
|
|
1190
1192
|
const s = {};
|
|
1191
1193
|
for (const i in n)
|
|
1192
|
-
Object.prototype.hasOwnProperty.call(n, i) && (s[i] =
|
|
1194
|
+
Object.prototype.hasOwnProperty.call(n, i) && (s[i] = S(n[i], e));
|
|
1193
1195
|
return s;
|
|
1194
1196
|
}
|
|
1195
1197
|
return n;
|
|
1196
1198
|
}
|
|
1197
|
-
function
|
|
1198
|
-
return n.data =
|
|
1199
|
+
function wt(n, e) {
|
|
1200
|
+
return n.data = M(n.data, e), delete n.attachments, n;
|
|
1199
1201
|
}
|
|
1200
|
-
function
|
|
1202
|
+
function M(n, e) {
|
|
1201
1203
|
if (!n)
|
|
1202
1204
|
return n;
|
|
1203
1205
|
if (n && n._placeholder === !0) {
|
|
@@ -1206,13 +1208,13 @@ function W(n, e) {
|
|
|
1206
1208
|
throw new Error("illegal attachments");
|
|
1207
1209
|
} else if (Array.isArray(n))
|
|
1208
1210
|
for (let t = 0; t < n.length; t++)
|
|
1209
|
-
n[t] =
|
|
1211
|
+
n[t] = M(n[t], e);
|
|
1210
1212
|
else if (typeof n == "object")
|
|
1211
1213
|
for (const t in n)
|
|
1212
|
-
Object.prototype.hasOwnProperty.call(n, t) && (n[t] =
|
|
1214
|
+
Object.prototype.hasOwnProperty.call(n, t) && (n[t] = M(n[t], e));
|
|
1213
1215
|
return n;
|
|
1214
1216
|
}
|
|
1215
|
-
const
|
|
1217
|
+
const bt = [
|
|
1216
1218
|
"connect",
|
|
1217
1219
|
// used on the client side
|
|
1218
1220
|
"connect_error",
|
|
@@ -1226,11 +1228,11 @@ const kt = [
|
|
|
1226
1228
|
"removeListener"
|
|
1227
1229
|
// used by the Node.js EventEmitter
|
|
1228
1230
|
];
|
|
1229
|
-
var
|
|
1231
|
+
var a;
|
|
1230
1232
|
(function(n) {
|
|
1231
1233
|
n[n.CONNECT = 0] = "CONNECT", n[n.DISCONNECT = 1] = "DISCONNECT", n[n.EVENT = 2] = "EVENT", n[n.ACK = 3] = "ACK", n[n.CONNECT_ERROR = 4] = "CONNECT_ERROR", n[n.BINARY_EVENT = 5] = "BINARY_EVENT", n[n.BINARY_ACK = 6] = "BINARY_ACK";
|
|
1232
|
-
})(
|
|
1233
|
-
class
|
|
1234
|
+
})(a || (a = {}));
|
|
1235
|
+
class vt {
|
|
1234
1236
|
/**
|
|
1235
1237
|
* Encoder constructor
|
|
1236
1238
|
*
|
|
@@ -1246,8 +1248,8 @@ class Tt {
|
|
|
1246
1248
|
* @param {Object} obj - packet object
|
|
1247
1249
|
*/
|
|
1248
1250
|
encode(e) {
|
|
1249
|
-
return (e.type ===
|
|
1250
|
-
type: e.type ===
|
|
1251
|
+
return (e.type === a.EVENT || e.type === a.ACK) && C(e) ? this.encodeAsBinary({
|
|
1252
|
+
type: e.type === a.EVENT ? a.BINARY_EVENT : a.BINARY_ACK,
|
|
1251
1253
|
nsp: e.nsp,
|
|
1252
1254
|
data: e.data,
|
|
1253
1255
|
id: e.id
|
|
@@ -1258,7 +1260,7 @@ class Tt {
|
|
|
1258
1260
|
*/
|
|
1259
1261
|
encodeAsString(e) {
|
|
1260
1262
|
let t = "" + e.type;
|
|
1261
|
-
return (e.type ===
|
|
1263
|
+
return (e.type === a.BINARY_EVENT || e.type === a.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;
|
|
1262
1264
|
}
|
|
1263
1265
|
/**
|
|
1264
1266
|
* Encode packet as 'buffer sequence' by removing blobs, and
|
|
@@ -1266,11 +1268,11 @@ class Tt {
|
|
|
1266
1268
|
* a list of buffers.
|
|
1267
1269
|
*/
|
|
1268
1270
|
encodeAsBinary(e) {
|
|
1269
|
-
const t =
|
|
1271
|
+
const t = _t(e), s = this.encodeAsString(t.packet), i = t.buffers;
|
|
1270
1272
|
return i.unshift(s), i;
|
|
1271
1273
|
}
|
|
1272
1274
|
}
|
|
1273
|
-
class
|
|
1275
|
+
class z extends u {
|
|
1274
1276
|
/**
|
|
1275
1277
|
* Decoder constructor
|
|
1276
1278
|
*/
|
|
@@ -1291,9 +1293,9 @@ class j extends l {
|
|
|
1291
1293
|
if (this.reconstructor)
|
|
1292
1294
|
throw new Error("got plaintext data when reconstructing a packet");
|
|
1293
1295
|
t = this.decodeString(e);
|
|
1294
|
-
const s = t.type ===
|
|
1295
|
-
s || t.type ===
|
|
1296
|
-
} else if (
|
|
1296
|
+
const s = t.type === a.BINARY_EVENT;
|
|
1297
|
+
s || t.type === a.BINARY_ACK ? (t.type = s ? a.EVENT : a.ACK, this.reconstructor = new Et(t)) : super.emitReserved("decoded", t);
|
|
1298
|
+
} else if (Y(e) || e.base64)
|
|
1297
1299
|
if (this.reconstructor)
|
|
1298
1300
|
t = this.reconstructor.takeBinaryData(e), t && (this.reconstructor = null, super.emitReserved("decoded", t));
|
|
1299
1301
|
else
|
|
@@ -1312,21 +1314,21 @@ class j extends l {
|
|
|
1312
1314
|
const s = {
|
|
1313
1315
|
type: Number(e.charAt(0))
|
|
1314
1316
|
};
|
|
1315
|
-
if (
|
|
1317
|
+
if (a[s.type] === void 0)
|
|
1316
1318
|
throw new Error("unknown packet type " + s.type);
|
|
1317
|
-
if (s.type ===
|
|
1319
|
+
if (s.type === a.BINARY_EVENT || s.type === a.BINARY_ACK) {
|
|
1318
1320
|
const r = t + 1;
|
|
1319
1321
|
for (; e.charAt(++t) !== "-" && t != e.length; )
|
|
1320
1322
|
;
|
|
1321
1323
|
const o = e.substring(r, t);
|
|
1322
1324
|
if (o != Number(o) || e.charAt(t) !== "-")
|
|
1323
1325
|
throw new Error("Illegal attachments");
|
|
1324
|
-
const
|
|
1325
|
-
if (!
|
|
1326
|
+
const c = Number(o);
|
|
1327
|
+
if (!kt(c) || c < 1)
|
|
1326
1328
|
throw new Error("Illegal attachments");
|
|
1327
|
-
if (
|
|
1329
|
+
if (c > this.opts.maxAttachments)
|
|
1328
1330
|
throw new Error("too many attachments");
|
|
1329
|
-
s.attachments =
|
|
1331
|
+
s.attachments = c;
|
|
1330
1332
|
}
|
|
1331
1333
|
if (e.charAt(t + 1) === "/") {
|
|
1332
1334
|
const r = t + 1;
|
|
@@ -1351,7 +1353,7 @@ class j extends l {
|
|
|
1351
1353
|
}
|
|
1352
1354
|
if (e.charAt(++t)) {
|
|
1353
1355
|
const r = this.tryParse(e.substr(t));
|
|
1354
|
-
if (
|
|
1356
|
+
if (z.isPayloadValid(s.type, r))
|
|
1355
1357
|
s.data = r;
|
|
1356
1358
|
else
|
|
1357
1359
|
throw new Error("invalid payload");
|
|
@@ -1367,17 +1369,17 @@ class j extends l {
|
|
|
1367
1369
|
}
|
|
1368
1370
|
static isPayloadValid(e, t) {
|
|
1369
1371
|
switch (e) {
|
|
1370
|
-
case
|
|
1371
|
-
return
|
|
1372
|
-
case
|
|
1372
|
+
case a.CONNECT:
|
|
1373
|
+
return re(t);
|
|
1374
|
+
case a.DISCONNECT:
|
|
1373
1375
|
return t === void 0;
|
|
1374
|
-
case
|
|
1375
|
-
return typeof t == "string" ||
|
|
1376
|
-
case
|
|
1377
|
-
case
|
|
1378
|
-
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" &&
|
|
1379
|
-
case
|
|
1380
|
-
case
|
|
1376
|
+
case a.CONNECT_ERROR:
|
|
1377
|
+
return typeof t == "string" || re(t);
|
|
1378
|
+
case a.EVENT:
|
|
1379
|
+
case a.BINARY_EVENT:
|
|
1380
|
+
return Array.isArray(t) && (typeof t[0] == "number" || typeof t[0] == "string" && bt.indexOf(t[0]) === -1);
|
|
1381
|
+
case a.ACK:
|
|
1382
|
+
case a.BINARY_ACK:
|
|
1381
1383
|
return Array.isArray(t);
|
|
1382
1384
|
}
|
|
1383
1385
|
}
|
|
@@ -1388,7 +1390,7 @@ class j extends l {
|
|
|
1388
1390
|
this.reconstructor && (this.reconstructor.finishedReconstruction(), this.reconstructor = null);
|
|
1389
1391
|
}
|
|
1390
1392
|
}
|
|
1391
|
-
class
|
|
1393
|
+
class Et {
|
|
1392
1394
|
constructor(e) {
|
|
1393
1395
|
this.packet = e, this.buffers = [], this.reconPack = e;
|
|
1394
1396
|
}
|
|
@@ -1402,7 +1404,7 @@ class At {
|
|
|
1402
1404
|
*/
|
|
1403
1405
|
takeBinaryData(e) {
|
|
1404
1406
|
if (this.buffers.push(e), this.buffers.length === this.reconPack.attachments) {
|
|
1405
|
-
const t =
|
|
1407
|
+
const t = wt(this.reconPack, this.buffers);
|
|
1406
1408
|
return this.finishedReconstruction(), t;
|
|
1407
1409
|
}
|
|
1408
1410
|
return null;
|
|
@@ -1414,26 +1416,26 @@ class At {
|
|
|
1414
1416
|
this.reconPack = null, this.buffers = [];
|
|
1415
1417
|
}
|
|
1416
1418
|
}
|
|
1417
|
-
const
|
|
1419
|
+
const kt = Number.isInteger || function(n) {
|
|
1418
1420
|
return typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
1419
1421
|
};
|
|
1420
|
-
function
|
|
1422
|
+
function re(n) {
|
|
1421
1423
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
1422
1424
|
}
|
|
1423
|
-
const
|
|
1425
|
+
const Tt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
1424
1426
|
__proto__: null,
|
|
1425
|
-
Decoder:
|
|
1426
|
-
Encoder:
|
|
1427
|
+
Decoder: z,
|
|
1428
|
+
Encoder: vt,
|
|
1427
1429
|
get PacketType() {
|
|
1428
|
-
return
|
|
1430
|
+
return a;
|
|
1429
1431
|
}
|
|
1430
1432
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
1431
|
-
function
|
|
1433
|
+
function y(n, e, t) {
|
|
1432
1434
|
return n.on(e, t), function() {
|
|
1433
1435
|
n.off(e, t);
|
|
1434
1436
|
};
|
|
1435
1437
|
}
|
|
1436
|
-
const
|
|
1438
|
+
const At = Object.freeze({
|
|
1437
1439
|
connect: 1,
|
|
1438
1440
|
connect_error: 1,
|
|
1439
1441
|
disconnect: 1,
|
|
@@ -1442,7 +1444,7 @@ const St = Object.freeze({
|
|
|
1442
1444
|
newListener: 1,
|
|
1443
1445
|
removeListener: 1
|
|
1444
1446
|
});
|
|
1445
|
-
class
|
|
1447
|
+
class _e extends u {
|
|
1446
1448
|
/**
|
|
1447
1449
|
* `Socket` constructor.
|
|
1448
1450
|
*/
|
|
@@ -1476,10 +1478,10 @@ class we extends l {
|
|
|
1476
1478
|
return;
|
|
1477
1479
|
const e = this.io;
|
|
1478
1480
|
this.subs = [
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1481
|
+
y(e, "open", this.onopen.bind(this)),
|
|
1482
|
+
y(e, "packet", this.onpacket.bind(this)),
|
|
1483
|
+
y(e, "error", this.onerror.bind(this)),
|
|
1484
|
+
y(e, "close", this.onclose.bind(this))
|
|
1483
1485
|
];
|
|
1484
1486
|
}
|
|
1485
1487
|
/**
|
|
@@ -1558,20 +1560,20 @@ class we extends l {
|
|
|
1558
1560
|
*/
|
|
1559
1561
|
emit(e, ...t) {
|
|
1560
1562
|
var s, i, r;
|
|
1561
|
-
if (
|
|
1563
|
+
if (At.hasOwnProperty(e))
|
|
1562
1564
|
throw new Error('"' + e.toString() + '" is a reserved event name');
|
|
1563
1565
|
if (t.unshift(e), this._opts.retries && !this.flags.fromQueue && !this.flags.volatile)
|
|
1564
1566
|
return this._addToQueue(t), this;
|
|
1565
1567
|
const o = {
|
|
1566
|
-
type:
|
|
1568
|
+
type: a.EVENT,
|
|
1567
1569
|
data: t
|
|
1568
1570
|
};
|
|
1569
1571
|
if (o.options = {}, o.options.compress = this.flags.compress !== !1, typeof t[t.length - 1] == "function") {
|
|
1570
|
-
const
|
|
1571
|
-
this._registerAckCallback(
|
|
1572
|
+
const f = this.ids++, d = t.pop();
|
|
1573
|
+
this._registerAckCallback(f, d), o.id = f;
|
|
1572
1574
|
}
|
|
1573
|
-
const
|
|
1574
|
-
return this.flags.volatile && !
|
|
1575
|
+
const c = (i = (s = this.io.engine) === null || s === void 0 ? void 0 : s.transport) === null || i === void 0 ? void 0 : i.writable, h = this.connected && !(!((r = this.io.engine) === null || r === void 0) && r._hasPingExpired());
|
|
1576
|
+
return this.flags.volatile && !c || (h ? (this.notifyOutgoingListeners(o), this.packet(o)) : this.sendBuffer.push(o)), this.flags = {}, this;
|
|
1575
1577
|
}
|
|
1576
1578
|
/**
|
|
1577
1579
|
* @private
|
|
@@ -1585,11 +1587,11 @@ class we extends l {
|
|
|
1585
1587
|
}
|
|
1586
1588
|
const r = this.io.setTimeoutFn(() => {
|
|
1587
1589
|
delete this.acks[e];
|
|
1588
|
-
for (let
|
|
1589
|
-
this.sendBuffer[
|
|
1590
|
+
for (let c = 0; c < this.sendBuffer.length; c++)
|
|
1591
|
+
this.sendBuffer[c].id === e && this.sendBuffer.splice(c, 1);
|
|
1590
1592
|
t.call(this, new Error("operation has timed out"));
|
|
1591
|
-
}, i), o = (...
|
|
1592
|
-
this.io.clearTimeoutFn(r), t.apply(this,
|
|
1593
|
+
}, i), o = (...c) => {
|
|
1594
|
+
this.io.clearTimeoutFn(r), t.apply(this, c);
|
|
1593
1595
|
};
|
|
1594
1596
|
o.withError = !0, this.acks[e] = o;
|
|
1595
1597
|
}
|
|
@@ -1611,7 +1613,7 @@ class we extends l {
|
|
|
1611
1613
|
*/
|
|
1612
1614
|
emitWithAck(e, ...t) {
|
|
1613
1615
|
return new Promise((s, i) => {
|
|
1614
|
-
const r = (o,
|
|
1616
|
+
const r = (o, c) => o ? i(o) : s(c);
|
|
1615
1617
|
r.withError = !0, t.push(r), this.emit(e, ...t);
|
|
1616
1618
|
});
|
|
1617
1619
|
}
|
|
@@ -1671,7 +1673,7 @@ class we extends l {
|
|
|
1671
1673
|
*/
|
|
1672
1674
|
_sendConnectPacket(e) {
|
|
1673
1675
|
this.packet({
|
|
1674
|
-
type:
|
|
1676
|
+
type: a.CONNECT,
|
|
1675
1677
|
data: this._pid ? Object.assign({ pid: this._pid, offset: this._lastOffset }, e) : e
|
|
1676
1678
|
});
|
|
1677
1679
|
}
|
|
@@ -1717,21 +1719,21 @@ class we extends l {
|
|
|
1717
1719
|
onpacket(e) {
|
|
1718
1720
|
if (e.nsp === this.nsp)
|
|
1719
1721
|
switch (e.type) {
|
|
1720
|
-
case
|
|
1722
|
+
case a.CONNECT:
|
|
1721
1723
|
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/)"));
|
|
1722
1724
|
break;
|
|
1723
|
-
case
|
|
1724
|
-
case
|
|
1725
|
+
case a.EVENT:
|
|
1726
|
+
case a.BINARY_EVENT:
|
|
1725
1727
|
this.onevent(e);
|
|
1726
1728
|
break;
|
|
1727
|
-
case
|
|
1728
|
-
case
|
|
1729
|
+
case a.ACK:
|
|
1730
|
+
case a.BINARY_ACK:
|
|
1729
1731
|
this.onack(e);
|
|
1730
1732
|
break;
|
|
1731
|
-
case
|
|
1733
|
+
case a.DISCONNECT:
|
|
1732
1734
|
this.ondisconnect();
|
|
1733
1735
|
break;
|
|
1734
|
-
case
|
|
1736
|
+
case a.CONNECT_ERROR:
|
|
1735
1737
|
this.destroy();
|
|
1736
1738
|
const s = new Error(e.data.message);
|
|
1737
1739
|
s.data = e.data.data, this.emitReserved("connect_error", s);
|
|
@@ -1766,7 +1768,7 @@ class we extends l {
|
|
|
1766
1768
|
let s = !1;
|
|
1767
1769
|
return function(...i) {
|
|
1768
1770
|
s || (s = !0, t.packet({
|
|
1769
|
-
type:
|
|
1771
|
+
type: a.ACK,
|
|
1770
1772
|
id: e,
|
|
1771
1773
|
data: i
|
|
1772
1774
|
}));
|
|
@@ -1835,7 +1837,7 @@ class we extends l {
|
|
|
1835
1837
|
* @return self
|
|
1836
1838
|
*/
|
|
1837
1839
|
disconnect() {
|
|
1838
|
-
return this.connected && this.packet({ type:
|
|
1840
|
+
return this.connected && this.packet({ type: a.DISCONNECT }), this.destroy(), this.connected && this.onclose("io client disconnect"), this;
|
|
1839
1841
|
}
|
|
1840
1842
|
/**
|
|
1841
1843
|
* Alias for {@link disconnect()}.
|
|
@@ -2034,10 +2036,10 @@ class we extends l {
|
|
|
2034
2036
|
}
|
|
2035
2037
|
}
|
|
2036
2038
|
}
|
|
2037
|
-
function
|
|
2039
|
+
function b(n) {
|
|
2038
2040
|
n = n || {}, this.ms = n.min || 100, this.max = n.max || 1e4, this.factor = n.factor || 2, this.jitter = n.jitter > 0 && n.jitter <= 1 ? n.jitter : 0, this.attempts = 0;
|
|
2039
2041
|
}
|
|
2040
|
-
|
|
2042
|
+
b.prototype.duration = function() {
|
|
2041
2043
|
var n = this.ms * Math.pow(this.factor, this.attempts++);
|
|
2042
2044
|
if (this.jitter) {
|
|
2043
2045
|
var e = Math.random(), t = Math.floor(e * this.jitter * n);
|
|
@@ -2045,27 +2047,27 @@ R.prototype.duration = function() {
|
|
|
2045
2047
|
}
|
|
2046
2048
|
return Math.min(n, this.max) | 0;
|
|
2047
2049
|
};
|
|
2048
|
-
|
|
2050
|
+
b.prototype.reset = function() {
|
|
2049
2051
|
this.attempts = 0;
|
|
2050
2052
|
};
|
|
2051
|
-
|
|
2053
|
+
b.prototype.setMin = function(n) {
|
|
2052
2054
|
this.ms = n;
|
|
2053
2055
|
};
|
|
2054
|
-
|
|
2056
|
+
b.prototype.setMax = function(n) {
|
|
2055
2057
|
this.max = n;
|
|
2056
2058
|
};
|
|
2057
|
-
|
|
2059
|
+
b.prototype.setJitter = function(n) {
|
|
2058
2060
|
this.jitter = n;
|
|
2059
2061
|
};
|
|
2060
|
-
class
|
|
2062
|
+
class H extends u {
|
|
2061
2063
|
constructor(e, t) {
|
|
2062
2064
|
var s;
|
|
2063
|
-
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,
|
|
2065
|
+
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, x(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((s = t.randomizationFactor) !== null && s !== void 0 ? s : 0.5), this.backoff = new b({
|
|
2064
2066
|
min: this.reconnectionDelay(),
|
|
2065
2067
|
max: this.reconnectionDelayMax(),
|
|
2066
2068
|
jitter: this.randomizationFactor()
|
|
2067
2069
|
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
2068
|
-
const i = t.parser ||
|
|
2070
|
+
const i = t.parser || Tt;
|
|
2069
2071
|
this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
2070
2072
|
}
|
|
2071
2073
|
reconnection(e) {
|
|
@@ -2108,20 +2110,20 @@ class Y extends l {
|
|
|
2108
2110
|
open(e) {
|
|
2109
2111
|
if (~this._readyState.indexOf("open"))
|
|
2110
2112
|
return this;
|
|
2111
|
-
this.engine = new
|
|
2113
|
+
this.engine = new lt(this.uri, this.opts);
|
|
2112
2114
|
const t = this.engine, s = this;
|
|
2113
2115
|
this._readyState = "opening", this.skipReconnect = !1;
|
|
2114
|
-
const i =
|
|
2116
|
+
const i = y(t, "open", function() {
|
|
2115
2117
|
s.onopen(), e && e();
|
|
2116
|
-
}), r = (
|
|
2117
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error",
|
|
2118
|
-
}, o =
|
|
2118
|
+
}), r = (c) => {
|
|
2119
|
+
this.cleanup(), this._readyState = "closed", this.emitReserved("error", c), e ? e(c) : this.maybeReconnectOnOpen();
|
|
2120
|
+
}, o = y(t, "error", r);
|
|
2119
2121
|
if (this._timeout !== !1) {
|
|
2120
|
-
const
|
|
2122
|
+
const c = this._timeout, h = this.setTimeoutFn(() => {
|
|
2121
2123
|
i(), r(new Error("timeout")), t.close();
|
|
2122
|
-
},
|
|
2123
|
-
this.opts.autoUnref &&
|
|
2124
|
-
this.clearTimeoutFn(
|
|
2124
|
+
}, c);
|
|
2125
|
+
this.opts.autoUnref && h.unref(), this.subs.push(() => {
|
|
2126
|
+
this.clearTimeoutFn(h);
|
|
2125
2127
|
});
|
|
2126
2128
|
}
|
|
2127
2129
|
return this.subs.push(i), this.subs.push(o), this;
|
|
@@ -2144,12 +2146,12 @@ class Y extends l {
|
|
|
2144
2146
|
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
2145
2147
|
const e = this.engine;
|
|
2146
2148
|
this.subs.push(
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2149
|
+
y(e, "ping", this.onping.bind(this)),
|
|
2150
|
+
y(e, "data", this.ondata.bind(this)),
|
|
2151
|
+
y(e, "error", this.onerror.bind(this)),
|
|
2152
|
+
y(e, "close", this.onclose.bind(this)),
|
|
2151
2153
|
// @ts-ignore
|
|
2152
|
-
|
|
2154
|
+
y(this.decoder, "decoded", this.ondecoded.bind(this))
|
|
2153
2155
|
);
|
|
2154
2156
|
}
|
|
2155
2157
|
/**
|
|
@@ -2178,7 +2180,7 @@ class Y extends l {
|
|
|
2178
2180
|
* @private
|
|
2179
2181
|
*/
|
|
2180
2182
|
ondecoded(e) {
|
|
2181
|
-
|
|
2183
|
+
N(() => {
|
|
2182
2184
|
this.emitReserved("packet", e);
|
|
2183
2185
|
}, this.setTimeoutFn);
|
|
2184
2186
|
}
|
|
@@ -2198,7 +2200,7 @@ class Y extends l {
|
|
|
2198
2200
|
*/
|
|
2199
2201
|
socket(e, t) {
|
|
2200
2202
|
let s = this.nsps[e];
|
|
2201
|
-
return s ? this._autoConnect && !s.active && s.connect() : (s = new
|
|
2203
|
+
return s ? this._autoConnect && !s.active && s.connect() : (s = new _e(this, e, t), this.nsps[e] = s), s;
|
|
2202
2204
|
}
|
|
2203
2205
|
/**
|
|
2204
2206
|
* Called upon a socket close.
|
|
@@ -2295,170 +2297,103 @@ class Y extends l {
|
|
|
2295
2297
|
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
2296
2298
|
}
|
|
2297
2299
|
}
|
|
2298
|
-
const
|
|
2299
|
-
function
|
|
2300
|
+
const E = {};
|
|
2301
|
+
function B(n, e) {
|
|
2300
2302
|
typeof n == "object" && (e = n, n = void 0), e = e || {};
|
|
2301
|
-
const t =
|
|
2302
|
-
let
|
|
2303
|
-
return
|
|
2303
|
+
const t = pt(n, e.path || "/socket.io"), s = t.source, i = t.id, r = t.path, o = E[i] && r in E[i].nsps, c = e.forceNew || e["force new connection"] || e.multiplex === !1 || o;
|
|
2304
|
+
let h;
|
|
2305
|
+
return c ? h = new H(s, e) : (E[i] || (E[i] = new H(s, e)), h = E[i]), t.query && !e.query && (e.query = t.queryKey), h.socket(t.path, e);
|
|
2304
2306
|
}
|
|
2305
|
-
Object.assign(
|
|
2306
|
-
Manager:
|
|
2307
|
-
Socket:
|
|
2308
|
-
io:
|
|
2309
|
-
connect:
|
|
2307
|
+
Object.assign(B, {
|
|
2308
|
+
Manager: H,
|
|
2309
|
+
Socket: _e,
|
|
2310
|
+
io: B,
|
|
2311
|
+
connect: B
|
|
2310
2312
|
});
|
|
2311
|
-
const
|
|
2313
|
+
const we = Ee(
|
|
2314
|
+
void 0
|
|
2315
|
+
), Ot = (n) => async () => {
|
|
2316
|
+
const t = await (n == null ? void 0 : n.get()) ?? localStorage.getItem("authToken");
|
|
2317
|
+
return {
|
|
2318
|
+
"Content-Type": "application/json",
|
|
2319
|
+
...t ? { Authorization: `Bearer ${t}` } : {}
|
|
2320
|
+
};
|
|
2321
|
+
}, Pt = ({
|
|
2312
2322
|
apiUrl: n,
|
|
2313
2323
|
adminApiUrl: e,
|
|
2314
2324
|
children: t
|
|
2315
2325
|
}) => {
|
|
2316
|
-
|
|
2317
|
-
|
|
2326
|
+
var Z;
|
|
2327
|
+
const s = (Z = Se().user) == null ? void 0 : Z.id, i = P(
|
|
2328
|
+
() => e ? Ae({ url: Oe(e) }) : null,
|
|
2318
2329
|
[e]
|
|
2319
|
-
),
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
}
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
try {
|
|
2329
|
-
const g = await fetch(
|
|
2330
|
-
`${n}/notifications?recipientId=${s.id}&page=${u}&limit=${p}&folder=${f}`,
|
|
2331
|
-
{ headers: await A() }
|
|
2332
|
-
);
|
|
2333
|
-
if (g.ok) {
|
|
2334
|
-
const k = await g.json();
|
|
2335
|
-
if (o(k), f === "inbox") {
|
|
2336
|
-
const Re = k.filter((Oe) => !Oe.isRead).length;
|
|
2337
|
-
c(Re);
|
|
2338
|
-
}
|
|
2339
|
-
}
|
|
2340
|
-
} catch (g) {
|
|
2341
|
-
console.error("Failed to fetch notifications:", g);
|
|
2342
|
-
} finally {
|
|
2343
|
-
v(!1);
|
|
2344
|
-
}
|
|
2345
|
-
}
|
|
2346
|
-
}, Ee = async (f) => {
|
|
2347
|
-
try {
|
|
2348
|
-
(await fetch(`${n}/notifications/${f}/read`, {
|
|
2349
|
-
method: "PATCH",
|
|
2350
|
-
headers: await A()
|
|
2351
|
-
})).ok && (o(
|
|
2352
|
-
(p) => p.map((g) => g.id === f ? { ...g, isRead: !0 } : g)
|
|
2353
|
-
), c((p) => Math.max(0, p - 1)));
|
|
2354
|
-
} catch (u) {
|
|
2355
|
-
console.error("Failed to mark notification as read:", u);
|
|
2356
|
-
}
|
|
2357
|
-
}, ve = async () => {
|
|
2358
|
-
if (s)
|
|
2359
|
-
try {
|
|
2360
|
-
(await fetch(`${n}/notifications/read-all?recipientId=${s.id}`, {
|
|
2361
|
-
method: "PATCH",
|
|
2362
|
-
headers: await A()
|
|
2363
|
-
})).ok && (o((u) => u.map((p) => ({ ...p, isRead: !0 }))), c(0));
|
|
2364
|
-
} catch (f) {
|
|
2365
|
-
console.error("Failed to mark all notifications as read:", f);
|
|
2366
|
-
}
|
|
2367
|
-
}, ke = async () => {
|
|
2368
|
-
if (s)
|
|
2369
|
-
try {
|
|
2370
|
-
(await fetch(`${n}/notifications/trash?recipientId=${s.id}`, {
|
|
2371
|
-
method: "DELETE",
|
|
2372
|
-
headers: await A()
|
|
2373
|
-
})).ok && o([]);
|
|
2374
|
-
} catch (f) {
|
|
2375
|
-
console.error("Failed to empty trash:", f);
|
|
2376
|
-
}
|
|
2377
|
-
}, Te = async (f) => {
|
|
2378
|
-
try {
|
|
2379
|
-
(await fetch(`${n}/notifications/${f}`, {
|
|
2380
|
-
method: "DELETE",
|
|
2381
|
-
headers: await A()
|
|
2382
|
-
})).ok && o((p) => {
|
|
2383
|
-
const g = p.find((k) => k.id === f);
|
|
2384
|
-
return g && !g.isRead && c((k) => Math.max(0, k - 1)), p.filter((k) => k.id !== f);
|
|
2385
|
-
});
|
|
2386
|
-
} catch (u) {
|
|
2387
|
-
console.error("Failed to delete notification:", u);
|
|
2388
|
-
}
|
|
2389
|
-
}, te = async () => {
|
|
2390
|
-
if (s)
|
|
2391
|
-
try {
|
|
2392
|
-
const f = await fetch(`${n}/notifications/preferences?recipientId=${s.id}`, {
|
|
2393
|
-
headers: await A()
|
|
2394
|
-
});
|
|
2395
|
-
if (f.ok) {
|
|
2396
|
-
const u = await f.json();
|
|
2397
|
-
d(u);
|
|
2398
|
-
}
|
|
2399
|
-
} catch (f) {
|
|
2400
|
-
console.error("Failed to fetch preferences:", f);
|
|
2401
|
-
}
|
|
2402
|
-
}, Ae = async (f) => {
|
|
2403
|
-
if (s)
|
|
2404
|
-
try {
|
|
2405
|
-
const u = await fetch(`${n}/notifications/preferences?recipientId=${s.id}`, {
|
|
2406
|
-
method: "PATCH",
|
|
2407
|
-
headers: await A(),
|
|
2408
|
-
body: JSON.stringify(f)
|
|
2409
|
-
});
|
|
2410
|
-
if (u.ok) {
|
|
2411
|
-
const p = await u.json();
|
|
2412
|
-
d(p);
|
|
2413
|
-
}
|
|
2414
|
-
} catch (u) {
|
|
2415
|
-
console.error("Failed to update preferences:", u);
|
|
2416
|
-
}
|
|
2417
|
-
};
|
|
2418
|
-
return xe(() => {
|
|
2330
|
+
), r = P(
|
|
2331
|
+
() => s ? Re({
|
|
2332
|
+
apiUrl: n,
|
|
2333
|
+
recipientId: s,
|
|
2334
|
+
getHeaders: Ot(i)
|
|
2335
|
+
}) : null,
|
|
2336
|
+
[n, s, i]
|
|
2337
|
+
), o = Be(r), c = Ne({ api: r, ...o }), { preferences: h, fetchPreferences: l, updatePreferences: f, clearPreferences: d } = xe(r), { fetchNotifications: m, receive: J, clear: X } = o;
|
|
2338
|
+
ke(() => {
|
|
2419
2339
|
if (!s) {
|
|
2420
|
-
i == null || i.clear(),
|
|
2340
|
+
i == null || i.clear(), X(), d();
|
|
2421
2341
|
return;
|
|
2422
2342
|
}
|
|
2423
|
-
const
|
|
2424
|
-
auth: (
|
|
2343
|
+
const ee = B(n, {
|
|
2344
|
+
auth: (L) => {
|
|
2425
2345
|
((i == null ? void 0 : i.get()) ?? Promise.resolve(null)).then(
|
|
2426
|
-
(
|
|
2346
|
+
(v) => L(v ? { token: v } : {})
|
|
2427
2347
|
);
|
|
2428
2348
|
},
|
|
2429
|
-
query: { userId: s
|
|
2349
|
+
query: { userId: s },
|
|
2430
2350
|
transports: ["websocket"]
|
|
2431
2351
|
});
|
|
2432
|
-
return
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
f.disconnect();
|
|
2352
|
+
return ee.on("notification", (L) => {
|
|
2353
|
+
const v = Ce(L);
|
|
2354
|
+
v && J(v);
|
|
2355
|
+
}), m("inbox"), l(), () => {
|
|
2356
|
+
ee.disconnect();
|
|
2438
2357
|
};
|
|
2439
|
-
}, [
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2358
|
+
}, [
|
|
2359
|
+
s,
|
|
2360
|
+
n,
|
|
2361
|
+
i,
|
|
2362
|
+
m,
|
|
2363
|
+
l,
|
|
2364
|
+
J,
|
|
2365
|
+
X,
|
|
2366
|
+
d
|
|
2367
|
+
]);
|
|
2368
|
+
const { notifications: Q, unreadCount: j, isLoading: G } = o, be = P(
|
|
2369
|
+
() => ({
|
|
2370
|
+
notifications: Q,
|
|
2371
|
+
unreadCount: j,
|
|
2372
|
+
preferences: h,
|
|
2373
|
+
isLoading: G,
|
|
2374
|
+
fetchNotifications: m,
|
|
2375
|
+
...c,
|
|
2376
|
+
fetchPreferences: l,
|
|
2377
|
+
updatePreferences: f
|
|
2378
|
+
}),
|
|
2379
|
+
[
|
|
2380
|
+
Q,
|
|
2381
|
+
j,
|
|
2382
|
+
h,
|
|
2383
|
+
G,
|
|
2384
|
+
m,
|
|
2385
|
+
c,
|
|
2386
|
+
l,
|
|
2387
|
+
f
|
|
2388
|
+
]
|
|
2457
2389
|
);
|
|
2390
|
+
return /* @__PURE__ */ ve(we.Provider, { value: be, children: t });
|
|
2458
2391
|
}, qt = () => {
|
|
2459
|
-
const n =
|
|
2392
|
+
const n = Te(we);
|
|
2460
2393
|
if (n === void 0)
|
|
2461
|
-
throw new Error(
|
|
2394
|
+
throw new Error(
|
|
2395
|
+
"useNotifications must be used within a NotificationProvider"
|
|
2396
|
+
);
|
|
2462
2397
|
return n;
|
|
2463
2398
|
};
|
|
2464
2399
|
export {
|