justrun-ws 0.1.3 → 0.2.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.
@@ -1,16 +1,16 @@
1
- export class LazyConn {
2
- constructor(c) {
3
- this.A = c;
1
+ export class g {
2
+ constructor(e) {
3
+ this.a1 = e;
4
4
  }
5
5
  get id() {
6
- return this.b?.id ?? -1;
6
+ return this.a?.id ?? -1;
7
7
  }
8
8
  get context() {
9
- return this.b?.context;
9
+ return this.a?.context;
10
10
  }
11
- set context(a) {
12
- if (this.b) {
13
- this.b.context = a;
11
+ set context(b) {
12
+ if (this.a) {
13
+ this.a.context = b;
14
14
  }
15
15
  }
16
16
  localAddress;
@@ -19,48 +19,59 @@ export class LazyConn {
19
19
  remoteFamily;
20
20
  remotePort;
21
21
  async sendErrorResponse(error, requestId) {
22
- return (this.b ?? await this.connect()).sendErrorResponse(error, requestId);
22
+ return (this.a ?? await this.c()).sendErrorResponse(error, requestId);
23
23
  }
24
24
  async sendResponse(request, requestId) {
25
- return (this.b ?? await this.connect()).sendResponse(request, requestId);
25
+ return (this.a ?? await this.c()).sendResponse(request, requestId);
26
26
  }
27
27
  async sendMessage(message) {
28
- return (this.b ?? await this.connect()).sendMessage(message);
28
+ return (this.a ?? await this.c()).sendMessage(message);
29
29
  }
30
30
  async sendRequest(request) {
31
- return (this.b ?? await this.connect()).sendRequest(request);
31
+ return (this.a ?? await this.c()).sendRequest(request);
32
32
  }
33
33
  async close(err) {
34
- const { b } = this;
35
- if (b) {
36
- this.b = undefined;
37
- await b.close(err);
34
+ const { a } = this;
35
+ if (a) {
36
+ this.a = undefined;
37
+ await a.close(err);
38
38
  return;
39
39
  }
40
- if (this.i) {
41
- await this.i.then((conn) => conn.close(err).then(() => this.b = undefined), () => this.b = undefined);
40
+ if (this.p) {
41
+ await this.p.then((conn) => {
42
+ this.a = undefined;
43
+ conn.close(err);
44
+ }, () => this.a = undefined);
42
45
  }
43
46
  }
44
- async connect() {
45
- let { i } = this;
46
- if (!i) {
47
- i = this.i = new Promise((f, g) => {
48
- this.A().then((conn) => {
47
+ async reconnect() {
48
+ if (!this.a) {
49
+ await this.c();
50
+ }
51
+ }
52
+ a5() {
53
+ this.a = undefined;
54
+ }
55
+ async c() {
56
+ let { p } = this;
57
+ if (!p) {
58
+ p = this.p = new Promise((d, i) => {
59
+ this.a1().then((conn) => {
49
60
  if (conn) {
50
- f(conn);
51
- this.b = conn;
52
- this.i = undefined;
61
+ d(conn);
62
+ this.a = conn;
63
+ this.p = undefined;
53
64
  }
54
65
  else {
55
- g(new Error('Connect failed'));
66
+ i(new Error('Connect failed'));
56
67
  }
57
68
  });
58
69
  });
59
70
  }
60
- return await i;
71
+ return await p;
61
72
  }
62
- A;
63
- b;
64
- i;
73
+ a1;
74
+ a;
75
+ p;
65
76
  }
66
77
  //# sourceMappingURL=LazyConn.js.map
@@ -0,0 +1,14 @@
1
+ export var NetErrorString;
2
+ (function (NetErrorString) {
3
+ NetErrorString["I"] = "AuthTimeout";
4
+ NetErrorString["a"] = "BadRequest";
5
+ NetErrorString["k"] = "ConnectFailed";
6
+ NetErrorString["a1"] = "ConnectionClosed";
7
+ NetErrorString["b"] = "InvalidConnString";
8
+ NetErrorString["l"] = "InvalidConnection";
9
+ NetErrorString["D"] = "InvalidPackage";
10
+ NetErrorString["g"] = "NotAuthenticated";
11
+ NetErrorString["a2"] = "Timeout";
12
+ NetErrorString["m"] = "UnknownError";
13
+ })(NetErrorString || (NetErrorString = {}));
14
+ //# sourceMappingURL=NetErrorString.js.map
@@ -39,33 +39,33 @@ class EventWrapper extends PkgWrapper {
39
39
  }
40
40
  }
41
41
  class RequestWrapper extends PkgWrapper {
42
- constructor(b, needParse) {
43
- super(b, needParse);
42
+ constructor(a, needParse) {
43
+ super(a, needParse);
44
44
  }
45
45
  isRequest() {
46
46
  return true;
47
47
  }
48
48
  get resp() {
49
- if (!this.r) {
50
- this.r = this.decodeResponse(this.s);
49
+ if (!this.z) {
50
+ this.z = this.decodeResponse(this.$);
51
51
  }
52
- return this.r;
52
+ return this.z;
53
53
  }
54
- set resp(a) {
55
- this.r = a;
56
- this.s = undefined;
54
+ set resp(b) {
55
+ this.z = b;
56
+ this.$ = undefined;
57
57
  }
58
58
  get respBuff() {
59
- if (!this.s) {
60
- this.s = this.encodeResponse(this.r);
59
+ if (!this.$) {
60
+ this.$ = this.encodeResponse(this.z);
61
61
  }
62
- return this.s;
62
+ return this.$;
63
63
  }
64
- set respBuff(a) {
65
- this.r = undefined;
66
- this.s = a;
64
+ set respBuff(b) {
65
+ this.z = undefined;
66
+ this.$ = b;
67
67
  }
68
- r;
69
- s;
68
+ z;
69
+ $;
70
70
  }
71
71
  //# sourceMappingURL=PackageWrapper.js.map
@@ -1,70 +1,70 @@
1
1
  import { ListNode, c } from '../common/List';
2
- import { i } from '../common/utils';
2
+ import { l } from '../common/utils';
3
3
  export class MonitorConn extends ListNode {
4
4
  }
5
5
  export class TimeoutMonitor {
6
- constructor(e, h, f) {
7
- this.D = e;
8
- this.y = h;
9
- this.w = f;
10
- this.j = 0;
11
- this.x = 0;
12
- this.o = [];
6
+ constructor(e, h, g) {
7
+ this.R = e;
8
+ this.I = h;
9
+ this.E = g;
10
+ this.o = 0;
11
+ this.F = 0;
12
+ this.r = [];
13
13
  if (e === 0) {
14
- this.insert = i;
15
- this.update = i;
16
- this.remove = i;
14
+ this.insert = l;
15
+ this.update = l;
16
+ this.remove = l;
17
17
  return;
18
18
  }
19
- for (let b = 0; b < f; b++) {
20
- this.o.push(new c());
19
+ for (let a = 0; a < g; a++) {
20
+ this.r.push(new c());
21
21
  }
22
22
  }
23
23
  insert(conn) {
24
- if (!this.x) {
25
- this.E = setInterval(this.M, this.D);
24
+ if (!this.F) {
25
+ this.S = setInterval(this.a2, this.R);
26
26
  }
27
- this.x++;
28
- this.o[this.j].C(conn);
27
+ this.F++;
28
+ this.r[this.o].Q(conn);
29
29
  }
30
30
  update(conn) {
31
31
  conn.remove();
32
- this.o[this.j].C(conn);
32
+ this.r[this.o].Q(conn);
33
33
  }
34
34
  remove(conn) {
35
35
  conn.remove();
36
- this.x--;
37
- if (!this.x) {
38
- clearInterval(this.E);
36
+ this.F--;
37
+ if (!this.F) {
38
+ clearInterval(this.S);
39
39
  }
40
40
  }
41
- M = () => {
42
- const { y, w, o } = this;
43
- this.j++;
44
- if (this.j === w) {
45
- this.j = 0;
41
+ a2 = () => {
42
+ const { I, E, r } = this;
43
+ this.o++;
44
+ if (this.o === E) {
45
+ this.o = 0;
46
46
  }
47
- if (y) {
48
- let d = this.j + y;
49
- if (d >= w) {
50
- d -= w;
47
+ if (I) {
48
+ let d = this.o + I;
49
+ if (d >= E) {
50
+ d -= E;
51
51
  }
52
- const a = o[d];
53
- for (let node = a.g; !a.B(node); node = node.getNext()) {
52
+ const b = r[d];
53
+ for (let node = b.f; !b.P(node); node = node.getNext()) {
54
54
  node.keepAlive();
55
55
  }
56
56
  }
57
- const a = o[this.j];
58
- for (let node = a.g; !a.B(node); node = node.getNext()) {
57
+ const b = r[this.o];
58
+ for (let node = b.f; !b.P(node); node = node.getNext()) {
59
59
  node.timeout();
60
60
  }
61
61
  };
62
- D;
63
- y;
64
- w;
65
- j;
66
- x;
62
+ R;
63
+ I;
67
64
  E;
68
65
  o;
66
+ F;
67
+ S;
68
+ r;
69
69
  }
70
70
  //# sourceMappingURL=TimeoutMonitor.js.map