mpp-client-net 1.2.0 → 1.2.2
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 +20 -12
- package/build/index.d.ts +0 -2
- package/build/index.d.ts.map +1 -1
- package/package.json +19 -19
- package/src/index.ts +0 -473
- package/src/test.ts +0 -10
- package/src/types.d.ts +0 -302
- package/tsconfig.json +0 -113
package/README.md
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
1
|
# mpp-client-net
|
|
2
2
|
|
|
3
|
-
This module is a fork of the [MPP client](https://github.com/
|
|
3
|
+
This module is a fork of the [MPP.net client](https://github.com/mppnet/frontend). This module is only meant for [MPP.net](https://multiplayerpiano.net), but it will likely work on any MPP site that uses token-based authentication in the same way as MPP.net.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
As of recently, this module is now the official MPP.net client.
|
|
6
6
|
|
|
7
7
|
## Usage
|
|
8
8
|
|
|
9
|
-
It is strongly recommended that you keep your tokens in a safe place where nobody else can access them.
|
|
9
|
+
It is strongly recommended that you keep your bot tokens in a safe place where nobody else can access them.
|
|
10
|
+
Personally, I keep mine in a `.env` file in the root of my project, as that is a typical place for project secrets.
|
|
11
|
+
|
|
12
|
+
For more information on what messages to send to the server, see the [MPP.net Protocol Documentation](https://github.com/mppnet/frontend/blob/main/docs/protocol.md).
|
|
10
13
|
|
|
11
14
|
```env
|
|
12
15
|
# .env
|
|
13
16
|
MPPNET_TOKEN=your token here
|
|
14
17
|
```
|
|
15
18
|
|
|
16
|
-
```
|
|
17
|
-
// index.
|
|
19
|
+
```ts
|
|
20
|
+
// index.ts
|
|
18
21
|
|
|
19
22
|
// Load environment variables into process.env
|
|
20
|
-
|
|
23
|
+
import { configDotenv } from "dotenv";
|
|
24
|
+
configDotenv();
|
|
25
|
+
|
|
26
|
+
import { Client } from "mpp-client-net";
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
// Instnatiate a new client
|
|
29
|
+
const client = new Client("wss://mppclone.com", process.env.MPPNET_TOKEN);
|
|
24
30
|
|
|
25
|
-
|
|
26
|
-
|
|
31
|
+
client.start();
|
|
32
|
+
client.setChannel('test/awkward');
|
|
27
33
|
|
|
28
|
-
|
|
34
|
+
// Listen for chat messages
|
|
35
|
+
client.on('a', msg => {
|
|
29
36
|
if (msg.a == "!ping") {
|
|
30
|
-
|
|
37
|
+
// Send a chat message back
|
|
38
|
+
client.sendArray([{
|
|
31
39
|
m: "a",
|
|
32
40
|
message: "Pong!"
|
|
33
41
|
}]);
|
package/build/index.d.ts
CHANGED
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
2
|
+
"name": "mpp-client-net",
|
|
3
|
+
"version": "1.2.2",
|
|
4
|
+
"description": "Client for multiplayerpiano.net",
|
|
5
|
+
"main": "build/index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"build": "npx tsc",
|
|
8
|
+
"test": "node build/test.js"
|
|
9
|
+
},
|
|
10
|
+
"author": "Hri7566 <hri7566@gmail.com>",
|
|
11
|
+
"license": "GPL-3.0-only",
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"ws": "^8.16.0"
|
|
14
|
+
},
|
|
15
|
+
"devDependencies": {
|
|
16
|
+
"@types/node": "^20.11.30",
|
|
17
|
+
"@types/ws": "^8.5.10",
|
|
18
|
+
"typescript": "^5.4.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
package/src/index.ts
DELETED
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "events";
|
|
2
|
-
import { WebSocket } from "ws";
|
|
3
|
-
|
|
4
|
-
export class Client extends EventEmitter {
|
|
5
|
-
public ws: WebSocket | undefined;
|
|
6
|
-
public serverTimeOffset = 0;
|
|
7
|
-
public user: User | undefined;
|
|
8
|
-
public participantId: Participant["id"] | undefined;
|
|
9
|
-
public channel: ChannelInfo | undefined;
|
|
10
|
-
public ppl: Record<Participant["id"], Participant> = {};
|
|
11
|
-
public connectionTime: number | undefined;
|
|
12
|
-
public connectionAttempts = 0;
|
|
13
|
-
public desiredChannelId: ChannelInfo["_id"] | undefined;
|
|
14
|
-
public desiredChannelSettings: Partial<ChannelSettings> | undefined;
|
|
15
|
-
public pingInterval: NodeJS.Timeout | undefined;
|
|
16
|
-
public canConnect = false;
|
|
17
|
-
public noteBuffer: Note[] = [];
|
|
18
|
-
public noteBufferTime = 0;
|
|
19
|
-
public noteFlushInterval: NodeJS.Timeout | undefined;
|
|
20
|
-
public permissions: any = {};
|
|
21
|
-
public "🐈": number = 0;
|
|
22
|
-
public loginInfo: LoginInfo | undefined;
|
|
23
|
-
public accountInfo: AccountInfo | undefined;
|
|
24
|
-
|
|
25
|
-
constructor(public uri: string, public token?: string) {
|
|
26
|
-
super();
|
|
27
|
-
|
|
28
|
-
this.bindEventListeners();
|
|
29
|
-
this.emit("status", "(Offline mode)");
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public isSupported() {
|
|
33
|
-
return typeof WebSocket === "function";
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
public isConnected() {
|
|
37
|
-
return (
|
|
38
|
-
this.isSupported() &&
|
|
39
|
-
this.ws &&
|
|
40
|
-
this.ws.readyState === WebSocket.OPEN
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
public isConnecting() {
|
|
45
|
-
return (
|
|
46
|
-
this.isSupported() &&
|
|
47
|
-
this.ws &&
|
|
48
|
-
this.ws.readyState === WebSocket.CONNECTING
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
public start() {
|
|
53
|
-
this.canConnect = true;
|
|
54
|
-
if (!this.connectionTime) {
|
|
55
|
-
this.connect();
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public stop() {
|
|
60
|
-
this.canConnect = false;
|
|
61
|
-
if (this.ws) this.ws.close();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
public connect() {
|
|
65
|
-
if (
|
|
66
|
-
!this.canConnect ||
|
|
67
|
-
!this.isSupported() ||
|
|
68
|
-
this.isConnected() ||
|
|
69
|
-
this.isConnecting()
|
|
70
|
-
)
|
|
71
|
-
return;
|
|
72
|
-
|
|
73
|
-
this.emit("status", "Connecting...");
|
|
74
|
-
if (typeof module !== "undefined") {
|
|
75
|
-
// nodejsicle
|
|
76
|
-
this.ws = new WebSocket(this.uri, {
|
|
77
|
-
origin: "https://multiplayerpiano.net"
|
|
78
|
-
});
|
|
79
|
-
} else {
|
|
80
|
-
// browseroni
|
|
81
|
-
this.ws = new WebSocket(this.uri);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
this.ws.addEventListener("close", evt => {
|
|
85
|
-
this.user = undefined;
|
|
86
|
-
this.participantId = undefined;
|
|
87
|
-
this.channel = undefined;
|
|
88
|
-
this.setParticipants([]);
|
|
89
|
-
clearInterval(this.pingInterval);
|
|
90
|
-
clearInterval(this.noteFlushInterval);
|
|
91
|
-
|
|
92
|
-
this.emit("disconnect", evt);
|
|
93
|
-
this.emit("status", "Offline mode");
|
|
94
|
-
|
|
95
|
-
// reconnect!
|
|
96
|
-
if (this.connectionTime) {
|
|
97
|
-
this.connectionTime = undefined;
|
|
98
|
-
this.connectionAttempts = 0;
|
|
99
|
-
} else {
|
|
100
|
-
++this.connectionAttempts;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const ms_lut = [50, 2500, 10000];
|
|
104
|
-
let idx = this.connectionAttempts;
|
|
105
|
-
if (idx >= ms_lut.length) idx = ms_lut.length - 1;
|
|
106
|
-
const ms = ms_lut[idx];
|
|
107
|
-
|
|
108
|
-
setTimeout(this.connect.bind(this), ms);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
this.ws.addEventListener("error", err => {
|
|
112
|
-
this.emit("wserror", err);
|
|
113
|
-
if (this.ws) this.ws.close(); // self.ws.emit("close");
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
this.ws.addEventListener("open", evt => {
|
|
117
|
-
this.pingInterval = setInterval(() => {
|
|
118
|
-
this.sendPing();
|
|
119
|
-
}, 20000);
|
|
120
|
-
|
|
121
|
-
this.noteBuffer = [];
|
|
122
|
-
this.noteBufferTime = 0;
|
|
123
|
-
|
|
124
|
-
this.noteFlushInterval = setInterval(() => {
|
|
125
|
-
if (this.noteBufferTime && this.noteBuffer.length > 0) {
|
|
126
|
-
this.sendArray([
|
|
127
|
-
{
|
|
128
|
-
m: "n",
|
|
129
|
-
t: this.noteBufferTime + this.serverTimeOffset,
|
|
130
|
-
n: this.noteBuffer
|
|
131
|
-
}
|
|
132
|
-
]);
|
|
133
|
-
this.noteBufferTime = 0;
|
|
134
|
-
this.noteBuffer = [];
|
|
135
|
-
}
|
|
136
|
-
}, 200);
|
|
137
|
-
|
|
138
|
-
this.emit("connect", undefined);
|
|
139
|
-
this.emit("status", "Joining channel...");
|
|
140
|
-
|
|
141
|
-
this.sendArray([
|
|
142
|
-
{
|
|
143
|
-
m: "hi",
|
|
144
|
-
token: this.token,
|
|
145
|
-
login: this.loginInfo
|
|
146
|
-
}
|
|
147
|
-
]);
|
|
148
|
-
});
|
|
149
|
-
|
|
150
|
-
this.ws.addEventListener("message", async evt => {
|
|
151
|
-
const transmission = JSON.parse(
|
|
152
|
-
(evt as unknown as { data: string }).data
|
|
153
|
-
);
|
|
154
|
-
|
|
155
|
-
for (let i = 0; i < transmission.length; i++) {
|
|
156
|
-
const msg = transmission[i];
|
|
157
|
-
this.emit(msg.m, msg);
|
|
158
|
-
}
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
protected bindEventListeners() {
|
|
163
|
-
this.on("hi", msg => {
|
|
164
|
-
this.connectionTime = Date.now();
|
|
165
|
-
this.user = msg.u;
|
|
166
|
-
this.receiveServerTime(msg.t, msg.e);
|
|
167
|
-
|
|
168
|
-
if (this.desiredChannelId) {
|
|
169
|
-
this.setChannel();
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
this.permissions = msg.permissions ? msg.permissions : {};
|
|
173
|
-
this.accountInfo = msg.accountInfo;
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
this.on("t", msg => {
|
|
177
|
-
this.receiveServerTime(msg.t, msg.e || undefined);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
this.on("ch", msg => {
|
|
181
|
-
this.desiredChannelId = msg.ch._id;
|
|
182
|
-
this.desiredChannelSettings = msg.ch.settings;
|
|
183
|
-
|
|
184
|
-
this.channel = msg.ch;
|
|
185
|
-
|
|
186
|
-
if (msg.p) this.participantId = msg.p;
|
|
187
|
-
this.setParticipants(msg.ppl);
|
|
188
|
-
});
|
|
189
|
-
|
|
190
|
-
this.on("p", msg => {
|
|
191
|
-
this.participantUpdate(msg);
|
|
192
|
-
this.emit(
|
|
193
|
-
"participant update",
|
|
194
|
-
this.findParticipantById(msg.id) as Participant
|
|
195
|
-
);
|
|
196
|
-
});
|
|
197
|
-
|
|
198
|
-
this.on("m", msg => {
|
|
199
|
-
if (this.ppl.hasOwnProperty(msg.id)) {
|
|
200
|
-
this.participantMoveMouse(msg);
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
this.on("bye", msg => {
|
|
205
|
-
this.removeParticipant(msg.p);
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
protected send(raw: string) {
|
|
210
|
-
if (this.isConnected() && this.ws) this.ws.send(raw);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
public sendArray<Event extends keyof OutgoingEvents>(
|
|
214
|
-
arr: OutgoingEvents[Event][]
|
|
215
|
-
) {
|
|
216
|
-
this.send(JSON.stringify(arr));
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
public setChannel(id?: string, set?: Partial<ChannelSettings>) {
|
|
220
|
-
this.desiredChannelId = id || this.desiredChannelId || "lobby";
|
|
221
|
-
this.desiredChannelSettings =
|
|
222
|
-
set || this.desiredChannelSettings || undefined;
|
|
223
|
-
|
|
224
|
-
this.sendArray([
|
|
225
|
-
{
|
|
226
|
-
m: "ch",
|
|
227
|
-
_id: this.desiredChannelId,
|
|
228
|
-
set: this.desiredChannelSettings
|
|
229
|
-
}
|
|
230
|
-
]);
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
protected offlineChannelSettings: Partial<ChannelSettings> = {
|
|
234
|
-
color: "#ecfaed"
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
public getChannelSetting(key: string) {
|
|
238
|
-
if (!this.isConnected() || !this.channel || !this.channel.settings) {
|
|
239
|
-
return this.offlineChannelSettings[key];
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
return this.channel.settings[key];
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
public setChannelSettings(settings: Partial<ChannelSettings>) {
|
|
246
|
-
if (!this.isConnected() || !this.channel || !this.channel.settings) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
if (this.desiredChannelSettings) {
|
|
251
|
-
for (const key of Object.keys(settings)) {
|
|
252
|
-
this.desiredChannelSettings[key] = settings[key];
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
this.sendArray([
|
|
256
|
-
{
|
|
257
|
-
m: "chset",
|
|
258
|
-
set: this.desiredChannelSettings
|
|
259
|
-
}
|
|
260
|
-
]);
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
protected offlineParticipant = {
|
|
265
|
-
_id: "",
|
|
266
|
-
name: "",
|
|
267
|
-
color: "#777"
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
public getOwnParticipant() {
|
|
271
|
-
return this.findParticipantById(this.participantId);
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
protected setParticipants(ppl: Participant[]) {
|
|
275
|
-
// remove participants who left
|
|
276
|
-
for (const id of Object.keys(this.ppl)) {
|
|
277
|
-
if (!this.ppl.hasOwnProperty(id)) continue;
|
|
278
|
-
|
|
279
|
-
let found = false;
|
|
280
|
-
|
|
281
|
-
for (let j = 0; j < ppl.length; j++) {
|
|
282
|
-
if (ppl[j].id === id) {
|
|
283
|
-
found = true;
|
|
284
|
-
break;
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
if (!found) {
|
|
289
|
-
this.removeParticipant(id);
|
|
290
|
-
}
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
// update all
|
|
294
|
-
for (let i = 0; i < ppl.length; i++) {
|
|
295
|
-
this.participantUpdate(ppl[i]);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
public countParticipants() {
|
|
300
|
-
let count = 0;
|
|
301
|
-
|
|
302
|
-
for (let i in this.ppl) {
|
|
303
|
-
if (this.ppl.hasOwnProperty(i)) ++count;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
return count;
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
public participantUpdate(update: any) {
|
|
310
|
-
let part = this.ppl[update.id] || null;
|
|
311
|
-
|
|
312
|
-
if (part === null) {
|
|
313
|
-
part = update;
|
|
314
|
-
this.ppl[part.id] = part;
|
|
315
|
-
|
|
316
|
-
this.emit("participant added", part);
|
|
317
|
-
this.emit("count", this.countParticipants());
|
|
318
|
-
} else {
|
|
319
|
-
Object.keys(update).forEach(key => {
|
|
320
|
-
(part as Record<string, any>)[key] = update[key];
|
|
321
|
-
});
|
|
322
|
-
|
|
323
|
-
if (!update.tag) delete part.tag;
|
|
324
|
-
if (!update.vanished) delete part.vanished;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
public participantMoveMouse(update: IncomingEvents["m"]) {
|
|
329
|
-
const part = this.ppl[update.id] || null;
|
|
330
|
-
|
|
331
|
-
if (part !== null) {
|
|
332
|
-
part.x = update.x;
|
|
333
|
-
part.y = update.y;
|
|
334
|
-
}
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
public removeParticipant(id: Participant["id"]) {
|
|
338
|
-
if (this.ppl.hasOwnProperty(id)) {
|
|
339
|
-
const part = this.ppl[id];
|
|
340
|
-
delete this.ppl[id];
|
|
341
|
-
|
|
342
|
-
this.emit("participant removed", part);
|
|
343
|
-
this.emit("count", this.countParticipants());
|
|
344
|
-
}
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
public findParticipantById(id?: string) {
|
|
348
|
-
return id
|
|
349
|
-
? this.ppl[id] || this.offlineParticipant
|
|
350
|
-
: this.offlineParticipant;
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
public isOwner() {
|
|
354
|
-
return (
|
|
355
|
-
this.channel &&
|
|
356
|
-
this.channel.crown &&
|
|
357
|
-
this.channel.crown.participantId === this.participantId
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
public preventsPlaying() {
|
|
362
|
-
return (
|
|
363
|
-
this.isConnected() &&
|
|
364
|
-
!this.isOwner() &&
|
|
365
|
-
this.getChannelSetting("crownsolo") === true &&
|
|
366
|
-
!this.permissions.playNotesAnywhere
|
|
367
|
-
);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
public receiveServerTime(time: number, echo?: number) {
|
|
371
|
-
const now = Date.now();
|
|
372
|
-
const target = time - now;
|
|
373
|
-
|
|
374
|
-
// console.log("Target serverTimeOffset: " + target);
|
|
375
|
-
const duration = 1000;
|
|
376
|
-
|
|
377
|
-
let step = 0;
|
|
378
|
-
const steps = 50;
|
|
379
|
-
const step_ms = duration / steps;
|
|
380
|
-
|
|
381
|
-
const difference = target - this.serverTimeOffset;
|
|
382
|
-
const inc = difference / steps;
|
|
383
|
-
|
|
384
|
-
let iv = setInterval(() => {
|
|
385
|
-
this.serverTimeOffset += inc;
|
|
386
|
-
|
|
387
|
-
if (++step >= steps) {
|
|
388
|
-
clearInterval(iv);
|
|
389
|
-
// console.log("serverTimeOffset reached: " + self.serverTimeOffset);
|
|
390
|
-
this.serverTimeOffset = target;
|
|
391
|
-
}
|
|
392
|
-
}, step_ms);
|
|
393
|
-
// smoothen
|
|
394
|
-
|
|
395
|
-
// this.serverTimeOffset = time - now; // mostly time zone offset ... also the lags so todo smoothen this
|
|
396
|
-
// not smooth:
|
|
397
|
-
// if(echo) this.serverTimeOffset += echo - now; // mostly round trip time offset
|
|
398
|
-
}
|
|
399
|
-
|
|
400
|
-
public startNote(note: Note["n"], vel: Note["v"]) {
|
|
401
|
-
if (typeof note !== "string") return;
|
|
402
|
-
|
|
403
|
-
if (this.isConnected()) {
|
|
404
|
-
let vel2 = typeof vel === "undefined" ? undefined : +vel.toFixed(3);
|
|
405
|
-
|
|
406
|
-
if (!this.noteBufferTime) {
|
|
407
|
-
this.noteBufferTime = Date.now();
|
|
408
|
-
this.noteBuffer.push({
|
|
409
|
-
n: note,
|
|
410
|
-
v: vel2
|
|
411
|
-
});
|
|
412
|
-
} else {
|
|
413
|
-
this.noteBuffer.push({
|
|
414
|
-
d: Date.now() - this.noteBufferTime,
|
|
415
|
-
n: note,
|
|
416
|
-
v: vel2
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
public stopNote(note: Note["n"]) {
|
|
423
|
-
if (typeof note !== "string") return;
|
|
424
|
-
|
|
425
|
-
if (this.isConnected()) {
|
|
426
|
-
if (!this.noteBufferTime) {
|
|
427
|
-
this.noteBufferTime = Date.now();
|
|
428
|
-
this.noteBuffer.push({ n: note, s: 1 });
|
|
429
|
-
} else {
|
|
430
|
-
this.noteBuffer.push({
|
|
431
|
-
d: Date.now() - this.noteBufferTime,
|
|
432
|
-
n: note,
|
|
433
|
-
s: 1
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
public sendPing() {
|
|
440
|
-
this.sendArray([
|
|
441
|
-
{
|
|
442
|
-
m: "t",
|
|
443
|
-
e: Date.now()
|
|
444
|
-
}
|
|
445
|
-
]);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
public setLoginInfo(loginInfo: LoginInfo) {
|
|
449
|
-
this.loginInfo = loginInfo;
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
public on<Event extends keyof EmittableEvents>(
|
|
453
|
-
event: Event,
|
|
454
|
-
listener: (msg: EmittableEvents[Event]) => void
|
|
455
|
-
): this {
|
|
456
|
-
super.on(event, listener);
|
|
457
|
-
return this;
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
public emit<Event extends keyof EmittableEvents>(
|
|
461
|
-
event: Event,
|
|
462
|
-
...args: Parameters<(msg: EmittableEvents[Event]) => void>
|
|
463
|
-
): boolean {
|
|
464
|
-
try {
|
|
465
|
-
super.emit(event, ...args);
|
|
466
|
-
return true;
|
|
467
|
-
} catch (err) {
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
export default Client;
|
package/src/test.ts
DELETED
package/src/types.d.ts
DELETED
|
@@ -1,302 +0,0 @@
|
|
|
1
|
-
declare interface Tag {
|
|
2
|
-
text: string;
|
|
3
|
-
color: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
declare interface User {
|
|
7
|
-
_id: string; // user id
|
|
8
|
-
name: string;
|
|
9
|
-
color: string;
|
|
10
|
-
tag?: Tag;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
declare interface Participant extends User {
|
|
14
|
-
id: string; // participant id (same as user id on mpp.net)
|
|
15
|
-
afk: boolean;
|
|
16
|
-
vanished?: boolean;
|
|
17
|
-
x: number | string;
|
|
18
|
-
y: number | string;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
declare type ChannelSettings = {
|
|
22
|
-
[key: string]: boolean | number | string;
|
|
23
|
-
color: string;
|
|
24
|
-
crownsolo: boolean;
|
|
25
|
-
chat: boolean;
|
|
26
|
-
visible: boolean;
|
|
27
|
-
limit: number;
|
|
28
|
-
} & Partial<{
|
|
29
|
-
color2: string;
|
|
30
|
-
lobby: boolean;
|
|
31
|
-
owner_id: string;
|
|
32
|
-
"lyrical notes": boolean;
|
|
33
|
-
"no cussing": boolean;
|
|
34
|
-
noindex: boolean;
|
|
35
|
-
}>;
|
|
36
|
-
|
|
37
|
-
declare interface ChannelInfo {
|
|
38
|
-
banned?: boolean;
|
|
39
|
-
count: number;
|
|
40
|
-
id: string;
|
|
41
|
-
_id: string;
|
|
42
|
-
crown?: Crown;
|
|
43
|
-
settings: ChannelSettings;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
declare type NoteLetter = `a` | `b` | `c` | `d` | `e` | `f` | `g`;
|
|
47
|
-
declare type NoteOctave = -1 | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
|
|
48
|
-
|
|
49
|
-
declare interface Note {
|
|
50
|
-
n: `${NoteLetter}${NoteOctave}`;
|
|
51
|
-
d?: number;
|
|
52
|
-
v?: number;
|
|
53
|
-
s?: 1;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
declare type LoginType = "discord";
|
|
57
|
-
|
|
58
|
-
declare interface LoginInfo {
|
|
59
|
-
type: LoginType;
|
|
60
|
-
code: string;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
declare interface AccountInfo {
|
|
64
|
-
type: LoginType;
|
|
65
|
-
username: string;
|
|
66
|
-
discriminator: string;
|
|
67
|
-
avatar: string;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
declare interface IncomingEvents {
|
|
71
|
-
a: {
|
|
72
|
-
m: "a";
|
|
73
|
-
a: string;
|
|
74
|
-
p: Participant;
|
|
75
|
-
t: number;
|
|
76
|
-
|
|
77
|
-
id: string;
|
|
78
|
-
r?: string;
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
b: {
|
|
82
|
-
m: "b";
|
|
83
|
-
code: string;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
bye: {
|
|
87
|
-
m: "bye";
|
|
88
|
-
p: Participant["id"];
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
c: {
|
|
92
|
-
m: "c";
|
|
93
|
-
c: IncomingEvents["a"][];
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
ch: {
|
|
97
|
-
m: "ch";
|
|
98
|
-
p: string;
|
|
99
|
-
ch: ChannelInfo;
|
|
100
|
-
ppl: Participant[];
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
custom: {
|
|
104
|
-
m: "custom";
|
|
105
|
-
data: any;
|
|
106
|
-
p: string;
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
dm: {
|
|
110
|
-
m: "dm";
|
|
111
|
-
id: string;
|
|
112
|
-
t: number;
|
|
113
|
-
a: string;
|
|
114
|
-
sender: Participant;
|
|
115
|
-
recipient: Participant;
|
|
116
|
-
r?: string;
|
|
117
|
-
};
|
|
118
|
-
|
|
119
|
-
hi: {
|
|
120
|
-
m: "hi";
|
|
121
|
-
t: number;
|
|
122
|
-
e: number;
|
|
123
|
-
u: User;
|
|
124
|
-
permissions: any;
|
|
125
|
-
token?: any;
|
|
126
|
-
accountInfo: any;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
|
-
ls: {
|
|
130
|
-
m: "ls";
|
|
131
|
-
c: boolean;
|
|
132
|
-
u: ChannelInfo[];
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
m: {
|
|
136
|
-
m: "m";
|
|
137
|
-
x: number;
|
|
138
|
-
y: number;
|
|
139
|
-
id: string;
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
n: {
|
|
143
|
-
m: "n";
|
|
144
|
-
t: number;
|
|
145
|
-
n: Note[];
|
|
146
|
-
p: string;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
notification: {
|
|
150
|
-
duration?: number;
|
|
151
|
-
class?: string;
|
|
152
|
-
id?: string;
|
|
153
|
-
title?: string;
|
|
154
|
-
text?: string;
|
|
155
|
-
html?: string;
|
|
156
|
-
target?: string;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
nq: {
|
|
160
|
-
m: "nq";
|
|
161
|
-
allowance: number;
|
|
162
|
-
max: number;
|
|
163
|
-
maxHistLen: number;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
p: {
|
|
167
|
-
m: "p";
|
|
168
|
-
x: number;
|
|
169
|
-
y: number;
|
|
170
|
-
} & Participant;
|
|
171
|
-
|
|
172
|
-
t: {
|
|
173
|
-
m: "t";
|
|
174
|
-
t: number;
|
|
175
|
-
e?: number;
|
|
176
|
-
};
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
declare interface OutgoingEvents {
|
|
180
|
-
a: {
|
|
181
|
-
m: "a";
|
|
182
|
-
message: string;
|
|
183
|
-
reply_to?: string;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
bye: {
|
|
187
|
-
m: "bye";
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
ch: {
|
|
191
|
-
m: "ch";
|
|
192
|
-
_id: string;
|
|
193
|
-
set?: Partial<ChannelSettings>;
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
chown: {
|
|
197
|
-
m: "chown";
|
|
198
|
-
id?: string;
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
chset: {
|
|
202
|
-
m: "chset";
|
|
203
|
-
set: Partial<ChannelSettings>;
|
|
204
|
-
};
|
|
205
|
-
|
|
206
|
-
custom: {
|
|
207
|
-
m: "custom";
|
|
208
|
-
data: any;
|
|
209
|
-
target: CustomTarget;
|
|
210
|
-
};
|
|
211
|
-
|
|
212
|
-
devices: {
|
|
213
|
-
m: "devices";
|
|
214
|
-
list: any[];
|
|
215
|
-
};
|
|
216
|
-
|
|
217
|
-
dm: {
|
|
218
|
-
m: "dm";
|
|
219
|
-
message: string;
|
|
220
|
-
_id: string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
hi: {
|
|
224
|
-
m: "hi";
|
|
225
|
-
token?: string;
|
|
226
|
-
login?: LoginInfo;
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
kickban: {
|
|
230
|
-
m: "kickban";
|
|
231
|
-
_id: string;
|
|
232
|
-
ms: number;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
m: {
|
|
236
|
-
m: "m";
|
|
237
|
-
x?: string | number;
|
|
238
|
-
y?: string | number;
|
|
239
|
-
};
|
|
240
|
-
|
|
241
|
-
"-custom": {
|
|
242
|
-
m: "-custom";
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
"-ls": {
|
|
246
|
-
m: "-ls";
|
|
247
|
-
};
|
|
248
|
-
|
|
249
|
-
n: {
|
|
250
|
-
m: "n";
|
|
251
|
-
t: number;
|
|
252
|
-
n: Note[];
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
"+custom": {
|
|
256
|
-
m: "+custom";
|
|
257
|
-
};
|
|
258
|
-
|
|
259
|
-
"+ls": {
|
|
260
|
-
m: "+ls";
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
t: {
|
|
264
|
-
m: "t";
|
|
265
|
-
e?: number;
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
unban: {
|
|
269
|
-
m: "unban";
|
|
270
|
-
_id: string;
|
|
271
|
-
};
|
|
272
|
-
|
|
273
|
-
userset: {
|
|
274
|
-
m: "userset";
|
|
275
|
-
set: { name?: string; color?: string };
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
setcolor: {
|
|
279
|
-
m: "setcolor";
|
|
280
|
-
color: string;
|
|
281
|
-
_id: string;
|
|
282
|
-
};
|
|
283
|
-
|
|
284
|
-
setname: {
|
|
285
|
-
m: "setname";
|
|
286
|
-
name: string;
|
|
287
|
-
_id: string;
|
|
288
|
-
};
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
declare interface LocalEvents {
|
|
292
|
-
count: number;
|
|
293
|
-
"participant added": Participant;
|
|
294
|
-
"participant removed": Participant;
|
|
295
|
-
"participant update": Participant;
|
|
296
|
-
status: string;
|
|
297
|
-
disconnect: any;
|
|
298
|
-
wserror: any;
|
|
299
|
-
connect: any;
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
declare type EmittableEvents = LocalEvents & IncomingEvents;
|
package/tsconfig.json
DELETED
|
@@ -1,113 +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
|
-
"rootDir": "src",
|
|
31
|
-
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
|
|
32
|
-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
|
|
33
|
-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
|
|
34
|
-
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
|
|
35
|
-
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
|
|
36
|
-
// "types": [], /* Specify type package names to be included without being referenced in a source file. */
|
|
37
|
-
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
|
|
38
|
-
// "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */
|
|
39
|
-
// "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */
|
|
40
|
-
// "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */
|
|
41
|
-
// "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */
|
|
42
|
-
// "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */
|
|
43
|
-
// "resolveJsonModule": true, /* Enable importing .json files. */
|
|
44
|
-
// "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */
|
|
45
|
-
// "noResolve": true, /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */
|
|
46
|
-
|
|
47
|
-
/* JavaScript Support */
|
|
48
|
-
// "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */
|
|
49
|
-
// "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */
|
|
50
|
-
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
51
|
-
|
|
52
|
-
/* Emit */
|
|
53
|
-
// "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
54
|
-
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
55
|
-
"declaration": true,
|
|
56
|
-
"declarationMap": true,
|
|
57
|
-
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
58
|
-
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|
|
59
|
-
// "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
|
|
60
|
-
// "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. */
|
|
61
|
-
// "outDir": "./", /* Specify an output folder for all emitted files. */
|
|
62
|
-
"outDir": "build",
|
|
63
|
-
// "removeComments": true, /* Disable emitting comments. */
|
|
64
|
-
// "noEmit": true, /* Disable emitting files from a compilation. */
|
|
65
|
-
// "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
|
|
66
|
-
// "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types. */
|
|
67
|
-
// "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
|
|
68
|
-
// "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
|
|
69
|
-
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
|
|
70
|
-
// "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
|
|
71
|
-
// "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
|
|
72
|
-
// "newLine": "crlf", /* Set the newline character for emitting files. */
|
|
73
|
-
// "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */
|
|
74
|
-
// "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */
|
|
75
|
-
// "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
|
|
76
|
-
// "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */
|
|
77
|
-
// "declarationDir": "./", /* Specify the output directory for generated declaration files. */
|
|
78
|
-
// "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
|
|
79
|
-
|
|
80
|
-
/* Interop Constraints */
|
|
81
|
-
// "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */
|
|
82
|
-
// "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. */
|
|
83
|
-
// "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */
|
|
84
|
-
"esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */,
|
|
85
|
-
// "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
|
|
86
|
-
"forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
|
|
87
|
-
|
|
88
|
-
/* Type Checking */
|
|
89
|
-
"strict": true /* Enable all strict type-checking options. */,
|
|
90
|
-
// "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */
|
|
91
|
-
// "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */
|
|
92
|
-
// "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
|
|
93
|
-
// "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */
|
|
94
|
-
// "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
|
|
95
|
-
// "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */
|
|
96
|
-
// "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */
|
|
97
|
-
// "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
|
|
98
|
-
// "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */
|
|
99
|
-
// "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */
|
|
100
|
-
// "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
|
|
101
|
-
// "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
|
|
102
|
-
// "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
|
|
103
|
-
// "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */
|
|
104
|
-
// "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
|
|
105
|
-
// "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */
|
|
106
|
-
// "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
|
|
107
|
-
// "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
|
|
108
|
-
|
|
109
|
-
/* Completeness */
|
|
110
|
-
// "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
|
|
111
|
-
"skipLibCheck": true /* Skip type checking all .d.ts files. */
|
|
112
|
-
}
|
|
113
|
-
}
|