larasopp 1.2.21 → 1.2.22
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/Core.d.ts +1 -0
- package/lib/Core.js +22 -10
- package/package.json +7 -3
- package/__tests__/connect.test.js +0 -5
- package/src/Core.ts +0 -185
- package/src/Listener.ts +0 -67
- package/src/constants.ts +0 -3
- package/src/index.ts +0 -89
- package/src/types.ts +0 -40
- package/tsconfig.json +0 -109
package/lib/Core.d.ts
CHANGED
package/lib/Core.js
CHANGED
|
@@ -37,6 +37,12 @@ class Core {
|
|
|
37
37
|
writable: true,
|
|
38
38
|
value: void 0
|
|
39
39
|
});
|
|
40
|
+
Object.defineProperty(this, "reconnectTimer", {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
configurable: true,
|
|
43
|
+
writable: true,
|
|
44
|
+
value: void 0
|
|
45
|
+
});
|
|
40
46
|
this.events = new easy_event_emitter_1.default;
|
|
41
47
|
this.reconnectCount = 0;
|
|
42
48
|
this.config = config;
|
|
@@ -44,6 +50,7 @@ class Core {
|
|
|
44
50
|
this.handleClose = this.handleClose.bind(this);
|
|
45
51
|
this.handleError = this.handleError.bind(this);
|
|
46
52
|
this.handleMessage = this.handleMessage.bind(this);
|
|
53
|
+
this.tryReconnect = this.tryReconnect.bind(this);
|
|
47
54
|
}
|
|
48
55
|
setConfig(config) {
|
|
49
56
|
this.config = config;
|
|
@@ -103,16 +110,21 @@ class Core {
|
|
|
103
110
|
return true;
|
|
104
111
|
}
|
|
105
112
|
tryReconnect() {
|
|
106
|
-
var _a
|
|
107
|
-
if (
|
|
108
|
-
this.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
var _a;
|
|
114
|
+
if (this.reconnectTimer)
|
|
115
|
+
clearTimeout(this.reconnectTimer);
|
|
116
|
+
this.reconnectTimer = setTimeout(() => {
|
|
117
|
+
var _a;
|
|
118
|
+
if (typeof this.config.reconnect === 'undefined' ||
|
|
119
|
+
this.reconnectCount >= this.config.reconnect ||
|
|
120
|
+
typeof this.ws === 'undefined' ||
|
|
121
|
+
this.status ||
|
|
122
|
+
((_a = this.ws) === null || _a === void 0 ? void 0 : _a.readyState) === this.ws.CONNECTING)
|
|
123
|
+
return;
|
|
124
|
+
++this.reconnectCount;
|
|
125
|
+
this.connect();
|
|
126
|
+
this.tryReconnect();
|
|
127
|
+
}, (_a = this.config.reconnectDelay) !== null && _a !== void 0 ? _a : 1000);
|
|
116
128
|
}
|
|
117
129
|
handleOpen(e) {
|
|
118
130
|
this.events.emit("open", e);
|
package/package.json
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "larasopp",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.22",
|
|
4
4
|
"description": "Websocket client for laravel",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "jest",
|
|
9
|
-
"build": "tsc"
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"prepublishOnly": "npm run build"
|
|
10
11
|
},
|
|
11
12
|
"jest": {
|
|
12
13
|
"transform": {
|
|
13
14
|
"^.+\\.[t|j]sx?$": "babel-jest"
|
|
14
15
|
}
|
|
15
16
|
},
|
|
17
|
+
"files": [
|
|
18
|
+
"lib"
|
|
19
|
+
],
|
|
16
20
|
"repository": {
|
|
17
21
|
"type": "git",
|
|
18
22
|
"url": "git+https://github.com/SergoMorello/larasopp.client.git"
|
|
@@ -37,6 +41,6 @@
|
|
|
37
41
|
"typescript": "^5.1.6"
|
|
38
42
|
},
|
|
39
43
|
"dependencies": {
|
|
40
|
-
"easy-event-emitter": "^1.
|
|
44
|
+
"easy-event-emitter": "^1.2.2"
|
|
41
45
|
}
|
|
42
46
|
}
|
package/src/Core.ts
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import EventEmitter from "easy-event-emitter";
|
|
2
|
-
import { ListenerEvents } from "./constants";
|
|
3
|
-
import type {
|
|
4
|
-
IConfig,
|
|
5
|
-
TListenerEvents,
|
|
6
|
-
TMessage
|
|
7
|
-
} from "./types";
|
|
8
|
-
|
|
9
|
-
abstract class Core {
|
|
10
|
-
public readonly events: EventEmitter;
|
|
11
|
-
private ws?: WebSocket;
|
|
12
|
-
private _socketId?: string;
|
|
13
|
-
private config: IConfig;
|
|
14
|
-
private reconnectCount: number;
|
|
15
|
-
|
|
16
|
-
constructor(config: IConfig) {
|
|
17
|
-
this.events = new EventEmitter;
|
|
18
|
-
this.reconnectCount = 0;
|
|
19
|
-
this.config = config;
|
|
20
|
-
|
|
21
|
-
this.handleOpen = this.handleOpen.bind(this);
|
|
22
|
-
this.handleClose = this.handleClose.bind(this);
|
|
23
|
-
this.handleError = this.handleError.bind(this);
|
|
24
|
-
this.handleMessage = this.handleMessage.bind(this);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
public setConfig(config: IConfig) {
|
|
28
|
-
this.config = config;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public setToken(token: string) {
|
|
33
|
-
this.config = {
|
|
34
|
-
...this.config,
|
|
35
|
-
token
|
|
36
|
-
};
|
|
37
|
-
if (this.status) {
|
|
38
|
-
this.send({
|
|
39
|
-
token
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Connect to websocket
|
|
47
|
-
* @returns {this}
|
|
48
|
-
*/
|
|
49
|
-
public connect(token?: string): this {
|
|
50
|
-
if (this.status) return this;
|
|
51
|
-
try {
|
|
52
|
-
if (token) this.setToken(token);
|
|
53
|
-
const host = this.config.host + '/token=' + this.config.token;
|
|
54
|
-
this.ws = new WebSocket(encodeURI(host));
|
|
55
|
-
this.ws.onopen = this.handleOpen;
|
|
56
|
-
this.ws.onclose = this.handleClose;
|
|
57
|
-
this.ws.onerror = this.handleError;
|
|
58
|
-
this.ws.onmessage = this.handleMessage;
|
|
59
|
-
}catch(e) {
|
|
60
|
-
console.warn(e);
|
|
61
|
-
this.handleError(new Event('Socket exception'));
|
|
62
|
-
this.handleClose(new CloseEvent(String(e)));
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Disconnect
|
|
70
|
-
* @returns {void}
|
|
71
|
-
*/
|
|
72
|
-
public disconnect(): void {
|
|
73
|
-
if (this.status) {
|
|
74
|
-
this.ws?.close();
|
|
75
|
-
}
|
|
76
|
-
this.ws = undefined;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
protected isJson(str: string) {
|
|
80
|
-
try {
|
|
81
|
-
JSON.parse(str);
|
|
82
|
-
} catch (e) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
return true;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
private tryReconnect() {
|
|
89
|
-
if (
|
|
90
|
-
typeof this.config.reconnect === 'undefined' ||
|
|
91
|
-
this.reconnectCount >= this.config.reconnect ||
|
|
92
|
-
typeof this.ws === 'undefined' ||
|
|
93
|
-
this.status ||
|
|
94
|
-
this.ws?.readyState === this.ws.CONNECTING
|
|
95
|
-
) return;
|
|
96
|
-
|
|
97
|
-
++this.reconnectCount;
|
|
98
|
-
this.connect();
|
|
99
|
-
setTimeout(() => this.tryReconnect(), this.config.reconnectDelay ?? 1000);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
private handleOpen(e: Event): void {
|
|
103
|
-
this.events.emit("open", e);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
private handleClose(e: CloseEvent): void {
|
|
107
|
-
this.events.emit("close", e);
|
|
108
|
-
this.tryReconnect();
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
private handleError(e: Event): void {
|
|
112
|
-
this.events.emit("error", e);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
private jsonParse(str: string) {
|
|
116
|
-
if (this.config) {
|
|
117
|
-
if (typeof this.config.reviver === 'function') {
|
|
118
|
-
return JSON.parse(str, this.config.reviver);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
if (this.config.dataReviver) {
|
|
122
|
-
const replace = this.config.dataReviver;
|
|
123
|
-
return JSON.parse(str, (key, value) => {
|
|
124
|
-
if (key === "createdAt" || key === "updatedAt") {
|
|
125
|
-
return new Date(value);
|
|
126
|
-
}
|
|
127
|
-
if (key in replace && typeof replace[key] === 'function') {
|
|
128
|
-
return replace[key](value);
|
|
129
|
-
}
|
|
130
|
-
return value;
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return JSON.parse(str);
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
private handleMessage(e: MessageEvent): void {
|
|
139
|
-
if (this.isJson(e.data)) {
|
|
140
|
-
const json = this.jsonParse(e.data);
|
|
141
|
-
if (json.socket_id) {
|
|
142
|
-
this._socketId = json.socket_id;
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.emitListener(json.channel, json.message);
|
|
146
|
-
this.events.emit(json.channel + ':' + json.event, json.message);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
private emitListener(method: TListenerEvents, channel: string): void {
|
|
151
|
-
if (ListenerEvents.includes(method)) {
|
|
152
|
-
this.events.emit(method + ':' + channel, {
|
|
153
|
-
channel
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
public get socketId() {
|
|
159
|
-
return this._socketId;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
public get status(): boolean {
|
|
163
|
-
if (!this.ws) return false;
|
|
164
|
-
return this.ws?.readyState === this.ws?.OPEN;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
private _send<T>(message: TMessage<T>) {
|
|
168
|
-
if (!this.ws || !this.status) return;
|
|
169
|
-
this.ws.send(JSON.stringify(message));
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
protected send<T>(message: TMessage<T>) {
|
|
173
|
-
if (this.status) {
|
|
174
|
-
this._send(message);
|
|
175
|
-
}else{
|
|
176
|
-
if (this.ws?.readyState !== this.ws?.CONNECTING) this.connect();
|
|
177
|
-
const event = this.events.addListener('open',() => {
|
|
178
|
-
this._send(message);
|
|
179
|
-
event.remove();
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export default Core;
|
package/src/Listener.ts
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import EventEmmiter, {
|
|
2
|
-
type EventListener
|
|
3
|
-
} from "easy-event-emitter";
|
|
4
|
-
import type Larasopp from ".";
|
|
5
|
-
|
|
6
|
-
type TListenerCacheEvents = {
|
|
7
|
-
[event: string]: unknown;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
class Listener extends EventEmmiter.Stack {
|
|
11
|
-
private readonly context: Larasopp;
|
|
12
|
-
private channel: string;
|
|
13
|
-
private listener?: EventListener;
|
|
14
|
-
private cacheEvents: TListenerCacheEvents;
|
|
15
|
-
|
|
16
|
-
constructor(channel: string, constext: Larasopp) {
|
|
17
|
-
super([]);
|
|
18
|
-
this.channel = channel;
|
|
19
|
-
this.context = constext;
|
|
20
|
-
this.cacheEvents = {};
|
|
21
|
-
|
|
22
|
-
this.here(()=>{}, true);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
public listen(event: string, callback: (data: any) => void, withCache = false) {
|
|
26
|
-
|
|
27
|
-
if (withCache && this.hasCache(event)) callback(this.getCache(event));
|
|
28
|
-
const listener = this.context.events.addListener(this.channel + ':' + event, (data) => {
|
|
29
|
-
callback(data);
|
|
30
|
-
if (withCache) this.pushCache(event, data);
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
this.push(listener);
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
public here(callback: (data: any) => void, withCache = true) {
|
|
38
|
-
return this.listen('__HERE', callback, withCache);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
public joining(callback: (data: any) => void, withCache = false) {
|
|
42
|
-
return this.listen('__JOIN', callback, withCache);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public leaving(callback: (data: any) => void, withCache = false) {
|
|
46
|
-
return this.listen('__LEAVE', callback, withCache);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public unsubscribe() {
|
|
50
|
-
this.context.unsubscribe(this.channel);
|
|
51
|
-
this.remove();
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private hasCache(event: string) {
|
|
55
|
-
return event in this.cacheEvents;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
private getCache(event: string) {
|
|
59
|
-
return this.cacheEvents[event];
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
private pushCache(event: string, data: unknown) {
|
|
63
|
-
this.cacheEvents[event] = data;
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export default Listener;
|
package/src/constants.ts
DELETED
package/src/index.ts
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type EventListener
|
|
3
|
-
} from "easy-event-emitter";
|
|
4
|
-
import Core from "./Core";
|
|
5
|
-
import { SocketEvents } from "./constants";
|
|
6
|
-
import Listener from "./Listener";
|
|
7
|
-
import type {
|
|
8
|
-
IConfig,
|
|
9
|
-
TPermissions,
|
|
10
|
-
TSocketEvents,
|
|
11
|
-
TListenerCallback,
|
|
12
|
-
TChannels
|
|
13
|
-
} from "./types";
|
|
14
|
-
|
|
15
|
-
class Larasopp extends Core {
|
|
16
|
-
private readonly channels: TChannels;
|
|
17
|
-
|
|
18
|
-
constructor(config: IConfig) {
|
|
19
|
-
super(config);
|
|
20
|
-
|
|
21
|
-
this.channels = {};
|
|
22
|
-
|
|
23
|
-
this.listenResumeSubscribes();
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
private listenResumeSubscribes() {
|
|
27
|
-
this.addListener('open', () => {
|
|
28
|
-
Object.keys(this.channels).forEach((channel) => this.send({
|
|
29
|
-
subscribe: channel
|
|
30
|
-
}));
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public subscribe(channel: string) {
|
|
35
|
-
const listener = new Listener(channel, this);
|
|
36
|
-
this.pushListener(channel, listener);
|
|
37
|
-
return listener;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public unsubscribe(channel: string) {
|
|
41
|
-
if (!this.channels[channel]) return;
|
|
42
|
-
this.channels[channel].forEach((listener) => listener.remove());
|
|
43
|
-
delete this.channels[channel];
|
|
44
|
-
this.send({
|
|
45
|
-
unsubscribe: channel
|
|
46
|
-
});
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
public trigger<T>(channel: string, event: string, message: T, permission: TPermissions = 'public', waitSubscribe: boolean = false): void {
|
|
50
|
-
const send = () => {
|
|
51
|
-
this.send<T>({
|
|
52
|
-
channel: channel,
|
|
53
|
-
event: event,
|
|
54
|
-
message: message,
|
|
55
|
-
type: permission
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
if (waitSubscribe) this.events.addListener(event + ':' + channel, send);
|
|
60
|
-
send();
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
private pushListener(channel: string, listener: Listener): void {
|
|
64
|
-
if (!this.channels[channel]) {
|
|
65
|
-
this.channels[channel] = [];
|
|
66
|
-
this.send({
|
|
67
|
-
subscribe: channel
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
this.channels[channel].push(listener);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
public countListeners(channel: string) {
|
|
74
|
-
if (!this.channels[channel]) return -1;
|
|
75
|
-
return this.channels[channel].length;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
public addListener(event: TSocketEvents, callback: TListenerCallback): EventListener | undefined {
|
|
79
|
-
if (!SocketEvents.includes(event)) return;
|
|
80
|
-
return this.events.addListener(event, callback);
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export type {
|
|
85
|
-
Listener,
|
|
86
|
-
EventListener
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
export default Larasopp;
|
package/src/types.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import type Listener from "./Listener";
|
|
2
|
-
import {
|
|
3
|
-
SocketEvents,
|
|
4
|
-
ListenerEvents
|
|
5
|
-
} from "./constants";
|
|
6
|
-
|
|
7
|
-
export type TSocketEvents = typeof SocketEvents[number];
|
|
8
|
-
|
|
9
|
-
export type TListenerEvents = typeof ListenerEvents[number];
|
|
10
|
-
|
|
11
|
-
export type TListenerCallback = (data:{channel: string}) => void;
|
|
12
|
-
|
|
13
|
-
export type TPermissions = 'public' | 'protected' | 'private';
|
|
14
|
-
|
|
15
|
-
export type TMessage<T> = {
|
|
16
|
-
subscribe?: string;
|
|
17
|
-
unsubscribe?: string;
|
|
18
|
-
channel?: string;
|
|
19
|
-
event?: string;
|
|
20
|
-
token?: string;
|
|
21
|
-
message?: T;
|
|
22
|
-
type?: TPermissions;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export type TConfigDataReviver = {
|
|
26
|
-
[index: string]: (value: any) => any;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export interface IConfig {
|
|
30
|
-
host: string;
|
|
31
|
-
token?: string;
|
|
32
|
-
reviver?: (this: any, key: string, value: any) => any;
|
|
33
|
-
dataReviver?: TConfigDataReviver;
|
|
34
|
-
reconnect?: number;
|
|
35
|
-
reconnectDelay?: number;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export type TChannels = {
|
|
39
|
-
[channel: string]: Listener[];
|
|
40
|
-
};
|
package/tsconfig.json
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
/* Visit https://aka.ms/tsconfig to read more about this file */
|
|
4
|
-
|
|
5
|
-
/* Projects */
|
|
6
|
-
// "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */
|
|
7
|
-
// "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
|
|
8
|
-
// "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */
|
|
9
|
-
// "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */
|
|
10
|
-
// "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
|
|
11
|
-
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
|
|
12
|
-
|
|
13
|
-
/* Language and Environment */
|
|
14
|
-
"target": "es2016", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
|
|
15
|
-
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
|
|
16
|
-
// "jsx": "preserve", /* Specify what JSX code is generated. */
|
|
17
|
-
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
|
|
18
|
-
// "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
|
|
19
|
-
// "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */
|
|
20
|
-
// "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
|
|
21
|
-
// "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */
|
|
22
|
-
// "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */
|
|
23
|
-
// "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
|
|
24
|
-
"useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
|
|
25
|
-
// "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */
|
|
26
|
-
|
|
27
|
-
/* Modules */
|
|
28
|
-
"module": "commonjs", /* Specify what module code is generated. */
|
|
29
|
-
// "rootDir": "./", /* Specify the root folder within your source files. */
|
|
30
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
31
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
32
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
33
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
34
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
35
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
36
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
37
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
38
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
39
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
40
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
41
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
42
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
43
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
44
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
45
|
-
|
|
46
|
-
/* JavaScript Support */
|
|
47
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
48
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
49
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
50
|
-
|
|
51
|
-
/* Emit */
|
|
52
|
-
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
53
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
54
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
55
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
56
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
57
|
-
// "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */
|
|
58
|
-
"outDir": "./lib/", /* Specify an output folder for all emitted files. */
|
|
59
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
60
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
61
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
62
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
63
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
64
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
65
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
66
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
67
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
68
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
69
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
70
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
71
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
72
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
73
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
74
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
75
|
-
|
|
76
|
-
/* Interop Constraints */
|
|
77
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
78
|
-
// "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */
|
|
79
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
80
|
-
"esModuleInterop": true, /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */
|
|
81
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
82
|
-
"forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
|
|
83
|
-
|
|
84
|
-
/* Type Checking */
|
|
85
|
-
"strict": true, /* Enable all strict type-checking options. */
|
|
86
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
87
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
88
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
89
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
90
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
91
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
92
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
93
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
94
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
95
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
96
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
97
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
98
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
99
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
100
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
101
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
102
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
103
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
104
|
-
|
|
105
|
-
/* Completeness */
|
|
106
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
107
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
108
|
-
}
|
|
109
|
-
}
|