justrun-ws 0.3.1 → 0.3.2
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/lib/index.d.ts +46 -45
- package/lib/index.min.mjs +1 -0
- package/package.json +3 -3
- package/lib/JustRunAuthProvider.js +0 -231
- package/lib/WsClient.js +0 -114
- package/lib/bundle.min.js +0 -1
- package/lib/common/AdjustableTimer.js +0 -52
- package/lib/common/DataWrapper.js +0 -29
- package/lib/common/List.js +0 -52
- package/lib/common/utils.js +0 -30
- package/lib/common/varUintOps.js +0 -103
- package/lib/handler/SimpleHandler.js +0 -124
- package/lib/handler/common.js +0 -10
- package/lib/index.js +0 -8
- package/lib/net/BrowserWsNet.js +0 -97
- package/lib/net/JsonPackageWrapper.js +0 -43
- package/lib/net/LazyConn.js +0 -77
- package/lib/net/NetErrorString.js +0 -15
- package/lib/net/PackageWrapper.js +0 -71
- package/lib/net/TimeoutMonitor.js +0 -70
- package/lib/net/TypedPkgHub.js +0 -307
- package/lib/net/hubPkgSerializer.js +0 -14
- package/lib/net/interfaces.js +0 -2
package/lib/common/List.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
export class ListNode {
|
|
2
|
-
constructor() {
|
|
3
|
-
this.b = this;
|
|
4
|
-
this.j = this;
|
|
5
|
-
}
|
|
6
|
-
getPrev() {
|
|
7
|
-
return this.b;
|
|
8
|
-
}
|
|
9
|
-
getNext() {
|
|
10
|
-
return this.j;
|
|
11
|
-
}
|
|
12
|
-
insertBefore(node) {
|
|
13
|
-
this.j = node;
|
|
14
|
-
this.b = node.b;
|
|
15
|
-
node.b = this;
|
|
16
|
-
this.b.j = this;
|
|
17
|
-
}
|
|
18
|
-
insertAfter(node) {
|
|
19
|
-
this.b = node;
|
|
20
|
-
this.j = node.j;
|
|
21
|
-
node.j = this;
|
|
22
|
-
this.j.b = this;
|
|
23
|
-
}
|
|
24
|
-
remove() {
|
|
25
|
-
this.b.j = this.j;
|
|
26
|
-
this.j.b = this.b;
|
|
27
|
-
}
|
|
28
|
-
b;
|
|
29
|
-
j;
|
|
30
|
-
}
|
|
31
|
-
export class c {
|
|
32
|
-
constructor() {
|
|
33
|
-
this._ = new ListNode();
|
|
34
|
-
}
|
|
35
|
-
get e() {
|
|
36
|
-
return this._.getNext();
|
|
37
|
-
}
|
|
38
|
-
get a() {
|
|
39
|
-
return this._.getPrev();
|
|
40
|
-
}
|
|
41
|
-
V(node) {
|
|
42
|
-
return node === this._;
|
|
43
|
-
}
|
|
44
|
-
W(node) {
|
|
45
|
-
node.insertAfter(this._);
|
|
46
|
-
}
|
|
47
|
-
am(node) {
|
|
48
|
-
node.insertBefore(this._);
|
|
49
|
-
}
|
|
50
|
-
_;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=List.js.map
|
package/lib/common/utils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const i = (e) => {
|
|
2
|
-
return new Promise((d) => setTimeout(d, e));
|
|
3
|
-
};
|
|
4
|
-
export const l = () => { };
|
|
5
|
-
export const j = (g = 0x100000000) => {
|
|
6
|
-
return (Math.random() * g) >>> 0;
|
|
7
|
-
};
|
|
8
|
-
export const k = (c) => {
|
|
9
|
-
let hash = 5381, a = 0;
|
|
10
|
-
while (a < c.length) {
|
|
11
|
-
hash = ((hash << 5) + hash) + c.charCodeAt(a++);
|
|
12
|
-
}
|
|
13
|
-
return hash >>> 0;
|
|
14
|
-
};
|
|
15
|
-
export const y = (h) => {
|
|
16
|
-
let a = 0;
|
|
17
|
-
let b = 0;
|
|
18
|
-
while (a < h.length) {
|
|
19
|
-
b += h[a++].length;
|
|
20
|
-
}
|
|
21
|
-
const f = new Uint8Array(b);
|
|
22
|
-
b = 0;
|
|
23
|
-
while (a > 0) {
|
|
24
|
-
const buff = h[--a];
|
|
25
|
-
f.set(buff, b);
|
|
26
|
-
b += buff.length;
|
|
27
|
-
}
|
|
28
|
-
return f;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/common/varUintOps.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
export const o = (b) => {
|
|
2
|
-
let f = 1;
|
|
3
|
-
while (b >>>= 7) {
|
|
4
|
-
f++;
|
|
5
|
-
}
|
|
6
|
-
return f;
|
|
7
|
-
};
|
|
8
|
-
export const j = (i) => {
|
|
9
|
-
let b;
|
|
10
|
-
let a = 0;
|
|
11
|
-
let f = 0;
|
|
12
|
-
while (a < i.length) {
|
|
13
|
-
f++;
|
|
14
|
-
b = i[a++];
|
|
15
|
-
while (b >>>= 7) {
|
|
16
|
-
f++;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return f;
|
|
20
|
-
};
|
|
21
|
-
export const p = (buffer, e = 0) => {
|
|
22
|
-
let c;
|
|
23
|
-
let d = e;
|
|
24
|
-
let b = 0;
|
|
25
|
-
let g = 0;
|
|
26
|
-
do {
|
|
27
|
-
c = buffer[d++];
|
|
28
|
-
b |= (c & 127) << g;
|
|
29
|
-
g += 7;
|
|
30
|
-
} while (c & 128);
|
|
31
|
-
if (c !== undefined && g <= 35) {
|
|
32
|
-
return {
|
|
33
|
-
b: b,
|
|
34
|
-
k: d - e,
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
throw new Error('Parsing failed');
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
export const l = (n, buffer, e = 0) => {
|
|
42
|
-
let a;
|
|
43
|
-
let c;
|
|
44
|
-
let d = e;
|
|
45
|
-
let b = 0;
|
|
46
|
-
let g = 0;
|
|
47
|
-
const h = [];
|
|
48
|
-
for (a = 0; a < n; a++) {
|
|
49
|
-
do {
|
|
50
|
-
c = buffer[d++];
|
|
51
|
-
b |= (c & 127) << g;
|
|
52
|
-
g += 7;
|
|
53
|
-
} while (c & 128);
|
|
54
|
-
if (c !== undefined && g <= 35) {
|
|
55
|
-
h.push(b);
|
|
56
|
-
b = 0;
|
|
57
|
-
g = 0;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
throw new Error('Parsing failed');
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return {
|
|
64
|
-
h,
|
|
65
|
-
k: d - e,
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
export const q = (b, buffer, e = 0) => {
|
|
69
|
-
let d = e;
|
|
70
|
-
let c = b & 127;
|
|
71
|
-
while (b >>>= 7) {
|
|
72
|
-
buffer[d++] = c | 128;
|
|
73
|
-
c = b & 127;
|
|
74
|
-
}
|
|
75
|
-
buffer[d++] = c;
|
|
76
|
-
if (d <= buffer.length) {
|
|
77
|
-
return d - e;
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
throw new Error('Buffer overflow');
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
export const m = (h, buffer, e = 0) => {
|
|
84
|
-
let a;
|
|
85
|
-
let b;
|
|
86
|
-
let d = e;
|
|
87
|
-
for (a = 0; a < h.length; a++) {
|
|
88
|
-
b = h[a];
|
|
89
|
-
let c = b & 127;
|
|
90
|
-
while (b >>>= 7) {
|
|
91
|
-
buffer[d++] = c | 128;
|
|
92
|
-
c = b & 127;
|
|
93
|
-
}
|
|
94
|
-
buffer[d++] = c;
|
|
95
|
-
}
|
|
96
|
-
if (d <= buffer.length) {
|
|
97
|
-
return d - e;
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
throw new Error('Buffer overflow');
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
//# sourceMappingURL=varUintOps.js.map
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { NetErrorString } from '../net/NetErrorString';
|
|
2
|
-
import { b } from './common';
|
|
3
|
-
const c = new Error(NetErrorString.NotAuthenticated);
|
|
4
|
-
export class h {
|
|
5
|
-
constructor(wrapperCtor, e, f) {
|
|
6
|
-
this.n = wrapperCtor;
|
|
7
|
-
this.v = e;
|
|
8
|
-
this.w = !f;
|
|
9
|
-
}
|
|
10
|
-
get pkgType() {
|
|
11
|
-
return this.n.pkgType;
|
|
12
|
-
}
|
|
13
|
-
get k() {
|
|
14
|
-
return this.n.name;
|
|
15
|
-
}
|
|
16
|
-
async x(conn, a) {
|
|
17
|
-
const { buff, bodyOffset } = a;
|
|
18
|
-
const body = buff.subarray(bodyOffset);
|
|
19
|
-
const message = new this.n(body, true);
|
|
20
|
-
if (conn.context !== undefined || !this.w) {
|
|
21
|
-
try {
|
|
22
|
-
await this.v(conn, message);
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
if (!err.isError) {
|
|
26
|
-
b(conn, err);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
b(conn, c);
|
|
32
|
-
}
|
|
33
|
-
if (conn.context === undefined) {
|
|
34
|
-
await conn.close();
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
async q(conn, message) {
|
|
38
|
-
if (conn.context !== undefined || !this.w) {
|
|
39
|
-
try {
|
|
40
|
-
return await this.v(conn, message);
|
|
41
|
-
}
|
|
42
|
-
catch (err) {
|
|
43
|
-
if (!err.isError) {
|
|
44
|
-
b(conn, err);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
else {
|
|
49
|
-
b(conn, c);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
n;
|
|
53
|
-
v;
|
|
54
|
-
w;
|
|
55
|
-
}
|
|
56
|
-
export class i {
|
|
57
|
-
constructor(wrapperCtor, e, f) {
|
|
58
|
-
this.n = wrapperCtor;
|
|
59
|
-
this.v = e;
|
|
60
|
-
this.w = !f;
|
|
61
|
-
}
|
|
62
|
-
get pkgType() {
|
|
63
|
-
return this.n.pkgType;
|
|
64
|
-
}
|
|
65
|
-
get k() {
|
|
66
|
-
return this.n.name;
|
|
67
|
-
}
|
|
68
|
-
async x(conn, a) {
|
|
69
|
-
const { buff, requestId, bodyOffset } = a;
|
|
70
|
-
const body = buff.subarray(bodyOffset);
|
|
71
|
-
const request = new this.n(body, true);
|
|
72
|
-
let error;
|
|
73
|
-
if (conn.context !== undefined || !this.w) {
|
|
74
|
-
try {
|
|
75
|
-
await this.v(conn, request);
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
if (err.isError) {
|
|
79
|
-
error = err;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
error = b(conn, err);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
error = b(conn, c);
|
|
88
|
-
}
|
|
89
|
-
try {
|
|
90
|
-
if (!error) {
|
|
91
|
-
await conn.sendResponse(request, requestId);
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
await conn.sendErrorResponse(error, requestId);
|
|
95
|
-
}
|
|
96
|
-
if (conn.context === undefined) {
|
|
97
|
-
await conn.close();
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
catch {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
async q(conn, request) {
|
|
105
|
-
if (conn.context !== undefined || !this.w) {
|
|
106
|
-
try {
|
|
107
|
-
return await this.v(conn, request);
|
|
108
|
-
}
|
|
109
|
-
catch (err) {
|
|
110
|
-
if (err.isError) {
|
|
111
|
-
throw err;
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
throw b(conn, err);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
throw b(conn, c);
|
|
119
|
-
}
|
|
120
|
-
n;
|
|
121
|
-
v;
|
|
122
|
-
w;
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=SimpleHandler.js.map
|
package/lib/handler/common.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { JsonError } from '../net/JsonPackageWrapper';
|
|
2
|
-
export class CommonError extends JsonError {
|
|
3
|
-
}
|
|
4
|
-
export let b = (a, err) => {
|
|
5
|
-
return new CommonError(err.message);
|
|
6
|
-
};
|
|
7
|
-
export const handleUncaughtErrorWith = (handler) => {
|
|
8
|
-
b = handler;
|
|
9
|
-
};
|
|
10
|
-
//# sourceMappingURL=common.js.map
|
package/lib/index.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { CommonError, handleUncaughtErrorWith } from './handler/common';
|
|
2
|
-
export { JsonError, JsonMessage, JsonRequest } from './net/JsonPackageWrapper';
|
|
3
|
-
export { NetErrorString } from './net/NetErrorString';
|
|
4
|
-
export { ErrorWrapper, EventWrapper, MessageWrapper, RequestWrapper } from './net/PackageWrapper';
|
|
5
|
-
export { TimeoutMonitor } from './net/TimeoutMonitor';
|
|
6
|
-
export { JustrunAuthProvider } from './JustRunAuthProvider';
|
|
7
|
-
export { createNumPkgTypeClient, WsClient } from './WsClient';
|
|
8
|
-
//# sourceMappingURL=index.js.map
|
package/lib/net/BrowserWsNet.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { y } from '../common/utils';
|
|
2
|
-
import { NetErrorString } from './NetErrorString';
|
|
3
|
-
export class m {
|
|
4
|
-
b() {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
init(E) {
|
|
8
|
-
this.E = E;
|
|
9
|
-
}
|
|
10
|
-
async I(r) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
async J() {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
async g(c) {
|
|
17
|
-
const f = new WebSocket(c);
|
|
18
|
-
return new Promise((d, j) => {
|
|
19
|
-
f.onerror = (l) => {
|
|
20
|
-
j(new Error(NetErrorString.UnknownError));
|
|
21
|
-
};
|
|
22
|
-
f.onopen = () => {
|
|
23
|
-
d(this.ai(f, true));
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
ai = (f, p) => {
|
|
28
|
-
const e = new q(f);
|
|
29
|
-
const { conn, _, o } = this.E(e, p);
|
|
30
|
-
f.onmessage = (k) => {
|
|
31
|
-
k.data.arrayBuffer().then((buff) => {
|
|
32
|
-
_(new Uint8Array(buff));
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
f.onerror = (l) => {
|
|
36
|
-
o(new Error(NetErrorString.UnknownError));
|
|
37
|
-
};
|
|
38
|
-
f.onclose = (k) => {
|
|
39
|
-
if (k.code === 1000) {
|
|
40
|
-
o();
|
|
41
|
-
}
|
|
42
|
-
else {
|
|
43
|
-
o(new Error(k.reason));
|
|
44
|
-
}
|
|
45
|
-
};
|
|
46
|
-
return conn;
|
|
47
|
-
};
|
|
48
|
-
E(a, s) {
|
|
49
|
-
throw new Error('Need to call "setConnWrapperMaker" before using');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class q {
|
|
53
|
-
constructor(f) {
|
|
54
|
-
this.i = f;
|
|
55
|
-
}
|
|
56
|
-
get socket() {
|
|
57
|
-
return {
|
|
58
|
-
localAddress: '',
|
|
59
|
-
localPort: 0,
|
|
60
|
-
remoteAddress: '',
|
|
61
|
-
remoteFamily: '',
|
|
62
|
-
remotePort: 0,
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
async F(buff) {
|
|
66
|
-
if (this.i) {
|
|
67
|
-
return this.i.send(buff);
|
|
68
|
-
}
|
|
69
|
-
throw new Error(NetErrorString.InvalidConnection);
|
|
70
|
-
}
|
|
71
|
-
async n(h) {
|
|
72
|
-
if (this.i) {
|
|
73
|
-
const buff = y(h);
|
|
74
|
-
return this.i.send(buff);
|
|
75
|
-
}
|
|
76
|
-
throw new Error(NetErrorString.InvalidConnection);
|
|
77
|
-
}
|
|
78
|
-
async close(err) {
|
|
79
|
-
const { i } = this;
|
|
80
|
-
if (i) {
|
|
81
|
-
this.i = undefined;
|
|
82
|
-
if (!err) {
|
|
83
|
-
if (i.readyState <= WebSocket.OPEN) {
|
|
84
|
-
i.close(1000);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
i.close(1006, err.message);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
G() {
|
|
93
|
-
return !this.i;
|
|
94
|
-
}
|
|
95
|
-
i;
|
|
96
|
-
}
|
|
97
|
-
//# sourceMappingURL=BrowserWsNet.js.map
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { ErrorWrapper, MessageWrapper, RequestWrapper } from './PackageWrapper';
|
|
2
|
-
export { JsonError, JsonMessage, JsonRequest, };
|
|
3
|
-
const b = new TextEncoder();
|
|
4
|
-
const c = new TextDecoder();
|
|
5
|
-
class JsonError extends ErrorWrapper {
|
|
6
|
-
encode(data) {
|
|
7
|
-
const a = JSON.stringify(data);
|
|
8
|
-
return b.encode(a);
|
|
9
|
-
}
|
|
10
|
-
decode(buffer) {
|
|
11
|
-
const a = c.decode(buffer);
|
|
12
|
-
return JSON.parse(a);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
class JsonMessage extends MessageWrapper {
|
|
16
|
-
encode(data) {
|
|
17
|
-
const a = JSON.stringify(data);
|
|
18
|
-
return b.encode(a);
|
|
19
|
-
}
|
|
20
|
-
decode(buffer) {
|
|
21
|
-
const a = c.decode(buffer);
|
|
22
|
-
return JSON.parse(a);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
class JsonRequest extends RequestWrapper {
|
|
26
|
-
encode(data) {
|
|
27
|
-
const a = JSON.stringify(data);
|
|
28
|
-
return b.encode(a);
|
|
29
|
-
}
|
|
30
|
-
decode(buffer) {
|
|
31
|
-
const a = c.decode(buffer);
|
|
32
|
-
return JSON.parse(a);
|
|
33
|
-
}
|
|
34
|
-
encodeResponse(response) {
|
|
35
|
-
const a = JSON.stringify(response);
|
|
36
|
-
return b.encode(a);
|
|
37
|
-
}
|
|
38
|
-
decodeResponse(buffer) {
|
|
39
|
-
const a = c.decode(buffer);
|
|
40
|
-
return JSON.parse(a);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
//# sourceMappingURL=JsonPackageWrapper.js.map
|
package/lib/net/LazyConn.js
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
export class e {
|
|
2
|
-
constructor(c) {
|
|
3
|
-
this.a6 = c;
|
|
4
|
-
}
|
|
5
|
-
get id() {
|
|
6
|
-
return this.a?.id ?? -1;
|
|
7
|
-
}
|
|
8
|
-
get context() {
|
|
9
|
-
return this.a?.context;
|
|
10
|
-
}
|
|
11
|
-
set context(b) {
|
|
12
|
-
if (this.a) {
|
|
13
|
-
this.a.context = b;
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
localAddress;
|
|
17
|
-
localPort;
|
|
18
|
-
remoteAddress;
|
|
19
|
-
remoteFamily;
|
|
20
|
-
remotePort;
|
|
21
|
-
async sendErrorResponse(error, requestId) {
|
|
22
|
-
return (this.a ?? await this.g()).sendErrorResponse(error, requestId);
|
|
23
|
-
}
|
|
24
|
-
async sendResponse(request, requestId) {
|
|
25
|
-
return (this.a ?? await this.g()).sendResponse(request, requestId);
|
|
26
|
-
}
|
|
27
|
-
async sendMessage(message) {
|
|
28
|
-
return (this.a ?? await this.g()).sendMessage(message);
|
|
29
|
-
}
|
|
30
|
-
async sendRequest(request) {
|
|
31
|
-
return (this.a ?? await this.g()).sendRequest(request);
|
|
32
|
-
}
|
|
33
|
-
async close(err) {
|
|
34
|
-
const { a } = this;
|
|
35
|
-
if (a) {
|
|
36
|
-
this.a = undefined;
|
|
37
|
-
await a.close(err);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
if (this.q) {
|
|
41
|
-
await this.q.then((conn) => {
|
|
42
|
-
this.a = undefined;
|
|
43
|
-
conn.close(err);
|
|
44
|
-
}, () => this.a = undefined);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
async aq() {
|
|
48
|
-
if (!this.a) {
|
|
49
|
-
await this.g();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
aj() {
|
|
53
|
-
this.a = undefined;
|
|
54
|
-
}
|
|
55
|
-
async g() {
|
|
56
|
-
let { q } = this;
|
|
57
|
-
if (!q) {
|
|
58
|
-
q = this.q = new Promise((d, j) => {
|
|
59
|
-
this.a6().then((conn) => {
|
|
60
|
-
if (conn) {
|
|
61
|
-
d(conn);
|
|
62
|
-
this.a = conn;
|
|
63
|
-
this.q = undefined;
|
|
64
|
-
}
|
|
65
|
-
else {
|
|
66
|
-
j(new Error('Connect failed'));
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return await q;
|
|
72
|
-
}
|
|
73
|
-
a6;
|
|
74
|
-
a;
|
|
75
|
-
q;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=LazyConn.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export var NetErrorString;
|
|
2
|
-
(function (NetErrorString) {
|
|
3
|
-
NetErrorString["AuthTimeout"] = "AuthTimeout";
|
|
4
|
-
NetErrorString["BadRequest"] = "BadRequest";
|
|
5
|
-
NetErrorString["ConnectFailed"] = "ConnectFailed";
|
|
6
|
-
NetErrorString["ConnectionClosed"] = "ConnectionClosed";
|
|
7
|
-
NetErrorString["InvalidConnString"] = "InvalidConnString";
|
|
8
|
-
NetErrorString["InvalidConnection"] = "InvalidConnection";
|
|
9
|
-
NetErrorString["InvalidPackage"] = "InvalidPackage";
|
|
10
|
-
NetErrorString["NotAuthenticated"] = "NotAuthenticated";
|
|
11
|
-
NetErrorString["NotFound"] = "NotFound";
|
|
12
|
-
NetErrorString["Timeout"] = "Timeout";
|
|
13
|
-
NetErrorString["UnknownError"] = "UnknownError";
|
|
14
|
-
})(NetErrorString || (NetErrorString = {}));
|
|
15
|
-
//# sourceMappingURL=NetErrorString.js.map
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { DataWrapper } from '../common/DataWrapper';
|
|
2
|
-
export { ErrorWrapper, MessageWrapper, EventWrapper, RequestWrapper, };
|
|
3
|
-
class PkgWrapper extends DataWrapper {
|
|
4
|
-
static context;
|
|
5
|
-
static registerPkgType(pkgType) {
|
|
6
|
-
let c;
|
|
7
|
-
try {
|
|
8
|
-
c = this.pkgType;
|
|
9
|
-
}
|
|
10
|
-
catch {
|
|
11
|
-
Object.defineProperty(this, 'pkgType', {
|
|
12
|
-
value: pkgType,
|
|
13
|
-
writable: false,
|
|
14
|
-
enumerable: false,
|
|
15
|
-
});
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (c !== pkgType) {
|
|
19
|
-
throw new Error(`Wrapper ${this.name} is already registered with type ${c}`);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
static get pkgType() {
|
|
23
|
-
throw new Error(`Wrapper ${this.name} need to be registered`);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
class ErrorWrapper extends PkgWrapper {
|
|
27
|
-
isError() {
|
|
28
|
-
return true;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
class MessageWrapper extends PkgWrapper {
|
|
32
|
-
isMessage() {
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
class EventWrapper extends PkgWrapper {
|
|
37
|
-
isEvent() {
|
|
38
|
-
return true;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
class RequestWrapper extends PkgWrapper {
|
|
42
|
-
constructor(a, needParse) {
|
|
43
|
-
super(a, needParse);
|
|
44
|
-
}
|
|
45
|
-
isRequest() {
|
|
46
|
-
return true;
|
|
47
|
-
}
|
|
48
|
-
get resp() {
|
|
49
|
-
if (!this.z) {
|
|
50
|
-
this.z = this.decodeResponse(this.$);
|
|
51
|
-
}
|
|
52
|
-
return this.z;
|
|
53
|
-
}
|
|
54
|
-
set resp(b) {
|
|
55
|
-
this.z = b;
|
|
56
|
-
this.$ = undefined;
|
|
57
|
-
}
|
|
58
|
-
get respBuff() {
|
|
59
|
-
if (!this.$) {
|
|
60
|
-
this.$ = this.encodeResponse(this.z);
|
|
61
|
-
}
|
|
62
|
-
return this.$;
|
|
63
|
-
}
|
|
64
|
-
set respBuff(b) {
|
|
65
|
-
this.z = undefined;
|
|
66
|
-
this.$ = b;
|
|
67
|
-
}
|
|
68
|
-
z;
|
|
69
|
-
$;
|
|
70
|
-
}
|
|
71
|
-
//# sourceMappingURL=PackageWrapper.js.map
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { ListNode, c } from '../common/List';
|
|
2
|
-
import { l } from '../common/utils';
|
|
3
|
-
export class MonitorItem extends ListNode {
|
|
4
|
-
}
|
|
5
|
-
export class TimeoutMonitor {
|
|
6
|
-
constructor(f, h, g) {
|
|
7
|
-
this.X = f;
|
|
8
|
-
this.J = h;
|
|
9
|
-
this.F = g;
|
|
10
|
-
this.p = 0;
|
|
11
|
-
this.G = 0;
|
|
12
|
-
this.r = [];
|
|
13
|
-
if (f === 0) {
|
|
14
|
-
this.insert = l;
|
|
15
|
-
this.update = l;
|
|
16
|
-
this.remove = l;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
for (let a = 0; a < g; a++) {
|
|
20
|
-
this.r.push(new c());
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
insert(item) {
|
|
24
|
-
if (!this.G) {
|
|
25
|
-
this.Y = setInterval(this.a8, this.X);
|
|
26
|
-
}
|
|
27
|
-
this.G++;
|
|
28
|
-
this.r[this.p].W(item);
|
|
29
|
-
}
|
|
30
|
-
update(item) {
|
|
31
|
-
item.remove();
|
|
32
|
-
this.r[this.p].W(item);
|
|
33
|
-
}
|
|
34
|
-
remove(item) {
|
|
35
|
-
item.remove();
|
|
36
|
-
this.G--;
|
|
37
|
-
if (!this.G) {
|
|
38
|
-
clearInterval(this.Y);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
a8 = () => {
|
|
42
|
-
const { J, F, r } = this;
|
|
43
|
-
this.p++;
|
|
44
|
-
if (this.p === F) {
|
|
45
|
-
this.p = 0;
|
|
46
|
-
}
|
|
47
|
-
if (J) {
|
|
48
|
-
let d = this.p + J;
|
|
49
|
-
if (d >= F) {
|
|
50
|
-
d -= F;
|
|
51
|
-
}
|
|
52
|
-
const b = r[d];
|
|
53
|
-
for (let node = b.e; !b.V(node); node = node.getNext()) {
|
|
54
|
-
node.warnTimeout();
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
const b = r[this.p];
|
|
58
|
-
for (let node = b.e; !b.V(node); node = node.getNext()) {
|
|
59
|
-
node.onTimeout();
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
X;
|
|
63
|
-
J;
|
|
64
|
-
F;
|
|
65
|
-
p;
|
|
66
|
-
G;
|
|
67
|
-
Y;
|
|
68
|
-
r;
|
|
69
|
-
}
|
|
70
|
-
//# sourceMappingURL=TimeoutMonitor.js.map
|