@mtkruto/node 0.0.832 → 0.0.835

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 (127) hide show
  1. package/esm/client/client.d.ts +7 -2
  2. package/esm/client/client.js +66 -13
  3. package/esm/client/client_abstract.d.ts +2 -2
  4. package/esm/client/client_abstract.js +3 -8
  5. package/esm/client/client_plain.js +8 -7
  6. package/esm/connection/connection.d.ts +2 -1
  7. package/esm/connection/connection_web_socket.d.ts +1 -0
  8. package/esm/connection/connection_web_socket.js +3 -0
  9. package/esm/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
  10. package/esm/deps/deno.land/std@0.69.0/fmt/colors.js +224 -0
  11. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
  12. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +71 -0
  13. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
  14. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +112 -0
  15. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
  16. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +2 -0
  17. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
  18. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +39 -0
  19. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
  20. package/esm/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +1 -0
  21. package/esm/deps.d.ts +2 -0
  22. package/esm/deps.js +2 -0
  23. package/esm/storage/storage.d.ts +1 -1
  24. package/esm/storage/storage_local_storage.d.ts +1 -1
  25. package/esm/storage/storage_memory.d.ts +1 -1
  26. package/esm/storage/storage_session_storage.d.ts +1 -1
  27. package/esm/transport/transport.d.ts +1 -1
  28. package/esm/types/0_chat_administrator_rights.d.ts +17 -0
  29. package/esm/types/0_chat_administrator_rights.js +38 -0
  30. package/esm/types/0_chat_photo.d.ts +24 -0
  31. package/esm/types/0_chat_photo.js +28 -0
  32. package/esm/types/0_force_reply.d.ts +8 -0
  33. package/esm/types/0_force_reply.js +17 -0
  34. package/esm/types/0_keyboard_button_poll_type.d.ts +3 -0
  35. package/esm/types/0_login_url.d.ts +6 -0
  36. package/esm/types/0_login_url.js +1 -0
  37. package/esm/types/0_message_entity.d.ts +1 -1
  38. package/esm/types/0_message_entity.js +2 -2
  39. package/esm/types/0_reply_keyboard_remove.d.ts +7 -0
  40. package/esm/types/0_reply_keyboard_remove.js +8 -0
  41. package/esm/types/0_web_app_info.d.ts +4 -0
  42. package/esm/types/0_web_app_info.js +3 -0
  43. package/esm/types/1_chat.d.ts +60 -0
  44. package/esm/types/1_chat.js +70 -0
  45. package/esm/types/1_inline_keyboard_button.d.ts +33 -0
  46. package/esm/types/1_inline_keyboard_button.js +63 -0
  47. package/esm/types/1_keyboard_button.d.ts +43 -0
  48. package/esm/types/1_keyboard_button.js +133 -0
  49. package/esm/types/1_user.d.ts +19 -0
  50. package/esm/types/1_user.js +25 -0
  51. package/esm/types/2_inline_keyboard_markup.d.ts +7 -0
  52. package/esm/types/2_inline_keyboard_markup.js +25 -0
  53. package/esm/types/2_reply_keyboard_markup.d.ts +12 -0
  54. package/esm/types/2_reply_keyboard_markup.js +37 -0
  55. package/esm/types/3_message.d.ts +22 -0
  56. package/esm/types/3_message.js +87 -0
  57. package/esm/utilities/0_control.d.ts +1 -0
  58. package/esm/utilities/0_control.js +3 -0
  59. package/esm/utilities/0_object.d.ts +1 -0
  60. package/esm/utilities/0_object.js +14 -0
  61. package/esm/utilities/0_types.js +1 -0
  62. package/package.json +8 -6
  63. package/script/client/client.d.ts +7 -2
  64. package/script/client/client.js +65 -12
  65. package/script/client/client_abstract.d.ts +2 -2
  66. package/script/client/client_abstract.js +3 -8
  67. package/script/client/client_plain.js +7 -6
  68. package/script/connection/connection.d.ts +2 -1
  69. package/script/connection/connection_web_socket.d.ts +1 -0
  70. package/script/connection/connection_web_socket.js +3 -0
  71. package/script/deps/deno.land/std@0.69.0/fmt/colors.d.ts +77 -0
  72. package/script/deps/deno.land/std@0.69.0/fmt/colors.js +298 -0
  73. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.d.ts +3 -0
  74. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/colors.js +98 -0
  75. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.d.ts +22 -0
  76. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/debug.js +141 -0
  77. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.d.ts +2 -0
  78. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/deps.js +32 -0
  79. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.d.ts +1 -0
  80. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/format.js +43 -0
  81. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.d.ts +1 -0
  82. package/script/deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js +17 -0
  83. package/script/deps.d.ts +2 -0
  84. package/script/deps.js +4 -1
  85. package/script/storage/storage.d.ts +1 -1
  86. package/script/storage/storage_local_storage.d.ts +1 -1
  87. package/script/storage/storage_memory.d.ts +1 -1
  88. package/script/storage/storage_session_storage.d.ts +1 -1
  89. package/script/transport/transport.d.ts +1 -1
  90. package/script/types/0_chat_administrator_rights.d.ts +17 -0
  91. package/script/types/0_chat_administrator_rights.js +66 -0
  92. package/script/types/0_chat_photo.d.ts +24 -0
  93. package/script/types/0_chat_photo.js +55 -0
  94. package/script/types/0_force_reply.d.ts +8 -0
  95. package/script/types/0_force_reply.js +45 -0
  96. package/script/types/0_keyboard_button_poll_type.d.ts +3 -0
  97. package/script/types/0_login_url.d.ts +6 -0
  98. package/script/types/0_login_url.js +2 -0
  99. package/script/types/0_message_entity.d.ts +1 -1
  100. package/script/types/0_message_entity.js +2 -2
  101. package/script/types/0_reply_keyboard_remove.d.ts +7 -0
  102. package/script/types/0_reply_keyboard_remove.js +36 -0
  103. package/script/types/0_web_app_info.d.ts +4 -0
  104. package/script/types/0_web_app_info.js +7 -0
  105. package/script/types/1_chat.d.ts +60 -0
  106. package/script/types/1_chat.js +97 -0
  107. package/script/types/1_inline_keyboard_button.d.ts +33 -0
  108. package/script/types/1_inline_keyboard_button.js +91 -0
  109. package/script/types/1_keyboard_button.d.ts +43 -0
  110. package/script/types/1_keyboard_button.js +161 -0
  111. package/script/types/1_user.d.ts +19 -0
  112. package/script/types/1_user.js +52 -0
  113. package/script/types/2_inline_keyboard_markup.d.ts +7 -0
  114. package/script/types/2_inline_keyboard_markup.js +53 -0
  115. package/script/types/2_reply_keyboard_markup.d.ts +12 -0
  116. package/script/types/2_reply_keyboard_markup.js +65 -0
  117. package/script/types/3_message.d.ts +22 -0
  118. package/script/types/3_message.js +114 -0
  119. package/script/utilities/0_control.d.ts +1 -0
  120. package/script/utilities/0_control.js +7 -0
  121. package/script/utilities/0_object.d.ts +1 -0
  122. package/script/utilities/0_object.js +18 -0
  123. package/script/utilities/0_types.js +2 -0
  124. /package/esm/{types.js → types/0_keyboard_button_poll_type.js} +0 -0
  125. /package/esm/{types.d.ts → utilities/0_types.d.ts} +0 -0
  126. /package/script/{types.js → types/0_keyboard_button_poll_type.js} +0 -0
  127. /package/script/{types.d.ts → utilities/0_types.d.ts} +0 -0
