justrun-ws 0.1.0

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/README.md ADDED
@@ -0,0 +1,4 @@
1
+ # justrun-ws
2
+ [![justrun-ws npm version](https://img.shields.io/npm/v/justrun-ws.svg?style=popout&color=blue&label=justrun-ws)](https://www.npmjs.com/package/justrun-ws)
3
+
4
+ Browser side network implementation with WebSocket for justrun.
@@ -0,0 +1 @@
1
+ (()=>{"use strict";new TextEncoder,new TextDecoder})();
@@ -0,0 +1,31 @@
1
+ export class DataWrapper {
2
+ constructor(b, needParse) {
3
+ if (needParse) {
4
+ this.k = b;
5
+ this.l = undefined;
6
+ }
7
+ else {
8
+ this.k = undefined;
9
+ this.l = b;
10
+ }
11
+ }
12
+ get data() {
13
+ if (!this.l) {
14
+ this.l = this.decode(this.k);
15
+ }
16
+ return this.l;
17
+ }
18
+ set data(a) {
19
+ this.l = a;
20
+ this.k = undefined;
21
+ }
22
+ get buff() {
23
+ if (!this.k) {
24
+ this.k = this.encode(this.l);
25
+ }
26
+ return this.k;
27
+ }
28
+ k;
29
+ l;
30
+ }
31
+ //# sourceMappingURL=DataWrapper.js.map
@@ -0,0 +1,52 @@
1
+ export class ListNode {
2
+ constructor() {
3
+ this.e = this;
4
+ this.f = this;
5
+ }
6
+ getPrev() {
7
+ return this.e;
8
+ }
9
+ getNext() {
10
+ return this.f;
11
+ }
12
+ insertBefore(node) {
13
+ this.f = node;
14
+ this.e = node.e;
15
+ node.e = this;
16
+ this.e.f = this;
17
+ }
18
+ insertAfter(node) {
19
+ this.e = node;
20
+ this.f = node.f;
21
+ node.f = this;
22
+ this.f.e = this;
23
+ }
24
+ remove() {
25
+ this.e.f = this.f;
26
+ this.f.e = this.e;
27
+ }
28
+ e;
29
+ f;
30
+ }
31
+ export class c {
32
+ constructor() {
33
+ this.t = new ListNode();
34
+ }
35
+ get g() {
36
+ return this.t.getNext();
37
+ }
38
+ get a() {
39
+ return this.t.getPrev();
40
+ }
41
+ C(node) {
42
+ return node === this.t;
43
+ }
44
+ D(node) {
45
+ node.insertAfter(this.t);
46
+ }
47
+ U(node) {
48
+ node.insertBefore(this.t);
49
+ }
50
+ t;
51
+ }
52
+ //# sourceMappingURL=List.js.map
@@ -0,0 +1,30 @@
1
+ export const j = (g) => {
2
+ return new Promise((f) => setTimeout(f, g));
3
+ };
4
+ export const i = () => { };
5
+ export const k = (h = 0x100000000) => {
6
+ return (Math.random() * h) << 0;
7
+ };
8
+ export const m = (d) => {
9
+ let c = 5381, b = 0;
10
+ while (b < d.length) {
11
+ c = ((c << 5) + c) + d.charCodeAt(b++);
12
+ }
13
+ return c >>> 0;
14
+ };
15
+ export const l = (buffVector) => {
16
+ let b = 0;
17
+ let a = 0;
18
+ while (b < buffVector.length) {
19
+ a += buffVector[b++].length;
20
+ }
21
+ const e = new Uint8Array(a);
22
+ a = 0;
23
+ while (b > 0) {
24
+ const buff = buffVector[--b];
25
+ e.set(buff, a);
26
+ a += buff.length;
27
+ }
28
+ return e;
29
+ };
30
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1,103 @@
1
+ export const o = (a) => {
2
+ let e = 1;
3
+ while (a >>>= 7) {
4
+ e++;
5
+ }
6
+ return e;
7
+ };
8
+ export const j = (i) => {
9
+ let a;
10
+ let b = 0;
11
+ let e = 0;
12
+ while (b < i.length) {
13
+ e++;
14
+ a = i[b++];
15
+ while (a >>>= 7) {
16
+ e++;
17
+ }
18
+ }
19
+ return e;
20
+ };
21
+ export const p = (buffer, f = 0) => {
22
+ let c;
23
+ let d = f;
24
+ let a = 0;
25
+ let g = 0;
26
+ do {
27
+ c = buffer[d++];
28
+ a |= (c & 127) << g;
29
+ g += 7;
30
+ } while (c & 128);
31
+ if (c !== undefined && g <= 35) {
32
+ return {
33
+ a: a,
34
+ k: d - f,
35
+ };
36
+ }
37
+ else {
38
+ throw new Error('Parsing failed');
39
+ }
40
+ };
41
+ export const l = (n, buffer, f = 0) => {
42
+ let b;
43
+ let c;
44
+ let d = f;
45
+ let a = 0;
46
+ let g = 0;
47
+ const h = [];
48
+ for (b = 0; b < n; b++) {
49
+ do {
50
+ c = buffer[d++];
51
+ a |= (c & 127) << g;
52
+ g += 7;
53
+ } while (c & 128);
54
+ if (c !== undefined && g <= 35) {
55
+ h.push(a);
56
+ a = 0;
57
+ g = 0;
58
+ }
59
+ else {
60
+ throw new Error('Parsing failed');
61
+ }
62
+ }
63
+ return {
64
+ h,
65
+ k: d - f,
66
+ };
67
+ };
68
+ export const q = (a, buffer, f = 0) => {
69
+ let d = f;
70
+ let c = a & 127;
71
+ while (a >>>= 7) {
72
+ buffer[d++] = c | 128;
73
+ c = a & 127;
74
+ }
75
+ buffer[d++] = c;
76
+ if (d <= buffer.length) {
77
+ return d - f;
78
+ }
79
+ else {
80
+ throw new Error('Buffer overflow');
81
+ }
82
+ };
83
+ export const m = (h, buffer, f = 0) => {
84
+ let b;
85
+ let a;
86
+ let d = f;
87
+ for (b = 0; b < h.length; b++) {
88
+ a = h[b];
89
+ let c = a & 127;
90
+ while (a >>>= 7) {
91
+ buffer[d++] = c | 128;
92
+ c = a & 127;
93
+ }
94
+ buffer[d++] = c;
95
+ }
96
+ if (d <= buffer.length) {
97
+ return d - f;
98
+ }
99
+ else {
100
+ throw new Error('Buffer overflow');
101
+ }
102
+ };
103
+ //# sourceMappingURL=varUintOps.js.map
@@ -0,0 +1,128 @@
1
+ import { a, c } from './common';
2
+ export class SimpleMessageHandler {
3
+ constructor(wrapperCtor, d, e = true) {
4
+ this.g = wrapperCtor;
5
+ this.m = d;
6
+ this.n = e;
7
+ }
8
+ get pkgType() {
9
+ return this.g.pkgType;
10
+ }
11
+ get pkgName() {
12
+ return this.g.name;
13
+ }
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) {
19
+ try {
20
+ await this.m(conn, message);
21
+ }
22
+ catch (err) {
23
+ if (!err.isError) {
24
+ this.wrapUncaughtError(conn, err);
25
+ }
26
+ }
27
+ }
28
+ else {
29
+ this.wrapUncaughtError(conn, a);
30
+ }
31
+ if (conn.context === undefined) {
32
+ await conn.close();
33
+ }
34
+ }
35
+ async runLocal(conn, message) {
36
+ if (conn.context !== undefined || !this.n) {
37
+ try {
38
+ return await this.m(conn, message);
39
+ }
40
+ catch (err) {
41
+ if (!err.isError) {
42
+ this.wrapUncaughtError(conn, err);
43
+ }
44
+ }
45
+ }
46
+ else {
47
+ this.wrapUncaughtError(conn, a);
48
+ }
49
+ }
50
+ wrapUncaughtError(conn, err) {
51
+ return c(conn, err);
52
+ }
53
+ g;
54
+ m;
55
+ n;
56
+ }
57
+ export class h {
58
+ constructor(wrapperCtor, d, e = true) {
59
+ this.g = wrapperCtor;
60
+ this.m = d;
61
+ this.n = e;
62
+ }
63
+ get pkgType() {
64
+ return this.g.pkgType;
65
+ }
66
+ get pkgName() {
67
+ return this.g.name;
68
+ }
69
+ async run(conn, parseResult) {
70
+ const { buff, requestId, bodyOffset } = parseResult;
71
+ const b = buff.subarray(bodyOffset);
72
+ const request = new this.g(b, true);
73
+ let error;
74
+ if (conn.context !== undefined || !this.n) {
75
+ try {
76
+ await this.m(conn, request);
77
+ }
78
+ catch (err) {
79
+ if (err.isError) {
80
+ error = err;
81
+ }
82
+ else {
83
+ error = this.wrapUncaughtError(conn, err);
84
+ }
85
+ }
86
+ }
87
+ else {
88
+ error = this.wrapUncaughtError(conn, a);
89
+ }
90
+ try {
91
+ if (!error) {
92
+ await conn.sendResponse(request, requestId);
93
+ }
94
+ else {
95
+ await conn.sendErrorResponse(error, requestId);
96
+ }
97
+ if (conn.context === undefined) {
98
+ await conn.close();
99
+ }
100
+ }
101
+ catch (err) {
102
+ await conn.close(err);
103
+ }
104
+ }
105
+ async runLocal(conn, request) {
106
+ if (conn.context !== undefined || !this.n) {
107
+ try {
108
+ return await this.m(conn, request);
109
+ }
110
+ catch (err) {
111
+ if (err.isError) {
112
+ throw err;
113
+ }
114
+ else {
115
+ throw this.wrapUncaughtError(conn, err);
116
+ }
117
+ }
118
+ }
119
+ throw this.wrapUncaughtError(conn, a);
120
+ }
121
+ wrapUncaughtError(conn, err) {
122
+ return c(conn, err);
123
+ }
124
+ g;
125
+ m;
126
+ n;
127
+ }
128
+ //# sourceMappingURL=SimpleHandler.js.map
@@ -0,0 +1,14 @@
1
+ import { JsonError } from '../net/JsonPackageWrapper';
2
+ export class f extends JsonError {
3
+ }
4
+ export const a = { message: 'Connection is not authenticated' };
5
+ let e = (b, err) => {
6
+ return new f(err.message);
7
+ };
8
+ export const c = (conn, err) => {
9
+ return e(conn, err);
10
+ };
11
+ export const h = (handler) => {
12
+ e = handler;
13
+ };
14
+ //# sourceMappingURL=common.js.map
package/lib/index.d.ts ADDED
@@ -0,0 +1,240 @@
1
+ // Generated by dts-bundle-generator v9.5.1
2
+
3
+ export interface IWrapper<DataT> {
4
+ get buff(): Uint8Array;
5
+ get data(): DataT;
6
+ }
7
+ declare abstract class DataWrapper<DataT> implements IWrapper<DataT> {
8
+ constructor(input: DataT | Uint8Array, needParse?: true);
9
+ get data(): DataT;
10
+ set data(val: DataT);
11
+ get buff(): Uint8Array;
12
+ protected abstract encode(data: DataT): Uint8Array;
13
+ protected abstract decode(buffer: Uint8Array): DataT;
14
+ private _buff?;
15
+ private _data?;
16
+ }
17
+ declare abstract class PkgWrapper<DataT> extends DataWrapper<DataT> {
18
+ static context: unknown;
19
+ static registerPkgType(pkgType: number | string): void;
20
+ static get pkgType(): number | string;
21
+ }
22
+ export declare abstract class ErrorWrapper<ErrorT> extends PkgWrapper<ErrorT> {
23
+ isError(): boolean;
24
+ }
25
+ export declare abstract class MessageWrapper<MessageT> extends PkgWrapper<MessageT> {
26
+ isMessage(): boolean;
27
+ }
28
+ export declare abstract class EventWrapper<EventT> extends PkgWrapper<EventT> {
29
+ isEvent(): boolean;
30
+ }
31
+ export declare abstract class RequestWrapper<RequestT, ResponseT> extends PkgWrapper<RequestT> {
32
+ constructor(input: RequestT | Uint8Array, needParse?: true);
33
+ isRequest(): boolean;
34
+ get resp(): ResponseT;
35
+ set resp(val: ResponseT);
36
+ get respBuff(): Uint8Array;
37
+ set respBuff(val: Uint8Array);
38
+ protected abstract encodeResponse(response: ResponseT): Uint8Array;
39
+ protected abstract decodeResponse(buffer: Uint8Array): ResponseT;
40
+ private _resp?;
41
+ private _respBuff?;
42
+ }
43
+ export type ErrorWrapperCtor<ErrorT, WrapperT extends ErrorWrapper<ErrorT> = ErrorWrapper<ErrorT>> = new (error: ErrorT | Uint8Array, needParse?: true) => WrapperT;
44
+ export type MessageWrapperCtor<MessageT, WrapperT extends MessageWrapper<MessageT> = MessageWrapper<MessageT>> = new (message: MessageT | Uint8Array, needParse?: true) => WrapperT;
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
+ export interface IConn<ConnContextT = void> {
75
+ context?: ConnContextT | undefined;
76
+ readonly id: number;
77
+ readonly localAddress?: string;
78
+ readonly localPort?: number;
79
+ readonly remoteAddress?: string;
80
+ readonly remoteFamily?: string;
81
+ readonly remotePort?: number;
82
+ sendMessage<MessageT>(message: MessageWrapper<MessageT>): Promise<void>;
83
+ sendRequest<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>): Promise<void>;
84
+ sendErrorResponse<ErrorT>(error: ErrorWrapper<ErrorT>, requestId: number): Promise<void>;
85
+ sendResponse<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>, requestId: number): Promise<void>;
86
+ close(err?: Error): Promise<void>;
87
+ }
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
+ export type ParseResult<PkgTypeT extends number | string> = {
98
+ buff: Uint8Array;
99
+ pkgType: PkgTypeT;
100
+ requestId: number;
101
+ bodyOffset: number;
102
+ };
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
+ wrapUncaughtError(conn: IConn<unknown>, err: Error): ErrorWrapper<unknown>;
108
+ }
109
+ export interface IMessageHandler<PkgTypeT extends number | string, MessageT, WrapperT extends MessageWrapper<MessageT>, ConnContextT = void> extends IPkgHandler<PkgTypeT, ConnContextT> {
110
+ runLocal(conn: IConn<ConnContextT>, message: WrapperT): void | Promise<void>;
111
+ }
112
+ export interface IRequestHandler<PkgTypeT extends number | string, RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT>, ConnContextT = void> extends IPkgHandler<PkgTypeT, ConnContextT> {
113
+ runLocal(conn: IConn<ConnContextT>, request: WrapperT): void | Promise<void>;
114
+ }
115
+ export type HandleFunc<WrapperT, ConnContextT> = (conn: IConn<ConnContextT>, wrapper: WrapperT) => void | Promise<void>;
116
+ export declare class SimpleMessageHandler<PkgTypeT extends number | string, MessageT, WrapperT extends MessageWrapper<MessageT>, ConnContextT> implements IMessageHandler<PkgTypeT, MessageT, WrapperT, ConnContextT> {
117
+ constructor(wrapperCtor: MessageWrapperCtor<MessageT, WrapperT>, handleFunc: HandleFunc<WrapperT, ConnContextT>, checkContext?: boolean);
118
+ get pkgType(): PkgTypeT;
119
+ get pkgName(): string;
120
+ run(conn: IConn<ConnContextT>, parseResult: ParseResult<PkgTypeT>): Promise<void>;
121
+ runLocal(conn: IConn<ConnContextT>, message: WrapperT): Promise<void>;
122
+ wrapUncaughtError(conn: IConn<unknown>, err: Error): ErrorWrapper<unknown>;
123
+ private _wrapperCtor;
124
+ private _handleFunc;
125
+ private _checkContext;
126
+ }
127
+ export declare class BrowserWsNet<ConnWrapperT> implements INet<ConnWrapperT> {
128
+ address(): AddressInfo | null;
129
+ setConnWrapperMaker(makeWrapper: (conn: IRawPkgConn, isActive?: boolean) => IPkgConnWrapper<ConnWrapperT>): void;
130
+ startListen(_connStr?: string): Promise<boolean>;
131
+ stopListen(): Promise<boolean>;
132
+ connect(connStr: string): Promise<ConnWrapperT>;
133
+ private setupConn;
134
+ private makeWrapper;
135
+ }
136
+ export declare const makeNumTypePkgBuff: (pkgType: number, requestId: number, encoded: Uint8Array[]) => void;
137
+ export declare const parseNumTypePkgBuff: (buff: Uint8Array) => ParseResult<number>;
138
+ export declare abstract class JsonError<ErrorT> extends ErrorWrapper<ErrorT> {
139
+ protected encode(data: ErrorT): Uint8Array;
140
+ protected decode(buffer: Uint8Array): ErrorT;
141
+ }
142
+ export declare abstract class JsonMessage<MessageT> extends MessageWrapper<MessageT> {
143
+ protected encode(data: MessageT): Uint8Array;
144
+ protected decode(buffer: Uint8Array): MessageT;
145
+ }
146
+ export declare abstract class JsonRequest<RequestT, ResponseT> extends RequestWrapper<RequestT, ResponseT> {
147
+ protected encode(data: RequestT): Uint8Array;
148
+ protected decode(buffer: Uint8Array): RequestT;
149
+ protected encodeResponse(response: ResponseT): Uint8Array;
150
+ protected decodeResponse(buffer: Uint8Array): ResponseT;
151
+ }
152
+ export declare class LazyConn<ConnContextT> implements IConn<ConnContextT> {
153
+ constructor(connectFunc: () => Promise<IConn<ConnContextT> | undefined>);
154
+ get id(): number;
155
+ get context(): ConnContextT | undefined;
156
+ set context(val: ConnContextT | undefined);
157
+ localAddress?: string | undefined;
158
+ localPort?: number | undefined;
159
+ remoteAddress?: string | undefined;
160
+ remoteFamily?: string | undefined;
161
+ remotePort?: number | undefined;
162
+ sendErrorResponse<ErrorT>(error: ErrorWrapper<ErrorT>, requestId: number): Promise<void>;
163
+ sendResponse<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>, requestId: number): Promise<void>;
164
+ sendMessage<MessageT>(message: MessageWrapper<MessageT>): Promise<void>;
165
+ sendRequest<RequestT, ResponseT>(request: RequestWrapper<RequestT, ResponseT>): Promise<void>;
166
+ close(err?: Error): Promise<void>;
167
+ private connect;
168
+ private _connectFunc;
169
+ private _conn?;
170
+ private _waitingConn?;
171
+ }
172
+ declare class ListNode {
173
+ constructor();
174
+ getPrev<SelfT extends ListNode>(this: SelfT): SelfT;
175
+ getNext<SelfT extends ListNode>(this: SelfT): SelfT;
176
+ insertBefore<SelfT extends ListNode>(this: SelfT, node: SelfT): void;
177
+ insertAfter<SelfT extends ListNode>(this: SelfT, node: SelfT): void;
178
+ remove(): void;
179
+ private _prev;
180
+ private _next;
181
+ }
182
+ declare abstract class MonitorConn extends ListNode {
183
+ abstract keepAlive(): void;
184
+ abstract timeout(): void;
185
+ }
186
+ export declare class TimeoutMonitor {
187
+ constructor(tickMilSec: number, aliveTick: number, timeoutTick: number);
188
+ insert(conn: MonitorConn): void;
189
+ update(conn: MonitorConn): void;
190
+ remove(conn: MonitorConn): void;
191
+ private check;
192
+ private _tickMilSec;
193
+ private _aliveTick;
194
+ private _timeoutTick;
195
+ private _currentTick;
196
+ private _monitorCount;
197
+ private _interval?;
198
+ private _checkArr;
199
+ }
200
+ export type TypedPkgHubOpts<PkgTypeT extends number | string> = {
201
+ readonly responsePkgType: PkgTypeT;
202
+ readonly timeoutMonitor?: TimeoutMonitor;
203
+ makePkgBuff: (pkgType: PkgTypeT, requestId: number, encoded: Uint8Array[]) => void;
204
+ parsePkgBuff: (buff: Uint8Array) => ParseResult<PkgTypeT>;
205
+ };
206
+ export declare class TypedPkgHub<PkgTypeT extends number | string, ConnContextT = void, HubContextT = void> implements IPkgHub<ConnContextT, HubContextT> {
207
+ constructor(net: INet<IConn<ConnContextT>>, opts: TypedPkgHubOpts<PkgTypeT>);
208
+ readonly responsePkgType: PkgTypeT;
209
+ context?: HubContextT | undefined;
210
+ onConnOpen?: (pkgHub: IPkgHub<ConnContextT, HubContextT>, conn: IConn<ConnContextT>, activeOpen: boolean) => void;
211
+ onConnClose?: (pkgHub: IPkgHub<ConnContextT, HubContextT>, conn: IConn<ConnContextT>, activeClose: boolean, err?: Error) => void;
212
+ address(): AddressInfo | null;
213
+ getConn(connId: number): IConn<ConnContextT> | undefined;
214
+ connect(connStr: string): Promise<IConn<ConnContextT>>;
215
+ connectLocal(): Promise<IConn<ConnContextT>>;
216
+ startServer(connStr?: string): Promise<boolean>;
217
+ stopServer(): Promise<boolean>;
218
+ sendMessageLocal<MessageT>(conn: IConn<ConnContextT>, message: MessageWrapper<MessageT>): void | Promise<void>;
219
+ sendRequestLocal<RequestT, ResponseT>(conn: IConn<ConnContextT>, request: RequestWrapper<RequestT, ResponseT>): void | Promise<void>;
220
+ registerError<ErrorT>(pkgType: PkgTypeT, wrapperCtor: ErrorWrapperCtor<ErrorT>): void;
221
+ registerMessage<MessageT>(pkgType: PkgTypeT, wrapperCtor: MessageWrapperCtor<MessageT>): void;
222
+ registerRequest<RequestT, ResponseT>(pkgType: PkgTypeT, wrapperCtor: RequestWrapperCtor<RequestT, ResponseT>): void;
223
+ handleMessageWith<MessageT, WrapperT extends MessageWrapper<MessageT>>(handler: IMessageHandler<PkgTypeT, MessageT, WrapperT, ConnContextT>): IPkgHandler<PkgTypeT, ConnContextT>;
224
+ handleRequestWith<RequestT, ResponseT, WrapperT extends RequestWrapper<RequestT, ResponseT>>(handler: IRequestHandler<PkgTypeT, RequestT, ResponseT, WrapperT, ConnContextT>): IPkgHandler<PkgTypeT, ConnContextT>;
225
+ removeHandler(handler: IPkgHandler<PkgTypeT, ConnContextT>): boolean;
226
+ private connPkgBuffCallback;
227
+ private connClosedCallback;
228
+ private onResponse;
229
+ private _connOpts;
230
+ private _nextConnId;
231
+ private _makePkgBuff;
232
+ private _parsePkgBuff;
233
+ private _net;
234
+ private _connMap;
235
+ private _handlerMap;
236
+ private _errorWrapperMap;
237
+ private _timeoutMonitor?;
238
+ }
239
+
240
+ export {};
package/lib/index.js ADDED
@@ -0,0 +1,9 @@
1
+ export { SimpleMessageHandler } from './handler/SimpleHandler';
2
+ export { BrowserWsNet } from './net/BrowserWsNet';
3
+ export { makeNumTypePkgBuff, parseNumTypePkgBuff } from './net/hubPkgSerializer';
4
+ export { JsonError, JsonMessage, JsonRequest } from './net/JsonPackageWrapper';
5
+ export { LazyConn } from './net/LazyConn';
6
+ export { ErrorWrapper, EventWrapper, MessageWrapper, RequestWrapper } from './net/PackageWrapper';
7
+ export { TimeoutMonitor } from './net/TimeoutMonitor';
8
+ export { TypedPkgHub } from './net/TypedPkgHub';
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,99 @@
1
+ import { l } from '../common/utils';
2
+ export class BrowserWsNet {
3
+ address() {
4
+ return null;
5
+ }
6
+ setConnWrapperMaker(makeWrapper) {
7
+ this.makeWrapper = makeWrapper;
8
+ }
9
+ async startListen(_connStr) {
10
+ return false;
11
+ }
12
+ async stopListen() {
13
+ return false;
14
+ }
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'));
20
+ };
21
+ c.onopen = () => {
22
+ f(this.M(c, true));
23
+ };
24
+ });
25
+ }
26
+ M = (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));
32
+ });
33
+ };
34
+ c.onerror = (h) => {
35
+ onClose(new Error('WebSocket error'));
36
+ };
37
+ c.onclose = (e) => {
38
+ if (e.code === 1000) {
39
+ onClose();
40
+ }
41
+ };
42
+ return conn;
43
+ };
44
+ makeWrapper(b, j) {
45
+ throw new Error('Need to call "setConnWrapperMaker" before using');
46
+ }
47
+ }
48
+ class i {
49
+ constructor(c) {
50
+ this.d = c;
51
+ }
52
+ get localAddress() {
53
+ return;
54
+ }
55
+ get localPort() {
56
+ return;
57
+ }
58
+ get remoteAddress() {
59
+ return;
60
+ }
61
+ get remoteFamily() {
62
+ return;
63
+ }
64
+ get remotePort() {
65
+ return;
66
+ }
67
+ async sendPkgBuff(buff) {
68
+ if (this.d) {
69
+ return this.d.send(buff);
70
+ }
71
+ throw new Error('Invalid socket');
72
+ }
73
+ async sendPkgBuffV(buffVector) {
74
+ if (this.d) {
75
+ const buff = l(buffVector);
76
+ return this.d.send(buff);
77
+ }
78
+ throw new Error('Invalid socket');
79
+ }
80
+ async close(err) {
81
+ const { d } = this;
82
+ if (d) {
83
+ this.d = undefined;
84
+ if (!err) {
85
+ if (d.readyState === WebSocket.OPEN) {
86
+ d.close(1000);
87
+ }
88
+ }
89
+ else {
90
+ d.close(3000, err.message);
91
+ }
92
+ }
93
+ }
94
+ hadClosed() {
95
+ return !this.d;
96
+ }
97
+ d;
98
+ }
99
+ //# sourceMappingURL=BrowserWsNet.js.map
@@ -0,0 +1,43 @@
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
@@ -0,0 +1,66 @@
1
+ export class LazyConn {
2
+ constructor(c) {
3
+ this.B = c;
4
+ }
5
+ get id() {
6
+ return this.b?.id ?? -1;
7
+ }
8
+ get context() {
9
+ return this.b?.context;
10
+ }
11
+ set context(a) {
12
+ if (this.b) {
13
+ this.b.context = a;
14
+ }
15
+ }
16
+ localAddress;
17
+ localPort;
18
+ remoteAddress;
19
+ remoteFamily;
20
+ remotePort;
21
+ async sendErrorResponse(error, requestId) {
22
+ return (this.b ?? await this.connect()).sendErrorResponse(error, requestId);
23
+ }
24
+ async sendResponse(request, requestId) {
25
+ return (this.b ?? await this.connect()).sendResponse(request, requestId);
26
+ }
27
+ async sendMessage(message) {
28
+ return (this.b ?? await this.connect()).sendMessage(message);
29
+ }
30
+ async sendRequest(request) {
31
+ return (this.b ?? await this.connect()).sendRequest(request);
32
+ }
33
+ async close(err) {
34
+ const { b } = this;
35
+ if (b) {
36
+ this.b = undefined;
37
+ await b.close(err);
38
+ return;
39
+ }
40
+ if (this.i) {
41
+ await this.i.then((conn) => conn.close(err).then(() => this.b = undefined), () => this.b = undefined);
42
+ }
43
+ }
44
+ async connect() {
45
+ let { i } = this;
46
+ if (!i) {
47
+ i = this.i = new Promise((f, g) => {
48
+ this.B().then((conn) => {
49
+ if (conn) {
50
+ f(conn);
51
+ this.b = conn;
52
+ this.i = undefined;
53
+ }
54
+ else {
55
+ g(new Error('Connect failed'));
56
+ }
57
+ });
58
+ });
59
+ }
60
+ return await i;
61
+ }
62
+ B;
63
+ b;
64
+ i;
65
+ }
66
+ //# sourceMappingURL=LazyConn.js.map
@@ -0,0 +1,71 @@
1
+ import { DataWrapper } from '../common/DataWrapper';
2
+ export { ErrorWrapper, MessageWrapper, EventWrapper, RequestWrapper, };
3
+ class PkgWrapper extends DataWrapper {
4
+ static context;
5
+ static $(pkgType) {
6
+ let c;
7
+ try {
8
+ c = this.pkgType;
9
+ }
10
+ catch {
11
+ Object.defineProperty(this, 'pkgType', {
12
+ value: pkgType,
13
+ writable: false,
14
+ enumerable: false,
15
+ });
16
+ return;
17
+ }
18
+ if (c !== pkgType) {
19
+ throw new Error(`Wrapper ${this.name} is already registered with type ${c}`);
20
+ }
21
+ }
22
+ static get pkgType() {
23
+ throw new Error(`Wrapper ${this.name} need to be registered`);
24
+ }
25
+ }
26
+ class ErrorWrapper extends PkgWrapper {
27
+ isError() {
28
+ return true;
29
+ }
30
+ }
31
+ class MessageWrapper extends PkgWrapper {
32
+ isMessage() {
33
+ return true;
34
+ }
35
+ }
36
+ class EventWrapper extends PkgWrapper {
37
+ isEvent() {
38
+ return true;
39
+ }
40
+ }
41
+ class RequestWrapper extends PkgWrapper {
42
+ constructor(b, needParse) {
43
+ super(b, needParse);
44
+ }
45
+ isRequest() {
46
+ return true;
47
+ }
48
+ get resp() {
49
+ if (!this.r) {
50
+ this.r = this.decodeResponse(this.s);
51
+ }
52
+ return this.r;
53
+ }
54
+ set resp(a) {
55
+ this.r = a;
56
+ this.s = undefined;
57
+ }
58
+ get respBuff() {
59
+ if (!this.s) {
60
+ this.s = this.encodeResponse(this.r);
61
+ }
62
+ return this.s;
63
+ }
64
+ set respBuff(a) {
65
+ this.r = undefined;
66
+ this.s = a;
67
+ }
68
+ r;
69
+ s;
70
+ }
71
+ //# sourceMappingURL=PackageWrapper.js.map
@@ -0,0 +1,70 @@
1
+ import { ListNode, c } from '../common/List';
2
+ import { i } from '../common/utils';
3
+ export class MonitorConn extends ListNode {
4
+ }
5
+ export class TimeoutMonitor {
6
+ constructor(e, h, f) {
7
+ this.E = e;
8
+ this.y = h;
9
+ this.w = f;
10
+ this.j = 0;
11
+ this.x = 0;
12
+ this.o = [];
13
+ if (e === 0) {
14
+ this.insert = i;
15
+ this.update = i;
16
+ this.remove = i;
17
+ return;
18
+ }
19
+ for (let b = 0; b < f; b++) {
20
+ this.o.push(new c());
21
+ }
22
+ }
23
+ insert(conn) {
24
+ if (!this.x) {
25
+ this.F = setInterval(this.N, this.E);
26
+ }
27
+ this.x++;
28
+ this.o[this.j].D(conn);
29
+ }
30
+ update(conn) {
31
+ conn.remove();
32
+ this.o[this.j].D(conn);
33
+ }
34
+ remove(conn) {
35
+ conn.remove();
36
+ this.x--;
37
+ if (!this.x) {
38
+ clearInterval(this.F);
39
+ }
40
+ }
41
+ N = () => {
42
+ const { y, w, o } = this;
43
+ this.j++;
44
+ if (this.j === w) {
45
+ this.j = 0;
46
+ }
47
+ if (y) {
48
+ let d = this.j + y;
49
+ if (d >= w) {
50
+ d -= w;
51
+ }
52
+ const a = o[d];
53
+ for (let node = a.g; !a.C(node); node = node.getNext()) {
54
+ node.keepAlive();
55
+ }
56
+ }
57
+ const a = o[this.j];
58
+ for (let node = a.g; !a.C(node); node = node.getNext()) {
59
+ node.timeout();
60
+ }
61
+ };
62
+ E;
63
+ y;
64
+ w;
65
+ j;
66
+ x;
67
+ F;
68
+ o;
69
+ }
70
+ //# sourceMappingURL=TimeoutMonitor.js.map
@@ -0,0 +1,319 @@
1
+ import { l, i } from '../common/utils';
2
+ import { MonitorConn } from './TimeoutMonitor';
3
+ export class TypedPkgHub {
4
+ constructor(s, m) {
5
+ const { responsePkgType, timeoutMonitor, makePkgBuff, parsePkgBuff } = m;
6
+ this.responsePkgType = responsePkgType;
7
+ this.context = undefined;
8
+ this.onConnOpen = undefined;
9
+ this.onConnClose = undefined;
10
+ this.p = 0;
11
+ this.q = new Map();
12
+ this.c = new Map();
13
+ this._ = new Map();
14
+ this.G = makePkgBuff;
15
+ this.H = parsePkgBuff;
16
+ this.u = s;
17
+ this.z = timeoutMonitor;
18
+ const o = this;
19
+ o.run = this.O;
20
+ const j = [];
21
+ this.G(responsePkgType, 0x200000, j);
22
+ this.I = {
23
+ makePkgBuff: makePkgBuff,
24
+ responsePkgType: responsePkgType,
25
+ j: l(j),
26
+ };
27
+ this.c.set(responsePkgType, o);
28
+ this.u.setConnWrapperMaker((a, isActive) => {
29
+ do {
30
+ this.p++;
31
+ } while (this.q.has(this.p & 0x1fffff));
32
+ const conn = new k(this.I, a, this.p & 0x1fffff);
33
+ this.q.set(conn.id, conn);
34
+ this.z?.insert(conn);
35
+ const e = {
36
+ conn,
37
+ onPkgBuff: (buff) => this.P(conn, buff),
38
+ onClose: (err) => this.Q(conn, err),
39
+ };
40
+ this.onConnOpen?.(this, conn, !!isActive);
41
+ return e;
42
+ });
43
+ }
44
+ responsePkgType;
45
+ context;
46
+ onConnOpen;
47
+ onConnClose;
48
+ address() {
49
+ return this.u.address();
50
+ }
51
+ getConn(connId) {
52
+ return this.q.get(connId);
53
+ }
54
+ connect(connStr) {
55
+ return this.u.connect(connStr);
56
+ }
57
+ async connectLocal() {
58
+ do {
59
+ this.p++;
60
+ } while (this.q.has(this.p & 0x1fffff));
61
+ const conn = new t(this.p & 0x1fffff, this);
62
+ this.q.set(conn.id, conn);
63
+ return conn;
64
+ }
65
+ async startServer(connStr) {
66
+ return this.u.startListen(connStr);
67
+ }
68
+ async stopServer() {
69
+ return this.u.stopListen();
70
+ }
71
+ sendMessageLocal(conn, message) {
72
+ const pkgType = message.constructor.pkgType;
73
+ const handler = this.c.get(pkgType);
74
+ if (handler) {
75
+ return handler?.runLocal(conn, message);
76
+ }
77
+ throw new Error('Invalid package');
78
+ }
79
+ sendRequestLocal(conn, request) {
80
+ const pkgType = request.constructor.pkgType;
81
+ const handler = this.c.get(pkgType);
82
+ if (handler) {
83
+ return handler?.runLocal(conn, request);
84
+ }
85
+ throw new Error('Invalid package');
86
+ }
87
+ registerError(pkgType, wrapperCtor) {
88
+ wrapperCtor.$(pkgType);
89
+ this._.set(pkgType, wrapperCtor);
90
+ const w = this.c.get(this.responsePkgType);
91
+ this.c.set(pkgType, w);
92
+ }
93
+ registerMessage(pkgType, wrapperCtor) {
94
+ wrapperCtor.$(pkgType);
95
+ }
96
+ registerRequest(pkgType, wrapperCtor) {
97
+ wrapperCtor.$(pkgType);
98
+ }
99
+ handleMessageWith(handler) {
100
+ const pkgType = handler.pkgType;
101
+ if (typeof pkgType !== typeof this.responsePkgType) {
102
+ throw new Error(`Wrapper ${handler.pkgName} has an incompatible pkgType ${typeof pkgType}`);
103
+ }
104
+ if (this.c.has(pkgType)) {
105
+ throw new Error(`Wrapper ${handler.pkgName} is already handled by another handler`);
106
+ }
107
+ this.c.set(pkgType, handler);
108
+ return handler;
109
+ }
110
+ handleRequestWith(handler) {
111
+ const pkgType = handler.pkgType;
112
+ if (typeof pkgType !== typeof this.responsePkgType) {
113
+ throw new Error(`Wrapper ${handler.pkgName} has an incompatible pkgType ${typeof pkgType}`);
114
+ }
115
+ if (this.c.has(pkgType)) {
116
+ throw new Error(`Wrapper ${handler.pkgName} is already handled by another handler`);
117
+ }
118
+ this.c.set(pkgType, handler);
119
+ return handler;
120
+ }
121
+ removeHandler(handler) {
122
+ const pkgType = handler.pkgType;
123
+ const x = this.c.get(pkgType);
124
+ if (x === handler) {
125
+ this.c.delete(pkgType);
126
+ return true;
127
+ }
128
+ return false;
129
+ }
130
+ P(conn, buff) {
131
+ this.z?.update(conn);
132
+ const parseResult = this.H(buff);
133
+ const handler = this.c.get(parseResult.pkgType);
134
+ if (handler) {
135
+ handler.run(conn, parseResult);
136
+ return;
137
+ }
138
+ conn.close(new Error('Invalid package'));
139
+ }
140
+ Q(conn, err) {
141
+ const connId = conn.id;
142
+ this.q.delete(connId);
143
+ this.z?.remove(conn);
144
+ conn.onClose(err);
145
+ this.onConnClose?.(this, conn, conn.a.hadClosed(), err);
146
+ }
147
+ O(conn, parseResult) {
148
+ const { buff, pkgType, requestId, bodyOffset } = parseResult;
149
+ if (pkgType === this.responsePkgType) {
150
+ const b = buff.subarray(bodyOffset);
151
+ conn.J(requestId, b);
152
+ }
153
+ else {
154
+ const r = this._.get(pkgType);
155
+ if (r) {
156
+ const b = buff.subarray(bodyOffset);
157
+ const y = new r(b, true);
158
+ conn.R(requestId, y);
159
+ }
160
+ }
161
+ }
162
+ I;
163
+ p;
164
+ G;
165
+ H;
166
+ u;
167
+ q;
168
+ c;
169
+ _;
170
+ z;
171
+ }
172
+ class k extends MonitorConn {
173
+ constructor(m, a, id) {
174
+ super();
175
+ this.context = undefined;
176
+ this.id = id;
177
+ this.a = a;
178
+ this.v = m;
179
+ this.h = undefined;
180
+ this.K = 0;
181
+ }
182
+ context;
183
+ id;
184
+ a;
185
+ get localAddress() {
186
+ return this.a.localAddress;
187
+ }
188
+ get localPort() {
189
+ return this.a.localPort;
190
+ }
191
+ get remoteAddress() {
192
+ return this.a.remoteAddress;
193
+ }
194
+ get remoteFamily() {
195
+ return this.a.remoteFamily;
196
+ }
197
+ get remotePort() {
198
+ return this.a.remotePort;
199
+ }
200
+ sendMessage(message) {
201
+ const pkgType = message.constructor.pkgType;
202
+ const encoded = [message.buff];
203
+ this.v.makePkgBuff(pkgType, 0, encoded);
204
+ return this.a.sendPkgBuffV(encoded);
205
+ }
206
+ sendRequest(request) {
207
+ this.h = new Map();
208
+ this.sendRequest = this.L;
209
+ this.J = this.S;
210
+ this.onClose = this.T;
211
+ return this.L(request);
212
+ }
213
+ sendErrorResponse(error, requestId) {
214
+ const pkgType = error.constructor.pkgType;
215
+ const encoded = [error.buff];
216
+ this.v.makePkgBuff(pkgType, requestId, encoded);
217
+ return this.a.sendPkgBuffV(encoded);
218
+ }
219
+ sendResponse(request, requestId) {
220
+ const encoded = [request.respBuff];
221
+ const { makePkgBuff, responsePkgType } = this.v;
222
+ makePkgBuff(responsePkgType, requestId, encoded);
223
+ return this.a.sendPkgBuffV(encoded);
224
+ }
225
+ async close(err) {
226
+ await this.a.close(err);
227
+ }
228
+ J(requestId, M) {
229
+ if (requestId === 0x200000 && this.context === undefined) {
230
+ this.close(new Error('Authenticating timeout'));
231
+ }
232
+ }
233
+ R(requestId, error) {
234
+ const d = this.h.get(requestId);
235
+ if (d) {
236
+ this.h.delete(requestId);
237
+ return d.g(error);
238
+ }
239
+ }
240
+ keepAlive() {
241
+ this.a.sendPkgBuff(this.v.j).catch(i);
242
+ }
243
+ timeout() {
244
+ this.close(new Error('Connection timeout'));
245
+ }
246
+ onClose(B) {
247
+ }
248
+ async L(request) {
249
+ const requestId = (this.K++) & 0x1fffff;
250
+ const C = new Promise((f, g) => {
251
+ const D = { f, g };
252
+ this.h.set(requestId, D);
253
+ });
254
+ const pkgType = request.constructor.pkgType;
255
+ const encoded = [request.buff];
256
+ this.v.makePkgBuff(pkgType, requestId, encoded);
257
+ this.a.sendPkgBuffV(encoded);
258
+ request.respBuff = await C;
259
+ }
260
+ S(requestId, b) {
261
+ const d = this.h.get(requestId);
262
+ if (d) {
263
+ this.h.delete(requestId);
264
+ d.f(b);
265
+ return;
266
+ }
267
+ if (requestId === 0x200000 && this.context === undefined) {
268
+ this.close(new Error('Authenticating timeout'));
269
+ }
270
+ }
271
+ T(err) {
272
+ const n = this.h;
273
+ if (n.size > 0) {
274
+ if (!err) {
275
+ err = new Error('Connection is closed');
276
+ }
277
+ for (const [requestId, d] of n) {
278
+ n.delete(requestId);
279
+ d.g(err);
280
+ }
281
+ }
282
+ this.h = undefined;
283
+ }
284
+ v;
285
+ h;
286
+ K;
287
+ }
288
+ class t {
289
+ constructor(id, E) {
290
+ this.context = undefined;
291
+ this.id = id;
292
+ this.A = E;
293
+ }
294
+ context;
295
+ id;
296
+ localAddress;
297
+ localPort;
298
+ remoteAddress;
299
+ remotePort;
300
+ get remoteFamily() {
301
+ return 'Local';
302
+ }
303
+ async sendMessage(message) {
304
+ return this.A.sendMessageLocal(this, message);
305
+ }
306
+ async sendRequest(request) {
307
+ return this.A.sendRequestLocal(this, request);
308
+ }
309
+ sendErrorResponse(N, F) {
310
+ throw null;
311
+ }
312
+ sendResponse(U, F) {
313
+ throw null;
314
+ }
315
+ async close(B) {
316
+ }
317
+ A;
318
+ }
319
+ //# sourceMappingURL=TypedPkgHub.js.map
@@ -0,0 +1,14 @@
1
+ import { j, l, m } from '../common/varUintOps';
2
+ export const makeNumTypePkgBuff = (pkgType, requestId, encoded) => {
3
+ const i = [requestId, pkgType];
4
+ const b = j(i);
5
+ const a = new Uint8Array(b);
6
+ m(i, a);
7
+ encoded.push(a);
8
+ };
9
+ export const parseNumTypePkgBuff = (buff) => {
10
+ const { h: [requestId, pkgType], k: bodyOffset } = l(2, buff);
11
+ const d = { buff, pkgType, requestId, bodyOffset };
12
+ return d;
13
+ };
14
+ //# sourceMappingURL=hubPkgSerializer.js.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interfaces.js.map
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "justrun-ws",
3
+ "version": "0.1.0",
4
+ "scripts": {
5
+ "start": "webpack serve"
6
+ },
7
+ "files": [
8
+ "./lib/*"
9
+ ],
10
+ "module": "./lib/index.js",
11
+ "typings": "./lib/index.d.ts",
12
+ "exports": {
13
+ ".": {
14
+ "default": "./lib/index.js",
15
+ "types": "./lib/index.d.ts"
16
+ }
17
+ },
18
+ "keywords": [
19
+ "justrun",
20
+ "justrun-ws"
21
+ ],
22
+ "author": "Andy Deng",
23
+ "license": "MIT",
24
+ "devDependencies": {
25
+ "@eslint/eslintrc": "^3.2.0",
26
+ "@eslint/js": "^9.19.0",
27
+ "@types/jest": "^29.5.1",
28
+ "@typescript-eslint/eslint-plugin": "^8.25.0",
29
+ "@typescript-eslint/parser": "^8.25.0",
30
+ "dts-bundle-generator": "^9.5.1",
31
+ "eslint": "^9.21.0",
32
+ "eslint-plugin-import": "^2.31.0",
33
+ "globals": "^15.14.0",
34
+ "minify-ts": "^1.2.3",
35
+ "ts-loader": "^9.5.2",
36
+ "webpack": "^5.98.0",
37
+ "webpack-cli": "^6.0.1"
38
+ }
39
+ }