justrun-ws 0.3.0 → 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 +60 -55
- package/lib/index.min.mjs +1 -0
- package/package.json +5 -6
- package/lib/JustRunAuthProvider.js +0 -242
- package/lib/WsClient.js +0 -124
- package/lib/bundle.min.js +0 -1
- package/lib/common/AdjustableTimer.js +0 -42
- 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 -103
- package/lib/net/JsonPackageWrapper.js +0 -43
- package/lib/net/LazyConn.js +0 -77
- package/lib/net/NetErrorString.js +0 -14
- 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
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
export class g {
|
|
2
|
-
constructor(a, b) {
|
|
3
|
-
this.a8 = new Promise((f) => {
|
|
4
|
-
this.L = f;
|
|
5
|
-
});
|
|
6
|
-
this.V = b;
|
|
7
|
-
if (a > 0) {
|
|
8
|
-
this.u = setTimeout(() => {
|
|
9
|
-
this.u = undefined;
|
|
10
|
-
this.V?.();
|
|
11
|
-
this.L();
|
|
12
|
-
}, a);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
this.L();
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
ak(a) {
|
|
19
|
-
if (this.u) {
|
|
20
|
-
clearTimeout(this.u);
|
|
21
|
-
}
|
|
22
|
-
if (a > 0) {
|
|
23
|
-
this.u = setTimeout(() => {
|
|
24
|
-
this.u = undefined;
|
|
25
|
-
this.V?.();
|
|
26
|
-
this.L();
|
|
27
|
-
}, a);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
this.u = undefined;
|
|
31
|
-
this.L();
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
async al() {
|
|
35
|
-
await this.a8;
|
|
36
|
-
}
|
|
37
|
-
L;
|
|
38
|
-
a8;
|
|
39
|
-
u;
|
|
40
|
-
V;
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=AdjustableTimer.js.map
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export class DataWrapper {
|
|
2
|
-
constructor(a, needParse) {
|
|
3
|
-
if (needParse) {
|
|
4
|
-
this._ = a;
|
|
5
|
-
}
|
|
6
|
-
else {
|
|
7
|
-
this.A = a;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
get data() {
|
|
11
|
-
if (!this.A) {
|
|
12
|
-
this.A = this.decode(this._);
|
|
13
|
-
}
|
|
14
|
-
return this.A;
|
|
15
|
-
}
|
|
16
|
-
set data(b) {
|
|
17
|
-
this.A = b;
|
|
18
|
-
this._ = undefined;
|
|
19
|
-
}
|
|
20
|
-
get buff() {
|
|
21
|
-
if (!this._) {
|
|
22
|
-
this._ = this.encode(this.A);
|
|
23
|
-
}
|
|
24
|
-
return this._;
|
|
25
|
-
}
|
|
26
|
-
_;
|
|
27
|
-
A;
|
|
28
|
-
}
|
|
29
|
-
//# sourceMappingURL=DataWrapper.js.map
|
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.D = new ListNode();
|
|
34
|
-
}
|
|
35
|
-
get e() {
|
|
36
|
-
return this.D.getNext();
|
|
37
|
-
}
|
|
38
|
-
get a() {
|
|
39
|
-
return this.D.getPrev();
|
|
40
|
-
}
|
|
41
|
-
Y(node) {
|
|
42
|
-
return node === this.D;
|
|
43
|
-
}
|
|
44
|
-
Z(node) {
|
|
45
|
-
node.insertAfter(this.D);
|
|
46
|
-
}
|
|
47
|
-
ar(node) {
|
|
48
|
-
node.insertBefore(this.D);
|
|
49
|
-
}
|
|
50
|
-
D;
|
|
51
|
-
}
|
|
52
|
-
//# sourceMappingURL=List.js.map
|
package/lib/common/utils.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export const i = (d) => {
|
|
2
|
-
return new Promise((f) => setTimeout(f, d));
|
|
3
|
-
};
|
|
4
|
-
export const l = () => { };
|
|
5
|
-
export const j = (e = 0x100000000) => {
|
|
6
|
-
return (Math.random() * e) >>> 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 z = (h) => {
|
|
16
|
-
let a = 0;
|
|
17
|
-
let b = 0;
|
|
18
|
-
while (a < h.length) {
|
|
19
|
-
b += h[a++].length;
|
|
20
|
-
}
|
|
21
|
-
const g = new Uint8Array(b);
|
|
22
|
-
b = 0;
|
|
23
|
-
while (a > 0) {
|
|
24
|
-
const buff = h[--a];
|
|
25
|
-
g.set(buff, b);
|
|
26
|
-
b += buff.length;
|
|
27
|
-
}
|
|
28
|
-
return g;
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=utils.js.map
|
package/lib/common/varUintOps.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
export const o = (b) => {
|
|
2
|
-
let g = 1;
|
|
3
|
-
while (b >>>= 7) {
|
|
4
|
-
g++;
|
|
5
|
-
}
|
|
6
|
-
return g;
|
|
7
|
-
};
|
|
8
|
-
export const j = (i) => {
|
|
9
|
-
let b;
|
|
10
|
-
let a = 0;
|
|
11
|
-
let g = 0;
|
|
12
|
-
while (a < i.length) {
|
|
13
|
-
g++;
|
|
14
|
-
b = i[a++];
|
|
15
|
-
while (b >>>= 7) {
|
|
16
|
-
g++;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return g;
|
|
20
|
-
};
|
|
21
|
-
export const p = (buffer, e = 0) => {
|
|
22
|
-
let c;
|
|
23
|
-
let d = e;
|
|
24
|
-
let b = 0;
|
|
25
|
-
let f = 0;
|
|
26
|
-
do {
|
|
27
|
-
c = buffer[d++];
|
|
28
|
-
b |= (c & 127) << f;
|
|
29
|
-
f += 7;
|
|
30
|
-
} while (c & 128);
|
|
31
|
-
if (c !== undefined && f <= 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 f = 0;
|
|
47
|
-
const h = [];
|
|
48
|
-
for (a = 0; a < n; a++) {
|
|
49
|
-
do {
|
|
50
|
-
c = buffer[d++];
|
|
51
|
-
b |= (c & 127) << f;
|
|
52
|
-
f += 7;
|
|
53
|
-
} while (c & 128);
|
|
54
|
-
if (c !== undefined && f <= 35) {
|
|
55
|
-
h.push(b);
|
|
56
|
-
b = 0;
|
|
57
|
-
f = 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 d = new Error(NetErrorString.g);
|
|
4
|
-
export class i {
|
|
5
|
-
constructor(wrapperCtor, e, f = true) {
|
|
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 y(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, d);
|
|
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, d);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
n;
|
|
53
|
-
v;
|
|
54
|
-
w;
|
|
55
|
-
}
|
|
56
|
-
export class j {
|
|
57
|
-
constructor(wrapperCtor, e, f = true) {
|
|
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 y(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, d);
|
|
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 (err) {
|
|
101
|
-
await conn.close(err);
|
|
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, d);
|
|
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,103 +0,0 @@
|
|
|
1
|
-
import { z } from '../common/utils';
|
|
2
|
-
import { NetErrorString } from './NetErrorString';
|
|
3
|
-
export class q {
|
|
4
|
-
b() {
|
|
5
|
-
return null;
|
|
6
|
-
}
|
|
7
|
-
I(H) {
|
|
8
|
-
this.H = H;
|
|
9
|
-
}
|
|
10
|
-
async J(t) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
async L() {
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
16
|
-
async d(e) {
|
|
17
|
-
const g = new WebSocket(e);
|
|
18
|
-
return new Promise((f, j) => {
|
|
19
|
-
g.onerror = (r) => {
|
|
20
|
-
j(new Error(NetErrorString.l));
|
|
21
|
-
};
|
|
22
|
-
g.onopen = () => {
|
|
23
|
-
f(this.am(g, true));
|
|
24
|
-
};
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
am = (g, p) => {
|
|
28
|
-
const c = new s(g);
|
|
29
|
-
const { conn, A, o } = this.H(c, p);
|
|
30
|
-
g.onmessage = (k) => {
|
|
31
|
-
k.data.arrayBuffer().then((buff) => {
|
|
32
|
-
A(new Uint8Array(buff));
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
g.onerror = (r) => {
|
|
36
|
-
o(new Error(NetErrorString.l));
|
|
37
|
-
};
|
|
38
|
-
g.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
|
-
H(a, u) {
|
|
49
|
-
throw new Error('Need to call "setConnWrapperMaker" before using');
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
class s {
|
|
53
|
-
constructor(g) {
|
|
54
|
-
this.i = g;
|
|
55
|
-
}
|
|
56
|
-
get localAddress() {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
get localPort() {
|
|
60
|
-
return;
|
|
61
|
-
}
|
|
62
|
-
get remoteAddress() {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
get remoteFamily() {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
get remotePort() {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
async D(buff) {
|
|
72
|
-
if (this.i) {
|
|
73
|
-
return this.i.send(buff);
|
|
74
|
-
}
|
|
75
|
-
throw new Error(NetErrorString.m);
|
|
76
|
-
}
|
|
77
|
-
async n(h) {
|
|
78
|
-
if (this.i) {
|
|
79
|
-
const buff = z(h);
|
|
80
|
-
return this.i.send(buff);
|
|
81
|
-
}
|
|
82
|
-
throw new Error(NetErrorString.m);
|
|
83
|
-
}
|
|
84
|
-
async close(err) {
|
|
85
|
-
const { i } = this;
|
|
86
|
-
if (i) {
|
|
87
|
-
this.i = undefined;
|
|
88
|
-
if (!err) {
|
|
89
|
-
if (i.readyState === WebSocket.OPEN) {
|
|
90
|
-
i.close(1000);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
i.close(3000, err.message);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
G() {
|
|
99
|
-
return !this.i;
|
|
100
|
-
}
|
|
101
|
-
i;
|
|
102
|
-
}
|
|
103
|
-
//# 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 h {
|
|
2
|
-
constructor(c) {
|
|
3
|
-
this.a9 = 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.d()).sendErrorResponse(error, requestId);
|
|
23
|
-
}
|
|
24
|
-
async sendResponse(request, requestId) {
|
|
25
|
-
return (this.a ?? await this.d()).sendResponse(request, requestId);
|
|
26
|
-
}
|
|
27
|
-
async sendMessage(message) {
|
|
28
|
-
return (this.a ?? await this.d()).sendMessage(message);
|
|
29
|
-
}
|
|
30
|
-
async sendRequest(request) {
|
|
31
|
-
return (this.a ?? await this.d()).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 an() {
|
|
48
|
-
if (!this.a) {
|
|
49
|
-
await this.d();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
ao() {
|
|
53
|
-
this.a = undefined;
|
|
54
|
-
}
|
|
55
|
-
async d() {
|
|
56
|
-
let { q } = this;
|
|
57
|
-
if (!q) {
|
|
58
|
-
q = this.q = new Promise((f, j) => {
|
|
59
|
-
this.a9().then((conn) => {
|
|
60
|
-
if (conn) {
|
|
61
|
-
f(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
|
-
a9;
|
|
74
|
-
a;
|
|
75
|
-
q;
|
|
76
|
-
}
|
|
77
|
-
//# sourceMappingURL=LazyConn.js.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export var NetErrorString;
|
|
2
|
-
(function (NetErrorString) {
|
|
3
|
-
NetErrorString["H"] = "AuthTimeout";
|
|
4
|
-
NetErrorString["a"] = "BadRequest";
|
|
5
|
-
NetErrorString["p"] = "ConnectFailed";
|
|
6
|
-
NetErrorString["Y"] = "ConnectionClosed";
|
|
7
|
-
NetErrorString["b"] = "InvalidConnString";
|
|
8
|
-
NetErrorString["m"] = "InvalidConnection";
|
|
9
|
-
NetErrorString["$"] = "InvalidPackage";
|
|
10
|
-
NetErrorString["g"] = "NotAuthenticated";
|
|
11
|
-
NetErrorString["Z"] = "Timeout";
|
|
12
|
-
NetErrorString["l"] = "UnknownError";
|
|
13
|
-
})(NetErrorString || (NetErrorString = {}));
|
|
14
|
-
//# sourceMappingURL=NetErrorString.js.map
|