@@ -0,0 +1,224 @@
1
+ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
2
+ /** A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
3
+ * on npm.
4
+ *
5
+ * ```
6
+ * import { bgBlue, red, bold } from "https://deno.land/std/fmt/colors.ts";
7
+ * console.log(bgBlue(red(bold("Hello world!"))));
8
+ * ```
9
+ *
10
+ * This module supports `NO_COLOR` environmental variable disabling any coloring
11
+ * if `NO_COLOR` is set.
12
+ *
13
+ * This module is browser compatible. */
14
+ import * as dntShim from "../../../../_dnt.shims.js";
15
+ const noColor = dntShim.dntGlobalThis.Deno?.noColor ?? true;
16
+ let enabled = !noColor;
17
+ export function setColorEnabled(value) {
18
+ if (noColor) {
19
+ return;
20
+ }
21
+ enabled = value;
22
+ }
23
+ export function getColorEnabled() {
24
+ return enabled;
25
+ }
26
+ function code(open, close) {
27
+ return {
28
+ open: `\x1b[${open.join(";")}m`,
29
+ close: `\x1b[${close}m`,
30
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
31
+ };
32
+ }
33
+ function run(str, code) {
34
+ return enabled
35
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
36
+ : str;
37
+ }
38
+ export function reset(str) {
39
+ return run(str, code([0], 0));
40
+ }
41
+ export function bold(str) {
42
+ return run(str, code([1], 22));
43
+ }
44
+ export function dim(str) {
45
+ return run(str, code([2], 22));
46
+ }
47
+ export function italic(str) {
48
+ return run(str, code([3], 23));
49
+ }
50
+ export function underline(str) {
51
+ return run(str, code([4], 24));
52
+ }
53
+ export function inverse(str) {
54
+ return run(str, code([7], 27));
55
+ }
56
+ export function hidden(str) {
57
+ return run(str, code([8], 28));
58
+ }
59
+ export function strikethrough(str) {
60
+ return run(str, code([9], 29));
61
+ }
62
+ export function black(str) {
63
+ return run(str, code([30], 39));
64
+ }
65
+ export function red(str) {
66
+ return run(str, code([31], 39));
67
+ }
68
+ export function green(str) {
69
+ return run(str, code([32], 39));
70
+ }
71
+ export function yellow(str) {
72
+ return run(str, code([33], 39));
73
+ }
74
+ export function blue(str) {
75
+ return run(str, code([34], 39));
76
+ }
77
+ export function magenta(str) {
78
+ return run(str, code([35], 39));
79
+ }
80
+ export function cyan(str) {
81
+ return run(str, code([36], 39));
82
+ }
83
+ export function white(str) {
84
+ return run(str, code([37], 39));
85
+ }
86
+ export function gray(str) {
87
+ return brightBlack(str);
88
+ }
89
+ export function brightBlack(str) {
90
+ return run(str, code([90], 39));
91
+ }
92
+ export function brightRed(str) {
93
+ return run(str, code([91], 39));
94
+ }
95
+ export function brightGreen(str) {
96
+ return run(str, code([92], 39));
97
+ }
98
+ export function brightYellow(str) {
99
+ return run(str, code([93], 39));
100
+ }
101
+ export function brightBlue(str) {
102
+ return run(str, code([94], 39));
103
+ }
104
+ export function brightMagenta(str) {
105
+ return run(str, code([95], 39));
106
+ }
107
+ export function brightCyan(str) {
108
+ return run(str, code([96], 39));
109
+ }
110
+ export function brightWhite(str) {
111
+ return run(str, code([97], 39));
112
+ }
113
+ export function bgBlack(str) {
114
+ return run(str, code([40], 49));
115
+ }
116
+ export function bgRed(str) {
117
+ return run(str, code([41], 49));
118
+ }
119
+ export function bgGreen(str) {
120
+ return run(str, code([42], 49));
121
+ }
122
+ export function bgYellow(str) {
123
+ return run(str, code([43], 49));
124
+ }
125
+ export function bgBlue(str) {
126
+ return run(str, code([44], 49));
127
+ }
128
+ export function bgMagenta(str) {
129
+ return run(str, code([45], 49));
130
+ }
131
+ export function bgCyan(str) {
132
+ return run(str, code([46], 49));
133
+ }
134
+ export function bgWhite(str) {
135
+ return run(str, code([47], 49));
136
+ }
137
+ export function bgBrightBlack(str) {
138
+ return run(str, code([100], 49));
139
+ }
140
+ export function bgBrightRed(str) {
141
+ return run(str, code([101], 49));
142
+ }
143
+ export function bgBrightGreen(str) {
144
+ return run(str, code([102], 49));
145
+ }
146
+ export function bgBrightYellow(str) {
147
+ return run(str, code([103], 49));
148
+ }
149
+ export function bgBrightBlue(str) {
150
+ return run(str, code([104], 49));
151
+ }
152
+ export function bgBrightMagenta(str) {
153
+ return run(str, code([105], 49));
154
+ }
155
+ export function bgBrightCyan(str) {
156
+ return run(str, code([106], 49));
157
+ }
158
+ export function bgBrightWhite(str) {
159
+ return run(str, code([107], 49));
160
+ }
161
+ /* Special Color Sequences */
162
+ function clampAndTruncate(n, max = 255, min = 0) {
163
+ return Math.trunc(Math.max(Math.min(n, max), min));
164
+ }
165
+ /** Set text color using paletted 8bit colors.
166
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */
167
+ export function rgb8(str, color) {
168
+ return run(str, code([38, 5, clampAndTruncate(color)], 39));
169
+ }
170
+ /** Set background color using paletted 8bit colors.
171
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit */
172
+ export function bgRgb8(str, color) {
173
+ return run(str, code([48, 5, clampAndTruncate(color)], 49));
174
+ }
175
+ /** Set text color using 24bit rgb.
176
+ * `color` can be a number in range `0x000000` to `0xffffff` or
177
+ * an `Rgb`.
178
+ *
179
+ * To produce the color magenta:
180
+ *
181
+ * rgba24("foo", 0xff00ff);
182
+ * rgba24("foo", {r: 255, g: 0, b: 255});
183
+ */
184
+ export function rgb24(str, color) {
185
+ if (typeof color === "number") {
186
+ return run(str, code([38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 39));
187
+ }
188
+ return run(str, code([
189
+ 38,
190
+ 2,
191
+ clampAndTruncate(color.r),
192
+ clampAndTruncate(color.g),
193
+ clampAndTruncate(color.b),
194
+ ], 39));
195
+ }
196
+ /** Set background color using 24bit rgb.
197
+ * `color` can be a number in range `0x000000` to `0xffffff` or
198
+ * an `Rgb`.
199
+ *
200
+ * To produce the color magenta:
201
+ *
202
+ * bgRgba24("foo", 0xff00ff);
203
+ * bgRgba24("foo", {r: 255, g: 0, b: 255});
204
+ */
205
+ export function bgRgb24(str, color) {
206
+ if (typeof color === "number") {
207
+ return run(str, code([48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff], 49));
208
+ }
209
+ return run(str, code([
210
+ 48,
211
+ 2,
212
+ clampAndTruncate(color.r),
213
+ clampAndTruncate(color.g),
214
+ clampAndTruncate(color.b),
215
+ ], 49));
216
+ }
217
+ // https://github.com/chalk/ansi-regex/blob/2b56fb0c7a07108e5b54241e8faec160d393aedb/index.js
218
+ const ANSI_PATTERN = new RegExp([
219
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:[a-zA-Z\\d]*(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
220
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))",
221
+ ].join("|"), "g");
222
+ export function stripColor(string) {
223
+ return string.replace(ANSI_PATTERN, "");
224
+ }
@@ -0,0 +1,3 @@
1
+ export type ColorFunction = (message: string) => string[];
2
+ export declare const colorFunctions: ColorFunction[];
3
+ export declare function generateColor(message: string): ColorFunction;
@@ -0,0 +1,71 @@
1
+ import * as dntShim from "../../../../../_dnt.shims.js";
2
+ import { colors } from "./deps.js";
3
+ // @ts-ignore: lib
4
+ const isBrowser = typeof dntShim.Deno === "undefined" &&
5
+ // @ts-ignore: lib
6
+ typeof process === "undefined" && typeof dntShim.dntGlobalThis !== "undefined" &&
7
+ // @ts-ignore: lib
8
+ typeof document !== "undefined";
9
+ export const colorFunctions = [
10
+ (v) => {
11
+ if (isBrowser) {
12
+ return [`%c${v}`, "color: red"];
13
+ }
14
+ else {
15
+ return [colors.red(v)];
16
+ }
17
+ },
18
+ (v) => {
19
+ if (isBrowser) {
20
+ return [`%c${v}`, "color: green"];
21
+ }
22
+ else {
23
+ return [colors.green(v)];
24
+ }
25
+ },
26
+ (v) => {
27
+ if (isBrowser) {
28
+ return [`%c${v}`, "color: yellow"];
29
+ }
30
+ else {
31
+ return [colors.yellow(v)];
32
+ }
33
+ },
34
+ (v) => {
35
+ if (isBrowser) {
36
+ return [`%c${v}`, "color: blue"];
37
+ }
38
+ else {
39
+ return [colors.blue(v)];
40
+ }
41
+ },
42
+ (v) => {
43
+ if (isBrowser) {
44
+ return [`%c${v}`, "color: magenta"];
45
+ }
46
+ else {
47
+ return [colors.magenta(v)];
48
+ }
49
+ },
50
+ (v) => {
51
+ if (isBrowser) {
52
+ return [`%c${v}`, "color: cyan"];
53
+ }
54
+ else {
55
+ return [colors.cyan(v)];
56
+ }
57
+ },
58
+ ];
59
+ function hashCode(s) {
60
+ let h = 0;
61
+ const l = s.length;
62
+ let i = 0;
63
+ if (l > 0)
64
+ while (i < l)
65
+ h = ((h << 5) - h + s.charCodeAt(i++)) | 0;
66
+ return h;
67
+ }
68
+ export function generateColor(message) {
69
+ const hash = Math.abs(hashCode(message));
70
+ return colorFunctions[hash % colorFunctions.length];
71
+ }
@@ -0,0 +1,22 @@
1
+ import { ColorFunction } from "./colors.js";
2
+ export interface Debug {
3
+ (fmt: string, ...args: unknown[]): void;
4
+ self: Debugger;
5
+ }
6
+ export declare class Debugger {
7
+ manager: DebugManager;
8
+ ns: string;
9
+ color: ColorFunction;
10
+ last: number;
11
+ enabled: boolean;
12
+ constructor(manager: DebugManager, namespace: string);
13
+ log(fmt: string, ...args: unknown[]): void;
14
+ }
15
+ declare class DebugManager {
16
+ debuggers: Map<string, Debugger>;
17
+ enabled: RegExp[];
18
+ constructor(enabled?: RegExp[]);
19
+ }
20
+ export declare function withoutEnv(enabled?: RegExp[] | string): void;
21
+ export declare function debug(namespace: string): Debug;
22
+ export {};
@@ -0,0 +1,112 @@
1
+ import * as dntShim from "../../../../../_dnt.shims.js";
2
+ import { generateColor } from "./colors.js";
3
+ import { format } from "./format.js";
4
+ export class Debugger {
5
+ constructor(manager, namespace) {
6
+ Object.defineProperty(this, "manager", {
7
+ enumerable: true,
8
+ configurable: true,
9
+ writable: true,
10
+ value: void 0
11
+ });
12
+ Object.defineProperty(this, "ns", {
13
+ enumerable: true,
14
+ configurable: true,
15
+ writable: true,
16
+ value: void 0
17
+ });
18
+ Object.defineProperty(this, "color", {
19
+ enumerable: true,
20
+ configurable: true,
21
+ writable: true,
22
+ value: void 0
23
+ });
24
+ Object.defineProperty(this, "last", {
25
+ enumerable: true,
26
+ configurable: true,
27
+ writable: true,
28
+ value: void 0
29
+ });
30
+ Object.defineProperty(this, "enabled", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ this.manager = manager;
37
+ this.ns = namespace;
38
+ this.color = generateColor(namespace);
39
+ this.last = 0;
40
+ this.enabled = manager.enabled.some((r) => r.test(namespace));
41
+ }
42
+ log(fmt, ...args) {
43
+ if (!this.enabled)
44
+ return;
45
+ const diff = Date.now() - (this.last || Date.now());
46
+ fmt = format(fmt, ...args);
47
+ console.debug(...this.color(this.ns), fmt, ...this.color(`+${diff}ms`));
48
+ this.last = Date.now();
49
+ }
50
+ }
51
+ class DebugManager {
52
+ constructor(enabled) {
53
+ Object.defineProperty(this, "debuggers", {
54
+ enumerable: true,
55
+ configurable: true,
56
+ writable: true,
57
+ value: void 0
58
+ });
59
+ Object.defineProperty(this, "enabled", {
60
+ enumerable: true,
61
+ configurable: true,
62
+ writable: true,
63
+ value: void 0
64
+ });
65
+ this.debuggers = new Map();
66
+ this.enabled = enabled ?? [];
67
+ }
68
+ }
69
+ function extract(opts) {
70
+ if (!opts || opts.length === 0)
71
+ return [];
72
+ opts = opts.replace(/\s/g, "").replace(/\*/g, ".+");
73
+ return opts.split(",").map((rule) => new RegExp(`^${rule}$`));
74
+ }
75
+ let manager;
76
+ export function withoutEnv(enabled) {
77
+ if (!enabled)
78
+ enabled = [];
79
+ if (typeof enabled === "string")
80
+ enabled = extract(enabled);
81
+ manager = new DebugManager(enabled);
82
+ }
83
+ // @ts-ignore: lib
84
+ const isDeno = typeof dntShim.Deno !== "undefined" &&
85
+ typeof dntShim.dntGlobalThis !== "undefined";
86
+ // @ts-ignore: lib
87
+ const isNode = typeof process !== "undefined" &&
88
+ typeof dntShim.dntGlobalThis === "undefined";
89
+ function getOpts() {
90
+ if (isDeno) {
91
+ // @ts-ignore: lib
92
+ return dntShim.Deno.env.get("DEBUG");
93
+ }
94
+ else if (isNode) {
95
+ // @ts-ignore: lib
96
+ return process.env.DEBUG;
97
+ }
98
+ else {
99
+ // @ts-ignore: lib
100
+ return globalThis.DEBUG;
101
+ }
102
+ }
103
+ export function debug(namespace) {
104
+ if (!manager)
105
+ manager = new DebugManager(extract(getOpts()));
106
+ const dbg = new Debugger(manager, namespace);
107
+ manager.debuggers.set(namespace, dbg);
108
+ const de = Object.assign(dbg.log.bind(dbg), {
109
+ self: dbg,
110
+ });
111
+ return de;
112
+ }
@@ -0,0 +1,2 @@
1
+ export * as colors from "../../../../deno.land/std@0.69.0/fmt/colors.js";
2
+ export { default as inspect } from "object-inspect";
@@ -0,0 +1,2 @@
1
+ export * as colors from "../../../../deno.land/std@0.69.0/fmt/colors.js";
2
+ export { default as inspect } from "object-inspect";
@@ -0,0 +1 @@
1
+ export declare function format(f: string, ...args: unknown[]): string;
@@ -0,0 +1,39 @@
1
+ import { inspect } from "./deps.js";
2
+ export function format(f, ...args) {
3
+ let i = 0;
4
+ const len = args.length;
5
+ let str = String(f).replace(/%[sdjoO%]/g, (x) => {
6
+ if (x === "%%")
7
+ return "%";
8
+ if (i >= len)
9
+ return x;
10
+ switch (x) {
11
+ case "%s":
12
+ return String(args[i++]);
13
+ case "%d":
14
+ return Number(args[i++]).toString();
15
+ case "%o":
16
+ return inspect(args[i++]).split("\n").map((_) => _.trim()).join(" ");
17
+ case "%O":
18
+ return inspect(args[i++]);
19
+ case "%j":
20
+ try {
21
+ return JSON.stringify(args[i++]);
22
+ }
23
+ catch {
24
+ return "[Circular]";
25
+ }
26
+ default:
27
+ return x;
28
+ }
29
+ });
30
+ for (const x of args.splice(i)) {
31
+ if (x === null || !(typeof x === "object" && x !== null)) {
32
+ str += " " + x;
33
+ }
34
+ else {
35
+ str += " " + inspect(x);
36
+ }
37
+ }
38
+ return str;
39
+ }
@@ -0,0 +1 @@
1
+ export * from "./debug.js";
@@ -0,0 +1 @@
1
+ export * from "./debug.js";
package/esm/deps.d.ts CHANGED
@@ -3,3 +3,5 @@ export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt,
3
3
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js";
4
4
  export { Mutex } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
6
+ import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js";
7
+ export declare const debug: typeof debug_;
package/esm/deps.js CHANGED
@@ -3,3 +3,5 @@ export { ctr256Decrypt, ctr256Encrypt, factorize, ige256Decrypt, ige256Encrypt,
3
3
  export { gunzip, gzip } from "./deps/raw.githubusercontent.com/MTKruto/compress/master/gzip/gzip.js";
4
4
  export { Mutex } from "async-mutex";
5
5
  export { Parser } from "./deps/deno.land/x/html_parser@v0.1.3/src/mod.js";
6
+ import { debug as debug_ } from "./deps/raw.githubusercontent.com/MTKruto/debug/master/mod.js";
7
+ export const debug = (v) => debug_(`mtkruto__${v}`);
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from "../types.js";
1
+ import { MaybePromise } from "../utilities/0_types.js";
2
2
  import { DC } from "../transport/transport_provider.js";
3
3
  export declare abstract class Storage {
4
4
  private _authKeyId;
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from "../types.js";
1
+ import { MaybePromise } from "../utilities/0_types.js";
2
2
  import { Storage } from "./storage.js";
3
3
  export declare class StorageLocalStorage extends Storage implements Storage {
4
4
  private readonly prefix;
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from "../types.js";
1
+ import { MaybePromise } from "../utilities/0_types.js";
2
2
  import { Storage } from "./storage.js";
3
3
  export declare class StorageMemory extends Storage implements Storage {
4
4
  protected map: Map<string, string>;
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from "../types.js";
1
+ import { MaybePromise } from "../utilities/0_types.js";
2
2
  import { Storage } from "./storage.js";
3
3
  export declare class StorageSessionStorage extends Storage implements Storage {
4
4
  private readonly prefix;
@@ -1,4 +1,4 @@
1
- import { MaybePromise } from "../types.js";
1
+ import { MaybePromise } from "../utilities/0_types.js";
2
2
  import { CTR } from "../utilities/0_crypto.js";
3
3
  export declare abstract class Transport {
4
4
  protected initialized: boolean;
@@ -0,0 +1,17 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface ChatAdministratorRights {
3
+ isAnonymous: boolean;
4
+ canManageChat: boolean;
5
+ canDeleteMessages: boolean;
6
+ canManageVideoChats: boolean;
7
+ canRestrictMembers: boolean;
8
+ canPromoteMembers: boolean;
9
+ canChangeInfo: boolean;
10
+ canInviteUsers: boolean;
11
+ canPostMessages?: boolean;
12
+ canEditMessages?: boolean;
13
+ canPinMessages?: boolean;
14
+ canManageTopics?: boolean;
15
+ }
16
+ export declare function constructChatAdministratorRights(rights_: types.ChatAdminRights): ChatAdministratorRights;
17
+ export declare function chatAdministratorRightsToTlObject(rights: ChatAdministratorRights): types.ChatAdminRights;
@@ -0,0 +1,38 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export function constructChatAdministratorRights(rights_) {
3
+ const rights = {
4
+ isAnonymous: rights_.anonymous || false,
5
+ canManageChat: rights_.other || false,
6
+ canDeleteMessages: rights_.deleteMessages || false,
7
+ canManageVideoChats: rights_.manageCall || false,
8
+ canRestrictMembers: rights_.banUsers || false,
9
+ canPromoteMembers: rights_.addAdmins || false,
10
+ canChangeInfo: rights_.changeInfo || false,
11
+ canInviteUsers: rights_.inviteUsers || false,
12
+ };
13
+ if (rights_.postMessages) {
14
+ rights.canPostMessages = rights_.postMessages;
15
+ }
16
+ if (rights_.editMessages) {
17
+ rights.canEditMessages = rights_.editMessages;
18
+ }
19
+ if (rights_.pinMessages) {
20
+ rights.canPinMessages = rights_.pinMessages;
21
+ }
22
+ if (rights_.manageTopics) {
23
+ rights.canManageTopics = rights_.manageTopics;
24
+ }
25
+ return rights;
26
+ }
27
+ export function chatAdministratorRightsToTlObject(rights) {
28
+ return new types.ChatAdminRights({
29
+ anonymous: rights.isAnonymous || undefined,
30
+ other: rights.canManageChat || undefined,
31
+ deleteMessages: rights.canDeleteMessages || undefined,
32
+ manageCall: rights.canManageChat || undefined,
33
+ banUsers: rights.canRestrictMembers || undefined,
34
+ addAdmins: rights.canPromoteMembers || undefined,
35
+ changeInfo: rights.canChangeInfo || undefined,
36
+ inviteUsers: rights.canInviteUsers || undefined,
37
+ });
38
+ }
@@ -0,0 +1,24 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export declare enum ChatPhotoType {
3
+ Chat = "chat",
4
+ User = "user"
5
+ }
6
+ export declare namespace ChatPhoto {
7
+ interface Base {
8
+ type: ChatPhotoType;
9
+ hasVideo: boolean;
10
+ photoId: bigint;
11
+ strippedThumb?: Uint8Array;
12
+ dcId: number;
13
+ }
14
+ interface User extends Base {
15
+ type: ChatPhotoType;
16
+ personal: boolean;
17
+ }
18
+ interface Chat extends Base {
19
+ type: ChatPhotoType;
20
+ }
21
+ }
22
+ export type ChatPhoto = ChatPhoto.User | ChatPhoto.Chat;
23
+ export declare function constructChatPhoto(photo: types.ChatPhoto): ChatPhoto.Chat;
24
+ export declare function constructChatPhoto(photo: types.UserProfilePhoto): ChatPhoto.User;
@@ -0,0 +1,28 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export var ChatPhotoType;
3
+ (function (ChatPhotoType) {
4
+ ChatPhotoType["Chat"] = "chat";
5
+ ChatPhotoType["User"] = "user";
6
+ })(ChatPhotoType || (ChatPhotoType = {}));
7
+ export function constructChatPhoto(photo) {
8
+ const { hasVideo = false, photoId, strippedThumb, dcId } = photo;
9
+ if (photo instanceof types.ChatPhoto) {
10
+ return {
11
+ type: ChatPhotoType.Chat,
12
+ hasVideo,
13
+ photoId,
14
+ strippedThumb,
15
+ dcId,
16
+ };
17
+ }
18
+ else {
19
+ return {
20
+ type: ChatPhotoType.User,
21
+ personal: photo.personal || false,
22
+ hasVideo,
23
+ photoId,
24
+ strippedThumb,
25
+ dcId,
26
+ };
27
+ }
28
+ }
@@ -0,0 +1,8 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export interface ForceReply {
3
+ forceReply: true;
4
+ inputFieldPlaceholder?: string;
5
+ selective?: boolean;
6
+ }
7
+ export declare function constructForceReply(replyMarkup_: types.ReplyKeyboardForceReply): ForceReply;
8
+ export declare function forceReplyToTlObject(replyMarkup: ForceReply): types.ReplyKeyboardForceReply;
@@ -0,0 +1,17 @@
1
+ import * as types from "../tl/2_types.js";
2
+ export function constructForceReply(replyMarkup_) {
3
+ const replyMarkup = { forceReply: true };
4
+ if (replyMarkup_.placeholder) {
5
+ replyMarkup.inputFieldPlaceholder = replyMarkup_.placeholder;
6
+ }
7
+ if (replyMarkup_.selective) {
8
+ replyMarkup.selective = true;
9
+ }
10
+ return replyMarkup;
11
+ }
12
+ export function forceReplyToTlObject(replyMarkup) {
13
+ return new types.ReplyKeyboardForceReply({
14
+ selective: replyMarkup.selective || undefined,
15
+ placeholder: replyMarkup.inputFieldPlaceholder,
16
+ });
17
+ }