@mtkruto/node 0.50.1 → 0.61.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/esm/2_tl.d.ts +4 -6
  2. package/esm/2_tl.d.ts.map +1 -1
  3. package/esm/2_tl.js +4 -6
  4. package/esm/3_types.d.ts +1 -0
  5. package/esm/3_types.d.ts.map +1 -1
  6. package/esm/3_types.js +1 -0
  7. package/esm/client/0_params.d.ts +12 -0
  8. package/esm/client/0_params.d.ts.map +1 -1
  9. package/esm/client/0_storage_operations.d.ts.map +1 -1
  10. package/esm/client/0_storage_operations.js +9 -9
  11. package/esm/client/1_client_encrypted.d.ts.map +1 -1
  12. package/esm/client/1_client_encrypted.js +173 -126
  13. package/esm/client/1_client_plain.d.ts.map +1 -1
  14. package/esm/client/1_client_plain.js +12 -8
  15. package/esm/client/3_message_manager.d.ts +1 -0
  16. package/esm/client/3_message_manager.d.ts.map +1 -1
  17. package/esm/client/3_message_manager.js +51 -50
  18. package/esm/client/4_forum_manager.d.ts +40 -0
  19. package/esm/client/4_forum_manager.d.ts.map +1 -0
  20. package/esm/client/4_forum_manager.js +134 -0
  21. package/esm/client/5_client.d.ts +67 -2
  22. package/esm/client/5_client.d.ts.map +1 -1
  23. package/esm/client/5_client.js +87 -2
  24. package/esm/tl/0_api.d.ts +1 -2
  25. package/esm/tl/0_api.d.ts.map +1 -1
  26. package/esm/tl/0_api.js +7345 -6639
  27. package/esm/tl/0_tl_raw_reader.d.ts +2 -0
  28. package/esm/tl/0_tl_raw_reader.d.ts.map +1 -1
  29. package/esm/tl/0_tl_raw_reader.js +10 -0
  30. package/esm/tl/1_utilities.d.ts +10 -1
  31. package/esm/tl/1_utilities.d.ts.map +1 -1
  32. package/esm/tl/1_utilities.js +25 -1
  33. package/esm/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
  34. package/esm/tl/2_message.d.ts.map +1 -0
  35. package/esm/tl/{5_message.js → 2_message.js} +16 -33
  36. package/esm/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
  37. package/esm/tl/2_tl_reader.d.ts.map +1 -0
  38. package/esm/tl/2_tl_reader.js +146 -0
  39. package/esm/tl/2_tl_reader_test.d.ts.map +1 -0
  40. package/{script/tl/4_tl_writer.d.ts → esm/tl/2_tl_writer.d.ts} +4 -3
  41. package/esm/tl/2_tl_writer.d.ts.map +1 -0
  42. package/esm/tl/2_tl_writer.js +209 -0
  43. package/esm/tl/2_tl_writer_test.d.ts.map +1 -0
  44. package/{script/tl/3_utilities.d.ts → esm/tl/2_utilities.d.ts} +1 -1
  45. package/esm/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
  46. package/esm/types/2_chosen_inline_result.d.ts.map +1 -1
  47. package/esm/types/2_chosen_inline_result.js +2 -2
  48. package/esm/types/4_message.d.ts +3 -3
  49. package/esm/types/4_message.d.ts.map +1 -1
  50. package/esm/types/4_message.js +16 -8
  51. package/esm/types/5_callback_query.d.ts.map +1 -1
  52. package/esm/types/5_callback_query.js +3 -3
  53. package/esm/{tl/4_rpc_result.d.ts → types/5_topic.d.ts} +14 -7
  54. package/esm/types/5_topic.d.ts.map +1 -0
  55. package/esm/types/5_topic.js +76 -0
  56. package/esm/utilities/0_misc.d.ts +0 -1
  57. package/esm/utilities/0_misc.d.ts.map +1 -1
  58. package/esm/utilities/0_misc.js +0 -1
  59. package/package.json +1 -1
  60. package/script/2_tl.d.ts +4 -6
  61. package/script/2_tl.d.ts.map +1 -1
  62. package/script/2_tl.js +4 -6
  63. package/script/3_types.d.ts +1 -0
  64. package/script/3_types.d.ts.map +1 -1
  65. package/script/3_types.js +1 -0
  66. package/script/client/0_params.d.ts +12 -0
  67. package/script/client/0_params.d.ts.map +1 -1
  68. package/script/client/0_storage_operations.d.ts.map +1 -1
  69. package/script/client/0_storage_operations.js +8 -8
  70. package/script/client/1_client_encrypted.d.ts.map +1 -1
  71. package/script/client/1_client_encrypted.js +171 -124
  72. package/script/client/1_client_plain.d.ts.map +1 -1
  73. package/script/client/1_client_plain.js +11 -7
  74. package/script/client/3_message_manager.d.ts +1 -0
  75. package/script/client/3_message_manager.d.ts.map +1 -1
  76. package/script/client/3_message_manager.js +51 -50
  77. package/script/client/4_forum_manager.d.ts +40 -0
  78. package/script/client/4_forum_manager.d.ts.map +1 -0
  79. package/script/client/4_forum_manager.js +138 -0
  80. package/script/client/5_client.d.ts +67 -2
  81. package/script/client/5_client.d.ts.map +1 -1
  82. package/script/client/5_client.js +87 -2
  83. package/script/tl/0_api.d.ts +1 -2
  84. package/script/tl/0_api.d.ts.map +1 -1
  85. package/script/tl/0_api.js +7346 -6640
  86. package/script/tl/0_tl_raw_reader.d.ts +2 -0
  87. package/script/tl/0_tl_raw_reader.d.ts.map +1 -1
  88. package/script/tl/0_tl_raw_reader.js +10 -0
  89. package/script/tl/1_utilities.d.ts +10 -1
  90. package/script/tl/1_utilities.d.ts.map +1 -1
  91. package/script/tl/1_utilities.js +29 -1
  92. package/script/tl/{5_message.d.ts → 2_message.d.ts} +5 -8
  93. package/script/tl/2_message.d.ts.map +1 -0
  94. package/script/tl/{5_message.js → 2_message.js} +17 -34
  95. package/script/tl/{3_tl_reader.d.ts → 2_tl_reader.d.ts} +4 -3
  96. package/script/tl/2_tl_reader.d.ts.map +1 -0
  97. package/script/tl/2_tl_reader.js +150 -0
  98. package/script/tl/2_tl_reader_test.d.ts.map +1 -0
  99. package/{esm/tl/4_tl_writer.d.ts → script/tl/2_tl_writer.d.ts} +4 -3
  100. package/script/tl/2_tl_writer.d.ts.map +1 -0
  101. package/script/tl/2_tl_writer.js +213 -0
  102. package/script/tl/2_tl_writer_test.d.ts.map +1 -0
  103. package/{esm/tl/3_utilities.d.ts → script/tl/2_utilities.d.ts} +1 -1
  104. package/script/tl/{3_utilities.d.ts.map → 2_utilities.d.ts.map} +1 -1
  105. package/script/types/2_chosen_inline_result.d.ts.map +1 -1
  106. package/script/types/2_chosen_inline_result.js +1 -1
  107. package/script/types/4_message.d.ts +3 -3
  108. package/script/types/4_message.d.ts.map +1 -1
  109. package/script/types/4_message.js +16 -8
  110. package/script/types/5_callback_query.d.ts.map +1 -1
  111. package/script/types/5_callback_query.js +2 -2
  112. package/script/types/5_topic.d.ts +34 -0
  113. package/script/types/5_topic.d.ts.map +1 -0
  114. package/script/types/5_topic.js +79 -0
  115. package/script/utilities/0_misc.d.ts +0 -1
  116. package/script/utilities/0_misc.d.ts.map +1 -1
  117. package/script/utilities/0_misc.js +1 -2
  118. package/esm/tl/2_deserialize.d.ts +0 -23
  119. package/esm/tl/2_deserialize.d.ts.map +0 -1
  120. package/esm/tl/2_deserialize.js +0 -98
  121. package/esm/tl/2_serialize.d.ts +0 -22
  122. package/esm/tl/2_serialize.d.ts.map +0 -1
  123. package/esm/tl/2_serialize.js +0 -163
  124. package/esm/tl/2_serialize_test.d.ts.map +0 -1
  125. package/esm/tl/3_deserialize_test.d.ts.map +0 -1
  126. package/esm/tl/3_tl_reader.d.ts.map +0 -1
  127. package/esm/tl/3_tl_reader.js +0 -49
  128. package/esm/tl/4_rpc_result.d.ts.map +0 -1
  129. package/esm/tl/4_rpc_result.js +0 -33
  130. package/esm/tl/4_tl_writer.d.ts.map +0 -1
  131. package/esm/tl/4_tl_writer.js +0 -45
  132. package/esm/tl/5_message.d.ts.map +0 -1
  133. package/script/tl/2_deserialize.d.ts +0 -23
  134. package/script/tl/2_deserialize.d.ts.map +0 -1
  135. package/script/tl/2_deserialize.js +0 -101
  136. package/script/tl/2_serialize.d.ts +0 -22
  137. package/script/tl/2_serialize.d.ts.map +0 -1
  138. package/script/tl/2_serialize.js +0 -166
  139. package/script/tl/2_serialize_test.d.ts.map +0 -1
  140. package/script/tl/3_deserialize_test.d.ts.map +0 -1
  141. package/script/tl/3_tl_reader.d.ts.map +0 -1
  142. package/script/tl/3_tl_reader.js +0 -53
  143. package/script/tl/4_rpc_result.d.ts +0 -27
  144. package/script/tl/4_rpc_result.d.ts.map +0 -1
  145. package/script/tl/4_rpc_result.js +0 -37
  146. package/script/tl/4_tl_writer.d.ts.map +0 -1
  147. package/script/tl/4_tl_writer.js +0 -49
  148. package/script/tl/5_message.d.ts.map +0 -1
  149. /package/esm/tl/{3_utilities.js → 2_utilities.js} +0 -0
  150. /package/script/tl/{3_utilities.js → 2_utilities.js} +0 -0
