justrun-ws 0.3.0 → 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.
@@ -46,26 +46,26 @@ class RequestWrapper extends PkgWrapper {
46
46
  return true;
47
47
  }
48
48
  get resp() {
49
- if (!this.B) {
50
- this.B = this.decodeResponse(this.C);
49
+ if (!this.z) {
50
+ this.z = this.decodeResponse(this.$);
51
51
  }
52
- return this.B;
52
+ return this.z;
53
53
  }
54
54
  set resp(b) {
55
- this.B = b;
56
- this.C = undefined;
55
+ this.z = b;
56
+ this.$ = undefined;
57
57
  }
58
58
  get respBuff() {
59
- if (!this.C) {
60
- this.C = this.encodeResponse(this.B);
59
+ if (!this.$) {
60
+ this.$ = this.encodeResponse(this.z);
61
61
  }
62
- return this.C;
62
+ return this.$;
63
63
  }
64
64
  set respBuff(b) {
65
- this.B = undefined;
66
- this.C = b;
65
+ this.z = undefined;
66
+ this.$ = b;
67
67
  }
68
- B;
69
- C;
68
+ z;
69
+ $;
70
70
  }
71
71
  //# sourceMappingURL=PackageWrapper.js.map
@@ -1,14 +1,14 @@
1
1
  import { ListNode, c } from '../common/List';
2
2
  import { l } from '../common/utils';
3
- export class MonitorConn extends ListNode {
3
+ export class MonitorItem extends ListNode {
4
4
  }
5
5
  export class TimeoutMonitor {
6
6
  constructor(f, h, g) {
7
- this.a0 = f;
8
- this.O = h;
9
- this.I = g;
7
+ this.X = f;
8
+ this.J = h;
9
+ this.F = g;
10
10
  this.p = 0;
11
- this.J = 0;
11
+ this.G = 0;
12
12
  this.r = [];
13
13
  if (f === 0) {
14
14
  this.insert = l;
@@ -20,51 +20,51 @@ export class TimeoutMonitor {
20
20
  this.r.push(new c());
21
21
  }
22
22
  }
23
- insert(conn) {
24
- if (!this.J) {
25
- this.a1 = setInterval(this.ab, this.a0);
23
+ insert(item) {
24
+ if (!this.G) {
25
+ this.Y = setInterval(this.a8, this.X);
26
26
  }
27
- this.J++;
28
- this.r[this.p].Z(conn);
27
+ this.G++;
28
+ this.r[this.p].W(item);
29
29
  }
30
- update(conn) {
31
- conn.remove();
32
- this.r[this.p].Z(conn);
30
+ update(item) {
31
+ item.remove();
32
+ this.r[this.p].W(item);
33
33
  }
34
- remove(conn) {
35
- conn.remove();
36
- this.J--;
37
- if (!this.J) {
38
- clearInterval(this.a1);
34
+ remove(item) {
35
+ item.remove();
36
+ this.G--;
37
+ if (!this.G) {
38
+ clearInterval(this.Y);
39
39
  }
40
40
  }
41
- ab = () => {
42
- const { O, I, r } = this;
41
+ a8 = () => {
42
+ const { J, F, r } = this;
43
43
  this.p++;
44
- if (this.p === I) {
44
+ if (this.p === F) {
45
45
  this.p = 0;
46
46
  }
47
- if (O) {
48
- let d = this.p + O;
49
- if (d >= I) {
50
- d -= I;
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.e; !b.Y(node); node = node.getNext()) {
54
- node.keepAlive();
53
+ for (let node = b.e; !b.V(node); node = node.getNext()) {
54
+ node.warnTimeout();
55
55
  }
56
56
  }
57
57
  const b = r[this.p];
58
- for (let node = b.e; !b.Y(node); node = node.getNext()) {
59
- node.timeout();
58
+ for (let node = b.e; !b.V(node); node = node.getNext()) {
59
+ node.onTimeout();
60
60
  }
61
61
  };
62
- a0;
63
- O;
64
- I;
65
- p;
62
+ X;
66
63
  J;
67
- a1;
64
+ F;
65
+ p;
66
+ G;
67
+ Y;
68
68
  r;
69
69
  }
70
70
  //# sourceMappingURL=TimeoutMonitor.js.map
@@ -1,92 +1,92 @@
1
- import { z, l } from '../common/utils';
1
+ import { y, l } from '../common/utils';
2
2
  import { NetErrorString } from './NetErrorString';
3
- import { MonitorConn } from './TimeoutMonitor';
3
+ import { MonitorItem } from './TimeoutMonitor';
4
4
  export class u {
5
- constructor(B, v) {
5
+ constructor(C, v) {
6
6
  const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } = v;
7
7
  this.responsePkgType = responsePkgType;
8
8
  this.s = 0;
9
9
  this.t = new Map();
10
10
  this.h = new Map();
11
- this.T = new Map();
12
- this.a2 = makePkgBuff;
13
- this.a3 = parsePkgBuff;
14
- this.E = B;
15
- this.P = timeoutMonitor;
16
- const M = this;
17
- M.y = this.ac;
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
18
  const r = [];
19
- this.a2(responsePkgType, 0x200000, r);
20
- this.a4 = {
19
+ this.Z(responsePkgType, 0x200000, r);
20
+ this.a1 = {
21
21
  makePkgBuff: makePkgBuff,
22
22
  responsePkgType: responsePkgType,
23
- r: z(r),
23
+ r: y(r),
24
24
  };
25
- this.h.set(responsePkgType, M);
26
- this.E.I((c, p) => {
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 w(this.a4, c, this.s & 0x1fffff);
30
+ const conn = new z(this.a1, e, this.s & 0x1fffff);
31
31
  this.t.set(conn.id, conn);
32
- this.P?.insert(conn);
33
- const g = {
32
+ this.K?.insert(conn);
33
+ const f = {
34
34
  conn,
35
- A: (buff) => this.ad(conn, buff),
36
- o: (err) => this.ae(conn, err),
35
+ _: (buff) => this.aa(conn, buff),
36
+ o: (err) => this.ab(conn, err),
37
37
  };
38
- this.Q?.(this, conn, !!p);
39
- return g;
38
+ this.L?.(this, conn, !!p);
39
+ return f;
40
40
  });
41
41
  }
42
42
  responsePkgType;
43
43
  context;
44
- Q;
45
- K;
44
+ L;
45
+ H;
46
46
  b() {
47
- return this.E.b();
47
+ return this.A.b();
48
48
  }
49
- S(x) {
50
- return this.t.get(x);
49
+ P(w) {
50
+ return this.t.get(w);
51
51
  }
52
- d(e) {
53
- return this.E.d(e);
52
+ g(c) {
53
+ return this.A.g(c);
54
54
  }
55
- async V() {
55
+ async Q() {
56
56
  do {
57
57
  this.s++;
58
58
  } while (this.t.has(this.s & 0x1fffff));
59
- const conn = new a0(this.s & 0x1fffff, this);
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 W(e) {
64
- return this.E.J(e);
63
+ async T(c) {
64
+ return this.A.I(c);
65
65
  }
66
- async X() {
67
- return this.E.L();
66
+ async U() {
67
+ return this.A.J();
68
68
  }
69
- af(conn, message) {
69
+ ac(conn, message) {
70
70
  const pkgType = message.constructor.pkgType;
71
71
  const handler = this.h.get(pkgType);
72
72
  if (handler) {
73
73
  return handler?.q(conn, message);
74
74
  }
75
- throw new Error(NetErrorString.$);
75
+ throw new Error(NetErrorString.InvalidPackage);
76
76
  }
77
- ag(conn, request) {
77
+ ad(conn, request) {
78
78
  const pkgType = request.constructor.pkgType;
79
79
  const handler = this.h.get(pkgType);
80
80
  if (handler) {
81
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.T.set(pkgType, wrapperCtor);
88
- const a1 = this.h.get(this.responsePkgType);
89
- this.h.set(pkgType, a1);
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);
@@ -116,171 +116,171 @@ export class u {
116
116
  this.h.set(pkgType, handler);
117
117
  return handler;
118
118
  }
119
- at(handler) {
119
+ an(handler) {
120
120
  const pkgType = handler.pkgType;
121
- const a8 = this.h.get(pkgType);
122
- if (a8 === handler) {
121
+ const X = this.h.get(pkgType);
122
+ if (X === handler) {
123
123
  this.h.delete(pkgType);
124
124
  return true;
125
125
  }
126
126
  return false;
127
127
  }
128
- ad(conn, buff) {
129
- this.P?.update(conn);
130
- const a = this.a3(buff);
128
+ aa(conn, buff) {
129
+ this.K?.update(conn);
130
+ const a = this.a0(buff);
131
131
  const handler = this.h.get(a.pkgType);
132
132
  if (handler) {
133
- handler.y(conn, a);
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
- ae(conn, err) {
139
- const x = conn.id;
140
- this.t.delete(x);
141
- this.P?.remove(conn);
138
+ ab(conn, err) {
139
+ const w = conn.id;
140
+ this.t.delete(w);
141
+ this.K?.remove(conn);
142
142
  conn.o(err);
143
- this.K?.(this, conn, conn.c.G(), err);
143
+ this.H?.(this, conn, conn.e.G(), err);
144
144
  }
145
- ac(conn, a) {
145
+ a9(conn, a) {
146
146
  try {
147
147
  const { buff, pkgType, requestId, bodyOffset } = a;
148
148
  if (pkgType === this.responsePkgType) {
149
149
  const body = buff.subarray(bodyOffset);
150
- conn.a5(requestId, body);
150
+ conn.a2(requestId, body);
151
151
  }
152
152
  else {
153
- const R = this.T.get(pkgType);
154
- if (R) {
153
+ const N = this.R.get(pkgType);
154
+ if (N) {
155
155
  const body = buff.subarray(bodyOffset);
156
- const a9 = new R(body, true);
157
- conn.ah(requestId, a9);
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
- a4;
165
+ a1;
166
166
  s;
167
- a2;
168
- a3;
169
- E;
167
+ Z;
168
+ a0;
169
+ A;
170
170
  t;
171
171
  h;
172
- T;
173
- P;
172
+ R;
173
+ K;
174
174
  }
175
- class w extends MonitorConn {
176
- constructor(v, c, id) {
175
+ class z extends MonitorItem {
176
+ constructor(v, e, id) {
177
177
  super();
178
178
  this.id = id;
179
- this.c = c;
180
- this.F = v;
181
- this.a6 = 0;
179
+ this.e = e;
180
+ this.B = v;
181
+ this.a3 = 0;
182
182
  }
183
183
  context;
184
184
  id;
185
- c;
185
+ e;
186
186
  get socket() {
187
- return this.c.socket;
187
+ return this.e.socket;
188
188
  }
189
189
  sendMessage(message) {
190
190
  const pkgType = message.constructor.pkgType;
191
191
  const encoded = [message.buff];
192
- this.F.makePkgBuff(pkgType, 0, encoded);
193
- return this.c.n(encoded);
192
+ this.B.makePkgBuff(pkgType, 0, encoded);
193
+ return this.e.n(encoded);
194
194
  }
195
195
  sendRequest(request) {
196
196
  this.m = new Map();
197
- this.sendRequest = this.a7;
198
- this.a5 = this.ai;
199
- this.o = this.aj;
200
- return this.a7(request);
197
+ this.sendRequest = this.a4;
198
+ this.a2 = this.af;
199
+ this.o = this.ag;
200
+ return this.a4(request);
201
201
  }
202
202
  sendErrorResponse(error, requestId) {
203
203
  const pkgType = error.constructor.pkgType;
204
204
  const encoded = [error.buff];
205
- this.F.makePkgBuff(pkgType, requestId, encoded);
206
- return this.c.n(encoded);
205
+ this.B.makePkgBuff(pkgType, requestId, encoded);
206
+ return this.e.n(encoded);
207
207
  }
208
208
  sendResponse(request, requestId) {
209
209
  const encoded = [request.respBuff];
210
- const { makePkgBuff, responsePkgType } = this.F;
210
+ const { makePkgBuff, responsePkgType } = this.B;
211
211
  makePkgBuff(responsePkgType, requestId, encoded);
212
- return this.c.n(encoded);
212
+ return this.e.n(encoded);
213
213
  }
214
214
  async close(err) {
215
- await this.c.close(err);
215
+ await this.e.close(err);
216
216
  }
217
- a5(requestId, an) {
217
+ a2(requestId, ai) {
218
218
  if (requestId === 0x200000 && this.context === undefined) {
219
- this.close(new Error(NetErrorString.H));
219
+ this.close(new Error(NetErrorString.AuthTimeout));
220
220
  }
221
221
  }
222
- ah(requestId, error) {
222
+ ae(requestId, error) {
223
223
  const i = this.m.get(requestId);
224
224
  if (i) {
225
225
  this.m.delete(requestId);
226
226
  return i.j(error);
227
227
  }
228
228
  }
229
- keepAlive() {
230
- this.c.D(this.F.r).catch(l);
229
+ warnTimeout() {
230
+ this.e.F(this.B.r).catch(l);
231
231
  }
232
- timeout() {
233
- this.close(new Error(NetErrorString.Z));
232
+ onTimeout() {
233
+ this.close(new Error(NetErrorString.Timeout));
234
234
  }
235
- o(aa) {
235
+ o(a5) {
236
236
  }
237
- async a7(request) {
238
- const requestId = (this.a6++) & 0x1fffff;
237
+ async a4(request) {
238
+ const requestId = (this.a3++) & 0x1fffff;
239
239
  const pkgType = request.constructor.pkgType;
240
240
  const encoded = [request.buff];
241
- this.F.makePkgBuff(pkgType, requestId, encoded);
242
- const ab = new Promise((f, j) => {
243
- const ak = { f, j };
244
- this.m.set(requestId, ak);
245
- this.c.n(encoded).catch((err) => {
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
246
  this.m.delete(requestId);
247
247
  j(err);
248
248
  });
249
249
  });
250
- request.respBuff = await ab;
250
+ request.respBuff = await a6;
251
251
  }
252
- ai(requestId, body) {
252
+ af(requestId, body) {
253
253
  const i = this.m.get(requestId);
254
254
  if (i) {
255
255
  this.m.delete(requestId);
256
- i.f(body);
256
+ i.d(body);
257
257
  return;
258
258
  }
259
259
  if (requestId === 0x200000 && this.context === undefined) {
260
- this.close(new Error(NetErrorString.H));
260
+ this.close(new Error(NetErrorString.AuthTimeout));
261
261
  }
262
262
  }
263
- aj(err) {
264
- const C = this.m;
265
- if (C.size > 0) {
263
+ ag(err) {
264
+ const D = this.m;
265
+ if (D.size > 0) {
266
266
  if (!err) {
267
- err = new Error(NetErrorString.Y);
267
+ err = new Error(NetErrorString.ConnectionClosed);
268
268
  }
269
- for (const [requestId, i] of C) {
270
- C.delete(requestId);
269
+ for (const [requestId, i] of D) {
270
+ D.delete(requestId);
271
271
  i.j(err);
272
272
  }
273
273
  }
274
274
  this.m = undefined;
275
275
  }
276
- F;
276
+ B;
277
277
  m;
278
- a6;
278
+ a3;
279
279
  }
280
- class a0 {
281
- constructor(id, al) {
280
+ class V {
281
+ constructor(id, a8) {
282
282
  this.id = id;
283
- this.U = al;
283
+ this.S = a8;
284
284
  }
285
285
  context;
286
286
  id;
@@ -289,19 +289,19 @@ class a0 {
289
289
  return 'Local';
290
290
  }
291
291
  async sendMessage(message) {
292
- return this.U.af(this, message);
292
+ return this.S.ac(this, message);
293
293
  }
294
294
  async sendRequest(request) {
295
- return this.U.ag(this, request);
295
+ return this.S.ad(this, request);
296
296
  }
297
- sendErrorResponse(ao, am) {
297
+ sendErrorResponse(aj, ah) {
298
298
  throw null;
299
299
  }
300
- sendResponse(ap, am) {
300
+ sendResponse(ak, ah) {
301
301
  throw null;
302
302
  }
303
- async close(aa) {
303
+ async close(a5) {
304
304
  }
305
- U;
305
+ S;
306
306
  }
307
307
  //# sourceMappingURL=TypedPkgHub.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "justrun-ws",
3
- "version": "0.3.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": "^15.14.0",
34
- "minify-ts": "^1.2.4",
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"