justrun-ws 0.2.3 → 0.3.1
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/JustRunAuthProvider.js +231 -0
- package/lib/WsClient.js +71 -168
- package/lib/bundle.min.js +1 -1
- package/lib/common/AdjustableTimer.js +34 -24
- package/lib/common/List.js +20 -20
- package/lib/common/utils.js +12 -12
- package/lib/common/varUintOps.js +16 -16
- package/lib/handler/SimpleHandler.js +29 -29
- package/lib/index.d.ts +56 -29
- package/lib/index.js +1 -0
- package/lib/net/BrowserWsNet.js +53 -59
- package/lib/net/LazyConn.js +22 -22
- package/lib/net/NetErrorString.js +11 -10
- package/lib/net/TimeoutMonitor.js +40 -40
- package/lib/net/TypedPkgHub.js +158 -173
- package/lib/net/hubPkgSerializer.js +2 -2
- package/package.json +3 -4
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
export var NetErrorString;
|
|
2
2
|
(function (NetErrorString) {
|
|
3
|
-
NetErrorString["
|
|
4
|
-
NetErrorString["
|
|
5
|
-
NetErrorString["
|
|
6
|
-
NetErrorString["
|
|
7
|
-
NetErrorString["
|
|
8
|
-
NetErrorString["
|
|
9
|
-
NetErrorString["
|
|
10
|
-
NetErrorString["
|
|
11
|
-
NetErrorString["
|
|
12
|
-
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";
|
|
13
14
|
})(NetErrorString || (NetErrorString = {}));
|
|
14
15
|
//# sourceMappingURL=NetErrorString.js.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ListNode, c } from '../common/List';
|
|
2
2
|
import { l } from '../common/utils';
|
|
3
|
-
export class
|
|
3
|
+
export class MonitorItem extends ListNode {
|
|
4
4
|
}
|
|
5
5
|
export class TimeoutMonitor {
|
|
6
|
-
constructor(
|
|
7
|
-
this.
|
|
8
|
-
this.
|
|
9
|
-
this.
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
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
12
|
this.r = [];
|
|
13
|
-
if (
|
|
13
|
+
if (f === 0) {
|
|
14
14
|
this.insert = l;
|
|
15
15
|
this.update = l;
|
|
16
16
|
this.remove = l;
|
|
@@ -20,51 +20,51 @@ export class TimeoutMonitor {
|
|
|
20
20
|
this.r.push(new c());
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
insert(
|
|
24
|
-
if (!this.
|
|
25
|
-
this.
|
|
23
|
+
insert(item) {
|
|
24
|
+
if (!this.G) {
|
|
25
|
+
this.Y = setInterval(this.a8, this.X);
|
|
26
26
|
}
|
|
27
|
-
this.
|
|
28
|
-
this.r[this.
|
|
27
|
+
this.G++;
|
|
28
|
+
this.r[this.p].W(item);
|
|
29
29
|
}
|
|
30
|
-
update(
|
|
31
|
-
|
|
32
|
-
this.r[this.
|
|
30
|
+
update(item) {
|
|
31
|
+
item.remove();
|
|
32
|
+
this.r[this.p].W(item);
|
|
33
33
|
}
|
|
34
|
-
remove(
|
|
35
|
-
|
|
36
|
-
this.
|
|
37
|
-
if (!this.
|
|
38
|
-
clearInterval(this.
|
|
34
|
+
remove(item) {
|
|
35
|
+
item.remove();
|
|
36
|
+
this.G--;
|
|
37
|
+
if (!this.G) {
|
|
38
|
+
clearInterval(this.Y);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
42
|
-
const {
|
|
43
|
-
this.
|
|
44
|
-
if (this.
|
|
45
|
-
this.
|
|
41
|
+
a8 = () => {
|
|
42
|
+
const { J, F, r } = this;
|
|
43
|
+
this.p++;
|
|
44
|
+
if (this.p === F) {
|
|
45
|
+
this.p = 0;
|
|
46
46
|
}
|
|
47
|
-
if (
|
|
48
|
-
let d = this.
|
|
49
|
-
if (d >=
|
|
50
|
-
d -=
|
|
47
|
+
if (J) {
|
|
48
|
+
let d = this.p + J;
|
|
49
|
+
if (d >= F) {
|
|
50
|
+
d -= F;
|
|
51
51
|
}
|
|
52
52
|
const b = r[d];
|
|
53
|
-
for (let node = b.
|
|
54
|
-
node.
|
|
53
|
+
for (let node = b.e; !b.V(node); node = node.getNext()) {
|
|
54
|
+
node.warnTimeout();
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
-
const b = r[this.
|
|
58
|
-
for (let node = b.
|
|
59
|
-
node.
|
|
57
|
+
const b = r[this.p];
|
|
58
|
+
for (let node = b.e; !b.V(node); node = node.getNext()) {
|
|
59
|
+
node.onTimeout();
|
|
60
60
|
}
|
|
61
61
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
E;
|
|
65
|
-
o;
|
|
62
|
+
X;
|
|
63
|
+
J;
|
|
66
64
|
F;
|
|
67
|
-
|
|
65
|
+
p;
|
|
66
|
+
G;
|
|
67
|
+
Y;
|
|
68
68
|
r;
|
|
69
69
|
}
|
|
70
70
|
//# sourceMappingURL=TimeoutMonitor.js.map
|
package/lib/net/TypedPkgHub.js
CHANGED
|
@@ -1,92 +1,92 @@
|
|
|
1
1
|
import { y, l } from '../common/utils';
|
|
2
2
|
import { NetErrorString } from './NetErrorString';
|
|
3
|
-
import {
|
|
4
|
-
export class
|
|
5
|
-
constructor(
|
|
6
|
-
const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } =
|
|
3
|
+
import { MonitorItem } from './TimeoutMonitor';
|
|
4
|
+
export class u {
|
|
5
|
+
constructor(C, v) {
|
|
6
|
+
const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } = v;
|
|
7
7
|
this.responsePkgType = responsePkgType;
|
|
8
8
|
this.s = 0;
|
|
9
9
|
this.t = new Map();
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
12
|
-
this.
|
|
13
|
-
this.
|
|
14
|
-
this.A =
|
|
15
|
-
this.
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
this.
|
|
20
|
-
this.
|
|
10
|
+
this.h = new Map();
|
|
11
|
+
this.R = new Map();
|
|
12
|
+
this.Z = makePkgBuff;
|
|
13
|
+
this.a0 = parsePkgBuff;
|
|
14
|
+
this.A = C;
|
|
15
|
+
this.K = timeoutMonitor;
|
|
16
|
+
const E = this;
|
|
17
|
+
E.x = this.a9;
|
|
18
|
+
const r = [];
|
|
19
|
+
this.Z(responsePkgType, 0x200000, r);
|
|
20
|
+
this.a1 = {
|
|
21
21
|
makePkgBuff: makePkgBuff,
|
|
22
22
|
responsePkgType: responsePkgType,
|
|
23
|
-
|
|
23
|
+
r: y(r),
|
|
24
24
|
};
|
|
25
|
-
this.
|
|
26
|
-
this.A.
|
|
25
|
+
this.h.set(responsePkgType, E);
|
|
26
|
+
this.A.init((e, p) => {
|
|
27
27
|
do {
|
|
28
28
|
this.s++;
|
|
29
29
|
} while (this.t.has(this.s & 0x1fffff));
|
|
30
|
-
const conn = new
|
|
30
|
+
const conn = new z(this.a1, e, this.s & 0x1fffff);
|
|
31
31
|
this.t.set(conn.id, conn);
|
|
32
|
-
this.
|
|
33
|
-
const
|
|
32
|
+
this.K?.insert(conn);
|
|
33
|
+
const f = {
|
|
34
34
|
conn,
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
_: (buff) => this.aa(conn, buff),
|
|
36
|
+
o: (err) => this.ab(conn, err),
|
|
37
37
|
};
|
|
38
|
-
this.
|
|
39
|
-
return
|
|
38
|
+
this.L?.(this, conn, !!p);
|
|
39
|
+
return f;
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
responsePkgType;
|
|
43
43
|
context;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
return this.A.
|
|
44
|
+
L;
|
|
45
|
+
H;
|
|
46
|
+
b() {
|
|
47
|
+
return this.A.b();
|
|
48
48
|
}
|
|
49
|
-
|
|
50
|
-
return this.t.get(
|
|
49
|
+
P(w) {
|
|
50
|
+
return this.t.get(w);
|
|
51
51
|
}
|
|
52
|
-
c
|
|
53
|
-
return this.A.c
|
|
52
|
+
g(c) {
|
|
53
|
+
return this.A.g(c);
|
|
54
54
|
}
|
|
55
|
-
async
|
|
55
|
+
async Q() {
|
|
56
56
|
do {
|
|
57
57
|
this.s++;
|
|
58
58
|
} while (this.t.has(this.s & 0x1fffff));
|
|
59
|
-
const conn = new
|
|
59
|
+
const conn = new V(this.s & 0x1fffff, this);
|
|
60
60
|
this.t.set(conn.id, conn);
|
|
61
61
|
return conn;
|
|
62
62
|
}
|
|
63
|
-
async
|
|
64
|
-
return this.A.
|
|
63
|
+
async T(c) {
|
|
64
|
+
return this.A.I(c);
|
|
65
65
|
}
|
|
66
|
-
async
|
|
67
|
-
return this.A.
|
|
66
|
+
async U() {
|
|
67
|
+
return this.A.J();
|
|
68
68
|
}
|
|
69
|
-
|
|
69
|
+
ac(conn, message) {
|
|
70
70
|
const pkgType = message.constructor.pkgType;
|
|
71
|
-
const handler = this.
|
|
71
|
+
const handler = this.h.get(pkgType);
|
|
72
72
|
if (handler) {
|
|
73
|
-
return handler?.
|
|
73
|
+
return handler?.q(conn, message);
|
|
74
74
|
}
|
|
75
|
-
throw new Error(NetErrorString.
|
|
75
|
+
throw new Error(NetErrorString.InvalidPackage);
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
ad(conn, request) {
|
|
78
78
|
const pkgType = request.constructor.pkgType;
|
|
79
|
-
const handler = this.
|
|
79
|
+
const handler = this.h.get(pkgType);
|
|
80
80
|
if (handler) {
|
|
81
|
-
return handler?.
|
|
81
|
+
return handler?.q(conn, request);
|
|
82
82
|
}
|
|
83
|
-
throw new Error(NetErrorString.
|
|
83
|
+
throw new Error(NetErrorString.InvalidPackage);
|
|
84
84
|
}
|
|
85
85
|
registerError(pkgType, wrapperCtor) {
|
|
86
86
|
wrapperCtor.registerPkgType(pkgType);
|
|
87
|
-
this.
|
|
88
|
-
const
|
|
89
|
-
this.
|
|
87
|
+
this.R.set(pkgType, wrapperCtor);
|
|
88
|
+
const W = this.h.get(this.responsePkgType);
|
|
89
|
+
this.h.set(pkgType, W);
|
|
90
90
|
}
|
|
91
91
|
registerMessage(pkgType, wrapperCtor) {
|
|
92
92
|
wrapperCtor.registerPkgType(pkgType);
|
|
@@ -97,226 +97,211 @@ export class v {
|
|
|
97
97
|
handleMessageWith(handler) {
|
|
98
98
|
const pkgType = handler.pkgType;
|
|
99
99
|
if (typeof pkgType !== typeof this.responsePkgType) {
|
|
100
|
-
throw new Error(`Wrapper ${handler.
|
|
100
|
+
throw new Error(`Wrapper ${handler.k} has an incompatible pkgType ${typeof pkgType}`);
|
|
101
101
|
}
|
|
102
|
-
if (this.
|
|
103
|
-
throw new Error(`Wrapper ${handler.
|
|
102
|
+
if (this.h.has(pkgType)) {
|
|
103
|
+
throw new Error(`Wrapper ${handler.k} is already handled by another handler`);
|
|
104
104
|
}
|
|
105
|
-
this.
|
|
105
|
+
this.h.set(pkgType, handler);
|
|
106
106
|
return handler;
|
|
107
107
|
}
|
|
108
108
|
handleRequestWith(handler) {
|
|
109
109
|
const pkgType = handler.pkgType;
|
|
110
110
|
if (typeof pkgType !== typeof this.responsePkgType) {
|
|
111
|
-
throw new Error(`Wrapper ${handler.
|
|
111
|
+
throw new Error(`Wrapper ${handler.k} has an incompatible pkgType ${typeof pkgType}`);
|
|
112
112
|
}
|
|
113
|
-
if (this.
|
|
114
|
-
throw new Error(`Wrapper ${handler.
|
|
113
|
+
if (this.h.has(pkgType)) {
|
|
114
|
+
throw new Error(`Wrapper ${handler.k} is already handled by another handler`);
|
|
115
115
|
}
|
|
116
|
-
this.
|
|
116
|
+
this.h.set(pkgType, handler);
|
|
117
117
|
return handler;
|
|
118
118
|
}
|
|
119
|
-
|
|
119
|
+
an(handler) {
|
|
120
120
|
const pkgType = handler.pkgType;
|
|
121
|
-
const
|
|
122
|
-
if (
|
|
123
|
-
this.
|
|
121
|
+
const X = this.h.get(pkgType);
|
|
122
|
+
if (X === handler) {
|
|
123
|
+
this.h.delete(pkgType);
|
|
124
124
|
return true;
|
|
125
125
|
}
|
|
126
126
|
return false;
|
|
127
127
|
}
|
|
128
|
-
|
|
129
|
-
this.
|
|
130
|
-
const a = this.
|
|
131
|
-
const handler = this.
|
|
128
|
+
aa(conn, buff) {
|
|
129
|
+
this.K?.update(conn);
|
|
130
|
+
const a = this.a0(buff);
|
|
131
|
+
const handler = this.h.get(a.pkgType);
|
|
132
132
|
if (handler) {
|
|
133
|
-
handler.
|
|
133
|
+
handler.x(conn, a);
|
|
134
134
|
return;
|
|
135
135
|
}
|
|
136
|
-
conn.close(new Error(NetErrorString.
|
|
136
|
+
conn.close(new Error(NetErrorString.InvalidPackage));
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
this.t.delete(
|
|
141
|
-
this.
|
|
142
|
-
conn.
|
|
143
|
-
this.
|
|
138
|
+
ab(conn, err) {
|
|
139
|
+
const w = conn.id;
|
|
140
|
+
this.t.delete(w);
|
|
141
|
+
this.K?.remove(conn);
|
|
142
|
+
conn.o(err);
|
|
143
|
+
this.H?.(this, conn, conn.e.G(), err);
|
|
144
144
|
}
|
|
145
|
-
|
|
145
|
+
a9(conn, a) {
|
|
146
146
|
try {
|
|
147
147
|
const { buff, pkgType, requestId, bodyOffset } = a;
|
|
148
148
|
if (pkgType === this.responsePkgType) {
|
|
149
|
-
const
|
|
150
|
-
conn.
|
|
149
|
+
const body = buff.subarray(bodyOffset);
|
|
150
|
+
conn.a2(requestId, body);
|
|
151
151
|
}
|
|
152
152
|
else {
|
|
153
|
-
const
|
|
154
|
-
if (
|
|
155
|
-
const
|
|
156
|
-
const
|
|
157
|
-
conn.
|
|
153
|
+
const N = this.R.get(pkgType);
|
|
154
|
+
if (N) {
|
|
155
|
+
const body = buff.subarray(bodyOffset);
|
|
156
|
+
const Y = new N(body, true);
|
|
157
|
+
conn.ae(requestId, Y);
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
catch {
|
|
162
|
-
conn.close(new Error(NetErrorString.
|
|
162
|
+
conn.close(new Error(NetErrorString.InvalidPackage));
|
|
163
163
|
}
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
a1;
|
|
166
166
|
s;
|
|
167
|
-
|
|
168
|
-
|
|
167
|
+
Z;
|
|
168
|
+
a0;
|
|
169
169
|
A;
|
|
170
170
|
t;
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
171
|
+
h;
|
|
172
|
+
R;
|
|
173
|
+
K;
|
|
174
174
|
}
|
|
175
|
-
class
|
|
176
|
-
constructor(
|
|
175
|
+
class z extends MonitorItem {
|
|
176
|
+
constructor(v, e, id) {
|
|
177
177
|
super();
|
|
178
178
|
this.id = id;
|
|
179
|
-
this.
|
|
180
|
-
this.
|
|
181
|
-
this.
|
|
179
|
+
this.e = e;
|
|
180
|
+
this.B = v;
|
|
181
|
+
this.a3 = 0;
|
|
182
182
|
}
|
|
183
183
|
context;
|
|
184
184
|
id;
|
|
185
|
-
|
|
186
|
-
get
|
|
187
|
-
return this.
|
|
188
|
-
}
|
|
189
|
-
get localPort() {
|
|
190
|
-
return this.b.localPort;
|
|
191
|
-
}
|
|
192
|
-
get remoteAddress() {
|
|
193
|
-
return this.b.remoteAddress;
|
|
194
|
-
}
|
|
195
|
-
get remoteFamily() {
|
|
196
|
-
return this.b.remoteFamily;
|
|
197
|
-
}
|
|
198
|
-
get remotePort() {
|
|
199
|
-
return this.b.remotePort;
|
|
185
|
+
e;
|
|
186
|
+
get socket() {
|
|
187
|
+
return this.e.socket;
|
|
200
188
|
}
|
|
201
189
|
sendMessage(message) {
|
|
202
190
|
const pkgType = message.constructor.pkgType;
|
|
203
191
|
const encoded = [message.buff];
|
|
204
|
-
this.
|
|
205
|
-
return this.
|
|
192
|
+
this.B.makePkgBuff(pkgType, 0, encoded);
|
|
193
|
+
return this.e.n(encoded);
|
|
206
194
|
}
|
|
207
195
|
sendRequest(request) {
|
|
208
|
-
this.
|
|
209
|
-
this.sendRequest = this.
|
|
210
|
-
this.
|
|
211
|
-
this.
|
|
212
|
-
return this.
|
|
196
|
+
this.m = new Map();
|
|
197
|
+
this.sendRequest = this.a4;
|
|
198
|
+
this.a2 = this.af;
|
|
199
|
+
this.o = this.ag;
|
|
200
|
+
return this.a4(request);
|
|
213
201
|
}
|
|
214
202
|
sendErrorResponse(error, requestId) {
|
|
215
203
|
const pkgType = error.constructor.pkgType;
|
|
216
204
|
const encoded = [error.buff];
|
|
217
|
-
this.
|
|
218
|
-
return this.
|
|
205
|
+
this.B.makePkgBuff(pkgType, requestId, encoded);
|
|
206
|
+
return this.e.n(encoded);
|
|
219
207
|
}
|
|
220
208
|
sendResponse(request, requestId) {
|
|
221
209
|
const encoded = [request.respBuff];
|
|
222
|
-
const { makePkgBuff, responsePkgType } = this.
|
|
210
|
+
const { makePkgBuff, responsePkgType } = this.B;
|
|
223
211
|
makePkgBuff(responsePkgType, requestId, encoded);
|
|
224
|
-
return this.
|
|
212
|
+
return this.e.n(encoded);
|
|
225
213
|
}
|
|
226
214
|
async close(err) {
|
|
227
|
-
await this.
|
|
215
|
+
await this.e.close(err);
|
|
228
216
|
}
|
|
229
|
-
|
|
217
|
+
a2(requestId, ai) {
|
|
230
218
|
if (requestId === 0x200000 && this.context === undefined) {
|
|
231
|
-
this.close(new Error(NetErrorString.
|
|
219
|
+
this.close(new Error(NetErrorString.AuthTimeout));
|
|
232
220
|
}
|
|
233
221
|
}
|
|
234
|
-
|
|
235
|
-
const
|
|
236
|
-
if (
|
|
237
|
-
this.
|
|
238
|
-
return j
|
|
222
|
+
ae(requestId, error) {
|
|
223
|
+
const i = this.m.get(requestId);
|
|
224
|
+
if (i) {
|
|
225
|
+
this.m.delete(requestId);
|
|
226
|
+
return i.j(error);
|
|
239
227
|
}
|
|
240
228
|
}
|
|
241
|
-
|
|
242
|
-
this.
|
|
229
|
+
warnTimeout() {
|
|
230
|
+
this.e.F(this.B.r).catch(l);
|
|
243
231
|
}
|
|
244
|
-
|
|
245
|
-
this.close(new Error(NetErrorString.
|
|
232
|
+
onTimeout() {
|
|
233
|
+
this.close(new Error(NetErrorString.Timeout));
|
|
246
234
|
}
|
|
247
|
-
|
|
235
|
+
o(a5) {
|
|
248
236
|
}
|
|
249
|
-
async
|
|
250
|
-
const requestId = (this.
|
|
237
|
+
async a4(request) {
|
|
238
|
+
const requestId = (this.a3++) & 0x1fffff;
|
|
251
239
|
const pkgType = request.constructor.pkgType;
|
|
252
240
|
const encoded = [request.buff];
|
|
253
|
-
this.
|
|
254
|
-
const
|
|
255
|
-
const
|
|
256
|
-
this.
|
|
257
|
-
this.
|
|
258
|
-
this.
|
|
259
|
-
|
|
241
|
+
this.B.makePkgBuff(pkgType, requestId, encoded);
|
|
242
|
+
const a6 = new Promise((d, j) => {
|
|
243
|
+
const a7 = { d, j };
|
|
244
|
+
this.m.set(requestId, a7);
|
|
245
|
+
this.e.n(encoded).catch((err) => {
|
|
246
|
+
this.m.delete(requestId);
|
|
247
|
+
j(err);
|
|
260
248
|
});
|
|
261
249
|
});
|
|
262
|
-
request.respBuff = await
|
|
250
|
+
request.respBuff = await a6;
|
|
263
251
|
}
|
|
264
|
-
|
|
265
|
-
const
|
|
266
|
-
if (
|
|
267
|
-
this.
|
|
268
|
-
|
|
252
|
+
af(requestId, body) {
|
|
253
|
+
const i = this.m.get(requestId);
|
|
254
|
+
if (i) {
|
|
255
|
+
this.m.delete(requestId);
|
|
256
|
+
i.d(body);
|
|
269
257
|
return;
|
|
270
258
|
}
|
|
271
259
|
if (requestId === 0x200000 && this.context === undefined) {
|
|
272
|
-
this.close(new Error(NetErrorString.
|
|
260
|
+
this.close(new Error(NetErrorString.AuthTimeout));
|
|
273
261
|
}
|
|
274
262
|
}
|
|
275
|
-
|
|
276
|
-
const
|
|
277
|
-
if (
|
|
263
|
+
ag(err) {
|
|
264
|
+
const D = this.m;
|
|
265
|
+
if (D.size > 0) {
|
|
278
266
|
if (!err) {
|
|
279
|
-
err = new Error(NetErrorString.
|
|
267
|
+
err = new Error(NetErrorString.ConnectionClosed);
|
|
280
268
|
}
|
|
281
|
-
for (const [requestId,
|
|
282
|
-
|
|
283
|
-
j
|
|
269
|
+
for (const [requestId, i] of D) {
|
|
270
|
+
D.delete(requestId);
|
|
271
|
+
i.j(err);
|
|
284
272
|
}
|
|
285
273
|
}
|
|
286
|
-
this.
|
|
274
|
+
this.m = undefined;
|
|
287
275
|
}
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
276
|
+
B;
|
|
277
|
+
m;
|
|
278
|
+
a3;
|
|
291
279
|
}
|
|
292
|
-
class
|
|
293
|
-
constructor(id,
|
|
280
|
+
class V {
|
|
281
|
+
constructor(id, a8) {
|
|
294
282
|
this.id = id;
|
|
295
|
-
this.
|
|
283
|
+
this.S = a8;
|
|
296
284
|
}
|
|
297
285
|
context;
|
|
298
286
|
id;
|
|
299
|
-
|
|
300
|
-
localPort;
|
|
301
|
-
remoteAddress;
|
|
302
|
-
remotePort;
|
|
287
|
+
socket;
|
|
303
288
|
get remoteFamily() {
|
|
304
289
|
return 'Local';
|
|
305
290
|
}
|
|
306
291
|
async sendMessage(message) {
|
|
307
|
-
return this.
|
|
292
|
+
return this.S.ac(this, message);
|
|
308
293
|
}
|
|
309
294
|
async sendRequest(request) {
|
|
310
|
-
return this.
|
|
295
|
+
return this.S.ad(this, request);
|
|
311
296
|
}
|
|
312
|
-
sendErrorResponse(
|
|
297
|
+
sendErrorResponse(aj, ah) {
|
|
313
298
|
throw null;
|
|
314
299
|
}
|
|
315
|
-
sendResponse(
|
|
300
|
+
sendResponse(ak, ah) {
|
|
316
301
|
throw null;
|
|
317
302
|
}
|
|
318
|
-
async close(
|
|
303
|
+
async close(a5) {
|
|
319
304
|
}
|
|
320
|
-
|
|
305
|
+
S;
|
|
321
306
|
}
|
|
322
307
|
//# sourceMappingURL=TypedPkgHub.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { j, l, m } from '../common/varUintOps';
|
|
2
|
-
export const
|
|
2
|
+
export const n = (pkgType, requestId, encoded) => {
|
|
3
3
|
const i = [requestId, pkgType];
|
|
4
4
|
const b = j(i);
|
|
5
5
|
const a = new Uint8Array(b);
|
|
6
6
|
m(i, a);
|
|
7
7
|
encoded.push(a);
|
|
8
8
|
};
|
|
9
|
-
export const
|
|
9
|
+
export const o = (buff) => {
|
|
10
10
|
const { h: [requestId, pkgType], k: bodyOffset } = l(2, buff);
|
|
11
11
|
const result = { buff, pkgType, requestId, bodyOffset };
|
|
12
12
|
return result;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "justrun-ws",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"start": "webpack serve"
|
|
6
6
|
},
|
|
@@ -24,14 +24,13 @@
|
|
|
24
24
|
"devDependencies": {
|
|
25
25
|
"@eslint/eslintrc": "^3.2.0",
|
|
26
26
|
"@eslint/js": "^9.19.0",
|
|
27
|
-
"@types/jest": "^29.5.1",
|
|
28
27
|
"@typescript-eslint/eslint-plugin": "^8.25.0",
|
|
29
28
|
"@typescript-eslint/parser": "^8.25.0",
|
|
30
29
|
"dts-bundle-generator": "^9.5.1",
|
|
31
30
|
"eslint": "^9.21.0",
|
|
32
31
|
"eslint-plugin-import": "^2.31.0",
|
|
33
|
-
"globals": "^
|
|
34
|
-
"minify-ts": "^1.2.
|
|
32
|
+
"globals": "^16.5.0",
|
|
33
|
+
"minify-ts": "^1.2.5",
|
|
35
34
|
"ts-loader": "^9.5.2",
|
|
36
35
|
"webpack": "^5.98.0",
|
|
37
36
|
"webpack-cli": "^6.0.1"
|