@@ -1,163 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- // deno-lint-ignore-file no-explicit-any
21
- import { flags, getType } from "./0_api.js";
22
- import { TLRawWriter } from "./0_tl_raw_writer.js";
23
- import { analyzeOptionalParam, assertIsValidType, getOptionalParamInnerType, isOptionalParam } from "./1_utilities.js";
24
- function serializeSingleParam(writer, value, type, ntype, debugInfo) {
25
- if (isOptionalParam(ntype)) {
26
- ntype = getOptionalParamInnerType(ntype);
27
- }
28
- const valueRepr = value == null ? null : (typeof value === "object" && "_" in value) ? value._ : value.constructor.name;
29
- if (type == Uint8Array) {
30
- if ((value instanceof Uint8Array)) {
31
- writer.writeBytes(value);
32
- return writer.buffer;
33
- }
34
- else {
35
- throw new TypeError(`Expected Uint8Array but received ${valueRepr} ${debugInfo}`);
36
- }
37
- }
38
- switch (type) {
39
- case "bigint":
40
- if (typeof value === "bigint") {
41
- if (ntype == "int128") {
42
- writer.writeInt128(value);
43
- }
44
- else if (ntype === "int256") {
45
- writer.writeInt256(value);
46
- }
47
- else {
48
- writer.writeInt64(value);
49
- }
50
- }
51
- else {
52
- throw new TypeError(`Expected bigint but received ${valueRepr} ${debugInfo}`);
53
- }
54
- break;
55
- case "boolean":
56
- if (typeof value === "boolean") {
57
- if (value) {
58
- writer.writeInt32(0x997275B5);
59
- }
60
- else {
61
- writer.writeInt32(0xBC799737);
62
- }
63
- }
64
- else {
65
- throw new TypeError(`Expected boolean but received ${valueRepr} ${debugInfo}`);
66
- }
67
- break;
68
- case "number":
69
- //
70
- if (value == null) {
71
- value = 0;
72
- }
73
- //
74
- if (typeof value === "number") {
75
- if (ntype == "double") {
76
- writer.writeDouble(value);
77
- }
78
- else {
79
- writer.writeInt32(value);
80
- }
81
- }
82
- else {
83
- throw new TypeError(`Expected number but received ${valueRepr} ${debugInfo}`);
84
- }
85
- break;
86
- case "string":
87
- if (typeof value === "string") {
88
- writer.writeString(value);
89
- }
90
- else if (value instanceof Uint8Array) {
91
- writer.writeBytes(value);
92
- }
93
- else {
94
- writer.writeString("");
95
- }
96
- // else {
97
- // throw new TypeError(`Expected string or Uint8Array but received ${valueRepr}`);
98
- // }
99
- break;
100
- case "true":
101
- if (value !== true) {
102
- throw new TypeError(`Expected true but received ${valueRepr} ${debugInfo}`);
103
- }
104
- break;
105
- default:
106
- // null = !X (generic)
107
- if (type != null && typeof type !== "string") {
108
- throw new TypeError(`Unexpected type: ${type} ${debugInfo}`);
109
- }
110
- writer.write(serialize(value));
111
- }
112
- return writer.buffer;
113
- }
114
- export function serialize(type_) {
115
- assertIsValidType(type_);
116
- const maybeParameters = getType(type_._);
117
- if (!maybeParameters) {
118
- throw new Error(`Unknown type: ${type_._}`);
119
- }
120
- const type__ = type_;
121
- const writer = new TLRawWriter();
122
- const [id, parameters_] = maybeParameters;
123
- writer.writeInt32(id, false);
124
- for (const [i, [name, type, ntype]] of parameters_.entries()) {
125
- if (isOptionalParam(ntype) && type__[name] === undefined) {
126
- continue;
127
- }
128
- const debugInfo = `[0x${id.toString(16).toUpperCase()}::${i}]`;
129
- if (type == flags) {
130
- let flags = 0;
131
- const flagField_ = name;
132
- for (const [name, _, ntype] of parameters_) {
133
- if (isOptionalParam(ntype)) {
134
- const { flagField, bitIndex } = analyzeOptionalParam(ntype);
135
- if (flagField == flagField_) {
136
- if (type__[name] !== undefined) {
137
- flags |= 1 << bitIndex;
138
- }
139
- }
140
- }
141
- }
142
- writer.writeInt32(flags);
143
- continue;
144
- }
145
- if (type__[name] === undefined && !isOptionalParam(ntype)) {
146
- throw new Error(`Missing required parameter: ${name}`);
147
- }
148
- if (type instanceof Array) {
149
- const itemsType = type[0];
150
- if (!Array.isArray(type__[name])) {
151
- throw new TypeError("Expected array");
152
- }
153
- writer.writeInt32(0x1CB5C415); // vector constructor
154
- writer.writeInt32(type__[name].length);
155
- for (const item of type__[name]) {
156
- serializeSingleParam(writer, item, itemsType, ntype, debugInfo);
157
- }
158
- continue;
159
- }
160
- serializeSingleParam(writer, type__[name], type, ntype, debugInfo);
161
- }
162
- return writer.buffer;
163
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"2_serialize_test.d.ts","sourceRoot":"","sources":["../../src/tl/2_serialize_test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"3_deserialize_test.d.ts","sourceRoot":"","sources":["../../src/tl/3_deserialize_test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"3_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/3_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAW,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAwB,MAAM,YAAY,CAAC;AAG7D,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAEjE,qBAAa,QAAS,SAAQ,WAAW;IACvC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;CAsBpC"}
@@ -1,49 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- // deno-lint-ignore-file no-explicit-any
21
- import { TLError, TLRawReader } from "./0_tl_raw_reader.js";
22
- import { getType, getTypeName } from "./0_api.js";
23
- import { deserialize } from "./2_deserialize.js";
24
- export class TLReader extends TLRawReader {
25
- readObject(id) {
26
- if (!id) {
27
- id = this.readInt32(false);
28
- }
29
- if (id == 0x1CB5C415) {
30
- const count = this.readInt32();
31
- const items = new Array();
32
- for (let i = 0; i < count; i++) {
33
- items.push(this.readObject());
34
- }
35
- return items;
36
- }
37
- else if (id == 0x997275b5) {
38
- return true;
39
- }
40
- else if (id == 0xbc799737) {
41
- return false;
42
- }
43
- const constructor = getTypeName(id);
44
- if (constructor) {
45
- return deserialize(this, getType(constructor)[1], constructor);
46
- }
47
- throw new TLError(`Unknown constructor ${id.toString(16)}`);
48
- }
49
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"4_rpc_result.d.ts","sourceRoot":"","sources":["../../src/tl/4_rpc_result.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AASH,eAAO,MAAM,aAAa,aAAa,CAAC;AAExC,MAAM,WAAW,UAAU;IACzB,CAAC,EAAE,YAAY,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IAEnB,MAAM,EAAE,GAAG,CAAC;CACb;AAED,wBAAsB,oBAAoB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAQlF"}
@@ -1,33 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- import { gunzip } from "../1_utilities.js";
21
- import { is } from "./1_utilities.js";
22
- import { TLReader } from "./3_tl_reader.js";
23
- // rpc_result#f35c6d01 req_msg_id:long result:Object = RpcResult;
24
- export const RPC_RESULT_ID = 0xF35C6D01;
25
- export async function deserializeRpcResult(buffer) {
26
- const reader = new TLReader(buffer);
27
- const messageId = reader.readInt64();
28
- let result = reader.readObject();
29
- if (is("gzip_packed", result)) {
30
- result = new TLReader(await gunzip(result.packed_data)).readObject();
31
- }
32
- return { _: "rpc_result", req_msg_id: messageId, result };
33
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"4_tl_writer.d.ts","sourceRoot":"","sources":["../../src/tl/4_tl_writer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE9C,qBAAa,QAAS,SAAQ,WAAW;IACvC,WAAW,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,IAAI;CAkB7C"}
@@ -1,45 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- import { VECTOR_CONSTRUCTOR } from "../1_utilities.js";
21
- import { TLRawWriter } from "./0_tl_raw_writer.js";
22
- import { serialize } from "./2_serialize.js";
23
- export class TLWriter extends TLRawWriter {
24
- writeObject(object) {
25
- if (Array.isArray(object)) {
26
- this.writeInt32(VECTOR_CONSTRUCTOR, false);
27
- this.writeInt32(object.length);
28
- for (const item of object) {
29
- this.writeObject(item);
30
- }
31
- }
32
- else if (typeof object === "boolean") {
33
- if (object) {
34
- this.writeInt32(0x997275B5, false);
35
- }
36
- else {
37
- this.writeInt32(0xBC799737, false);
38
- }
39
- }
40
- else {
41
- this.write(serialize(object));
42
- }
43
- return this;
44
- }
45
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"5_message.d.ts","sourceRoot":"","sources":["../../src/tl/5_message.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAE,SAAS,EAAW,MAAM,YAAY,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAwB,UAAU,EAAiB,MAAM,mBAAmB,CAAC;AAKpF,eAAO,MAAM,YAAY,eAA6B,CAAC;AAIvD,MAAM,WAAW,OAAO;IACtB,CAAC,EAAE,SAAS,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,SAAS,GAAG,aAAa,GAAG,UAAU,CAAC;CAC9C;AAED,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,CAoB5E;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,CAoB3E;AAID,MAAM,WAAW,aAAa;IAC5B,CAAC,EAAE,eAAe,CAAC;IACnB,QAAQ,EAAE,OAAO,EAAE,CAAC;CACrB;AAED,eAAO,MAAM,gBAAgB,aAAa,CAAC;AAE3C,wBAAsB,qBAAqB,CAAC,YAAY,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,CAAC,CAQ5F;AAED,wBAAsB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,CAQxF"}
@@ -1,23 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- import { TLRawReader } from "./0_tl_raw_reader.js";
21
- import { AnyType } from "./0_api.js";
22
- export declare function deserialize(reader: TLRawReader, paramDesc: [string, unknown, string][], name: string): AnyType;
23
- //# sourceMappingURL=2_deserialize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"2_deserialize.d.ts","sourceRoot":"","sources":["../../src/tl/2_deserialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD,OAAO,EAAE,OAAO,EAA+B,MAAM,YAAY,CAAC;AAkDlE,wBAAgB,WAAW,CACzB,MAAM,EAAE,WAAW,EACnB,SAAS,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,EACtC,IAAI,EAAE,MAAM,GACX,OAAO,CAqCT"}
@@ -1,101 +0,0 @@
1
- "use strict";
2
- /**
3
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
4
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
5
- *
6
- * This file is part of MTKruto.
7
- *
8
- * This program is free software: you can redistribute it and/or modify
9
- * it under the terms of the GNU Lesser General Public License as published by
10
- * the Free Software Foundation, either version 3 of the License, or
11
- * (at your option) any later version.
12
- *
13
- * This program is distributed in the hope that it will be useful,
14
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
- * GNU Lesser General Public License for more details.
17
- *
18
- * You should have received a copy of the GNU Lesser General Public License
19
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
20
- */
21
- // deno-lint-ignore-file no-explicit-any
22
- Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.deserialize = deserialize;
24
- const _0_deps_js_1 = require("../0_deps.js");
25
- const _1_utilities_js_1 = require("./1_utilities.js");
26
- const _0_api_js_1 = require("./0_api.js");
27
- function deserializeSingleParam(reader, type, ntype) {
28
- if ((0, _1_utilities_js_1.isOptionalParam)(ntype)) {
29
- ntype = (0, _1_utilities_js_1.getOptionalParamInnerType)(ntype);
30
- }
31
- if (type == Uint8Array) {
32
- return reader.readBytes();
33
- }
34
- else {
35
- switch (type) {
36
- case "bigint":
37
- if (ntype == "int128") {
38
- return reader.readInt128();
39
- }
40
- else if (ntype === "int256") {
41
- return reader.readInt256();
42
- }
43
- else {
44
- return reader.readInt64();
45
- }
46
- case "boolean":
47
- return reader.readInt32(false) == 0x997275B5;
48
- case "number":
49
- if (ntype == "double") {
50
- return reader.readDouble();
51
- }
52
- else {
53
- return reader.readInt32();
54
- }
55
- case "string":
56
- return reader.readString();
57
- case "true":
58
- return true;
59
- default: {
60
- const cid = reader.readInt32(false);
61
- const name = (0, _0_api_js_1.getTypeName)(cid);
62
- if (!name) {
63
- throw new Error(`Constructor with ID 0x${cid.toString(16).toUpperCase()} not found`);
64
- }
65
- return deserialize(reader, (0, _0_api_js_1.getType)(name)[1], name);
66
- }
67
- }
68
- }
69
- }
70
- function deserialize(reader, paramDesc, name) {
71
- const type_ = { _: name };
72
- const flagFields = {};
73
- for (const [name, type, ntype] of paramDesc) {
74
- if ((0, _1_utilities_js_1.isOptionalParam)(ntype)) {
75
- const { flagField, bitIndex } = (0, _1_utilities_js_1.analyzeOptionalParam)(ntype);
76
- const bits = flagFields[flagField];
77
- if ((bits & (1 << bitIndex)) == 0) {
78
- continue;
79
- }
80
- }
81
- if (type == _0_api_js_1.flags && ntype == "#") {
82
- flagFields[name] = reader.readInt32();
83
- continue;
84
- }
85
- if (type instanceof Array) {
86
- (0, _0_deps_js_1.assertEquals)(reader.readInt32(false), 0x1CB5C415);
87
- const count = reader.readInt32();
88
- const items = new Array();
89
- for (let i = 0; i < count; i++) {
90
- items.push(deserializeSingleParam(reader, type[0], ntype));
91
- }
92
- type_[name] = items;
93
- continue;
94
- }
95
- const value = deserializeSingleParam(reader, type, ntype);
96
- if (typeof value !== "boolean" || value) {
97
- type_[name] = value;
98
- }
99
- }
100
- return type_;
101
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
3
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
4
- *
5
- * This file is part of MTKruto.
6
- *
7
- * This program is free software: you can redistribute it and/or modify
8
- * it under the terms of the GNU Lesser General Public License as published by
9
- * the Free Software Foundation, either version 3 of the License, or
10
- * (at your option) any later version.
11
- *
12
- * This program is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
- * GNU Lesser General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU Lesser General Public License
18
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
- */
20
- import { AnyObject } from "./0_api.js";
21
- export declare function serialize(type_: AnyObject): Uint8Array;
22
- //# sourceMappingURL=2_serialize.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"2_serialize.d.ts","sourceRoot":"","sources":["../../src/tl/2_serialize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAkB,MAAM,YAAY,CAAC;AA8FvD,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,UAAU,CA0DtD"}
@@ -1,166 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serialize = serialize;
4
- /**
5
- * MTKruto - Cross-runtime JavaScript library for building Telegram clients
6
- * Copyright (C) 2023-2025 Roj <https://roj.im/>
7
- *
8
- * This file is part of MTKruto.
9
- *
10
- * This program is free software: you can redistribute it and/or modify
11
- * it under the terms of the GNU Lesser General Public License as published by
12
- * the Free Software Foundation, either version 3 of the License, or
13
- * (at your option) any later version.
14
- *
15
- * This program is distributed in the hope that it will be useful,
16
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
- * GNU Lesser General Public License for more details.
19
- *
20
- * You should have received a copy of the GNU Lesser General Public License
21
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
- */
23
- // deno-lint-ignore-file no-explicit-any
24
- const _0_api_js_1 = require("./0_api.js");
25
- const _0_tl_raw_writer_js_1 = require("./0_tl_raw_writer.js");
26
- const _1_utilities_js_1 = require("./1_utilities.js");
27
- function serializeSingleParam(writer, value, type, ntype, debugInfo) {
28
- if ((0, _1_utilities_js_1.isOptionalParam)(ntype)) {
29
- ntype = (0, _1_utilities_js_1.getOptionalParamInnerType)(ntype);
30
- }
31
- const valueRepr = value == null ? null : (typeof value === "object" && "_" in value) ? value._ : value.constructor.name;
32
- if (type == Uint8Array) {
33
- if ((value instanceof Uint8Array)) {
34
- writer.writeBytes(value);
35
- return writer.buffer;
36
- }
37
- else {
38
- throw new TypeError(`Expected Uint8Array but received ${valueRepr} ${debugInfo}`);
39
- }
40
- }
41
- switch (type) {
42
- case "bigint":
43
- if (typeof value === "bigint") {
44
- if (ntype == "int128") {
45
- writer.writeInt128(value);
46
- }
47
- else if (ntype === "int256") {
48
- writer.writeInt256(value);
49
- }
50
- else {
51
- writer.writeInt64(value);
52
- }
53
- }
54
- else {
55
- throw new TypeError(`Expected bigint but received ${valueRepr} ${debugInfo}`);
56
- }
57
- break;
58
- case "boolean":
59
- if (typeof value === "boolean") {
60
- if (value) {
61
- writer.writeInt32(0x997275B5);
62
- }
63
- else {
64
- writer.writeInt32(0xBC799737);
65
- }
66
- }
67
- else {
68
- throw new TypeError(`Expected boolean but received ${valueRepr} ${debugInfo}`);
69
- }
70
- break;
71
- case "number":
72
- //
73
- if (value == null) {
74
- value = 0;
75
- }
76
- //
77
- if (typeof value === "number") {
78
- if (ntype == "double") {
79
- writer.writeDouble(value);
80
- }
81
- else {
82
- writer.writeInt32(value);
83
- }
84
- }
85
- else {
86
- throw new TypeError(`Expected number but received ${valueRepr} ${debugInfo}`);
87
- }
88
- break;
89
- case "string":
90
- if (typeof value === "string") {
91
- writer.writeString(value);
92
- }
93
- else if (value instanceof Uint8Array) {
94
- writer.writeBytes(value);
95
- }
96
- else {
97
- writer.writeString("");
98
- }
99
- // else {
100
- // throw new TypeError(`Expected string or Uint8Array but received ${valueRepr}`);
101
- // }
102
- break;
103
- case "true":
104
- if (value !== true) {
105
- throw new TypeError(`Expected true but received ${valueRepr} ${debugInfo}`);
106
- }
107
- break;
108
- default:
109
- // null = !X (generic)
110
- if (type != null && typeof type !== "string") {
111
- throw new TypeError(`Unexpected type: ${type} ${debugInfo}`);
112
- }
113
- writer.write(serialize(value));
114
- }
115
- return writer.buffer;
116
- }
117
- function serialize(type_) {
118
- (0, _1_utilities_js_1.assertIsValidType)(type_);
119
- const maybeParameters = (0, _0_api_js_1.getType)(type_._);
120
- if (!maybeParameters) {
121
- throw new Error(`Unknown type: ${type_._}`);
122
- }
123
- const type__ = type_;
124
- const writer = new _0_tl_raw_writer_js_1.TLRawWriter();
125
- const [id, parameters_] = maybeParameters;
126
- writer.writeInt32(id, false);
127
- for (const [i, [name, type, ntype]] of parameters_.entries()) {
128
- if ((0, _1_utilities_js_1.isOptionalParam)(ntype) && type__[name] === undefined) {
129
- continue;
130
- }
131
- const debugInfo = `[0x${id.toString(16).toUpperCase()}::${i}]`;
132
- if (type == _0_api_js_1.flags) {
133
- let flags = 0;
134
- const flagField_ = name;
135
- for (const [name, _, ntype] of parameters_) {
136
- if ((0, _1_utilities_js_1.isOptionalParam)(ntype)) {
137
- const { flagField, bitIndex } = (0, _1_utilities_js_1.analyzeOptionalParam)(ntype);
138
- if (flagField == flagField_) {
139
- if (type__[name] !== undefined) {
140
- flags |= 1 << bitIndex;
141
- }
142
- }
143
- }
144
- }
145
- writer.writeInt32(flags);
146
- continue;
147
- }
148
- if (type__[name] === undefined && !(0, _1_utilities_js_1.isOptionalParam)(ntype)) {
149
- throw new Error(`Missing required parameter: ${name}`);
150
- }
151
- if (type instanceof Array) {
152
- const itemsType = type[0];
153
- if (!Array.isArray(type__[name])) {
154
- throw new TypeError("Expected array");
155
- }
156
- writer.writeInt32(0x1CB5C415); // vector constructor
157
- writer.writeInt32(type__[name].length);
158
- for (const item of type__[name]) {
159
- serializeSingleParam(writer, item, itemsType, ntype, debugInfo);
160
- }
161
- continue;
162
- }
163
- serializeSingleParam(writer, type__[name], type, ntype, debugInfo);
164
- }
165
- return writer.buffer;
166
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"2_serialize_test.d.ts","sourceRoot":"","sources":["../../src/tl/2_serialize_test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"3_deserialize_test.d.ts","sourceRoot":"","sources":["../../src/tl/3_deserialize_test.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- {"version":3,"file":"3_tl_reader.d.ts","sourceRoot":"","sources":["../../src/tl/3_tl_reader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,EAAW,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAwB,MAAM,YAAY,CAAC;AAG7D,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;AAEjE,qBAAa,QAAS,SAAQ,WAAW;IACvC,UAAU,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;CAsBpC"}