@mtkruto/node 0.0.910 → 0.0.920

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 (41) hide show
  1. package/esm/client/1_client_abstract.d.ts +2 -1
  2. package/esm/client/1_client_abstract.js +9 -3
  3. package/esm/client/3_client.d.ts +4 -2
  4. package/esm/client/3_client.js +138 -76
  5. package/esm/constants.d.ts +1 -1
  6. package/esm/constants.js +1 -1
  7. package/esm/deps.d.ts +1 -2
  8. package/esm/deps.js +0 -1
  9. package/esm/types/!0_file_id.d.ts +6 -6
  10. package/esm/types/!0_file_id.js +11 -58
  11. package/esm/types/0_chat_photo.d.ts +1 -0
  12. package/esm/types/0_chat_photo.js +4 -2
  13. package/esm/types/3_message.js +0 -3
  14. package/esm/utilities/0_base64.d.ts +2 -0
  15. package/esm/utilities/0_base64.js +9 -0
  16. package/esm/utilities/0_rle.d.ts +2 -0
  17. package/esm/utilities/0_rle.js +49 -0
  18. package/esm/utilities/0_rle_test.d.ts +1 -0
  19. package/package.json +1 -1
  20. package/script/client/1_client_abstract.d.ts +2 -1
  21. package/script/client/1_client_abstract.js +9 -3
  22. package/script/client/3_client.d.ts +4 -2
  23. package/script/client/3_client.js +137 -75
  24. package/script/constants.d.ts +1 -1
  25. package/script/constants.js +1 -1
  26. package/script/deps.d.ts +1 -2
  27. package/script/deps.js +1 -3
  28. package/script/types/!0_file_id.d.ts +6 -6
  29. package/script/types/!0_file_id.js +11 -58
  30. package/script/types/0_chat_photo.d.ts +1 -0
  31. package/script/types/0_chat_photo.js +4 -2
  32. package/script/types/3_message.js +0 -3
  33. package/script/utilities/0_base64.d.ts +2 -0
  34. package/script/utilities/0_base64.js +14 -0
  35. package/script/utilities/0_rle.d.ts +2 -0
  36. package/script/utilities/0_rle.js +54 -0
  37. package/script/utilities/0_rle_test.d.ts +1 -0
  38. package/esm/deps/deno.land/x/q@v0.0.1/mod.d.ts +0 -6
  39. package/esm/deps/deno.land/x/q@v0.0.1/mod.js +0 -71
  40. package/script/deps/deno.land/x/q@v0.0.1/mod.d.ts +0 -6
  41. package/script/deps/deno.land/x/q@v0.0.1/mod.js +0 -75
@@ -30,7 +30,7 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
30
30
  const smallFileId = new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.ChatPhoto, photo.dcId, {
31
31
  mediaId: photo.photoId,
32
32
  thumbnailSource: _0_file_id_js_1.ThumbnailSource.ChatPhotoSmall,
33
- chatId: BigInt(chatId),
33
+ chatId,
34
34
  chatAccessHash,
35
35
  accessHash: 0n,
36
36
  volumeId: 0n,
@@ -40,7 +40,7 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
40
40
  const bigFileId = new _0_file_id_js_1.FileID(null, null, _0_file_id_js_1.FileType.ChatPhoto, photo.dcId, {
41
41
  mediaId: photo.photoId,
42
42
  thumbnailSource: _0_file_id_js_1.ThumbnailSource.ChatPhotoBig,
43
- chatId: BigInt(chatId),
43
+ chatId,
44
44
  chatAccessHash,
45
45
  accessHash: 0n,
46
46
  volumeId: 0n,
@@ -53,6 +53,7 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
53
53
  smallFileUniqueId,
54
54
  bigFileId,
55
55
  bigFileUniqueId,
56
+ hasVideo: photo.hasVideo || false,
56
57
  };
57
58
  }
58
59
  else {
@@ -62,6 +63,7 @@ function constructChatPhoto(photo, chatId, chatAccessHash) {
62
63
  smallFileUniqueId,
63
64
  bigFileId,
64
65
  bigFileUniqueId,
66
+ hasVideo: photo.hasVideo || false,
65
67
  };
66
68
  }
67
69
  }
