@glodon-aiot/agent-cli-sdk 2.4.7 → 3.0.4
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 +128 -41
- package/dist/agent-cli-sdk.js +28505 -30335
- package/dist/agent-cli-sdk.umd.cjs +113 -123
- package/dist/src/AgentSession.d.ts +4 -3
- package/dist/src/BotClient.d.ts +7 -5
- package/dist/src/DialogSession.d.ts +4 -3
- package/dist/src/Session.d.ts +70 -16
- package/dist/src/api/fetchEventSource/fetch.d.ts +1 -1
- package/dist/src/api/fetchEventSource/index.d.ts +1 -1
- package/package.json +13 -22
- package/dist/cdn/agent-cli-sdk.js +0 -32945
- package/dist/cdn/agent-cli-sdk.umd.cjs +0 -140
- package/dist/cdn/src/AgentPlugin.d.ts +0 -17
- package/dist/cdn/src/AgentSession.d.ts +0 -8
- package/dist/cdn/src/BotClient.d.ts +0 -46
- package/dist/cdn/src/Config.d.ts +0 -32
- package/dist/cdn/src/DialogSession.d.ts +0 -21
- package/dist/cdn/src/EventBus.d.ts +0 -23
- package/dist/cdn/src/Logger.d.ts +0 -12
- package/dist/cdn/src/PayloadTypes.d.ts +0 -84
- package/dist/cdn/src/Session.d.ts +0 -156
- package/dist/cdn/src/__ tests __/AgentClient.spec.d.ts +0 -1
- package/dist/cdn/src/__ tests __/AgentSession.spec.d.ts +0 -1
- package/dist/cdn/src/__ tests __/DialogClient.spec.d.ts +0 -1
- package/dist/cdn/src/api/fetchEventSource/fetch.d.ts +0 -44
- package/dist/cdn/src/api/fetchEventSource/index.d.ts +0 -1
- package/dist/cdn/src/api/fetchEventSource/parse.d.ts +0 -36
- package/dist/cdn/src/api/index.d.ts +0 -2
- package/dist/cdn/src/index.d.ts +0 -5
- package/dist/cdn/src/utils.d.ts +0 -4
- package/dist/es/AgentPlugin.mjs +0 -20
- package/dist/es/AgentSession.mjs +0 -243
- package/dist/es/BotClient.mjs +0 -242
- package/dist/es/Config.mjs +0 -34
- package/dist/es/DialogSession.mjs +0 -281
- package/dist/es/EventBus.mjs +0 -64
- package/dist/es/Logger.mjs +0 -31
- package/dist/es/PayloadTypes.mjs +0 -4
- package/dist/es/Session.mjs +0 -527
- package/dist/es/_virtual/_commonjsHelpers.mjs +0 -4
- package/dist/es/_virtual/index.mjs +0 -4
- package/dist/es/_virtual/index2.mjs +0 -4
- package/dist/es/_virtual/index3.mjs +0 -4
- package/dist/es/_virtual/minio-zj.mjs +0 -4
- package/dist/es/api/fetchEventSource/fetch.mjs +0 -112
- package/dist/es/api/fetchEventSource/parse.mjs +0 -97
- package/dist/es/api/index.mjs +0 -48
- package/dist/es/index.mjs +0 -11
- package/dist/es/node_modules/@glodon-aiot/minio/dist/minio-zj.mjs +0 -26485
- package/dist/es/node_modules/@socket.io/component-emitter/lib/esm/index.mjs +0 -54
- package/dist/es/node_modules/base64-js/index.mjs +0 -47
- package/dist/es/node_modules/buffer/index.mjs +0 -927
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/has-cors.mjs +0 -9
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseqs.mjs +0 -18
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/parseuri.mjs +0 -24
- package/dist/es/node_modules/engine.io-client/build/esm/contrib/yeast.mjs +0 -19
- package/dist/es/node_modules/engine.io-client/build/esm/globalThis.browser.mjs +0 -4
- package/dist/es/node_modules/engine.io-client/build/esm/socket.mjs +0 -317
- package/dist/es/node_modules/engine.io-client/build/esm/transport.mjs +0 -113
- package/dist/es/node_modules/engine.io-client/build/esm/transports/index.mjs +0 -11
- package/dist/es/node_modules/engine.io-client/build/esm/transports/polling.mjs +0 -273
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket-constructor.browser.mjs +0 -8
- package/dist/es/node_modules/engine.io-client/build/esm/transports/websocket.mjs +0 -87
- package/dist/es/node_modules/engine.io-client/build/esm/transports/webtransport.mjs +0 -52
- package/dist/es/node_modules/engine.io-client/build/esm/transports/xmlhttprequest.browser.mjs +0 -21
- package/dist/es/node_modules/engine.io-client/build/esm/util.mjs +0 -23
- package/dist/es/node_modules/engine.io-parser/build/esm/commons.mjs +0 -21
- package/dist/es/node_modules/engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs +0 -14
- package/dist/es/node_modules/engine.io-parser/build/esm/decodePacket.browser.mjs +0 -39
- package/dist/es/node_modules/engine.io-parser/build/esm/encodePacket.browser.mjs +0 -28
- package/dist/es/node_modules/engine.io-parser/build/esm/index.mjs +0 -105
- package/dist/es/node_modules/ieee754/index.mjs +0 -28
- package/dist/es/node_modules/js-base64/base64.mjs +0 -31
- package/dist/es/node_modules/socket.io-client/build/esm/contrib/backo2.mjs +0 -26
- package/dist/es/node_modules/socket.io-client/build/esm/index.mjs +0 -25
- package/dist/es/node_modules/socket.io-client/build/esm/manager.mjs +0 -242
- package/dist/es/node_modules/socket.io-client/build/esm/on.mjs +0 -8
- package/dist/es/node_modules/socket.io-client/build/esm/socket.mjs +0 -608
- package/dist/es/node_modules/socket.io-client/build/esm/url.mjs +0 -19
- package/dist/es/node_modules/socket.io-parser/build/esm/binary.mjs +0 -52
- package/dist/es/node_modules/socket.io-parser/build/esm/index.mjs +0 -203
- package/dist/es/node_modules/socket.io-parser/build/esm/is-binary.mjs +0 -26
- package/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -6
- package/dist/es/node_modules/uuid/dist/esm-browser/rng.mjs +0 -10
- package/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -9
- package/dist/es/node_modules/uuid/dist/esm-browser/v4.mjs +0 -19
- package/dist/es/packages/apis/dist/es/aecpilot/model.mjs +0 -4
- package/dist/es/packages/apis/dist/es/aecpilotui/index.mjs +0 -8
- package/dist/es/packages/apis/dist/es/agentcliui/index.mjs +0 -8
- package/dist/es/packages/apis/dist/es/base/index.mjs +0 -154
- package/dist/es/packages/apis/dist/es/cvforce/index.mjs +0 -431
- package/dist/es/packages/apis/dist/es/cvforce/model.mjs +0 -5
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/native.mjs +0 -1
- package/dist/es/packages/apis/dist/es/node_modules/uuid/dist/esm-browser/stringify.mjs +0 -3
- package/dist/es/utils.mjs +0 -11
- package/dist/lib/index.js +0 -126
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { __exports as v } from "../../_virtual/index3.mjs";
|
|
2
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
3
|
-
v.read = function(s, a, x, f, M) {
|
|
4
|
-
var t, r, h = M * 8 - f - 1, w = (1 << h) - 1, N = w >> 1, i = -7, o = x ? M - 1 : 0, d = x ? -1 : 1, p = s[a + o];
|
|
5
|
-
for (o += d, t = p & (1 << -i) - 1, p >>= -i, i += h; i > 0; t = t * 256 + s[a + o], o += d, i -= 8)
|
|
6
|
-
;
|
|
7
|
-
for (r = t & (1 << -i) - 1, t >>= -i, i += f; i > 0; r = r * 256 + s[a + o], o += d, i -= 8)
|
|
8
|
-
;
|
|
9
|
-
if (t === 0)
|
|
10
|
-
t = 1 - N;
|
|
11
|
-
else {
|
|
12
|
-
if (t === w)
|
|
13
|
-
return r ? NaN : (p ? -1 : 1) * (1 / 0);
|
|
14
|
-
r = r + Math.pow(2, f), t = t - N;
|
|
15
|
-
}
|
|
16
|
-
return (p ? -1 : 1) * r * Math.pow(2, t - f);
|
|
17
|
-
};
|
|
18
|
-
v.write = function(s, a, x, f, M, t) {
|
|
19
|
-
var r, h, w, N = t * 8 - M - 1, i = (1 << N) - 1, o = i >> 1, d = M === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0, p = f ? 0 : t - 1, c = f ? 1 : -1, I = a < 0 || a === 0 && 1 / a < 0 ? 1 : 0;
|
|
20
|
-
for (a = Math.abs(a), isNaN(a) || a === 1 / 0 ? (h = isNaN(a) ? 1 : 0, r = i) : (r = Math.floor(Math.log(a) / Math.LN2), a * (w = Math.pow(2, -r)) < 1 && (r--, w *= 2), r + o >= 1 ? a += d / w : a += d * Math.pow(2, 1 - o), a * w >= 2 && (r++, w /= 2), r + o >= i ? (h = 0, r = i) : r + o >= 1 ? (h = (a * w - 1) * Math.pow(2, M), r = r + o) : (h = a * Math.pow(2, o - 1) * Math.pow(2, M), r = 0)); M >= 8; s[x + p] = h & 255, p += c, h /= 256, M -= 8)
|
|
21
|
-
;
|
|
22
|
-
for (r = r << M | h, N += M; N > 0; s[x + p] = r & 255, p += c, r /= 256, N -= 8)
|
|
23
|
-
;
|
|
24
|
-
s[x + p - c] |= I * 128;
|
|
25
|
-
};
|
|
26
|
-
export {
|
|
27
|
-
v as default
|
|
28
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const d = typeof Buffer == "function", i = typeof TextDecoder == "function" ? new TextDecoder() : void 0;
|
|
2
|
-
typeof TextEncoder == "function" && new TextEncoder();
|
|
3
|
-
const u = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", b = Array.prototype.slice.call(u), f = ((t) => {
|
|
4
|
-
let e = {};
|
|
5
|
-
return t.forEach((r, a) => e[r] = a), e;
|
|
6
|
-
})(b), l = /^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/, o = String.fromCharCode.bind(String), s = typeof Uint8Array.from == "function" ? Uint8Array.from.bind(Uint8Array) : (t) => new Uint8Array(Array.prototype.slice.call(t, 0)), A = (t) => t.replace(/[^A-Za-z0-9\+\/]/g, ""), y = /[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g, p = (t) => {
|
|
7
|
-
switch (t.length) {
|
|
8
|
-
case 4:
|
|
9
|
-
var e = (7 & t.charCodeAt(0)) << 18 | (63 & t.charCodeAt(1)) << 12 | (63 & t.charCodeAt(2)) << 6 | 63 & t.charCodeAt(3), r = e - 65536;
|
|
10
|
-
return o((r >>> 10) + 55296) + o((r & 1023) + 56320);
|
|
11
|
-
case 3:
|
|
12
|
-
return o((15 & t.charCodeAt(0)) << 12 | (63 & t.charCodeAt(1)) << 6 | 63 & t.charCodeAt(2));
|
|
13
|
-
default:
|
|
14
|
-
return o((31 & t.charCodeAt(0)) << 6 | 63 & t.charCodeAt(1));
|
|
15
|
-
}
|
|
16
|
-
}, C = (t) => t.replace(y, p), c = (t) => {
|
|
17
|
-
if (t = t.replace(/\s+/g, ""), !l.test(t))
|
|
18
|
-
throw new TypeError("malformed base64.");
|
|
19
|
-
t += "==".slice(2 - (t.length & 3));
|
|
20
|
-
let e, r = "", a, x;
|
|
21
|
-
for (let n = 0; n < t.length; )
|
|
22
|
-
e = f[t.charAt(n++)] << 18 | f[t.charAt(n++)] << 12 | (a = f[t.charAt(n++)]) << 6 | (x = f[t.charAt(n++)]), r += a === 64 ? o(e >> 16 & 255) : x === 64 ? o(e >> 16 & 255, e >> 8 & 255) : o(e >> 16 & 255, e >> 8 & 255, e & 255);
|
|
23
|
-
return r;
|
|
24
|
-
}, h = typeof atob == "function" ? (t) => atob(A(t)) : d ? (t) => Buffer.from(t, "base64").toString("binary") : c, m = d ? (t) => s(Buffer.from(t, "base64")) : (t) => s(h(t).split("").map((e) => e.charCodeAt(0))), g = d ? (t) => Buffer.from(t, "base64").toString("utf8") : i ? (t) => i.decode(m(t)) : (t) => C(h(t)), _ = (t) => A(t.replace(/[-_]/g, (e) => e == "-" ? "+" : "/")), B = (t) => g(_(t));
|
|
25
|
-
export {
|
|
26
|
-
h as atob,
|
|
27
|
-
c as atobPolyfill,
|
|
28
|
-
C as btou,
|
|
29
|
-
B as decode,
|
|
30
|
-
B as fromBase64
|
|
31
|
-
};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
function i(t) {
|
|
2
|
-
t = t || {}, this.ms = t.min || 100, this.max = t.max || 1e4, this.factor = t.factor || 2, this.jitter = t.jitter > 0 && t.jitter <= 1 ? t.jitter : 0, this.attempts = 0;
|
|
3
|
-
}
|
|
4
|
-
i.prototype.duration = function() {
|
|
5
|
-
var t = this.ms * Math.pow(this.factor, this.attempts++);
|
|
6
|
-
if (this.jitter) {
|
|
7
|
-
var r = Math.random(), e = Math.floor(r * this.jitter * t);
|
|
8
|
-
t = Math.floor(r * 10) & 1 ? t + e : t - e;
|
|
9
|
-
}
|
|
10
|
-
return Math.min(t, this.max) | 0;
|
|
11
|
-
};
|
|
12
|
-
i.prototype.reset = function() {
|
|
13
|
-
this.attempts = 0;
|
|
14
|
-
};
|
|
15
|
-
i.prototype.setMin = function(t) {
|
|
16
|
-
this.ms = t;
|
|
17
|
-
};
|
|
18
|
-
i.prototype.setMax = function(t) {
|
|
19
|
-
this.max = t;
|
|
20
|
-
};
|
|
21
|
-
i.prototype.setJitter = function(t) {
|
|
22
|
-
this.jitter = t;
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
i as Backoff
|
|
26
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { url as l } from "./url.mjs";
|
|
2
|
-
import { Manager as i } from "./manager.mjs";
|
|
3
|
-
import { Socket as d } from "./socket.mjs";
|
|
4
|
-
import { protocol as q } from "../../../socket.io-parser/build/esm/index.mjs";
|
|
5
|
-
const c = {};
|
|
6
|
-
function a(t, e) {
|
|
7
|
-
typeof t == "object" && (e = t, t = void 0), e = e || {};
|
|
8
|
-
const n = l(t, e.path || "/socket.io"), f = n.source, o = n.id, s = n.path, m = c[o] && s in c[o].nsps, u = e.forceNew || e["force new connection"] || e.multiplex === !1 || m;
|
|
9
|
-
let r;
|
|
10
|
-
return u ? r = new i(f, e) : (c[o] || (c[o] = new i(f, e)), r = c[o]), n.query && !e.query && (e.query = n.queryKey), r.socket(n.path, e);
|
|
11
|
-
}
|
|
12
|
-
Object.assign(a, {
|
|
13
|
-
Manager: i,
|
|
14
|
-
Socket: d,
|
|
15
|
-
io: a,
|
|
16
|
-
connect: a
|
|
17
|
-
});
|
|
18
|
-
export {
|
|
19
|
-
i as Manager,
|
|
20
|
-
d as Socket,
|
|
21
|
-
a as connect,
|
|
22
|
-
a as default,
|
|
23
|
-
a as io,
|
|
24
|
-
q as protocol
|
|
25
|
-
};
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
import { Socket as a } from "../../../engine.io-client/build/esm/socket.mjs";
|
|
2
|
-
import "../../../engine.io-parser/build/esm/encodePacket.browser.mjs";
|
|
3
|
-
import "../../../engine.io-parser/build/esm/commons.mjs";
|
|
4
|
-
import "../../../engine.io-parser/build/esm/contrib/base64-arraybuffer.mjs";
|
|
5
|
-
import { Emitter as d } from "../../../@socket.io/component-emitter/lib/esm/index.mjs";
|
|
6
|
-
import { installTimerFunctions as f } from "../../../engine.io-client/build/esm/util.mjs";
|
|
7
|
-
import "../../../engine.io-client/build/esm/transports/polling.mjs";
|
|
8
|
-
import "../../../engine.io-client/build/esm/transports/websocket.mjs";
|
|
9
|
-
import { nextTick as u } from "../../../engine.io-client/build/esm/transports/websocket-constructor.browser.mjs";
|
|
10
|
-
import { Socket as m } from "./socket.mjs";
|
|
11
|
-
import * as l from "../../../socket.io-parser/build/esm/index.mjs";
|
|
12
|
-
import { on as s } from "./on.mjs";
|
|
13
|
-
import { Backoff as p } from "./contrib/backo2.mjs";
|
|
14
|
-
class T extends d {
|
|
15
|
-
constructor(e, t) {
|
|
16
|
-
var n;
|
|
17
|
-
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, f(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 p({
|
|
18
|
-
min: this.reconnectionDelay(),
|
|
19
|
-
max: this.reconnectionDelayMax(),
|
|
20
|
-
jitter: this.randomizationFactor()
|
|
21
|
-
}), this.timeout(t.timeout == null ? 2e4 : t.timeout), this._readyState = "closed", this.uri = e;
|
|
22
|
-
const i = t.parser || l;
|
|
23
|
-
this.encoder = new i.Encoder(), this.decoder = new i.Decoder(), this._autoConnect = t.autoConnect !== !1, this._autoConnect && this.open();
|
|
24
|
-
}
|
|
25
|
-
reconnection(e) {
|
|
26
|
-
return arguments.length ? (this._reconnection = !!e, this) : this._reconnection;
|
|
27
|
-
}
|
|
28
|
-
reconnectionAttempts(e) {
|
|
29
|
-
return e === void 0 ? this._reconnectionAttempts : (this._reconnectionAttempts = e, this);
|
|
30
|
-
}
|
|
31
|
-
reconnectionDelay(e) {
|
|
32
|
-
var t;
|
|
33
|
-
return e === void 0 ? this._reconnectionDelay : (this._reconnectionDelay = e, (t = this.backoff) === null || t === void 0 || t.setMin(e), this);
|
|
34
|
-
}
|
|
35
|
-
randomizationFactor(e) {
|
|
36
|
-
var t;
|
|
37
|
-
return e === void 0 ? this._randomizationFactor : (this._randomizationFactor = e, (t = this.backoff) === null || t === void 0 || t.setJitter(e), this);
|
|
38
|
-
}
|
|
39
|
-
reconnectionDelayMax(e) {
|
|
40
|
-
var t;
|
|
41
|
-
return e === void 0 ? this._reconnectionDelayMax : (this._reconnectionDelayMax = e, (t = this.backoff) === null || t === void 0 || t.setMax(e), this);
|
|
42
|
-
}
|
|
43
|
-
timeout(e) {
|
|
44
|
-
return arguments.length ? (this._timeout = e, this) : this._timeout;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Starts trying to reconnect if reconnection is enabled and we have not
|
|
48
|
-
* started reconnecting yet
|
|
49
|
-
*
|
|
50
|
-
* @private
|
|
51
|
-
*/
|
|
52
|
-
maybeReconnectOnOpen() {
|
|
53
|
-
!this._reconnecting && this._reconnection && this.backoff.attempts === 0 && this.reconnect();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Sets the current transport `socket`.
|
|
57
|
-
*
|
|
58
|
-
* @param {Function} fn - optional, callback
|
|
59
|
-
* @return self
|
|
60
|
-
* @public
|
|
61
|
-
*/
|
|
62
|
-
open(e) {
|
|
63
|
-
if (~this._readyState.indexOf("open"))
|
|
64
|
-
return this;
|
|
65
|
-
this.engine = new a(this.uri, this.opts);
|
|
66
|
-
const t = this.engine, n = this;
|
|
67
|
-
this._readyState = "opening", this.skipReconnect = !1;
|
|
68
|
-
const i = s(t, "open", function() {
|
|
69
|
-
n.onopen(), e && e();
|
|
70
|
-
}), r = (o) => {
|
|
71
|
-
this.cleanup(), this._readyState = "closed", this.emitReserved("error", o), e ? e(o) : this.maybeReconnectOnOpen();
|
|
72
|
-
}, h = s(t, "error", r);
|
|
73
|
-
if (this._timeout !== !1) {
|
|
74
|
-
const o = this._timeout, c = this.setTimeoutFn(() => {
|
|
75
|
-
i(), r(new Error("timeout")), t.close();
|
|
76
|
-
}, o);
|
|
77
|
-
this.opts.autoUnref && c.unref(), this.subs.push(() => {
|
|
78
|
-
this.clearTimeoutFn(c);
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return this.subs.push(i), this.subs.push(h), this;
|
|
82
|
-
}
|
|
83
|
-
/**
|
|
84
|
-
* Alias for open()
|
|
85
|
-
*
|
|
86
|
-
* @return self
|
|
87
|
-
* @public
|
|
88
|
-
*/
|
|
89
|
-
connect(e) {
|
|
90
|
-
return this.open(e);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Called upon transport open.
|
|
94
|
-
*
|
|
95
|
-
* @private
|
|
96
|
-
*/
|
|
97
|
-
onopen() {
|
|
98
|
-
this.cleanup(), this._readyState = "open", this.emitReserved("open");
|
|
99
|
-
const e = this.engine;
|
|
100
|
-
this.subs.push(s(e, "ping", this.onping.bind(this)), s(e, "data", this.ondata.bind(this)), s(e, "error", this.onerror.bind(this)), s(e, "close", this.onclose.bind(this)), s(this.decoder, "decoded", this.ondecoded.bind(this)));
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Called upon a ping.
|
|
104
|
-
*
|
|
105
|
-
* @private
|
|
106
|
-
*/
|
|
107
|
-
onping() {
|
|
108
|
-
this.emitReserved("ping");
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Called with data.
|
|
112
|
-
*
|
|
113
|
-
* @private
|
|
114
|
-
*/
|
|
115
|
-
ondata(e) {
|
|
116
|
-
try {
|
|
117
|
-
this.decoder.add(e);
|
|
118
|
-
} catch (t) {
|
|
119
|
-
this.onclose("parse error", t);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Called when parser fully decodes a packet.
|
|
124
|
-
*
|
|
125
|
-
* @private
|
|
126
|
-
*/
|
|
127
|
-
ondecoded(e) {
|
|
128
|
-
u(() => {
|
|
129
|
-
this.emitReserved("packet", e);
|
|
130
|
-
}, this.setTimeoutFn);
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Called upon socket error.
|
|
134
|
-
*
|
|
135
|
-
* @private
|
|
136
|
-
*/
|
|
137
|
-
onerror(e) {
|
|
138
|
-
this.emitReserved("error", e);
|
|
139
|
-
}
|
|
140
|
-
/**
|
|
141
|
-
* Creates a new socket for the given `nsp`.
|
|
142
|
-
*
|
|
143
|
-
* @return {Socket}
|
|
144
|
-
* @public
|
|
145
|
-
*/
|
|
146
|
-
socket(e, t) {
|
|
147
|
-
let n = this.nsps[e];
|
|
148
|
-
return n ? this._autoConnect && !n.active && n.connect() : (n = new m(this, e, t), this.nsps[e] = n), n;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Called upon a socket close.
|
|
152
|
-
*
|
|
153
|
-
* @param socket
|
|
154
|
-
* @private
|
|
155
|
-
*/
|
|
156
|
-
_destroy(e) {
|
|
157
|
-
const t = Object.keys(this.nsps);
|
|
158
|
-
for (const n of t)
|
|
159
|
-
if (this.nsps[n].active)
|
|
160
|
-
return;
|
|
161
|
-
this._close();
|
|
162
|
-
}
|
|
163
|
-
/**
|
|
164
|
-
* Writes a packet.
|
|
165
|
-
*
|
|
166
|
-
* @param packet
|
|
167
|
-
* @private
|
|
168
|
-
*/
|
|
169
|
-
_packet(e) {
|
|
170
|
-
const t = this.encoder.encode(e);
|
|
171
|
-
for (let n = 0; n < t.length; n++)
|
|
172
|
-
this.engine.write(t[n], e.options);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Clean up transport subscriptions and packet buffer.
|
|
176
|
-
*
|
|
177
|
-
* @private
|
|
178
|
-
*/
|
|
179
|
-
cleanup() {
|
|
180
|
-
this.subs.forEach((e) => e()), this.subs.length = 0, this.decoder.destroy();
|
|
181
|
-
}
|
|
182
|
-
/**
|
|
183
|
-
* Close the current socket.
|
|
184
|
-
*
|
|
185
|
-
* @private
|
|
186
|
-
*/
|
|
187
|
-
_close() {
|
|
188
|
-
this.skipReconnect = !0, this._reconnecting = !1, this.onclose("forced close"), this.engine && this.engine.close();
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
|
-
* Alias for close()
|
|
192
|
-
*
|
|
193
|
-
* @private
|
|
194
|
-
*/
|
|
195
|
-
disconnect() {
|
|
196
|
-
return this._close();
|
|
197
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Called upon engine close.
|
|
200
|
-
*
|
|
201
|
-
* @private
|
|
202
|
-
*/
|
|
203
|
-
onclose(e, t) {
|
|
204
|
-
this.cleanup(), this.backoff.reset(), this._readyState = "closed", this.emitReserved("close", e, t), this._reconnection && !this.skipReconnect && this.reconnect();
|
|
205
|
-
}
|
|
206
|
-
/**
|
|
207
|
-
* Attempt a reconnection.
|
|
208
|
-
*
|
|
209
|
-
* @private
|
|
210
|
-
*/
|
|
211
|
-
reconnect() {
|
|
212
|
-
if (this._reconnecting || this.skipReconnect)
|
|
213
|
-
return this;
|
|
214
|
-
const e = this;
|
|
215
|
-
if (this.backoff.attempts >= this._reconnectionAttempts)
|
|
216
|
-
this.backoff.reset(), this.emitReserved("reconnect_failed"), this._reconnecting = !1;
|
|
217
|
-
else {
|
|
218
|
-
const t = this.backoff.duration();
|
|
219
|
-
this._reconnecting = !0;
|
|
220
|
-
const n = this.setTimeoutFn(() => {
|
|
221
|
-
e.skipReconnect || (this.emitReserved("reconnect_attempt", e.backoff.attempts), !e.skipReconnect && e.open((i) => {
|
|
222
|
-
i ? (e._reconnecting = !1, e.reconnect(), this.emitReserved("reconnect_error", i)) : e.onreconnect();
|
|
223
|
-
}));
|
|
224
|
-
}, t);
|
|
225
|
-
this.opts.autoUnref && n.unref(), this.subs.push(() => {
|
|
226
|
-
this.clearTimeoutFn(n);
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* Called upon successful reconnect.
|
|
232
|
-
*
|
|
233
|
-
* @private
|
|
234
|
-
*/
|
|
235
|
-
onreconnect() {
|
|
236
|
-
const e = this.backoff.attempts;
|
|
237
|
-
this._reconnecting = !1, this.backoff.reset(), this.emitReserved("reconnect", e);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
export {
|
|
241
|
-
T as Manager
|
|
242
|
-
};
|