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,88 +1,90 @@
1
- import { c, a } from './common';
2
- export class SimpleMessageHandler {
1
+ import { NetErrorString } from '../net/NetErrorString';
2
+ import { b } from './common';
3
+ const c = new Error(NetErrorString.g);
4
+ export class n {
3
5
  constructor(wrapperCtor, d, e = true) {
4
- this.g = wrapperCtor;
5
- this.m = d;
6
- this.n = e;
6
+ this.l = wrapperCtor;
7
+ this.v = d;
8
+ this.w = e;
7
9
  }
8
10
  get pkgType() {
9
- return this.g.pkgType;
11
+ return this.l.pkgType;
10
12
  }
11
- get pkgName() {
12
- return this.g.name;
13
+ get m() {
14
+ return this.l.name;
13
15
  }
14
- async run(conn, parseResult) {
15
- const { buff, bodyOffset } = parseResult;
16
- const b = buff.subarray(bodyOffset);
17
- const message = new this.g(b, true);
18
- if (conn.context !== undefined || !this.n) {
16
+ async $(conn, a) {
17
+ const { buff, bodyOffset } = a;
18
+ const h = buff.subarray(bodyOffset);
19
+ const message = new this.l(h, true);
20
+ if (conn.context !== undefined || !this.w) {
19
21
  try {
20
- await this.m(conn, message);
22
+ await this.v(conn, message);
21
23
  }
22
24
  catch (err) {
23
25
  if (!err.isError) {
24
- a(conn, err);
26
+ b(conn, err);
25
27
  }
26
28
  }
27
29
  }
28
30
  else {
29
- a(conn, c);
31
+ b(conn, c);
30
32
  }
31
33
  if (conn.context === undefined) {
32
34
  await conn.close();
33
35
  }
34
36
  }
35
- async runLocal(conn, message) {
36
- if (conn.context !== undefined || !this.n) {
37
+ async r(conn, message) {
38
+ if (conn.context !== undefined || !this.w) {
37
39
  try {
38
- return await this.m(conn, message);
40
+ return await this.v(conn, message);
39
41
  }
40
42
  catch (err) {
41
43
  if (!err.isError) {
42
- a(conn, err);
44
+ b(conn, err);
43
45
  }
44
46
  }
45
47
  }
46
48
  else {
47
- a(conn, c);
49
+ b(conn, c);
48
50
  }
49
51
  }
50
- g;
51
- m;
52
- n;
52
+ l;
53
+ v;
54
+ w;
53
55
  }
54
- export class h {
56
+ export class o {
55
57
  constructor(wrapperCtor, d, e = true) {
56
- this.g = wrapperCtor;
57
- this.m = d;
58
- this.n = e;
58
+ this.l = wrapperCtor;
59
+ this.v = d;
60
+ this.w = e;
59
61
  }
60
62
  get pkgType() {
61
- return this.g.pkgType;
63
+ return this.l.pkgType;
62
64
  }
63
- get pkgName() {
64
- return this.g.name;
65
+ get m() {
66
+ return this.l.name;
65
67
  }
66
- async run(conn, parseResult) {
67
- const { buff, requestId, bodyOffset } = parseResult;
68
- const b = buff.subarray(bodyOffset);
69
- const request = new this.g(b, true);
68
+ async $(conn, a) {
69
+ const { buff, requestId, bodyOffset } = a;
70
+ const h = buff.subarray(bodyOffset);
71
+ const request = new this.l(h, true);
70
72
  let error;
71
- if (conn.context !== undefined || !this.n) {
73
+ if (conn.context !== undefined || !this.w) {
72
74
  try {
73
- await this.m(conn, request);
75
+ await this.v(conn, request);
74
76
  }
75
77
  catch (err) {
76
78
  if (err.isError) {
77
79
  error = err;
78
80
  }
79
81
  else {
80
- error = a(conn, err);
82
+ error = b(conn, err);
81
83
  }
82
84
  }
83
85
  }
84
86
  else {
85
- error = a(conn, c);
87
+ error = b(conn, c);
86
88
  }
87
89
  try {
88
90
  if (!error) {
@@ -99,24 +101,24 @@ export class h {
99
101
  await conn.close(err);
100
102
  }
101
103
  }
102
- async runLocal(conn, request) {
103
- if (conn.context !== undefined || !this.n) {
104
+ async r(conn, request) {
105
+ if (conn.context !== undefined || !this.w) {
104
106
  try {
105
- return await this.m(conn, request);
107
+ return await this.v(conn, request);
106
108
  }
107
109
  catch (err) {
108
110
  if (err.isError) {
109
111
  throw err;
110
112
  }
111
113
  else {
112
- throw a(conn, err);
114
+ throw b(conn, err);
113
115
  }
114
116
  }
115
117
  }
116
- throw a(conn, c);
118
+ throw b(conn, c);
117
119
  }
118
- g;
119
- m;
120
- n;
120
+ l;
121
+ v;
122
+ w;
121
123
  }
122
124
  //# sourceMappingURL=SimpleHandler.js.map
@@ -1,11 +1,10 @@
1
1
  import { JsonError } from '../net/JsonPackageWrapper';
2
2
  export class CommonError extends JsonError {
3
3
  }
4
- export const c = new Error('Connection is not authenticated');
5
- export let a = (b, err) => {
4
+ export let b = (a, err) => {
6
5
  return new CommonError(err.message);
7
6
  };
8
7
  export const handleUncaughtErrorWith = (handler) => {
9
- a = handler;
8
+ b = handler;
10
9
  };
11
10
  //# sourceMappingURL=common.js.map
package/lib/index.d.ts CHANGED
@@ -43,34 +43,6 @@ export declare abstract class RequestWrapper<RequestT, ResponseT> extends PkgWra
43
43
  export type ErrorWrapperCtor<ErrorT, WrapperT extends ErrorWrapper<ErrorT> = ErrorWrapper<ErrorT>> = new (error: ErrorT | Uint8Array, needParse?: true) => WrapperT;
44
44
  export type MessageWrapperCtor<MessageT, WrapperT extends MessageWrapper<MessageT> = MessageWrapper<MessageT>> = new (message: MessageT | Uint8Array, needParse?: true) => WrapperT;
45
45
  export type RequestWrapperCtor<RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT> = RequestWrapper<RequestT, ResponseT>> = new (request: RequestT | Uint8Array, needParse?: true, _response?: ResponseT) => WrapperT;
46
- export interface AddressInfo {
47
- address: string;
48
- family: string;
49
- port: number;
50
- }
51
- export interface IRawPkgConn {
52
- readonly localAddress?: string;
53
- readonly localPort?: number;
54
- readonly remoteAddress?: string;
55
- readonly remoteFamily?: string;
56
- readonly remotePort?: number;
57
- sendPkgBuff(buff: Uint8Array): Promise<void>;
58
- sendPkgBuffV(buffVector: Uint8Array[]): Promise<void>;
59
- close(err?: Error): Promise<void>;
60
- hadClosed(): boolean;
61
- }
62
- export interface IPkgConnWrapper<ConnWrapperT> {
63
- readonly conn: ConnWrapperT;
64
- onPkgBuff: (buff: Uint8Array) => void;
65
- onClose: (err?: Error) => void;
66
- }
67
- export interface INet<ConnWrapperT> {
68
- address(): AddressInfo | null;
69
- setConnWrapperMaker(makeWrapper: (conn: IRawPkgConn, isActive?: boolean) => IPkgConnWrapper<ConnWrapperT>): void;
70
- startListen(connStr?: string): Promise<boolean>;
71
- stopListen(): Promise<boolean>;
72
- connect(connStr: string): Promise<ConnWrapperT>;
73
- }
74
46
  export interface IConn<ConnContextT = void> {
75
47
  context?: ConnContextT | undefined;
76
48
  readonly id: number;
@@ -85,97 +57,12 @@ export interface IConn<ConnContextT = void> {
85
57
  sendResponse<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>, requestId: number): Promise<void>;
86
58
  close(err?: Error): Promise<void>;
87
59
  }
88
- export interface IPkgHub<ConnContextT = void, HubContextT = void> {
89
- context?: HubContextT | undefined;
90
- address(): AddressInfo | null;
91
- getConn(connId: number): IConn<ConnContextT> | undefined;
92
- connect(connStr: string): Promise<IConn<ConnContextT>>;
93
- connectLocal(): Promise<IConn<ConnContextT>>;
94
- startServer(connStr?: string): Promise<boolean>;
95
- stopServer(): Promise<boolean>;
96
- }
97
60
  export type ParseResult<PkgTypeT extends number | string> = {
98
61
  buff: Uint8Array;
99
62
  pkgType: PkgTypeT;
100
63
  requestId: number;
101
64
  bodyOffset: number;
102
65
  };
103
- export interface IPkgHandler<PkgTypeT extends number | string, ConnContextT = void> {
104
- get pkgType(): PkgTypeT;
105
- get pkgName(): string;
106
- run(conn: IConn<ConnContextT>, parseResult: ParseResult<PkgTypeT>): void | Promise<void>;
107
- }
108
- export interface IMessageHandler<PkgTypeT extends number | string, MessageT, WrapperT extends MessageWrapper<MessageT>, ConnContextT = void> extends IPkgHandler<PkgTypeT, ConnContextT> {
109
- runLocal(conn: IConn<ConnContextT>, message: WrapperT): void | Promise<void>;
110
- }
111
- export interface IRequestHandler<PkgTypeT extends number | string, RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT>, ConnContextT = void> extends IPkgHandler<PkgTypeT, ConnContextT> {
112
- runLocal(conn: IConn<ConnContextT>, request: WrapperT): void | Promise<void>;
113
- }
114
- export declare abstract class JsonError<ErrorT> extends ErrorWrapper<ErrorT> {
115
- protected encode(data: ErrorT): Uint8Array;
116
- protected decode(buffer: Uint8Array): ErrorT;
117
- }
118
- export declare abstract class JsonMessage<MessageT> extends MessageWrapper<MessageT> {
119
- protected encode(data: MessageT): Uint8Array;
120
- protected decode(buffer: Uint8Array): MessageT;
121
- }
122
- export declare abstract class JsonRequest<RequestT, ResponseT> extends RequestWrapper<RequestT, ResponseT> {
123
- protected encode(data: RequestT): Uint8Array;
124
- protected decode(buffer: Uint8Array): RequestT;
125
- protected encodeResponse(response: ResponseT): Uint8Array;
126
- protected decodeResponse(buffer: Uint8Array): ResponseT;
127
- }
128
- export declare class CommonError extends JsonError<string> {
129
- }
130
- export interface DoneResp<ResultT extends string | number | boolean = boolean> {
131
- result: ResultT;
132
- }
133
- export interface ClientPkg {
134
- cid: string;
135
- }
136
- export declare const handleUncaughtErrorWith: (handler: (conn: IConn<unknown>, err: Error) => ErrorWrapper<unknown>) => void;
137
- export type HandleFunc<WrapperT, ConnContextT> = (conn: IConn<ConnContextT>, wrapper: WrapperT) => void | Promise<void>;
138
- export declare class SimpleMessageHandler<PkgTypeT extends number | string, MessageT, WrapperT extends MessageWrapper<MessageT>, ConnContextT> implements IMessageHandler<PkgTypeT, MessageT, WrapperT, ConnContextT> {
139
- constructor(wrapperCtor: MessageWrapperCtor<MessageT, WrapperT>, handleFunc: HandleFunc<WrapperT, ConnContextT>, checkContext?: boolean);
140
- get pkgType(): PkgTypeT;
141
- get pkgName(): string;
142
- run(conn: IConn<ConnContextT>, parseResult: ParseResult<PkgTypeT>): Promise<void>;
143
- runLocal(conn: IConn<ConnContextT>, message: WrapperT): Promise<void>;
144
- private _wrapperCtor;
145
- private _handleFunc;
146
- private _checkContext;
147
- }
148
- export declare class BrowserWsNet<ConnWrapperT> implements INet<ConnWrapperT> {
149
- address(): AddressInfo | null;
150
- setConnWrapperMaker(makeWrapper: (conn: IRawPkgConn, isActive?: boolean) => IPkgConnWrapper<ConnWrapperT>): void;
151
- startListen(_connStr?: string): Promise<boolean>;
152
- stopListen(): Promise<boolean>;
153
- connect(connStr: string): Promise<ConnWrapperT>;
154
- private setupConn;
155
- private makeWrapper;
156
- }
157
- export declare const makeNumTypePkgBuff: (pkgType: number, requestId: number, encoded: Uint8Array[]) => void;
158
- export declare const parseNumTypePkgBuff: (buff: Uint8Array) => ParseResult<number>;
159
- export declare class LazyConn<ConnContextT> implements IConn<ConnContextT> {
160
- constructor(connectFunc: () => Promise<IConn<ConnContextT> | undefined>);
161
- get id(): number;
162
- get context(): ConnContextT | undefined;
163
- set context(val: ConnContextT | undefined);
164
- localAddress?: string | undefined;
165
- localPort?: number | undefined;
166
- remoteAddress?: string | undefined;
167
- remoteFamily?: string | undefined;
168
- remotePort?: number | undefined;
169
- sendErrorResponse<ErrorT>(error: ErrorWrapper<ErrorT>, requestId: number): Promise<void>;
170
- sendResponse<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>, requestId: number): Promise<void>;
171
- sendMessage<MessageT>(message: MessageWrapper<MessageT>): Promise<void>;
172
- sendRequest<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>): Promise<void>;
173
- close(err?: Error): Promise<void>;
174
- private connect;
175
- private _connectFunc;
176
- private _conn?;
177
- private _waitingConn?;
178
- }
179
66
  declare class ListNode {
180
67
  constructor();
181
68
  getPrev<SelfT extends ListNode>(this: SelfT): SelfT;
@@ -210,38 +97,69 @@ export type TypedPkgHubOpts<PkgTypeT extends number | string> = {
210
97
  makePkgBuff: (pkgType: PkgTypeT, requestId: number, encoded: Uint8Array[]) => void;
211
98
  parsePkgBuff: (buff: Uint8Array) => ParseResult<PkgTypeT>;
212
99
  };
213
- export declare class TypedPkgHub<PkgTypeT extends number | string, ConnContextT = void, HubContextT = void> implements IPkgHub<ConnContextT, HubContextT> {
214
- constructor(net: INet<IConn<ConnContextT>>, opts: TypedPkgHubOpts<PkgTypeT>);
215
- readonly responsePkgType: PkgTypeT;
216
- context?: HubContextT | undefined;
217
- onConnOpen?: (pkgHub: IPkgHub<ConnContextT, HubContextT>, conn: IConn<ConnContextT>, activeOpen: boolean) => void;
218
- onConnClose?: (pkgHub: IPkgHub<ConnContextT, HubContextT>, conn: IConn<ConnContextT>, activeClose: boolean, err?: Error) => void;
219
- address(): AddressInfo | null;
220
- getConn(connId: number): IConn<ConnContextT> | undefined;
221
- connect(connStr: string): Promise<IConn<ConnContextT>>;
222
- connectLocal(): Promise<IConn<ConnContextT>>;
223
- startServer(connStr?: string): Promise<boolean>;
224
- stopServer(): Promise<boolean>;
225
- sendMessageLocal<MessageT>(conn: IConn<ConnContextT>, message: MessageWrapper<MessageT>): void | Promise<void>;
226
- sendRequestLocal<RequestT, ResponseT>(conn: IConn<ConnContextT>, request: RequestWrapper<RequestT, ResponseT>): void | Promise<void>;
100
+ export declare abstract class JsonError<ErrorT> extends ErrorWrapper<ErrorT> {
101
+ protected encode(data: ErrorT): Uint8Array;
102
+ protected decode(buffer: Uint8Array): ErrorT;
103
+ }
104
+ export declare abstract class JsonMessage<MessageT> extends MessageWrapper<MessageT> {
105
+ protected encode(data: MessageT): Uint8Array;
106
+ protected decode(buffer: Uint8Array): MessageT;
107
+ }
108
+ export declare abstract class JsonRequest<RequestT, ResponseT> extends RequestWrapper<RequestT, ResponseT> {
109
+ protected encode(data: RequestT): Uint8Array;
110
+ protected decode(buffer: Uint8Array): RequestT;
111
+ protected encodeResponse(response: ResponseT): Uint8Array;
112
+ protected decodeResponse(buffer: Uint8Array): ResponseT;
113
+ }
114
+ export declare class CommonError extends JsonError<string> {
115
+ }
116
+ export interface DoneResp<ResultT extends string | number | boolean = boolean> {
117
+ result: ResultT;
118
+ }
119
+ export interface IAuthResp {
120
+ cid: string;
121
+ token: string;
122
+ shard?: number;
123
+ }
124
+ export declare const handleUncaughtErrorWith: (handler: (conn: IConn<unknown>, err: Error) => ErrorWrapper<unknown>) => void;
125
+ export declare enum NetErrorString {
126
+ AuthTimeout = "AuthTimeout",
127
+ BadRequest = "BadRequest",
128
+ ConnectFailed = "ConnectFailed",
129
+ ConnectionClosed = "ConnectionClosed",
130
+ InvalidConnString = "InvalidConnString",
131
+ InvalidConnection = "InvalidConnection",
132
+ InvalidPackage = "InvalidPackage",
133
+ NotAuthenticated = "NotAuthenticated",
134
+ Timeout = "Timeout",
135
+ UnknownError = "UnknownError"
136
+ }
137
+ export declare const createNumPkgTypeClient: (getConnStr: (shard?: number) => string, timeoutMonitor?: TimeoutMonitor) => WsClient<number>;
138
+ export declare class WsClient<PkgTypeT extends number | string> {
139
+ constructor(getConnStr: (shard?: number) => string, opts: TypedPkgHubOpts<PkgTypeT>);
227
140
  registerError<ErrorT>(pkgType: PkgTypeT, wrapperCtor: ErrorWrapperCtor<ErrorT>): void;
228
141
  registerMessage<MessageT>(pkgType: PkgTypeT, wrapperCtor: MessageWrapperCtor<MessageT>): void;
229
142
  registerRequest<RequestT, ResponseT>(pkgType: PkgTypeT, wrapperCtor: RequestWrapperCtor<RequestT, ResponseT>): void;
230
- handleMessageWith<MessageT, WrapperT extends MessageWrapper<MessageT>>(handler: IMessageHandler<PkgTypeT, MessageT, WrapperT, ConnContextT>): IPkgHandler<PkgTypeT, ConnContextT>;
231
- handleRequestWith<RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT>>(handler: IRequestHandler<PkgTypeT, RequestT, ResponseT, WrapperT, ConnContextT>): IPkgHandler<PkgTypeT, ConnContextT>;
232
- removeHandler(handler: IPkgHandler<PkgTypeT, ConnContextT>): boolean;
233
- private connPkgBuffCallback;
234
- private connClosedCallback;
235
- private onResponse;
236
- private _connOpts;
237
- private _nextConnId;
238
- private _makePkgBuff;
239
- private _parsePkgBuff;
240
- private _net;
241
- private _connMap;
242
- private _handlerMap;
243
- private _errorWrapperMap;
244
- private _timeoutMonitor?;
143
+ handleMessageWith<MessageT, WrapperT extends MessageWrapper<MessageT>>(wrapperCtor: MessageWrapperCtor<MessageT, WrapperT>, handler: (message: MessageT) => void | Promise<void>): void;
144
+ handleRequestWith<RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT>>(wrapperCtor: RequestWrapperCtor<RequestT, ResponseT, WrapperT>, handler: (request: RequestT) => ResponseT | Promise<ResponseT>): void;
145
+ sendMessage<MessageT>(message: MessageWrapper<MessageT>): Promise<void>;
146
+ sendRequest<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>): Promise<ResponseT>;
147
+ sendCustomAuthRequest<RequestT, ResponseT extends IAuthResp>(_request: RequestWrapper<RequestT, ResponseT>): Promise<ResponseT>;
148
+ resetAuthState(): void;
149
+ enableAuthenticate(proxyAuthPkgType: PkgTypeT, authStatusCallback: (cid: string) => void, allowAnonymous?: true): void;
150
+ reconnect(delay?: number): void;
151
+ onConnectionStatus(listener: (isOpen: boolean, active: boolean, err?: Error) => void): void;
152
+ private connect;
153
+ private onConnOpen;
154
+ private onConnClose;
155
+ private _pkgHub;
156
+ private _conn;
157
+ private _cid;
158
+ private _connState;
159
+ private _getConnStr;
160
+ private _originConnect;
161
+ private _connectDelay?;
162
+ private _listenerArr?;
245
163
  }
246
164
 
247
165
  export {};
package/lib/index.js CHANGED
@@ -1,10 +1,7 @@
1
1
  export { CommonError, handleUncaughtErrorWith } from './handler/common';
2
- export { SimpleMessageHandler } from './handler/SimpleHandler';
3
- export { BrowserWsNet } from './net/BrowserWsNet';
4
- export { makeNumTypePkgBuff, parseNumTypePkgBuff } from './net/hubPkgSerializer';
5
2
  export { JsonError, JsonMessage, JsonRequest } from './net/JsonPackageWrapper';
6
- export { LazyConn } from './net/LazyConn';
3
+ export { NetErrorString } from './net/NetErrorString';
7
4
  export { ErrorWrapper, EventWrapper, MessageWrapper, RequestWrapper } from './net/PackageWrapper';
8
5
  export { TimeoutMonitor } from './net/TimeoutMonitor';
9
- export { TypedPkgHub } from './net/TypedPkgHub';
6
+ export { createNumPkgTypeClient, WsClient } from './WsClient';
10
7
  //# sourceMappingURL=index.js.map
@@ -1,53 +1,57 @@
1
- import { l } from '../common/utils';
2
- export class BrowserWsNet {
3
- address() {
1
+ import { y } from '../common/utils';
2
+ import { NetErrorString } from './NetErrorString';
3
+ export class r {
4
+ o() {
4
5
  return null;
5
6
  }
6
- setConnWrapperMaker(makeWrapper) {
7
- this.makeWrapper = makeWrapper;
7
+ P(D) {
8
+ this.D = D;
8
9
  }
9
- async startListen(_connStr) {
10
+ async Q(t) {
10
11
  return false;
11
12
  }
12
- async stopListen() {
13
+ async R() {
13
14
  return false;
14
15
  }
15
- async connect(connStr) {
16
- const c = new WebSocket(connStr);
17
- return new Promise((f, g) => {
18
- c.onerror = (h) => {
19
- g(new Error('WebSocket error'));
16
+ async c(e) {
17
+ const f = new WebSocket(e);
18
+ return new Promise((d, i) => {
19
+ f.onerror = (k) => {
20
+ i(new Error(NetErrorString.m));
20
21
  };
21
- c.onopen = () => {
22
- f(this.L(c, true));
22
+ f.onopen = () => {
23
+ d(this.a4(f, true));
23
24
  };
24
25
  });
25
26
  }
26
- L = (c, isActive) => {
27
- const a = new i(c);
28
- const { conn, onPkgBuff, onClose } = this.makeWrapper(a, isActive);
29
- c.onmessage = (e) => {
30
- e.data.arrayBuffer().then((buff) => {
31
- onPkgBuff(new Uint8Array(buff));
27
+ a4 = (f, q) => {
28
+ const b = new s(f);
29
+ const { conn, E, n } = this.D(b, q);
30
+ f.onmessage = (j) => {
31
+ j.data.arrayBuffer().then((buff) => {
32
+ E(new Uint8Array(buff));
32
33
  });
33
34
  };
34
- c.onerror = (h) => {
35
- onClose(new Error('WebSocket error'));
35
+ f.onerror = (k) => {
36
+ n(new Error(NetErrorString.m));
36
37
  };
37
- c.onclose = (e) => {
38
- if (e.code === 1000) {
39
- onClose();
38
+ f.onclose = (j) => {
39
+ if (j.code === 1000) {
40
+ n();
41
+ }
42
+ else {
43
+ n(new Error(j.reason));
40
44
  }
41
45
  };
42
46
  return conn;
43
47
  };
44
- makeWrapper(b, j) {
48
+ D(a, u) {
45
49
  throw new Error('Need to call "setConnWrapperMaker" before using');
46
50
  }
47
51
  }
48
- class i {
49
- constructor(c) {
50
- this.d = c;
52
+ class s {
53
+ constructor(f) {
54
+ this.g = f;
51
55
  }
52
56
  get localAddress() {
53
57
  return;
@@ -64,36 +68,36 @@ class i {
64
68
  get remotePort() {
65
69
  return;
66
70
  }
67
- async sendPkgBuff(buff) {
68
- if (this.d) {
69
- return this.d.send(buff);
71
+ async N(buff) {
72
+ if (this.g) {
73
+ return this.g.send(buff);
70
74
  }
71
- throw new Error('Invalid socket');
75
+ throw new Error(NetErrorString.l);
72
76
  }
73
- async sendPkgBuffV(buffVector) {
74
- if (this.d) {
75
- const buff = l(buffVector);
76
- return this.d.send(buff);
77
+ async p(h) {
78
+ if (this.g) {
79
+ const buff = y(h);
80
+ return this.g.send(buff);
77
81
  }
78
- throw new Error('Invalid socket');
82
+ throw new Error(NetErrorString.l);
79
83
  }
80
84
  async close(err) {
81
- const { d } = this;
82
- if (d) {
83
- this.d = undefined;
85
+ const { g } = this;
86
+ if (g) {
87
+ this.g = undefined;
84
88
  if (!err) {
85
- if (d.readyState === WebSocket.OPEN) {
86
- d.close(1000);
89
+ if (g.readyState === WebSocket.OPEN) {
90
+ g.close(1000);
87
91
  }
88
92
  }
89
93
  else {
90
- d.close(3000, err.message);
94
+ g.close(3000, err.message);
91
95
  }
92
96
  }
93
97
  }
94
- hadClosed() {
95
- return !this.d;
98
+ O() {
99
+ return !this.g;
96
100
  }
97
- d;
101
+ g;
98
102
  }
99
103
  //# sourceMappingURL=BrowserWsNet.js.map