@@ -99,9 +99,6 @@ async function constructMessage(message_, getEntity, getMessage) {
99
99
  (0, _0_control_js_1.UNREACHABLE)();
100
100
  }
101
101
  }
102
- else {
103
- (0, _0_control_js_1.UNREACHABLE)();
104
- }
105
102
  if (message_.message) {
106
103
  if (message_.media == undefined) {
107
104
  message.text = message_.message;
@@ -0,0 +1,2 @@
1
+ export declare function base64EncodeUrlSafe(data: ArrayBuffer | string): string;
2
+ export declare function base64DecodeUrlSafe(data: string): Uint8Array;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.base64DecodeUrlSafe = exports.base64EncodeUrlSafe = void 0;
4
+ const deps_js_1 = require("../deps.js");
5
+ // TODO: test
6
+ function base64EncodeUrlSafe(data) {
7
+ return (0, deps_js_1.base64Encode)(data).replace(/=*$/, "").replaceAll("+", "-").replaceAll("/", "_");
8
+ }
9
+ exports.base64EncodeUrlSafe = base64EncodeUrlSafe;
10
+ function base64DecodeUrlSafe(data) {
11
+ data = data.replaceAll("_", "/").replaceAll("-", "+");
12
+ return (0, deps_js_1.base64Decode)(data + "=".repeat(data.length % 4));
13
+ }
14
+ exports.base64DecodeUrlSafe = base64DecodeUrlSafe;
@@ -0,0 +1,2 @@
1
+ export declare function rleEncode(s: Uint8Array): Uint8Array;
2
+ export declare function rleDecode(s: Uint8Array): Uint8Array;
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.rleDecode = exports.rleEncode = void 0;
4
+ function rleEncode(s) {
5
+ const r = new Array();
6
+ let n = 0;
7
+ for (const b of s) {
8
+ if (!b) {
9
+ if (n == 255) {
10
+ r.push(0);
11
+ r.push(n);
12
+ n = 1;
13
+ }
14
+ else {
15
+ n++;
16
+ }
17
+ }
18
+ else {
19
+ if (n) {
20
+ r.push(0);
21
+ r.push(n);
22
+ n = 0;
23
+ }
24
+ r.push(b);
25
+ }
26
+ }
27
+ if (n) {
28
+ r.push(0);
29
+ r.push(n);
30
+ }
31
+ return new Uint8Array(r);
32
+ }
33
+ exports.rleEncode = rleEncode;
34
+ function rleDecode(s) {
35
+ const r = new Array();
36
+ let z = false;
37
+ for (const b of s) {
38
+ if (!b) {
39
+ z = true;
40
+ continue;
41
+ }
42
+ if (z) {
43
+ for (let i = 0; i < b; i++) {
44
+ r.push(0);
45
+ }
46
+ z = false;
47
+ }
48
+ else {
49
+ r.push(b);
50
+ }
51
+ }
52
+ return new Uint8Array(r);
53
+ }
54
+ exports.rleDecode = rleDecode;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +0,0 @@
1
- export declare function queue<T, R>(runner: (task: T) => R, concurrency: number): {
2
- push: (task: T | T[]) => void;
3
- drain: (fn?: any) => void | Promise<any>;
4
- onError: (fn: (task: T, error: Error) => any) => (task: T, error: Error) => any;
5
- onDone: (fn: (task: T, result: R) => any) => (task: T, result: R) => any;
6
- };
@@ -1,71 +0,0 @@
1
- export function queue(runner, concurrency) {
2
- if (concurrency <= 0) {
3
- throw new RangeError('concurrency can only be a positive integer');
4
- }
5
- if (!Number.isInteger(concurrency)) {
6
- throw new RangeError('concurrency can only be a positive integer');
7
- }
8
- const tasks = [];
9
- let running = 0;
10
- let drains = [];
11
- let onError = () => { };
12
- let onDone = () => { };
13
- let drainAwaiters = [];
14
- function drained() {
15
- drains.forEach((d) => d());
16
- drains = [];
17
- drainAwaiters.forEach((s) => s());
18
- drainAwaiters = [];
19
- }
20
- async function runNext() {
21
- if (running < concurrency && tasks.length > 0) {
22
- running++;
23
- const task = tasks.shift();
24
- if (task) {
25
- try {
26
- const result = await runner(task);
27
- onDone(task, result);
28
- }
29
- catch (err) {
30
- onError(task, err);
31
- }
32
- }
33
- running--;
34
- if (tasks.length > 0) {
35
- queueMicrotask(runNext); // to prevent "Maximum call stack size exceeded"
36
- }
37
- else if (running === 0) {
38
- drained();
39
- }
40
- }
41
- }
42
- return {
43
- push: (task) => {
44
- let needed = 1;
45
- if (Array.isArray(task)) {
46
- tasks.push(...task);
47
- needed = task.length;
48
- }
49
- else {
50
- tasks.push(task);
51
- }
52
- const free = concurrency - running;
53
- for (let i = 0; i < Math.max(free, needed); i++) {
54
- runNext();
55
- }
56
- },
57
- drain: (fn) => {
58
- if (fn) {
59
- drains.push(fn);
60
- }
61
- else if (tasks.length > 0 || running > 0) {
62
- return new Promise((resolve) => drainAwaiters.push(resolve));
63
- }
64
- else {
65
- return Promise.resolve();
66
- }
67
- },
68
- onError: (fn) => (onError = fn),
69
- onDone: (fn) => (onDone = fn),
70
- };
71
- }
@@ -1,6 +0,0 @@
1
- export declare function queue<T, R>(runner: (task: T) => R, concurrency: number): {
2
- push: (task: T | T[]) => void;
3
- drain: (fn?: any) => void | Promise<any>;
4
- onError: (fn: (task: T, error: Error) => any) => (task: T, error: Error) => any;
5
- onDone: (fn: (task: T, result: R) => any) => (task: T, result: R) => any;
6
- };
@@ -1,75 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queue = void 0;
4
- function queue(runner, concurrency) {
5
- if (concurrency <= 0) {
6
- throw new RangeError('concurrency can only be a positive integer');
7
- }
8
- if (!Number.isInteger(concurrency)) {
9
- throw new RangeError('concurrency can only be a positive integer');
10
- }
11
- const tasks = [];
12
- let running = 0;
13
- let drains = [];
14
- let onError = () => { };
15
- let onDone = () => { };
16
- let drainAwaiters = [];
17
- function drained() {
18
- drains.forEach((d) => d());
19
- drains = [];
20
- drainAwaiters.forEach((s) => s());
21
- drainAwaiters = [];
22
- }
23
- async function runNext() {
24
- if (running < concurrency && tasks.length > 0) {
25
- running++;
26
- const task = tasks.shift();
27
- if (task) {
28
- try {
29
- const result = await runner(task);
30
- onDone(task, result);
31
- }
32
- catch (err) {
33
- onError(task, err);
34
- }
35
- }
36
- running--;
37
- if (tasks.length > 0) {
38
- queueMicrotask(runNext); // to prevent "Maximum call stack size exceeded"
39
- }
40
- else if (running === 0) {
41
- drained();
42
- }
43
- }
44
- }
45
- return {
46
- push: (task) => {
47
- let needed = 1;
48
- if (Array.isArray(task)) {
49
- tasks.push(...task);
50
- needed = task.length;
51
- }
52
- else {
53
- tasks.push(task);
54
- }
55
- const free = concurrency - running;
56
- for (let i = 0; i < Math.max(free, needed); i++) {
57
- runNext();
58
- }
59
- },
60
- drain: (fn) => {
61
- if (fn) {
62
- drains.push(fn);
63
- }
64
- else if (tasks.length > 0 || running > 0) {
65
- return new Promise((resolve) => drainAwaiters.push(resolve));
66
- }
67
- else {
68
- return Promise.resolve();
69
- }
70
- },
71
- onError: (fn) => (onError = fn),
72
- onDone: (fn) => (onDone = fn),
73
- };
74
- }
75
- exports.queue = queue;