mpp-client-net 1.2.1 → 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/build/index.d.ts +70 -0
- package/build/index.d.ts.map +1 -0
- package/{src/index.ts → build/index.js} +116 -199
- package/build/test.d.ts +2 -0
- package/build/test.d.ts.map +1 -0
- package/build/test.js +12 -0
- package/package.json +1 -1
- package/src/test.ts +0 -10
- package/src/types.d.ts +0 -302
- package/tsconfig.json +0 -113
package/build/index.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
import { WebSocket } from "ws";
|
|
3
|
+
export declare class Client extends EventEmitter {
|
|
4
|
+
uri: string;
|
|
5
|
+
token?: string | undefined;
|
|
6
|
+
ws: WebSocket | undefined;
|
|
7
|
+
serverTimeOffset: number;
|
|
8
|
+
user: User | undefined;
|
|
9
|
+
participantId: Participant["id"] | undefined;
|
|
10
|
+
channel: ChannelInfo | undefined;
|
|
11
|
+
ppl: Record<Participant["id"], Participant>;
|
|
12
|
+
connectionTime: number | undefined;
|
|
13
|
+
connectionAttempts: number;
|
|
14
|
+
desiredChannelId: ChannelInfo["_id"] | undefined;
|
|
15
|
+
desiredChannelSettings: Partial<ChannelSettings> | undefined;
|
|
16
|
+
pingInterval: NodeJS.Timeout | undefined;
|
|
17
|
+
canConnect: boolean;
|
|
18
|
+
noteBuffer: Note[];
|
|
19
|
+
noteBufferTime: number;
|
|
20
|
+
noteFlushInterval: NodeJS.Timeout | undefined;
|
|
21
|
+
permissions: any;
|
|
22
|
+
"🐈": number;
|
|
23
|
+
loginInfo: LoginInfo | undefined;
|
|
24
|
+
accountInfo: AccountInfo | undefined;
|
|
25
|
+
constructor(uri: string, token?: string | undefined);
|
|
26
|
+
isSupported(): boolean;
|
|
27
|
+
isConnected(): boolean | undefined;
|
|
28
|
+
isConnecting(): boolean | undefined;
|
|
29
|
+
start(): void;
|
|
30
|
+
stop(): void;
|
|
31
|
+
connect(): void;
|
|
32
|
+
protected bindEventListeners(): void;
|
|
33
|
+
protected send(raw: string): void;
|
|
34
|
+
sendArray<Event extends keyof OutgoingEvents>(arr: OutgoingEvents[Event][]): void;
|
|
35
|
+
setChannel(id?: string, set?: Partial<ChannelSettings>): void;
|
|
36
|
+
protected offlineChannelSettings: Partial<ChannelSettings>;
|
|
37
|
+
getChannelSetting(key: string): string | number | boolean | undefined;
|
|
38
|
+
setChannelSettings(settings: Partial<ChannelSettings>): void;
|
|
39
|
+
protected offlineParticipant: {
|
|
40
|
+
_id: string;
|
|
41
|
+
name: string;
|
|
42
|
+
color: string;
|
|
43
|
+
};
|
|
44
|
+
getOwnParticipant(): {
|
|
45
|
+
_id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
color: string;
|
|
48
|
+
};
|
|
49
|
+
protected setParticipants(ppl: Participant[]): void;
|
|
50
|
+
countParticipants(): number;
|
|
51
|
+
participantUpdate(update: any): void;
|
|
52
|
+
participantMoveMouse(update: IncomingEvents["m"]): void;
|
|
53
|
+
removeParticipant(id: Participant["id"]): void;
|
|
54
|
+
findParticipantById(id?: string): {
|
|
55
|
+
_id: string;
|
|
56
|
+
name: string;
|
|
57
|
+
color: string;
|
|
58
|
+
};
|
|
59
|
+
isOwner(): any;
|
|
60
|
+
preventsPlaying(): boolean | undefined;
|
|
61
|
+
receiveServerTime(time: number, echo?: number): void;
|
|
62
|
+
startNote(note: Note["n"], vel: Note["v"]): void;
|
|
63
|
+
stopNote(note: Note["n"]): void;
|
|
64
|
+
sendPing(): void;
|
|
65
|
+
setLoginInfo(loginInfo: LoginInfo): void;
|
|
66
|
+
on<Event extends keyof EmittableEvents>(event: Event, listener: (msg: EmittableEvents[Event]) => void): this;
|
|
67
|
+
emit<Event extends keyof EmittableEvents>(event: Event, ...args: Parameters<(msg: EmittableEvents[Event]) => void>): boolean;
|
|
68
|
+
}
|
|
69
|
+
export default Client;
|
|
70
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,86 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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) {
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.Client = void 0;
|
|
13
|
+
const events_1 = require("events");
|
|
14
|
+
const ws_1 = require("ws");
|
|
15
|
+
class Client extends events_1.EventEmitter {
|
|
16
|
+
constructor(uri, token) {
|
|
26
17
|
super();
|
|
27
|
-
|
|
18
|
+
this.uri = uri;
|
|
19
|
+
this.token = token;
|
|
20
|
+
this.serverTimeOffset = 0;
|
|
21
|
+
this.ppl = {};
|
|
22
|
+
this.connectionAttempts = 0;
|
|
23
|
+
this.canConnect = false;
|
|
24
|
+
this.noteBuffer = [];
|
|
25
|
+
this.noteBufferTime = 0;
|
|
26
|
+
this.permissions = {};
|
|
27
|
+
this["🐈"] = 0;
|
|
28
|
+
this.offlineChannelSettings = {
|
|
29
|
+
color: "#ecfaed"
|
|
30
|
+
};
|
|
31
|
+
this.offlineParticipant = {
|
|
32
|
+
_id: "",
|
|
33
|
+
name: "",
|
|
34
|
+
color: "#777"
|
|
35
|
+
};
|
|
28
36
|
this.bindEventListeners();
|
|
29
37
|
this.emit("status", "(Offline mode)");
|
|
30
38
|
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return typeof WebSocket === "function";
|
|
39
|
+
isSupported() {
|
|
40
|
+
return typeof ws_1.WebSocket === "function";
|
|
34
41
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
this.isSupported() &&
|
|
42
|
+
isConnected() {
|
|
43
|
+
return (this.isSupported() &&
|
|
39
44
|
this.ws &&
|
|
40
|
-
this.ws.readyState === WebSocket.OPEN
|
|
41
|
-
);
|
|
45
|
+
this.ws.readyState === ws_1.WebSocket.OPEN);
|
|
42
46
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
this.isSupported() &&
|
|
47
|
+
isConnecting() {
|
|
48
|
+
return (this.isSupported() &&
|
|
47
49
|
this.ws &&
|
|
48
|
-
this.ws.readyState === WebSocket.CONNECTING
|
|
49
|
-
);
|
|
50
|
+
this.ws.readyState === ws_1.WebSocket.CONNECTING);
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
public start() {
|
|
52
|
+
start() {
|
|
53
53
|
this.canConnect = true;
|
|
54
54
|
if (!this.connectionTime) {
|
|
55
55
|
this.connect();
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
public stop() {
|
|
58
|
+
stop() {
|
|
60
59
|
this.canConnect = false;
|
|
61
|
-
if (this.ws)
|
|
60
|
+
if (this.ws)
|
|
61
|
+
this.ws.close();
|
|
62
62
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
!this.canConnect ||
|
|
63
|
+
connect() {
|
|
64
|
+
if (!this.canConnect ||
|
|
67
65
|
!this.isSupported() ||
|
|
68
66
|
this.isConnected() ||
|
|
69
|
-
this.isConnecting()
|
|
70
|
-
)
|
|
67
|
+
this.isConnecting())
|
|
71
68
|
return;
|
|
72
|
-
|
|
73
69
|
this.emit("status", "Connecting...");
|
|
74
70
|
if (typeof module !== "undefined") {
|
|
75
71
|
// nodejsicle
|
|
76
|
-
this.ws = new WebSocket(this.uri, {
|
|
72
|
+
this.ws = new ws_1.WebSocket(this.uri, {
|
|
77
73
|
origin: "https://multiplayerpiano.net"
|
|
78
74
|
});
|
|
79
|
-
}
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
80
77
|
// browseroni
|
|
81
|
-
this.ws = new WebSocket(this.uri);
|
|
78
|
+
this.ws = new ws_1.WebSocket(this.uri);
|
|
82
79
|
}
|
|
83
|
-
|
|
84
80
|
this.ws.addEventListener("close", evt => {
|
|
85
81
|
this.user = undefined;
|
|
86
82
|
this.participantId = undefined;
|
|
@@ -88,39 +84,34 @@ export class Client extends EventEmitter {
|
|
|
88
84
|
this.setParticipants([]);
|
|
89
85
|
clearInterval(this.pingInterval);
|
|
90
86
|
clearInterval(this.noteFlushInterval);
|
|
91
|
-
|
|
92
87
|
this.emit("disconnect", evt);
|
|
93
88
|
this.emit("status", "Offline mode");
|
|
94
|
-
|
|
95
89
|
// reconnect!
|
|
96
90
|
if (this.connectionTime) {
|
|
97
91
|
this.connectionTime = undefined;
|
|
98
92
|
this.connectionAttempts = 0;
|
|
99
|
-
}
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
100
95
|
++this.connectionAttempts;
|
|
101
96
|
}
|
|
102
|
-
|
|
103
97
|
const ms_lut = [50, 2500, 10000];
|
|
104
98
|
let idx = this.connectionAttempts;
|
|
105
|
-
if (idx >= ms_lut.length)
|
|
99
|
+
if (idx >= ms_lut.length)
|
|
100
|
+
idx = ms_lut.length - 1;
|
|
106
101
|
const ms = ms_lut[idx];
|
|
107
|
-
|
|
108
102
|
setTimeout(this.connect.bind(this), ms);
|
|
109
103
|
});
|
|
110
|
-
|
|
111
104
|
this.ws.addEventListener("error", err => {
|
|
112
105
|
this.emit("wserror", err);
|
|
113
|
-
if (this.ws)
|
|
106
|
+
if (this.ws)
|
|
107
|
+
this.ws.close(); // self.ws.emit("close");
|
|
114
108
|
});
|
|
115
|
-
|
|
116
109
|
this.ws.addEventListener("open", evt => {
|
|
117
110
|
this.pingInterval = setInterval(() => {
|
|
118
111
|
this.sendPing();
|
|
119
112
|
}, 20000);
|
|
120
|
-
|
|
121
113
|
this.noteBuffer = [];
|
|
122
114
|
this.noteBufferTime = 0;
|
|
123
|
-
|
|
124
115
|
this.noteFlushInterval = setInterval(() => {
|
|
125
116
|
if (this.noteBufferTime && this.noteBuffer.length > 0) {
|
|
126
117
|
this.sendArray([
|
|
@@ -134,10 +125,8 @@ export class Client extends EventEmitter {
|
|
|
134
125
|
this.noteBuffer = [];
|
|
135
126
|
}
|
|
136
127
|
}, 200);
|
|
137
|
-
|
|
138
128
|
this.emit("connect", undefined);
|
|
139
129
|
this.emit("status", "Joining channel...");
|
|
140
|
-
|
|
141
130
|
this.sendArray([
|
|
142
131
|
{
|
|
143
132
|
m: "hi",
|
|
@@ -146,81 +135,60 @@ export class Client extends EventEmitter {
|
|
|
146
135
|
}
|
|
147
136
|
]);
|
|
148
137
|
});
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
const transmission = JSON.parse(
|
|
152
|
-
(evt as unknown as { data: string }).data
|
|
153
|
-
);
|
|
154
|
-
|
|
138
|
+
this.ws.addEventListener("message", (evt) => __awaiter(this, void 0, void 0, function* () {
|
|
139
|
+
const transmission = JSON.parse(evt.data);
|
|
155
140
|
for (let i = 0; i < transmission.length; i++) {
|
|
156
141
|
const msg = transmission[i];
|
|
157
142
|
this.emit(msg.m, msg);
|
|
158
143
|
}
|
|
159
|
-
});
|
|
144
|
+
}));
|
|
160
145
|
}
|
|
161
|
-
|
|
162
|
-
protected bindEventListeners() {
|
|
146
|
+
bindEventListeners() {
|
|
163
147
|
this.on("hi", msg => {
|
|
164
148
|
this.connectionTime = Date.now();
|
|
165
149
|
this.user = msg.u;
|
|
166
150
|
this.receiveServerTime(msg.t, msg.e);
|
|
167
|
-
|
|
168
151
|
if (this.desiredChannelId) {
|
|
169
152
|
this.setChannel();
|
|
170
153
|
}
|
|
171
|
-
|
|
172
154
|
this.permissions = msg.permissions ? msg.permissions : {};
|
|
173
155
|
this.accountInfo = msg.accountInfo;
|
|
174
156
|
});
|
|
175
|
-
|
|
176
157
|
this.on("t", msg => {
|
|
177
158
|
this.receiveServerTime(msg.t, msg.e || undefined);
|
|
178
159
|
});
|
|
179
|
-
|
|
180
160
|
this.on("ch", msg => {
|
|
181
161
|
this.desiredChannelId = msg.ch._id;
|
|
182
162
|
this.desiredChannelSettings = msg.ch.settings;
|
|
183
|
-
|
|
184
163
|
this.channel = msg.ch;
|
|
185
|
-
|
|
186
|
-
|
|
164
|
+
if (msg.p)
|
|
165
|
+
this.participantId = msg.p;
|
|
187
166
|
this.setParticipants(msg.ppl);
|
|
188
167
|
});
|
|
189
|
-
|
|
190
168
|
this.on("p", msg => {
|
|
191
169
|
this.participantUpdate(msg);
|
|
192
|
-
this.emit(
|
|
193
|
-
"participant update",
|
|
194
|
-
this.findParticipantById(msg.id) as Participant
|
|
195
|
-
);
|
|
170
|
+
this.emit("participant update", this.findParticipantById(msg.id));
|
|
196
171
|
});
|
|
197
|
-
|
|
198
172
|
this.on("m", msg => {
|
|
199
173
|
if (this.ppl.hasOwnProperty(msg.id)) {
|
|
200
174
|
this.participantMoveMouse(msg);
|
|
201
175
|
}
|
|
202
176
|
});
|
|
203
|
-
|
|
204
177
|
this.on("bye", msg => {
|
|
205
178
|
this.removeParticipant(msg.p);
|
|
206
179
|
});
|
|
207
180
|
}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
181
|
+
send(raw) {
|
|
182
|
+
if (this.isConnected() && this.ws)
|
|
183
|
+
this.ws.send(raw);
|
|
211
184
|
}
|
|
212
|
-
|
|
213
|
-
public sendArray<Event extends keyof OutgoingEvents>(
|
|
214
|
-
arr: OutgoingEvents[Event][]
|
|
215
|
-
) {
|
|
185
|
+
sendArray(arr) {
|
|
216
186
|
this.send(JSON.stringify(arr));
|
|
217
187
|
}
|
|
218
|
-
|
|
219
|
-
public setChannel(id?: string, set?: Partial<ChannelSettings>) {
|
|
188
|
+
setChannel(id, set) {
|
|
220
189
|
this.desiredChannelId = id || this.desiredChannelId || "lobby";
|
|
221
190
|
this.desiredChannelSettings =
|
|
222
191
|
set || this.desiredChannelSettings || undefined;
|
|
223
|
-
|
|
224
192
|
this.sendArray([
|
|
225
193
|
{
|
|
226
194
|
m: "ch",
|
|
@@ -229,29 +197,20 @@ export class Client extends EventEmitter {
|
|
|
229
197
|
}
|
|
230
198
|
]);
|
|
231
199
|
}
|
|
232
|
-
|
|
233
|
-
protected offlineChannelSettings: Partial<ChannelSettings> = {
|
|
234
|
-
color: "#ecfaed"
|
|
235
|
-
};
|
|
236
|
-
|
|
237
|
-
public getChannelSetting(key: string) {
|
|
200
|
+
getChannelSetting(key) {
|
|
238
201
|
if (!this.isConnected() || !this.channel || !this.channel.settings) {
|
|
239
202
|
return this.offlineChannelSettings[key];
|
|
240
203
|
}
|
|
241
|
-
|
|
242
204
|
return this.channel.settings[key];
|
|
243
205
|
}
|
|
244
|
-
|
|
245
|
-
public setChannelSettings(settings: Partial<ChannelSettings>) {
|
|
206
|
+
setChannelSettings(settings) {
|
|
246
207
|
if (!this.isConnected() || !this.channel || !this.channel.settings) {
|
|
247
208
|
return;
|
|
248
209
|
}
|
|
249
|
-
|
|
250
210
|
if (this.desiredChannelSettings) {
|
|
251
211
|
for (const key of Object.keys(settings)) {
|
|
252
212
|
this.desiredChannelSettings[key] = settings[key];
|
|
253
213
|
}
|
|
254
|
-
|
|
255
214
|
this.sendArray([
|
|
256
215
|
{
|
|
257
216
|
m: "chset",
|
|
@@ -260,130 +219,99 @@ export class Client extends EventEmitter {
|
|
|
260
219
|
]);
|
|
261
220
|
}
|
|
262
221
|
}
|
|
263
|
-
|
|
264
|
-
protected offlineParticipant = {
|
|
265
|
-
_id: "",
|
|
266
|
-
name: "",
|
|
267
|
-
color: "#777"
|
|
268
|
-
};
|
|
269
|
-
|
|
270
|
-
public getOwnParticipant() {
|
|
222
|
+
getOwnParticipant() {
|
|
271
223
|
return this.findParticipantById(this.participantId);
|
|
272
224
|
}
|
|
273
|
-
|
|
274
|
-
protected setParticipants(ppl: Participant[]) {
|
|
225
|
+
setParticipants(ppl) {
|
|
275
226
|
// remove participants who left
|
|
276
227
|
for (const id of Object.keys(this.ppl)) {
|
|
277
|
-
if (!this.ppl.hasOwnProperty(id))
|
|
278
|
-
|
|
228
|
+
if (!this.ppl.hasOwnProperty(id))
|
|
229
|
+
continue;
|
|
279
230
|
let found = false;
|
|
280
|
-
|
|
281
231
|
for (let j = 0; j < ppl.length; j++) {
|
|
282
232
|
if (ppl[j].id === id) {
|
|
283
233
|
found = true;
|
|
284
234
|
break;
|
|
285
235
|
}
|
|
286
236
|
}
|
|
287
|
-
|
|
288
237
|
if (!found) {
|
|
289
238
|
this.removeParticipant(id);
|
|
290
239
|
}
|
|
291
240
|
}
|
|
292
|
-
|
|
293
241
|
// update all
|
|
294
242
|
for (let i = 0; i < ppl.length; i++) {
|
|
295
243
|
this.participantUpdate(ppl[i]);
|
|
296
244
|
}
|
|
297
245
|
}
|
|
298
|
-
|
|
299
|
-
public countParticipants() {
|
|
246
|
+
countParticipants() {
|
|
300
247
|
let count = 0;
|
|
301
|
-
|
|
302
248
|
for (let i in this.ppl) {
|
|
303
|
-
if (this.ppl.hasOwnProperty(i))
|
|
249
|
+
if (this.ppl.hasOwnProperty(i))
|
|
250
|
+
++count;
|
|
304
251
|
}
|
|
305
|
-
|
|
306
252
|
return count;
|
|
307
253
|
}
|
|
308
|
-
|
|
309
|
-
public participantUpdate(update: any) {
|
|
254
|
+
participantUpdate(update) {
|
|
310
255
|
let part = this.ppl[update.id] || null;
|
|
311
|
-
|
|
312
256
|
if (part === null) {
|
|
313
257
|
part = update;
|
|
314
258
|
this.ppl[part.id] = part;
|
|
315
|
-
|
|
316
259
|
this.emit("participant added", part);
|
|
317
260
|
this.emit("count", this.countParticipants());
|
|
318
|
-
}
|
|
261
|
+
}
|
|
262
|
+
else {
|
|
319
263
|
Object.keys(update).forEach(key => {
|
|
320
|
-
|
|
264
|
+
part[key] = update[key];
|
|
321
265
|
});
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
if (!update.vanished)
|
|
266
|
+
if (!update.tag)
|
|
267
|
+
delete part.tag;
|
|
268
|
+
if (!update.vanished)
|
|
269
|
+
delete part.vanished;
|
|
325
270
|
}
|
|
326
271
|
}
|
|
327
|
-
|
|
328
|
-
public participantMoveMouse(update: IncomingEvents["m"]) {
|
|
272
|
+
participantMoveMouse(update) {
|
|
329
273
|
const part = this.ppl[update.id] || null;
|
|
330
|
-
|
|
331
274
|
if (part !== null) {
|
|
332
275
|
part.x = update.x;
|
|
333
276
|
part.y = update.y;
|
|
334
277
|
}
|
|
335
278
|
}
|
|
336
|
-
|
|
337
|
-
public removeParticipant(id: Participant["id"]) {
|
|
279
|
+
removeParticipant(id) {
|
|
338
280
|
if (this.ppl.hasOwnProperty(id)) {
|
|
339
281
|
const part = this.ppl[id];
|
|
340
282
|
delete this.ppl[id];
|
|
341
|
-
|
|
342
283
|
this.emit("participant removed", part);
|
|
343
284
|
this.emit("count", this.countParticipants());
|
|
344
285
|
}
|
|
345
286
|
}
|
|
346
|
-
|
|
347
|
-
public findParticipantById(id?: string) {
|
|
287
|
+
findParticipantById(id) {
|
|
348
288
|
return id
|
|
349
289
|
? this.ppl[id] || this.offlineParticipant
|
|
350
290
|
: this.offlineParticipant;
|
|
351
291
|
}
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
return (
|
|
355
|
-
this.channel &&
|
|
292
|
+
isOwner() {
|
|
293
|
+
return (this.channel &&
|
|
356
294
|
this.channel.crown &&
|
|
357
|
-
this.channel.crown.participantId === this.participantId
|
|
358
|
-
);
|
|
295
|
+
this.channel.crown.participantId === this.participantId);
|
|
359
296
|
}
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
return (
|
|
363
|
-
this.isConnected() &&
|
|
297
|
+
preventsPlaying() {
|
|
298
|
+
return (this.isConnected() &&
|
|
364
299
|
!this.isOwner() &&
|
|
365
300
|
this.getChannelSetting("crownsolo") === true &&
|
|
366
|
-
!this.permissions.playNotesAnywhere
|
|
367
|
-
);
|
|
301
|
+
!this.permissions.playNotesAnywhere);
|
|
368
302
|
}
|
|
369
|
-
|
|
370
|
-
public receiveServerTime(time: number, echo?: number) {
|
|
303
|
+
receiveServerTime(time, echo) {
|
|
371
304
|
const now = Date.now();
|
|
372
305
|
const target = time - now;
|
|
373
|
-
|
|
374
306
|
// console.log("Target serverTimeOffset: " + target);
|
|
375
307
|
const duration = 1000;
|
|
376
|
-
|
|
377
308
|
let step = 0;
|
|
378
309
|
const steps = 50;
|
|
379
310
|
const step_ms = duration / steps;
|
|
380
|
-
|
|
381
311
|
const difference = target - this.serverTimeOffset;
|
|
382
312
|
const inc = difference / steps;
|
|
383
|
-
|
|
384
313
|
let iv = setInterval(() => {
|
|
385
314
|
this.serverTimeOffset += inc;
|
|
386
|
-
|
|
387
315
|
if (++step >= steps) {
|
|
388
316
|
clearInterval(iv);
|
|
389
317
|
// console.log("serverTimeOffset reached: " + self.serverTimeOffset);
|
|
@@ -391,25 +319,23 @@ export class Client extends EventEmitter {
|
|
|
391
319
|
}
|
|
392
320
|
}, step_ms);
|
|
393
321
|
// smoothen
|
|
394
|
-
|
|
395
322
|
// this.serverTimeOffset = time - now; // mostly time zone offset ... also the lags so todo smoothen this
|
|
396
323
|
// not smooth:
|
|
397
324
|
// if(echo) this.serverTimeOffset += echo - now; // mostly round trip time offset
|
|
398
325
|
}
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
326
|
+
startNote(note, vel) {
|
|
327
|
+
if (typeof note !== "string")
|
|
328
|
+
return;
|
|
403
329
|
if (this.isConnected()) {
|
|
404
330
|
let vel2 = typeof vel === "undefined" ? undefined : +vel.toFixed(3);
|
|
405
|
-
|
|
406
331
|
if (!this.noteBufferTime) {
|
|
407
332
|
this.noteBufferTime = Date.now();
|
|
408
333
|
this.noteBuffer.push({
|
|
409
334
|
n: note,
|
|
410
335
|
v: vel2
|
|
411
336
|
});
|
|
412
|
-
}
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
413
339
|
this.noteBuffer.push({
|
|
414
340
|
d: Date.now() - this.noteBufferTime,
|
|
415
341
|
n: note,
|
|
@@ -418,15 +344,15 @@ export class Client extends EventEmitter {
|
|
|
418
344
|
}
|
|
419
345
|
}
|
|
420
346
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
347
|
+
stopNote(note) {
|
|
348
|
+
if (typeof note !== "string")
|
|
349
|
+
return;
|
|
425
350
|
if (this.isConnected()) {
|
|
426
351
|
if (!this.noteBufferTime) {
|
|
427
352
|
this.noteBufferTime = Date.now();
|
|
428
353
|
this.noteBuffer.push({ n: note, s: 1 });
|
|
429
|
-
}
|
|
354
|
+
}
|
|
355
|
+
else {
|
|
430
356
|
this.noteBuffer.push({
|
|
431
357
|
d: Date.now() - this.noteBufferTime,
|
|
432
358
|
n: note,
|
|
@@ -435,8 +361,7 @@ export class Client extends EventEmitter {
|
|
|
435
361
|
}
|
|
436
362
|
}
|
|
437
363
|
}
|
|
438
|
-
|
|
439
|
-
public sendPing() {
|
|
364
|
+
sendPing() {
|
|
440
365
|
this.sendArray([
|
|
441
366
|
{
|
|
442
367
|
m: "t",
|
|
@@ -444,30 +369,22 @@ export class Client extends EventEmitter {
|
|
|
444
369
|
}
|
|
445
370
|
]);
|
|
446
371
|
}
|
|
447
|
-
|
|
448
|
-
public setLoginInfo(loginInfo: LoginInfo) {
|
|
372
|
+
setLoginInfo(loginInfo) {
|
|
449
373
|
this.loginInfo = loginInfo;
|
|
450
374
|
}
|
|
451
|
-
|
|
452
|
-
public on<Event extends keyof EmittableEvents>(
|
|
453
|
-
event: Event,
|
|
454
|
-
listener: (msg: EmittableEvents[Event]) => void
|
|
455
|
-
): this {
|
|
375
|
+
on(event, listener) {
|
|
456
376
|
super.on(event, listener);
|
|
457
377
|
return this;
|
|
458
378
|
}
|
|
459
|
-
|
|
460
|
-
public emit<Event extends keyof EmittableEvents>(
|
|
461
|
-
event: Event,
|
|
462
|
-
...args: Parameters<(msg: EmittableEvents[Event]) => void>
|
|
463
|
-
): boolean {
|
|
379
|
+
emit(event, ...args) {
|
|
464
380
|
try {
|
|
465
381
|
super.emit(event, ...args);
|
|
466
382
|
return true;
|
|
467
|
-
}
|
|
383
|
+
}
|
|
384
|
+
catch (err) {
|
|
468
385
|
return false;
|
|
469
386
|
}
|
|
470
387
|
}
|
|
471
388
|
}
|
|
472
|
-
|
|
473
|
-
|
|
389
|
+
exports.Client = Client;
|
|
390
|
+
exports.default = Client;
|
package/build/test.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":""}
|
package/build/test.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const index_1 = __importDefault(require("./index"));
|
|
7
|
+
const cl = new index_1.default("wss://mppclone.com:8443", process.env.MPPNET_TOKEN);
|
|
8
|
+
cl.start();
|
|
9
|
+
cl.setChannel("✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧");
|
|
10
|
+
cl.on("a", msg => {
|
|
11
|
+
console.log(`${msg.p.name}: ${msg.a}`);
|
|
12
|
+
});
|
package/package.json
CHANGED
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
|
-
}
|