@mtkruto/node 0.1.107 → 0.1.109
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/esm/0_deps.d.ts +1 -1
- package/esm/0_deps.js +1 -1
- package/esm/4_constants.d.ts +2 -2
- package/esm/4_constants.js +3 -3
- package/esm/5_client.d.ts +1 -0
- package/esm/5_client.js +1 -0
- package/esm/client/0_html.js +26 -14
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities.js +1 -2
- package/esm/client/1_client_abstract.d.ts +1 -1
- package/esm/client/1_client_abstract.js +16 -8
- package/esm/client/2_client_plain.d.ts +1 -2
- package/esm/client/2_client_plain.js +20 -15
- package/esm/client/3_types.d.ts +1 -1
- package/esm/client/4_client.d.ts +6 -57
- package/esm/client/4_client.js +619 -716
- package/esm/connection/1_connection_web_socket.d.ts +1 -9
- package/esm/connection/1_connection_web_socket.js +81 -108
- package/esm/storage/0_storage.d.ts +3 -2
- package/esm/storage/0_storage.js +35 -26
- package/esm/storage/0_utilities.d.ts +1 -1
- package/esm/storage/0_utilities.js +56 -26
- package/esm/storage/1_storage_local_storage.d.ts +1 -1
- package/esm/storage/1_storage_session_storage.d.ts +1 -1
- package/esm/tl/2_types.d.ts +441 -58
- package/esm/tl/2_types.js +1584 -118
- package/esm/tl/3_functions.d.ts +113 -16
- package/esm/tl/3_functions.js +364 -39
- package/esm/transport/1_transport_abridged.d.ts +1 -2
- package/esm/transport/1_transport_abridged.js +24 -19
- package/esm/transport/1_transport_intermediate.d.ts +1 -2
- package/esm/transport/1_transport_intermediate.js +23 -18
- package/esm/types/0_color.d.ts +2 -1
- package/esm/types/0_color.js +21 -1
- package/esm/types/0_message_entity.d.ts +1 -1
- package/esm/types/1_chat.js +5 -5
- package/esm/types/1_user.js +2 -2
- package/esm/types/3_message.js +1 -1
- package/esm/utilities/0_base64.js +3 -3
- package/esm/utilities/0_queue.d.ts +2 -4
- package/esm/utilities/0_queue.js +39 -36
- package/package.json +1 -1
- package/script/0_deps.d.ts +1 -1
- package/script/0_deps.js +3 -3
- package/script/4_constants.d.ts +2 -2
- package/script/4_constants.js +3 -3
- package/script/5_client.d.ts +1 -0
- package/script/5_client.js +1 -0
- package/script/client/0_html.js +26 -14
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities.js +1 -2
- package/script/client/1_client_abstract.d.ts +1 -1
- package/script/client/1_client_abstract.js +16 -8
- package/script/client/2_client_plain.d.ts +1 -2
- package/script/client/2_client_plain.js +20 -15
- package/script/client/3_types.d.ts +1 -1
- package/script/client/4_client.d.ts +6 -57
- package/script/client/4_client.js +619 -716
- package/script/connection/1_connection_web_socket.d.ts +1 -9
- package/script/connection/1_connection_web_socket.js +81 -108
- package/script/storage/0_storage.d.ts +3 -2
- package/script/storage/0_storage.js +35 -26
- package/script/storage/0_utilities.d.ts +1 -1
- package/script/storage/0_utilities.js +55 -25
- package/script/storage/1_storage_local_storage.d.ts +1 -1
- package/script/storage/1_storage_session_storage.d.ts +1 -1
- package/script/tl/2_types.d.ts +441 -58
- package/script/tl/2_types.js +1646 -158
- package/script/tl/3_functions.d.ts +113 -16
- package/script/tl/3_functions.js +386 -53
- package/script/transport/1_transport_abridged.d.ts +1 -2
- package/script/transport/1_transport_abridged.js +24 -19
- package/script/transport/1_transport_intermediate.d.ts +1 -2
- package/script/transport/1_transport_intermediate.js +23 -18
- package/script/types/0_color.d.ts +2 -1
- package/script/types/0_color.js +24 -3
- package/script/types/0_message_entity.d.ts +1 -1
- package/script/types/1_chat.js +4 -4
- package/script/types/1_user.js +1 -1
- package/script/types/3_message.js +1 -1
- package/script/utilities/0_base64.js +2 -2
- package/script/utilities/0_queue.d.ts +2 -4
- package/script/utilities/0_queue.js +39 -36
|
@@ -1,29 +1,33 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _TransportAbridged_connection, _TransportAbridged_obfuscated;
|
|
1
13
|
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
14
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
15
|
import { Transport } from "./0_transport.js";
|
|
4
16
|
export class TransportAbridged extends Transport {
|
|
5
17
|
constructor(connection, obfuscated = false) {
|
|
6
18
|
super();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value: connection
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "obfuscated", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: obfuscated
|
|
18
|
-
});
|
|
19
|
+
_TransportAbridged_connection.set(this, void 0);
|
|
20
|
+
_TransportAbridged_obfuscated.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _TransportAbridged_connection, connection, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _TransportAbridged_obfuscated, obfuscated, "f");
|
|
19
23
|
}
|
|
20
24
|
async initialize() {
|
|
21
25
|
if (!this.initialized) {
|
|
22
|
-
if (this
|
|
23
|
-
this.obfuscationParameters = await getObfuscationParameters(0xEFEFEFEF, this
|
|
26
|
+
if (__classPrivateFieldGet(this, _TransportAbridged_obfuscated, "f")) {
|
|
27
|
+
this.obfuscationParameters = await getObfuscationParameters(0xEFEFEFEF, __classPrivateFieldGet(this, _TransportAbridged_connection, "f"));
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
|
-
await this.
|
|
30
|
+
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(new Uint8Array([0xEF]));
|
|
27
31
|
}
|
|
28
32
|
this.initialized = true;
|
|
29
33
|
}
|
|
@@ -35,14 +39,14 @@ export class TransportAbridged extends Transport {
|
|
|
35
39
|
let length;
|
|
36
40
|
{
|
|
37
41
|
const buffer = new Uint8Array(1);
|
|
38
|
-
await this.
|
|
42
|
+
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").read(buffer);
|
|
39
43
|
this.decrypt(buffer);
|
|
40
44
|
if (buffer[0] < 0x7F) {
|
|
41
45
|
length = buffer[0];
|
|
42
46
|
}
|
|
43
47
|
else {
|
|
44
48
|
const buffer = new Uint8Array(3);
|
|
45
|
-
await this.
|
|
49
|
+
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").read(buffer);
|
|
46
50
|
this.decrypt(buffer);
|
|
47
51
|
const dataView = new DataView(buffer.buffer);
|
|
48
52
|
length = dataView.getUint16(0, true);
|
|
@@ -50,7 +54,7 @@ export class TransportAbridged extends Transport {
|
|
|
50
54
|
}
|
|
51
55
|
length *= 4;
|
|
52
56
|
const buffer = new Uint8Array(length);
|
|
53
|
-
await this.
|
|
57
|
+
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").read(buffer);
|
|
54
58
|
this.decrypt(buffer);
|
|
55
59
|
return buffer;
|
|
56
60
|
}
|
|
@@ -63,9 +67,10 @@ export class TransportAbridged extends Transport {
|
|
|
63
67
|
const length = bufferLength >= 0x7F ? bufferFromBigInt(bufferLength, 3) : new Uint8Array();
|
|
64
68
|
const data = concat(header, length, buffer);
|
|
65
69
|
this.encrypt(data);
|
|
66
|
-
await this.
|
|
70
|
+
await __classPrivateFieldGet(this, _TransportAbridged_connection, "f").write(data);
|
|
67
71
|
}
|
|
68
72
|
deinitialize() {
|
|
69
73
|
this.initialized = false;
|
|
70
74
|
}
|
|
71
75
|
}
|
|
76
|
+
_TransportAbridged_connection = new WeakMap(), _TransportAbridged_obfuscated = new WeakMap();
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Connection } from "../2_connection.js";
|
|
2
2
|
import { Transport } from "./0_transport.js";
|
|
3
3
|
export declare class TransportIntermediate extends Transport implements Transport {
|
|
4
|
-
private
|
|
5
|
-
private readonly obfuscated;
|
|
4
|
+
#private;
|
|
6
5
|
constructor(connection: Connection, obfuscated?: boolean);
|
|
7
6
|
initialize(): Promise<void>;
|
|
8
7
|
receive(): Promise<Uint8Array>;
|
|
@@ -1,29 +1,33 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _TransportIntermediate_connection, _TransportIntermediate_obfuscated;
|
|
1
13
|
import { bufferFromBigInt, concat } from "../1_utilities.js";
|
|
2
14
|
import { getObfuscationParameters } from "./0_obfuscation.js";
|
|
3
15
|
import { Transport } from "./0_transport.js";
|
|
4
16
|
export class TransportIntermediate extends Transport {
|
|
5
17
|
constructor(connection, obfuscated = false) {
|
|
6
18
|
super();
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
value: connection
|
|
12
|
-
});
|
|
13
|
-
Object.defineProperty(this, "obfuscated", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
configurable: true,
|
|
16
|
-
writable: true,
|
|
17
|
-
value: obfuscated
|
|
18
|
-
});
|
|
19
|
+
_TransportIntermediate_connection.set(this, void 0);
|
|
20
|
+
_TransportIntermediate_obfuscated.set(this, void 0);
|
|
21
|
+
__classPrivateFieldSet(this, _TransportIntermediate_connection, connection, "f");
|
|
22
|
+
__classPrivateFieldSet(this, _TransportIntermediate_obfuscated, obfuscated, "f");
|
|
19
23
|
}
|
|
20
24
|
async initialize() {
|
|
21
25
|
if (!this.initialized) {
|
|
22
|
-
if (this
|
|
23
|
-
this.obfuscationParameters = await getObfuscationParameters(0xEEEEEEEE, this
|
|
26
|
+
if (__classPrivateFieldGet(this, _TransportIntermediate_obfuscated, "f")) {
|
|
27
|
+
this.obfuscationParameters = await getObfuscationParameters(0xEEEEEEEE, __classPrivateFieldGet(this, _TransportIntermediate_connection, "f"));
|
|
24
28
|
}
|
|
25
29
|
else {
|
|
26
|
-
await this.
|
|
30
|
+
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(new Uint8Array([0xEE, 0xEE, 0xEE, 0xEE]));
|
|
27
31
|
}
|
|
28
32
|
this.initialized = true;
|
|
29
33
|
}
|
|
@@ -35,13 +39,13 @@ export class TransportIntermediate extends Transport {
|
|
|
35
39
|
let length;
|
|
36
40
|
{
|
|
37
41
|
const buffer = new Uint8Array(4);
|
|
38
|
-
await this.
|
|
42
|
+
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").read(buffer);
|
|
39
43
|
this.decrypt(buffer);
|
|
40
44
|
const dataView = new DataView(buffer.buffer);
|
|
41
45
|
length = dataView.getUint32(0, true);
|
|
42
46
|
}
|
|
43
47
|
const buffer = new Uint8Array(length);
|
|
44
|
-
await this.
|
|
48
|
+
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").read(buffer);
|
|
45
49
|
this.decrypt(buffer);
|
|
46
50
|
return buffer;
|
|
47
51
|
}
|
|
@@ -52,9 +56,10 @@ export class TransportIntermediate extends Transport {
|
|
|
52
56
|
const length = bufferFromBigInt(buffer.length, 4);
|
|
53
57
|
const data = concat(length, buffer);
|
|
54
58
|
this.encrypt(data);
|
|
55
|
-
await this.
|
|
59
|
+
await __classPrivateFieldGet(this, _TransportIntermediate_connection, "f").write(data);
|
|
56
60
|
}
|
|
57
61
|
deinitialize() {
|
|
58
62
|
this.initialized = false;
|
|
59
63
|
}
|
|
60
64
|
}
|
|
65
|
+
_TransportIntermediate_connection = new WeakMap(), _TransportIntermediate_obfuscated = new WeakMap();
|
package/esm/types/0_color.d.ts
CHANGED
package/esm/types/0_color.js
CHANGED
|
@@ -7,10 +7,30 @@ const colors = [
|
|
|
7
7
|
"blue",
|
|
8
8
|
"pink",
|
|
9
9
|
];
|
|
10
|
-
export function
|
|
10
|
+
export function getColorFromPeerId(id) {
|
|
11
11
|
id = Number(String(id).replaceAll("-100", "-"));
|
|
12
12
|
if (id < 0) {
|
|
13
13
|
id = -id;
|
|
14
14
|
}
|
|
15
15
|
return colors[id % 7];
|
|
16
16
|
}
|
|
17
|
+
export function getColorFromColorId(id) {
|
|
18
|
+
switch (id) {
|
|
19
|
+
case 0:
|
|
20
|
+
return "red";
|
|
21
|
+
case 1:
|
|
22
|
+
return "orange";
|
|
23
|
+
case 2:
|
|
24
|
+
return "violet";
|
|
25
|
+
case 3:
|
|
26
|
+
return "green";
|
|
27
|
+
case 4:
|
|
28
|
+
return "cyan";
|
|
29
|
+
case 5:
|
|
30
|
+
return "blue";
|
|
31
|
+
case 6:
|
|
32
|
+
return "pink";
|
|
33
|
+
default:
|
|
34
|
+
return "blue";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -77,4 +77,4 @@ export declare namespace MessageEntity {
|
|
|
77
77
|
/** A single entity of a message's text or caption. */
|
|
78
78
|
export type MessageEntity = MessageEntity.Mention | MessageEntity.Hashtag | MessageEntity.BotCommand | MessageEntity.URL | MessageEntity.EmailAddress | MessageEntity.Bold | MessageEntity.Italic | MessageEntity.Code | MessageEntity.Pre | MessageEntity.TextLink | MessageEntity.TextMention | MessageEntity.Cashtag | MessageEntity.PhoneNumber | MessageEntity.Underline | MessageEntity.Strikethrough | MessageEntity.Blockquote | MessageEntity.BankCard | MessageEntity.Spoiler | MessageEntity.CustomEmoji;
|
|
79
79
|
export declare function constructMessageEntity(obj: types.TypeMessageEntity): MessageEntity | null;
|
|
80
|
-
export declare function messageEntityToTlObject(entity: MessageEntity): types.MessageEntityMention | types.MessageEntityHashtag | types.MessageEntityBotCommand | types.MessageEntityURL | types.MessageEntityEmail | types.MessageEntityBold | types.MessageEntityItalic | types.MessageEntityCode | types.MessageEntityPre | types.MessageEntityTextURL | types.MessageEntityMentionName | types.MessageEntityPhone | types.MessageEntityCashtag | types.MessageEntityUnderline | types.MessageEntityStrike | types.
|
|
80
|
+
export declare function messageEntityToTlObject(entity: MessageEntity): types.MessageEntityMention | types.MessageEntityHashtag | types.MessageEntityBotCommand | types.MessageEntityURL | types.MessageEntityEmail | types.MessageEntityBold | types.MessageEntityItalic | types.MessageEntityCode | types.MessageEntityPre | types.MessageEntityTextURL | types.MessageEntityMentionName | types.MessageEntityPhone | types.MessageEntityCashtag | types.MessageEntityUnderline | types.MessageEntityStrike | types.MessageEntityBankCard | types.MessageEntitySpoiler | types.MessageEntityCustomEmoji | types.MessageEntityBlockquote;
|
package/esm/types/1_chat.js
CHANGED
|
@@ -2,7 +2,7 @@ import { cleanObject, UNREACHABLE } from "../1_utilities.js";
|
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { ZERO_CHANNEL_ID } from "../4_constants.js";
|
|
4
4
|
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
5
|
-
import {
|
|
5
|
+
import { getColorFromColorId, getColorFromPeerId } from "./0_color.js";
|
|
6
6
|
import { constructRestrictionReason } from "./0_restriction_reason.js";
|
|
7
7
|
export function constructChat(chat) {
|
|
8
8
|
if (chat instanceof types.User) {
|
|
@@ -11,7 +11,7 @@ export function constructChat(chat) {
|
|
|
11
11
|
type: "private",
|
|
12
12
|
isBot: chat.bot || false,
|
|
13
13
|
id,
|
|
14
|
-
color:
|
|
14
|
+
color: chat.color !== undefined ? getColorFromColorId(chat.color) : getColorFromPeerId(id),
|
|
15
15
|
firstName: chat.firstName || "",
|
|
16
16
|
lastName: chat.lastName,
|
|
17
17
|
isScam: chat.scam || false,
|
|
@@ -33,7 +33,7 @@ export function constructChat(chat) {
|
|
|
33
33
|
const chat_ = {
|
|
34
34
|
type: "group",
|
|
35
35
|
id,
|
|
36
|
-
color:
|
|
36
|
+
color: getColorFromPeerId(id),
|
|
37
37
|
title: chat.title,
|
|
38
38
|
isCreator: chat.creator || false,
|
|
39
39
|
};
|
|
@@ -49,7 +49,7 @@ export function constructChat(chat) {
|
|
|
49
49
|
if (chat.megagroup) {
|
|
50
50
|
chat_ = {
|
|
51
51
|
id,
|
|
52
|
-
color:
|
|
52
|
+
color: chat.color !== undefined ? getColorFromColorId(chat.color) : getColorFromPeerId(id),
|
|
53
53
|
type: "supergroup",
|
|
54
54
|
title,
|
|
55
55
|
isScam,
|
|
@@ -63,7 +63,7 @@ export function constructChat(chat) {
|
|
|
63
63
|
const id = ZERO_CHANNEL_ID + -Number(chat.id);
|
|
64
64
|
chat_ = {
|
|
65
65
|
id,
|
|
66
|
-
color:
|
|
66
|
+
color: chat.color !== undefined ? getColorFromColorId(chat.color) : getColorFromPeerId(id),
|
|
67
67
|
type: "channel",
|
|
68
68
|
title,
|
|
69
69
|
isScam,
|
package/esm/types/1_user.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cleanObject } from "../1_utilities.js";
|
|
2
2
|
import { types } from "../2_tl.js";
|
|
3
3
|
import { constructChatPhoto } from "./0_chat_photo.js";
|
|
4
|
-
import {
|
|
4
|
+
import { getColorFromColorId, getColorFromPeerId } from "./0_color.js";
|
|
5
5
|
export function constructUser(user_) {
|
|
6
6
|
const id = Number(user_.id);
|
|
7
7
|
const user = {
|
|
8
8
|
id,
|
|
9
|
-
color:
|
|
9
|
+
color: user_.color !== undefined ? getColorFromColorId(user_.color) : getColorFromPeerId(id),
|
|
10
10
|
isBot: user_.bot || false,
|
|
11
11
|
firstName: user_.firstName || "",
|
|
12
12
|
lastName: user_.lastName,
|
package/esm/types/3_message.js
CHANGED
|
@@ -46,7 +46,7 @@ async function getSender(message_, getEntity) {
|
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
async function getReply(message_, chat, getMessage) {
|
|
49
|
-
if (getMessage && message_.replyTo instanceof types.MessageReplyHeader) {
|
|
49
|
+
if (getMessage && message_.replyTo instanceof types.MessageReplyHeader && message_.replyTo.replyToMsgId) {
|
|
50
50
|
let isTopicMessage = false;
|
|
51
51
|
if (message_.replyTo.forumTopic) {
|
|
52
52
|
isTopicMessage = true;
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { decodeBase64, encodeBase64 } from "../0_deps.js";
|
|
2
2
|
export function base64EncodeUrlSafe(data) {
|
|
3
|
-
return
|
|
3
|
+
return encodeBase64(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
|
|
4
4
|
}
|
|
5
5
|
export function base64DecodeUrlSafe(data) {
|
|
6
6
|
data = data.replaceAll("_", "/").replaceAll("-", "+");
|
|
7
7
|
if (data.length != 4) {
|
|
8
8
|
data += "=".repeat(4 - data.length % 4);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return decodeBase64(data);
|
|
11
11
|
}
|
package/esm/utilities/0_queue.js
CHANGED
|
@@ -1,50 +1,53 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Queue_instances, _Queue_d, _Queue_busy, _Queue_check;
|
|
1
13
|
import { debug } from "../0_deps.js";
|
|
2
14
|
export class Queue {
|
|
3
15
|
constructor(name) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
configurable: true,
|
|
7
|
-
writable: true,
|
|
8
|
-
value: void 0
|
|
9
|
-
});
|
|
16
|
+
_Queue_instances.add(this);
|
|
17
|
+
_Queue_d.set(this, void 0);
|
|
10
18
|
Object.defineProperty(this, "functions", {
|
|
11
19
|
enumerable: true,
|
|
12
20
|
configurable: true,
|
|
13
21
|
writable: true,
|
|
14
22
|
value: new Array()
|
|
15
23
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
configurable: true,
|
|
19
|
-
writable: true,
|
|
20
|
-
value: false
|
|
21
|
-
});
|
|
22
|
-
this.d = debug(`q/${name}`);
|
|
24
|
+
_Queue_busy.set(this, false);
|
|
25
|
+
__classPrivateFieldSet(this, _Queue_d, debug(`q/${name}`), "f");
|
|
23
26
|
}
|
|
24
27
|
add(fn) {
|
|
25
28
|
this.functions.push(fn);
|
|
26
|
-
this.
|
|
27
|
-
}
|
|
28
|
-
check() {
|
|
29
|
-
if (this.busy) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this.busy = true;
|
|
34
|
-
}
|
|
35
|
-
const fn = this.functions.shift();
|
|
36
|
-
if (fn !== undefined) {
|
|
37
|
-
fn()
|
|
38
|
-
.catch((err) => {
|
|
39
|
-
this.d("%o", "stack" in err ? err.stack : err);
|
|
40
|
-
})
|
|
41
|
-
.finally(() => {
|
|
42
|
-
this.busy = false;
|
|
43
|
-
this.check();
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
this.busy = false;
|
|
48
|
-
}
|
|
29
|
+
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_check).call(this);
|
|
49
30
|
}
|
|
50
31
|
}
|
|
32
|
+
_Queue_d = new WeakMap(), _Queue_busy = new WeakMap(), _Queue_instances = new WeakSet(), _Queue_check = function _Queue_check() {
|
|
33
|
+
if (__classPrivateFieldGet(this, _Queue_busy, "f")) {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
__classPrivateFieldSet(this, _Queue_busy, true, "f");
|
|
38
|
+
}
|
|
39
|
+
const fn = this.functions.shift();
|
|
40
|
+
if (fn !== undefined) {
|
|
41
|
+
fn()
|
|
42
|
+
.catch((err) => {
|
|
43
|
+
__classPrivateFieldGet(this, _Queue_d, "f").call(this, "%o", "stack" in err ? err.stack : err);
|
|
44
|
+
})
|
|
45
|
+
.finally(() => {
|
|
46
|
+
__classPrivateFieldSet(this, _Queue_busy, false, "f");
|
|
47
|
+
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_check).call(this);
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
__classPrivateFieldSet(this, _Queue_busy, false, "f");
|
|
52
|
+
}
|
|
53
|
+
};
|
package/package.json
CHANGED
package/script/0_deps.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export { Mutex, type MutexInterface } from "async-mutex";
|
|
|
5
5
|
export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
|
|
6
6
|
import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/main/mod.js";
|
|
7
7
|
export declare const debug: typeof debug_;
|
|
8
|
-
export {
|
|
8
|
+
export { decodeBase64, encodeBase64 } from "./deps/deno.land/std@0.204.0/encoding/base64.js";
|
package/script/0_deps.js
CHANGED
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.
|
|
17
|
+
exports.encodeBase64 = exports.decodeBase64 = exports.debug = exports.Parser = exports.Mutex = exports.gzip = exports.gunzip = exports.initTgCrypto = exports.ige256Encrypt = exports.ige256Decrypt = exports.factorize = exports.ctr256 = void 0;
|
|
18
18
|
__exportStar(require("./deps/deno.land/std@0.204.0/assert/mod.js"), exports);
|
|
19
19
|
var mod_js_1 = require("./deps/deno.land/x/tgcrypto@0.3.3/mod.js");
|
|
20
20
|
Object.defineProperty(exports, "ctr256", { enumerable: true, get: function () { return mod_js_1.ctr256; } });
|
|
@@ -33,5 +33,5 @@ const mod_js_3 = require("./deps/raw.githubusercontent.com/MTKruto/debug/main/mo
|
|
|
33
33
|
const debug = (v) => (0, mod_js_3.debug)(v);
|
|
34
34
|
exports.debug = debug;
|
|
35
35
|
var base64_js_1 = require("./deps/deno.land/std@0.204.0/encoding/base64.js");
|
|
36
|
-
Object.defineProperty(exports, "
|
|
37
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "decodeBase64", { enumerable: true, get: function () { return base64_js_1.decodeBase64; } });
|
|
37
|
+
Object.defineProperty(exports, "encodeBase64", { enumerable: true, get: function () { return base64_js_1.encodeBase64; } });
|
package/script/4_constants.d.ts
CHANGED
|
@@ -4,8 +4,8 @@ export type PublicKeys = readonly [bigint, [bigint, bigint]][];
|
|
|
4
4
|
export declare const PUBLIC_KEYS: PublicKeys;
|
|
5
5
|
export declare const VECTOR_CONSTRUCTOR = 481674261;
|
|
6
6
|
export declare const INITIAL_DC: DC;
|
|
7
|
-
export declare const LAYER =
|
|
8
|
-
export declare const APP_VERSION = "MTKruto 0.1.
|
|
7
|
+
export declare const LAYER = 166;
|
|
8
|
+
export declare const APP_VERSION = "MTKruto 0.1.109";
|
|
9
9
|
export declare const DEVICE_MODEL: string;
|
|
10
10
|
export declare const LANG_CODE: string;
|
|
11
11
|
export declare const LANG_PACK = "";
|
package/script/4_constants.js
CHANGED
|
@@ -78,9 +78,9 @@ exports.PUBLIC_KEYS = Object.freeze([
|
|
|
78
78
|
],
|
|
79
79
|
]);
|
|
80
80
|
exports.VECTOR_CONSTRUCTOR = 0x1CB5C415;
|
|
81
|
-
exports.INITIAL_DC = "2
|
|
82
|
-
exports.LAYER =
|
|
83
|
-
exports.APP_VERSION = "MTKruto 0.1.
|
|
81
|
+
exports.INITIAL_DC = "2";
|
|
82
|
+
exports.LAYER = 166;
|
|
83
|
+
exports.APP_VERSION = "MTKruto 0.1.109";
|
|
84
84
|
// @ts-ignore: lib
|
|
85
85
|
exports.DEVICE_MODEL = typeof dntShim.Deno === "undefined" ? typeof navigator === "undefined" ? typeof process === "undefined" ? "Unknown" : process.platform + "-" + process.arch : navigator.userAgent.split(" ")[0] : dntShim.Deno.build.os + "-" + dntShim.Deno.build.arch;
|
|
86
86
|
exports.LANG_CODE = typeof navigator === "undefined" ? "en" : navigator.language.split("-")[0];
|
package/script/5_client.d.ts
CHANGED
package/script/5_client.js
CHANGED
|
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./client/2_client_plain.js"), exports);
|
|
18
|
+
__exportStar(require("./client/3_types.js"), exports);
|
|
18
19
|
__exportStar(require("./client/4_client.js"), exports);
|
package/script/client/0_html.js
CHANGED
|
@@ -3,26 +3,27 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseHtml = void 0;
|
|
4
4
|
const _0_deps_js_1 = require("../0_deps.js");
|
|
5
5
|
function parseHtml(html) {
|
|
6
|
+
html = html.trim();
|
|
6
7
|
let text = "";
|
|
7
8
|
const entities = new Array();
|
|
8
|
-
const
|
|
9
|
+
const stack = new Array();
|
|
9
10
|
const parser = new _0_deps_js_1.Parser({
|
|
10
11
|
onopentag(name, attribs) {
|
|
11
12
|
switch (name) {
|
|
12
13
|
case "b":
|
|
13
14
|
case "strong":
|
|
14
|
-
|
|
15
|
+
stack.push({ type: "bold", offset: text.length, length: 0 });
|
|
15
16
|
break;
|
|
16
17
|
case "em":
|
|
17
18
|
case "i":
|
|
18
|
-
|
|
19
|
+
stack.push({ type: "italic", offset: text.length, length: 0 });
|
|
19
20
|
break;
|
|
20
21
|
case "code":
|
|
21
|
-
|
|
22
|
+
stack.push({ type: "code", offset: text.length, length: 0 });
|
|
22
23
|
break;
|
|
23
24
|
case "pre": {
|
|
24
25
|
const language = attribs.language ?? "";
|
|
25
|
-
|
|
26
|
+
stack.push({ type: "pre", offset: text.length, length: 0, language });
|
|
26
27
|
break;
|
|
27
28
|
}
|
|
28
29
|
case "a": {
|
|
@@ -30,16 +31,16 @@ function parseHtml(html) {
|
|
|
30
31
|
if (!url) {
|
|
31
32
|
throw new Error("Missing attribute href");
|
|
32
33
|
}
|
|
33
|
-
|
|
34
|
+
stack.push({ type: "textLink", offset: text.length, length: 0, url });
|
|
34
35
|
break;
|
|
35
36
|
}
|
|
36
37
|
case "ins":
|
|
37
38
|
case "u":
|
|
38
|
-
|
|
39
|
+
stack.push({ type: "underline", offset: text.length, length: 0 });
|
|
39
40
|
break;
|
|
40
41
|
case "del":
|
|
41
42
|
case "strike":
|
|
42
|
-
|
|
43
|
+
stack.push({ type: "strikethrough", offset: text.length, length: 0 });
|
|
43
44
|
break;
|
|
44
45
|
case "span":
|
|
45
46
|
if (attribs.class != "tg-spoiler") {
|
|
@@ -47,24 +48,29 @@ function parseHtml(html) {
|
|
|
47
48
|
}
|
|
48
49
|
// falls through
|
|
49
50
|
case "tg-spoiler":
|
|
50
|
-
|
|
51
|
+
stack.push({ type: "spoiler", offset: text.length, length: 0 });
|
|
51
52
|
break;
|
|
52
53
|
case "tg-emoji":
|
|
53
54
|
if (!attribs["emoji-id"]) {
|
|
54
55
|
throw new Error("Missing attribute emoji-id");
|
|
55
56
|
}
|
|
56
|
-
|
|
57
|
+
stack.push({ type: "spoiler", offset: text.length, length: 0 });
|
|
58
|
+
break;
|
|
59
|
+
case "blockquote":
|
|
60
|
+
stack.push({ type: "blockquote", offset: text.length, length: 0 });
|
|
57
61
|
}
|
|
58
62
|
},
|
|
59
63
|
ontext(data) {
|
|
64
|
+
if (!text.length) {
|
|
65
|
+
data = data.trimStart();
|
|
66
|
+
}
|
|
60
67
|
text += data;
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
lastItem.length += data.length;
|
|
68
|
+
for (const item of stack) {
|
|
69
|
+
item.length += data.length;
|
|
64
70
|
}
|
|
65
71
|
},
|
|
66
72
|
onclosetag() {
|
|
67
|
-
const lastItem =
|
|
73
|
+
const lastItem = stack.pop();
|
|
68
74
|
if (lastItem) {
|
|
69
75
|
entities.push(lastItem);
|
|
70
76
|
}
|
|
@@ -72,6 +78,12 @@ function parseHtml(html) {
|
|
|
72
78
|
});
|
|
73
79
|
parser.write(html);
|
|
74
80
|
parser.end();
|
|
81
|
+
text = text.trimEnd();
|
|
82
|
+
for (const entity of entities) {
|
|
83
|
+
while (text[entity.offset + (entity.length - 1)] === undefined) {
|
|
84
|
+
--entity.length;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
75
87
|
return [text, entities];
|
|
76
88
|
}
|
|
77
89
|
exports.parseHtml = parseHtml;
|
|
@@ -2,4 +2,4 @@ import { types } from "../2_tl.js";
|
|
|
2
2
|
export declare const resolve: () => Promise<void>;
|
|
3
3
|
export type With<T, K extends keyof T> = T & Required<Pick<T, K>>;
|
|
4
4
|
export declare function isPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateShortMessage | types.UpdateShortChatMessage | types.UpdateShortSentMessage | types.UpdateNewMessage | types.UpdateDeleteMessages | types.UpdateReadHistoryInbox | types.UpdateReadHistoryOutbox | types.UpdatePinnedChannelMessages | types.UpdatePinnedMessages | types.UpdateFolderPeers | types.UpdateChannelWebPage | types.UpdateEditMessage | types.UpdateReadMessagesContents | types.UpdateWebPage;
|
|
5
|
-
export declare function isChannelPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages
|
|
5
|
+
export declare function isChannelPtsUpdate(v: types.TypeUpdate | types.TypeUpdates): v is types.UpdateNewChannelMessage | types.UpdateEditChannelMessage | types.UpdateDeleteChannelMessages;
|
|
@@ -24,7 +24,6 @@ exports.isPtsUpdate = isPtsUpdate;
|
|
|
24
24
|
function isChannelPtsUpdate(v) {
|
|
25
25
|
return v instanceof _2_tl_js_1.types.UpdateNewChannelMessage ||
|
|
26
26
|
v instanceof _2_tl_js_1.types.UpdateEditChannelMessage ||
|
|
27
|
-
v instanceof _2_tl_js_1.types.UpdateDeleteChannelMessages
|
|
28
|
-
v instanceof _2_tl_js_1.types.UpdateReadChannelInbox;
|
|
27
|
+
v instanceof _2_tl_js_1.types.UpdateDeleteChannelMessages;
|
|
29
28
|
}
|
|
30
29
|
exports.isChannelPtsUpdate = isChannelPtsUpdate;
|
|
@@ -15,11 +15,11 @@ export interface ClientAbstractParams {
|
|
|
15
15
|
cdn?: boolean;
|
|
16
16
|
}
|
|
17
17
|
export declare abstract class ClientAbstract {
|
|
18
|
+
#private;
|
|
18
19
|
protected readonly initialDc: DC;
|
|
19
20
|
protected readonly transportProvider: TransportProvider;
|
|
20
21
|
protected readonly cdn: boolean;
|
|
21
22
|
protected transport?: ReturnType<TransportProvider>;
|
|
22
|
-
private dc?;
|
|
23
23
|
constructor(params?: ClientAbstractParams);
|
|
24
24
|
protected stateChangeHandler?: (connected: boolean) => void;
|
|
25
25
|
get dcId(): number;
|