@mtcute/node 0.16.7 → 0.16.13
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/chunks/cjs/BpvQ752Q.js +33 -0
- package/chunks/cjs/D7i-4e0W.js +74 -0
- package/chunks/cjs/HP2yqAk_.js +79 -0
- package/chunks/cjs/package.json +3 -0
- package/chunks/es/CKso6cAV.js +75 -0
- package/chunks/es/CnOjjhdK.js +29 -0
- package/chunks/es/HZgHrOPU.js +69 -0
- package/{cjs/client.d.ts → client.d.ts} +3 -4
- package/{cjs/common-internals-node → common-internals-node}/platform.d.ts +1 -1
- package/index.cjs +449 -0
- package/index.d.ts +8 -1
- package/index.js +410 -1
- package/{cjs/methods → methods}/download-file.d.ts +1 -1
- package/{esm/methods → methods}/download-node-stream.d.ts +2 -2
- package/methods.cjs +17 -0
- package/methods.d.ts +3 -1
- package/methods.js +6 -1
- package/package.json +49 -33
- package/{esm/sqlite → sqlite}/driver.d.ts +2 -3
- package/{esm/sqlite → sqlite}/index.d.ts +1 -1
- package/sqlite/sqlite.test.d.ts +1 -0
- package/{cjs/utils → utils}/crypto.d.ts +1 -2
- package/utils/crypto.test.d.ts +1 -0
- package/{cjs/utils → utils}/normalize-file.d.ts +1 -1
- package/utils/stream-utils.test.d.ts +1 -0
- package/{cjs/utils → utils}/tcp.d.ts +4 -5
- package/utils/tcp.test.d.ts +1 -0
- package/utils.cjs +20 -0
- package/utils.d.ts +3 -1
- package/utils.js +9 -1
- package/{cjs/worker.d.ts → worker.d.ts} +1 -2
- package/cjs/client.js +0 -112
- package/cjs/client.js.map +0 -1
- package/cjs/common-internals-node/exit-hook.js +0 -45
- package/cjs/common-internals-node/exit-hook.js.map +0 -1
- package/cjs/common-internals-node/logging.js +0 -34
- package/cjs/common-internals-node/logging.js.map +0 -1
- package/cjs/common-internals-node/platform.js +0 -85
- package/cjs/common-internals-node/platform.js.map +0 -1
- package/cjs/index.js +0 -31
- package/cjs/index.js.map +0 -1
- package/cjs/methods/download-file.js +0 -33
- package/cjs/methods/download-file.js.map +0 -1
- package/cjs/methods/download-node-stream.d.ts +0 -8
- package/cjs/methods/download-node-stream.js +0 -14
- package/cjs/methods/download-node-stream.js.map +0 -1
- package/cjs/methods.js +0 -29
- package/cjs/methods.js.map +0 -1
- package/cjs/package.json +0 -3
- package/cjs/sqlite/driver.d.ts +0 -26
- package/cjs/sqlite/driver.js +0 -29
- package/cjs/sqlite/driver.js.map +0 -1
- package/cjs/sqlite/index.d.ts +0 -8
- package/cjs/sqlite/index.js +0 -18
- package/cjs/sqlite/index.js.map +0 -1
- package/cjs/utils/crypto.js +0 -71
- package/cjs/utils/crypto.js.map +0 -1
- package/cjs/utils/normalize-file.js +0 -30
- package/cjs/utils/normalize-file.js.map +0 -1
- package/cjs/utils/stream-utils.js +0 -76
- package/cjs/utils/stream-utils.js.map +0 -1
- package/cjs/utils/tcp.js +0 -126
- package/cjs/utils/tcp.js.map +0 -1
- package/cjs/utils/version.js +0 -21
- package/cjs/utils/version.js.map +0 -1
- package/cjs/utils.js +0 -26
- package/cjs/utils.js.map +0 -1
- package/cjs/worker.js +0 -48
- package/cjs/worker.js.map +0 -1
- package/esm/client.d.ts +0 -48
- package/esm/client.js +0 -107
- package/esm/client.js.map +0 -1
- package/esm/common-internals-node/exit-hook.d.ts +0 -1
- package/esm/common-internals-node/exit-hook.js +0 -42
- package/esm/common-internals-node/exit-hook.js.map +0 -1
- package/esm/common-internals-node/logging.d.ts +0 -2
- package/esm/common-internals-node/logging.js +0 -31
- package/esm/common-internals-node/logging.js.map +0 -1
- package/esm/common-internals-node/platform.d.ts +0 -18
- package/esm/common-internals-node/platform.js +0 -58
- package/esm/common-internals-node/platform.js.map +0 -1
- package/esm/index.d.ts +0 -8
- package/esm/index.js +0 -9
- package/esm/index.js.map +0 -1
- package/esm/methods/download-file.d.ts +0 -9
- package/esm/methods/download-file.js +0 -30
- package/esm/methods/download-file.js.map +0 -1
- package/esm/methods/download-node-stream.js +0 -11
- package/esm/methods/download-node-stream.js.map +0 -1
- package/esm/methods.d.ts +0 -3
- package/esm/methods.js +0 -4
- package/esm/methods.js.map +0 -1
- package/esm/sqlite/driver.js +0 -22
- package/esm/sqlite/driver.js.map +0 -1
- package/esm/sqlite/index.js +0 -13
- package/esm/sqlite/index.js.map +0 -1
- package/esm/utils/crypto.d.ts +0 -16
- package/esm/utils/crypto.js +0 -69
- package/esm/utils/crypto.js.map +0 -1
- package/esm/utils/normalize-file.d.ts +0 -6
- package/esm/utils/normalize-file.js +0 -27
- package/esm/utils/normalize-file.js.map +0 -1
- package/esm/utils/stream-utils.d.ts +0 -3
- package/esm/utils/stream-utils.js +0 -72
- package/esm/utils/stream-utils.js.map +0 -1
- package/esm/utils/tcp.d.ts +0 -30
- package/esm/utils/tcp.js +0 -118
- package/esm/utils/tcp.js.map +0 -1
- package/esm/utils/version.d.ts +0 -3
- package/esm/utils/version.js +0 -17
- package/esm/utils/version.js.map +0 -1
- package/esm/utils.d.ts +0 -3
- package/esm/utils.js +0 -4
- package/esm/utils.js.map +0 -1
- package/esm/worker.d.ts +0 -11
- package/esm/worker.js +0 -43
- package/esm/worker.js.map +0 -1
- /package/{cjs/common-internals-node → common-internals-node}/exit-hook.d.ts +0 -0
- /package/{cjs/common-internals-node → common-internals-node}/logging.d.ts +0 -0
- /package/{cjs/index.d.ts → index.d.cts} +0 -0
- /package/{cjs/methods.d.ts → methods.d.cts} +0 -0
- /package/{cjs/utils → utils}/stream-utils.d.ts +0 -0
- /package/{cjs/utils → utils}/version.d.ts +0 -0
- /package/{cjs/utils.d.ts → utils.d.cts} +0 -0
package/cjs/client.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TelegramClient = exports.BaseTelegramClient = void 0;
|
|
4
|
-
const node_readline_1 = require("node:readline");
|
|
5
|
-
const client_js_1 = require("@mtcute/core/client.js");
|
|
6
|
-
const platform_js_1 = require("@mtcute/core/platform.js");
|
|
7
|
-
const platform_js_2 = require("./common-internals-node/platform.js");
|
|
8
|
-
const download_file_js_1 = require("./methods/download-file.js");
|
|
9
|
-
const download_node_stream_js_1 = require("./methods/download-node-stream.js");
|
|
10
|
-
const index_js_1 = require("./sqlite/index.js");
|
|
11
|
-
const crypto_js_1 = require("./utils/crypto.js");
|
|
12
|
-
const tcp_js_1 = require("./utils/tcp.js");
|
|
13
|
-
let nativeCrypto;
|
|
14
|
-
try {
|
|
15
|
-
/* eslint-disable ts/ban-ts-comment,ts/no-unsafe-assignment */
|
|
16
|
-
// @ts-ignore not in deps
|
|
17
|
-
// @esm-replace-import
|
|
18
|
-
nativeCrypto = (require('@mtcute/crypto-node')).NodeNativeCryptoProvider;
|
|
19
|
-
/* eslint-enable ts/ban-ts-comment,ts/no-unsafe-assignment */
|
|
20
|
-
}
|
|
21
|
-
catch { }
|
|
22
|
-
class BaseTelegramClient extends client_js_1.BaseTelegramClient {
|
|
23
|
-
constructor(opts) {
|
|
24
|
-
if (!opts.platformless)
|
|
25
|
-
(0, platform_js_1.setPlatform)(new platform_js_2.NodePlatform());
|
|
26
|
-
super({
|
|
27
|
-
// eslint-disable-next-line
|
|
28
|
-
crypto: nativeCrypto ? new nativeCrypto() : new crypto_js_1.NodeCryptoProvider(),
|
|
29
|
-
transport: () => new tcp_js_1.TcpTransport(),
|
|
30
|
-
...opts,
|
|
31
|
-
storage: typeof opts.storage === 'string'
|
|
32
|
-
? new index_js_1.SqliteStorage(opts.storage)
|
|
33
|
-
: opts.storage ?? new index_js_1.SqliteStorage('client.session'),
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.BaseTelegramClient = BaseTelegramClient;
|
|
38
|
-
/**
|
|
39
|
-
* Telegram client for use in Node.js
|
|
40
|
-
*/
|
|
41
|
-
class TelegramClient extends client_js_1.TelegramClient {
|
|
42
|
-
constructor(opts) {
|
|
43
|
-
if ('client' in opts) {
|
|
44
|
-
super(opts);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
super({
|
|
48
|
-
client: new BaseTelegramClient(opts),
|
|
49
|
-
disableUpdates: opts.disableUpdates,
|
|
50
|
-
skipConversationUpdates: opts.skipConversationUpdates,
|
|
51
|
-
updates: opts.updates,
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
_rl;
|
|
55
|
-
/**
|
|
56
|
-
* Tiny wrapper over Node `readline` package
|
|
57
|
-
* for simpler user input for `.start()` method.
|
|
58
|
-
*
|
|
59
|
-
* Associated `readline` interface is closed
|
|
60
|
-
* after `start()` returns, or with the client.
|
|
61
|
-
*
|
|
62
|
-
* @param text Text of the question
|
|
63
|
-
*/
|
|
64
|
-
input(text) {
|
|
65
|
-
if (!this._rl) {
|
|
66
|
-
this._rl = (0, node_readline_1.createInterface)({
|
|
67
|
-
input: process.stdin,
|
|
68
|
-
output: process.stdout,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return new Promise(res => this._rl?.question(text, res));
|
|
72
|
-
}
|
|
73
|
-
close() {
|
|
74
|
-
this._rl?.close();
|
|
75
|
-
return super.close();
|
|
76
|
-
}
|
|
77
|
-
start(params = {}) {
|
|
78
|
-
if (!params.botToken) {
|
|
79
|
-
if (!params.phone)
|
|
80
|
-
params.phone = () => this.input('phone > ');
|
|
81
|
-
if (!params.code)
|
|
82
|
-
params.code = () => this.input('code > ');
|
|
83
|
-
if (!params.password) {
|
|
84
|
-
params.password = () => this.input('2fa password > ');
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return super.start(params).then((user) => {
|
|
88
|
-
if (this._rl) {
|
|
89
|
-
this._rl.close();
|
|
90
|
-
delete this._rl;
|
|
91
|
-
}
|
|
92
|
-
return user;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
run(params, then) {
|
|
96
|
-
if (typeof params === 'function') {
|
|
97
|
-
then = params;
|
|
98
|
-
params = {};
|
|
99
|
-
}
|
|
100
|
-
this.start(params)
|
|
101
|
-
.then(then)
|
|
102
|
-
.catch(err => this.emitError(err));
|
|
103
|
-
}
|
|
104
|
-
downloadToFile(filename, location, params) {
|
|
105
|
-
return (0, download_file_js_1.downloadToFile)(this, filename, location, params);
|
|
106
|
-
}
|
|
107
|
-
downloadAsNodeStream(location, params) {
|
|
108
|
-
return (0, download_node_stream_js_1.downloadAsNodeStream)(this, location, params);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
exports.TelegramClient = TelegramClient;
|
|
112
|
-
//# sourceMappingURL=client.js.map
|
package/cjs/client.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AACA,iDAA+C;AAQ/C,sDAG+B;AAC/B,0DAAsD;AAEtD,qEAAkE;AAClE,iEAA2D;AAC3D,+EAAwE;AACxE,gDAAiD;AACjD,iDAAsD;AACtD,2CAA6C;AAI7C,IAAI,YAAiB,CAAA;AAErB,IAAI,CAAC;IACD,8DAA8D;IAE9D,0BAA0B;IAC1B,sBAAsB;IACtB,YAAY,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,wBAAwB,CAAA;IACxE,6DAA6D;AACjE,CAAC;AAAC,MAAM,CAAC,CAAA,CAAC;AAuBV,MAAa,kBAAmB,SAAQ,8BAAsB;IAC1D,YAAY,IAA+B;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,IAAA,yBAAW,EAAC,IAAI,0BAAY,EAAE,CAAC,CAAA;QAEvD,KAAK,CAAC;YACF,2BAA2B;YAC3B,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,IAAI,YAAY,EAAE,CAAC,CAAC,CAAC,IAAI,8BAAkB,EAAE;YACpE,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,qBAAY,EAAE;YACnC,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,K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,CAAC,CAAA;IACvD,CAAC;CACJ;AAzFD,wCAyFC","sourcesContent":["import type { Interface as RlInterface } from 'node:readline'\nimport { createInterface } from 'node:readline'\nimport type { Readable } from 'node:stream'\n\nimport type { FileDownloadLocation, FileDownloadParameters, ITelegramStorageProvider, PartialOnly, User } from '@mtcute/core'\nimport type {\n BaseTelegramClientOptions as BaseTelegramClientOptionsBase,\n TelegramClientOptions,\n} from '@mtcute/core/client.js'\nimport {\n BaseTelegramClient as BaseTelegramClientBase,\n TelegramClient as TelegramClientBase,\n} from '@mtcute/core/client.js'\nimport { setPlatform } from '@mtcute/core/platform.js'\n\nimport { NodePlatform } from './common-internals-node/platform.js'\nimport { downloadToFile } from './methods/download-file.js'\nimport { downloadAsNodeStream } from './methods/download-node-stream.js'\nimport { SqliteStorage } from './sqlite/index.js'\nimport { NodeCryptoProvider } from './utils/crypto.js'\nimport { TcpTransport } from './utils/tcp.js'\n\nexport type { TelegramClientOptions }\n\nlet nativeCrypto: any\n\ntry {\n /* eslint-disable ts/ban-ts-comment,ts/no-unsafe-assignment */\n\n // @ts-ignore not in deps\n // @esm-replace-import\n nativeCrypto = (require('@mtcute/crypto-node')).NodeNativeCryptoProvider\n /* eslint-enable ts/ban-ts-comment,ts/no-unsafe-assignment */\n} catch {}\n\nexport interface BaseTelegramClientOptions\n extends PartialOnly<Omit<BaseTelegramClientOptionsBase, 'storage'>, 'transport' | 'crypto'> {\n /**\n * Storage to use for this client.\n *\n * If a string is passed, it will be used as\n * a name for an SQLite database file.\n *\n * @default `\"client.session\"`\n */\n storage?: string | ITelegramStorageProvider\n\n /**\n * **ADVANCED USE ONLY**\n *\n * Whether to not set up the platform.\n * This is useful if you call `setPlatform` yourself.\n */\n platformless?: boolean\n}\n\nexport class BaseTelegramClient extends BaseTelegramClientBase {\n constructor(opts: BaseTelegramClientOptions) {\n if (!opts.platformless) setPlatform(new NodePlatform())\n\n super({\n // eslint-disable-next-line\n crypto: nativeCrypto ? new nativeCrypto() : new NodeCryptoProvider(),\n transport: () => new TcpTransport(),\n ...opts,\n storage:\n typeof opts.storage === 'string'\n ? new SqliteStorage(opts.storage)\n : opts.storage ?? new SqliteStorage('client.session'),\n })\n }\n}\n\n/**\n * Telegram client for use in Node.js\n */\nexport class TelegramClient extends TelegramClientBase {\n constructor(opts: TelegramClientOptions) {\n if ('client' in opts) {\n super(opts)\n\n return\n }\n\n super({\n client: new BaseTelegramClient(opts),\n disableUpdates: opts.disableUpdates,\n skipConversationUpdates: opts.skipConversationUpdates,\n updates: opts.updates,\n })\n }\n\n private _rl?: RlInterface\n\n /**\n * Tiny wrapper over Node `readline` package\n * for simpler user input for `.start()` method.\n *\n * Associated `readline` interface is closed\n * after `start()` returns, or with the client.\n *\n * @param text Text of the question\n */\n input(text: string): Promise<string> {\n if (!this._rl) {\n this._rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n })\n }\n\n return new Promise(res => this._rl?.question(text, res))\n }\n\n close(): Promise<void> {\n this._rl?.close()\n\n return super.close()\n }\n\n start(params: Parameters<TelegramClientBase['start']>[0] = {}): Promise<User> {\n if (!params.botToken) {\n if (!params.phone) params.phone = () => this.input('phone > ')\n if (!params.code) params.code = () => this.input('code > ')\n\n if (!params.password) {\n params.password = () => this.input('2fa password > ')\n }\n }\n\n return super.start(params).then((user) => {\n if (this._rl) {\n this._rl.close()\n delete this._rl\n }\n\n return user\n })\n }\n\n run(\n params: Parameters<TelegramClient['start']>[0] | ((user: User) => void | Promise<void>),\n then?: (user: User) => void | Promise<void>,\n ): void {\n if (typeof params === 'function') {\n then = params\n params = {}\n }\n\n this.start(params)\n .then(then)\n .catch(err => this.emitError(err))\n }\n\n downloadToFile(\n filename: string,\n location: FileDownloadLocation,\n params?: FileDownloadParameters | undefined,\n ): Promise<void> {\n return downloadToFile(this, filename, location, params)\n }\n\n downloadAsNodeStream(location: FileDownloadLocation, params?: FileDownloadParameters | undefined): Readable {\n return downloadAsNodeStream(this, location, params)\n }\n}\n"]}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// roughly based on https://github.com/sindresorhus/exit-hook/blob/main/index.js, MIT license
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.beforeExit = beforeExit;
|
|
5
|
-
let installed = false;
|
|
6
|
-
let handled = false;
|
|
7
|
-
const callbacks = new Set();
|
|
8
|
-
const myHandlers = new Map();
|
|
9
|
-
function register(shouldManuallyExit, signal, event) {
|
|
10
|
-
function eventHandler() {
|
|
11
|
-
if (handled) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
handled = true;
|
|
15
|
-
for (const callback of callbacks) {
|
|
16
|
-
callback();
|
|
17
|
-
}
|
|
18
|
-
for (const [event, handler] of myHandlers) {
|
|
19
|
-
process.off(event, handler);
|
|
20
|
-
}
|
|
21
|
-
if (shouldManuallyExit) {
|
|
22
|
-
// send the signal again and let node handle it
|
|
23
|
-
process.kill(process.pid, signal);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
process.on(event, eventHandler);
|
|
27
|
-
myHandlers.set(event, eventHandler);
|
|
28
|
-
}
|
|
29
|
-
function beforeExit(fn) {
|
|
30
|
-
// unsupported platform
|
|
31
|
-
if (typeof process === 'undefined')
|
|
32
|
-
return () => { };
|
|
33
|
-
if (!installed) {
|
|
34
|
-
installed = true;
|
|
35
|
-
register(true, 0, 'beforeExit');
|
|
36
|
-
register(true, 2, 'SIGINT');
|
|
37
|
-
register(true, 15, 'SIGTERM');
|
|
38
|
-
register(false, 15, 'exit');
|
|
39
|
-
}
|
|
40
|
-
callbacks.add(fn);
|
|
41
|
-
return () => {
|
|
42
|
-
callbacks.delete(fn);
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=exit-hook.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"exit-hook.js","sourceRoot":"","sources":["../../../src/common-internals-node/exit-hook.ts"],"names":[],"mappings":";AAAA,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C,CAAA;QAC7B,QAAQ,CAAC,KAAK,EAAE,EAAE,EAAE,MAAM,CAAC,CAAA;IAC/B,CAAC;IAED,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;IAEjB,OAAO,GAAG,EAAE;QACR,SAAS,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;IACxB,CAAC,CAAA;AACL,CAAC","sourcesContent":["// roughly based on https://github.com/sindresorhus/exit-hook/blob/main/index.js, MIT license\n\nlet installed = false\nlet handled = false\n\nconst callbacks = new Set<() => void>()\n\nconst myHandlers = new Map<string, () => void>()\n\nfunction register(shouldManuallyExit: boolean, signal: number, event: string) {\n function eventHandler() {\n if (handled) {\n return\n }\n\n handled = true\n\n for (const callback of callbacks) {\n callback()\n }\n\n for (const [event, handler] of myHandlers) {\n process.off(event, handler)\n }\n\n if (shouldManuallyExit) {\n // send the signal again and let node handle it\n process.kill(process.pid, signal)\n }\n }\n\n process.on(event, eventHandler)\n myHandlers.set(event, eventHandler)\n}\n\nexport function beforeExit(fn: () => void): () => void {\n // unsupported platform\n if (typeof process === 'undefined') return () => {}\n\n if (!installed) {\n installed = true\n\n register(true, 0, 'beforeExit')\n register(true, 2, 'SIGINT')\n register(true, 15, 'SIGTERM')\n register(false, 15, 'exit')\n }\n\n callbacks.add(fn)\n\n return () => {\n callbacks.delete(fn)\n }\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultLoggingHandler = void 0;
|
|
4
|
-
const isTty = typeof process === 'object' && Boolean(process.stdout?.isTTY);
|
|
5
|
-
const BASE_FORMAT = isTty ? '%s [%s] [%s%s\x1B[0m] ' : '%s [%s] [%s] ';
|
|
6
|
-
const LEVEL_NAMES = isTty
|
|
7
|
-
? [
|
|
8
|
-
'', // OFF
|
|
9
|
-
'\x1B[31mERR\x1B[0m',
|
|
10
|
-
'\x1B[33mWRN\x1B[0m',
|
|
11
|
-
'\x1B[34mINF\x1B[0m',
|
|
12
|
-
'\x1B[36mDBG\x1B[0m',
|
|
13
|
-
'\x1B[35mVRB\x1B[0m',
|
|
14
|
-
]
|
|
15
|
-
: [
|
|
16
|
-
'', // OFF
|
|
17
|
-
'ERR',
|
|
18
|
-
'WRN',
|
|
19
|
-
'INF',
|
|
20
|
-
'DBG',
|
|
21
|
-
'VRB',
|
|
22
|
-
];
|
|
23
|
-
const TAG_COLORS = [6, 2, 3, 4, 5, 1].map(i => `\x1B[3${i};1m`);
|
|
24
|
-
/** @internal */
|
|
25
|
-
exports.defaultLoggingHandler = isTty
|
|
26
|
-
? (color, level, tag, fmt, args) => {
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], TAG_COLORS[color], tag, ...args);
|
|
29
|
-
}
|
|
30
|
-
: (color, level, tag, fmt, args) => {
|
|
31
|
-
// eslint-disable-next-line no-console
|
|
32
|
-
console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], tag, ...args);
|
|
33
|
-
};
|
|
34
|
-
//# sourceMappingURL=logging.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../../../src/common-internals-node/logging.ts"],"names":[],"mappings":";;;AAAA,MAAM,KAAK,GAAG,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA;AAE3E,MAAM,WAAW,GAAG,KAAK,CAAC,CAAC,CAAC,wBAAwB,CAAC,CAAC,CAAC,eAAe,CAAA;AACtE,MAAM,WAAW,GAAG,KAAK;IACrB,CAAC,CAAC;QACE,EAAE,EAAE,MAAM;QACV,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;QACpB,oBAAoB;KACvB;IACD,CAAC,CAAC;QACE,EAAE,EAAE,MAAM;QACV,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;QACL,KAAK;KACR,CAAA;AACL,MAAM,UAAU,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;AAE/D,gBAAgB;AACH,QAAA,qBAAqB,GAMtB,KAAK;IACb,CAAC,CAAC,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,IAAe,EAAQ,EAAE;QAChF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IACjH,CAAC;IACD,CAAC,CAAC,CAAC,KAAa,EAAE,KAAa,EAAE,GAAW,EAAE,GAAW,EAAE,IAAe,EAAQ,EAAE;QAChF,sCAAsC;QACtC,OAAO,CAAC,GAAG,CAAC,WAAW,GAAG,GAAG,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAA;IAC9F,CAAC,CAAA","sourcesContent":["const isTty = typeof process === 'object' && Boolean(process.stdout?.isTTY)\n\nconst BASE_FORMAT = isTty ? '%s [%s] [%s%s\\x1B[0m] ' : '%s [%s] [%s] '\nconst LEVEL_NAMES = isTty\n ? [\n '', // OFF\n '\\x1B[31mERR\\x1B[0m',\n '\\x1B[33mWRN\\x1B[0m',\n '\\x1B[34mINF\\x1B[0m',\n '\\x1B[36mDBG\\x1B[0m',\n '\\x1B[35mVRB\\x1B[0m',\n ]\n : [\n '', // OFF\n 'ERR',\n 'WRN',\n 'INF',\n 'DBG',\n 'VRB',\n ]\nconst TAG_COLORS = [6, 2, 3, 4, 5, 1].map(i => `\\x1B[3${i};1m`)\n\n/** @internal */\nexport const defaultLoggingHandler: (\n color: number,\n level: number,\n tag: string,\n fmt: string,\n args: unknown[]\n) => void = isTty\n ? (color: number, level: number, tag: string, fmt: string, args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], TAG_COLORS[color], tag, ...args)\n }\n : (color: number, level: number, tag: string, fmt: string, args: unknown[]): void => {\n // eslint-disable-next-line no-console\n console.log(BASE_FORMAT + fmt, new Date().toISOString(), LEVEL_NAMES[level], tag, ...args)\n }\n"]}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.NodePlatform = void 0;
|
|
27
|
-
const os = __importStar(require("node:os"));
|
|
28
|
-
const normalize_file_js_1 = require("../utils/normalize-file.js");
|
|
29
|
-
const exit_hook_js_1 = require("./exit-hook.js");
|
|
30
|
-
const logging_js_1 = require("./logging.js");
|
|
31
|
-
const BUFFER_BASE64_URL_AVAILABLE = typeof Buffer.isEncoding === 'function' && Buffer.isEncoding('base64url');
|
|
32
|
-
const toBuffer = (buf) => Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
33
|
-
class NodePlatform {
|
|
34
|
-
getDeviceModel() {
|
|
35
|
-
return `Node.js/${process.version} (${os.type()} ${os.arch()})`;
|
|
36
|
-
}
|
|
37
|
-
getDefaultLogLevel() {
|
|
38
|
-
const envLogLevel = Number.parseInt(process.env.MTCUTE_LOG_LEVEL ?? '');
|
|
39
|
-
if (!Number.isNaN(envLogLevel)) {
|
|
40
|
-
return envLogLevel;
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
// ITlPlatform
|
|
45
|
-
utf8ByteLength(str) {
|
|
46
|
-
return Buffer.byteLength(str, 'utf8');
|
|
47
|
-
}
|
|
48
|
-
utf8Encode(str) {
|
|
49
|
-
return Buffer.from(str, 'utf8');
|
|
50
|
-
}
|
|
51
|
-
utf8Decode(buf) {
|
|
52
|
-
return toBuffer(buf).toString('utf8');
|
|
53
|
-
}
|
|
54
|
-
hexEncode(buf) {
|
|
55
|
-
return toBuffer(buf).toString('hex');
|
|
56
|
-
}
|
|
57
|
-
hexDecode(str) {
|
|
58
|
-
return Buffer.from(str, 'hex');
|
|
59
|
-
}
|
|
60
|
-
base64Encode(buf, url = false) {
|
|
61
|
-
const nodeBuffer = toBuffer(buf);
|
|
62
|
-
if (url && BUFFER_BASE64_URL_AVAILABLE)
|
|
63
|
-
return nodeBuffer.toString('base64url');
|
|
64
|
-
const str = nodeBuffer.toString('base64');
|
|
65
|
-
if (url)
|
|
66
|
-
return str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
67
|
-
return str;
|
|
68
|
-
}
|
|
69
|
-
base64Decode(string, url = false) {
|
|
70
|
-
if (url && BUFFER_BASE64_URL_AVAILABLE) {
|
|
71
|
-
return Buffer.from(string, 'base64url');
|
|
72
|
-
}
|
|
73
|
-
if (url) {
|
|
74
|
-
string = string.replace(/-/g, '+').replace(/_/g, '/');
|
|
75
|
-
while (string.length % 4)
|
|
76
|
-
string += '=';
|
|
77
|
-
}
|
|
78
|
-
return Buffer.from(string, 'base64');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
exports.NodePlatform = NodePlatform;
|
|
82
|
-
NodePlatform.prototype.log = logging_js_1.defaultLoggingHandler;
|
|
83
|
-
NodePlatform.prototype.beforeExit = exit_hook_js_1.beforeExit;
|
|
84
|
-
NodePlatform.prototype.normalizeFile = normalize_file_js_1.normalizeFile;
|
|
85
|
-
//# sourceMappingURL=platform.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../../src/common-internals-node/platform.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAA6B;AAI7B,kEAA0D;AAE1D,iDAA2C;AAC3C,6CAAoD;AAEpD,MAAM,2BAA2B,GAAG,OAAO,MAAM,CAAC,UAAU,KAAK,UAAU,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAA;AAE7G,MAAM,QAAQ,GAAG,CAAC,GAAe,EAAU,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,UAAU,CAAC,CAAA;AAErG,MAAa,YAAY;IAMrB,cAAc;QACV,OAAO,WAAW,OAAO,CAAC,OAAO,KAAK,EAAE,CAAC,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AAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;QAE7E,OAAO,GAAG,CAAA;IACd,CAAC;IAED,YAAY,CAAC,MAAc,EAAE,GAAG,GAAG,KAAK;QACpC,IAAI,GAAG,IAAI,2BAA2B,EAAE,CAAC;YACrC,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;QAC3C,CAAC;QAED,IAAI,GAAG,EAAE,CAAC;YACN,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACrD,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,MAAM,IAAI,GAAG,CAAA;QAC3C,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAA;IACxC,CAAC;CACJ;AAhED,oCAgEC;AAED,YAAY,CAAC,SAAS,CAAC,GAAG,GAAG,kCAAqB,CAAA;AAClD,YAAY,CAAC,SAAS,CAAC,UAAU,GAAG,yBAAU,CAAA;AAC9C,YAAY,CAAC,SAAS,CAAC,aAAa,GAAG,iCAAa,CAAA","sourcesContent":["import * as os from 'node:os'\n\nimport type { ICorePlatform } from '@mtcute/core/platform.js'\n\nimport { normalizeFile } from '../utils/normalize-file.js'\n\nimport { beforeExit } from './exit-hook.js'\nimport { defaultLoggingHandler } from './logging.js'\n\nconst BUFFER_BASE64_URL_AVAILABLE = typeof Buffer.isEncoding === 'function' && Buffer.isEncoding('base64url')\n\nconst toBuffer = (buf: Uint8Array): Buffer => Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength)\n\nexport class NodePlatform implements ICorePlatform {\n // ICorePlatform\n declare log: typeof defaultLoggingHandler\n declare beforeExit: typeof beforeExit\n declare normalizeFile: typeof normalizeFile\n\n getDeviceModel(): string {\n return `Node.js/${process.version} (${os.type()} ${os.arch()})`\n }\n\n getDefaultLogLevel(): number | null {\n const envLogLevel = Number.parseInt(process.env.MTCUTE_LOG_LEVEL ?? '')\n\n if (!Number.isNaN(envLogLevel)) {\n return envLogLevel\n }\n\n return null\n }\n\n // ITlPlatform\n utf8ByteLength(str: string): number {\n return Buffer.byteLength(str, 'utf8')\n }\n\n utf8Encode(str: string): Uint8Array {\n return Buffer.from(str, 'utf8')\n }\n\n utf8Decode(buf: Uint8Array): string {\n return toBuffer(buf).toString('utf8')\n }\n\n hexEncode(buf: Uint8Array): string {\n return toBuffer(buf).toString('hex')\n }\n\n hexDecode(str: string): Uint8Array {\n return Buffer.from(str, 'hex')\n }\n\n base64Encode(buf: Uint8Array, url = false): string {\n const nodeBuffer = toBuffer(buf)\n\n if (url && BUFFER_BASE64_URL_AVAILABLE) return nodeBuffer.toString('base64url')\n\n const str = nodeBuffer.toString('base64')\n if (url) return str.replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=/g, '')\n\n return str\n }\n\n base64Decode(string: string, url = false): Uint8Array {\n if (url && BUFFER_BASE64_URL_AVAILABLE) {\n return Buffer.from(string, 'base64url')\n }\n\n if (url) {\n string = string.replace(/-/g, '+').replace(/_/g, '/')\n while (string.length % 4) string += '='\n }\n\n return Buffer.from(string, 'base64')\n }\n}\n\nNodePlatform.prototype.log = defaultLoggingHandler\nNodePlatform.prototype.beforeExit = beforeExit\nNodePlatform.prototype.normalizeFile = normalizeFile\n"]}
|
package/cjs/index.js
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
if (typeof globalThis !== 'undefined' && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
3
|
-
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true
|
|
4
|
-
console.warn("[@mtcute/node] CommonJS support is deprecated and will be removed soon. Please consider switching to ESM, it's "+(new Date()).getFullYear()+" already.")
|
|
5
|
-
console.warn("[@mtcute/node] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c")
|
|
6
|
-
}
|
|
7
|
-
"use strict";
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
__exportStar(require("./client.js"), exports);
|
|
24
|
-
__exportStar(require("./common-internals-node/platform.js"), exports);
|
|
25
|
-
__exportStar(require("./sqlite/index.js"), exports);
|
|
26
|
-
__exportStar(require("./utils/tcp.js"), exports);
|
|
27
|
-
__exportStar(require("./worker.js"), exports);
|
|
28
|
-
__exportStar(require("@mtcute/core"), exports);
|
|
29
|
-
__exportStar(require("@mtcute/html-parser"), exports);
|
|
30
|
-
__exportStar(require("@mtcute/markdown-parser"), exports);
|
|
31
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,sEAAmD;AACnD,oDAAiC;AACjC,iDAA8B;AAC9B,8CAA2B;AAC3B,+CAA4B;AAC5B,sDAAmC;AACnC,0DAAuC","sourcesContent":["export * from './client.js'\nexport * from './common-internals-node/platform.js'\nexport * from './sqlite/index.js'\nexport * from './utils/tcp.js'\nexport * from './worker.js'\nexport * from '@mtcute/core'\nexport * from '@mtcute/html-parser'\nexport * from '@mtcute/markdown-parser'\n"]}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadToFile = downloadToFile;
|
|
4
|
-
const node_fs_1 = require("node:fs");
|
|
5
|
-
const promises_1 = require("node:fs/promises");
|
|
6
|
-
const core_1 = require("@mtcute/core");
|
|
7
|
-
const methods_js_1 = require("@mtcute/core/methods.js");
|
|
8
|
-
/**
|
|
9
|
-
* Download a remote file to a local file (only for NodeJS).
|
|
10
|
-
* Promise will resolve once the download is complete.
|
|
11
|
-
*
|
|
12
|
-
* @param filename Local file name to which the remote file will be downloaded
|
|
13
|
-
* @param params File download parameters
|
|
14
|
-
*/
|
|
15
|
-
async function downloadToFile(client, filename, location, params) {
|
|
16
|
-
if (location instanceof core_1.FileLocation && ArrayBuffer.isView(location.location)) {
|
|
17
|
-
// early return for inline files
|
|
18
|
-
await (0, promises_1.writeFile)(filename, location.location);
|
|
19
|
-
}
|
|
20
|
-
const output = (0, node_fs_1.createWriteStream)(filename);
|
|
21
|
-
if (params?.abortSignal) {
|
|
22
|
-
params.abortSignal.addEventListener('abort', () => {
|
|
23
|
-
client.log.debug('aborting file download %s - cleaning up', filename);
|
|
24
|
-
output.destroy();
|
|
25
|
-
(0, node_fs_1.rmSync)(filename);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
for await (const chunk of (0, methods_js_1.downloadAsIterable)(client, location, params)) {
|
|
29
|
-
output.write(chunk);
|
|
30
|
-
}
|
|
31
|
-
output.end();
|
|
32
|
-
}
|
|
33
|
-
//# sourceMappingURL=download-file.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-file.js","sourceRoot":"","sources":["../../../src/methods/download-file.ts"],"names":[],"mappings":";;AAcA,wCA0BC;AAxCD,qCAAmD;AACnD,+CAA4C;AAG5C,uCAA2C;AAC3C,wDAA4D;AAE5D;;;;;;GAMG;AACI,KAAK,UAAU,cAAc,CAChC,MAAuB,EACvB,QAAgB,EAChB,QAA8B,EAC9B,MAA+B;IAE/B,IAAI,QAAQ,YAAY,mBAAY,IAAI,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5E,gCAAgC;QAChC,MAAM,IAAA,oBAAS,EAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAA;IAChD,CAAC;IAED,MAAM,MAAM,GAAG,IAAA,2BAAiB,EAAC,QAAQ,CAAC,CAAA;IAE1C,IAAI,MAAM,EAAE,WAAW,EAAE,CAAC;QACtB,MAAM,CAAC,WAAW,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;YAC9C,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,yCAAyC,EAAE,QAAQ,CAAC,CAAA;YACrE,MAAM,CAAC,OAAO,EAAE,CAAA;YAChB,IAAA,gBAAM,EAAC,QAAQ,CAAC,CAAA;QACpB,CAAC,CAAC,CAAA;IACN,CAAC;IAED,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,IAAA,+BAAkB,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,EAAE,CAAC;QACrE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;IACvB,CAAC;IAED,MAAM,CAAC,GAAG,EAAE,CAAA;AAChB,CAAC","sourcesContent":["import { createWriteStream, rmSync } from 'node:fs'\nimport { writeFile } from 'node:fs/promises'\n\nimport type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core'\nimport { FileLocation } from '@mtcute/core'\nimport { downloadAsIterable } from '@mtcute/core/methods.js'\n\n/**\n * Download a remote file to a local file (only for NodeJS).\n * Promise will resolve once the download is complete.\n *\n * @param filename Local file name to which the remote file will be downloaded\n * @param params File download parameters\n */\nexport async function downloadToFile(\n client: ITelegramClient,\n filename: string,\n location: FileDownloadLocation,\n params?: FileDownloadParameters,\n): Promise<void> {\n if (location instanceof FileLocation && ArrayBuffer.isView(location.location)) {\n // early return for inline files\n await writeFile(filename, location.location)\n }\n\n const output = createWriteStream(filename)\n\n if (params?.abortSignal) {\n params.abortSignal.addEventListener('abort', () => {\n client.log.debug('aborting file download %s - cleaning up', filename)\n output.destroy()\n rmSync(filename)\n })\n }\n\n for await (const chunk of downloadAsIterable(client, location, params)) {\n output.write(chunk)\n }\n\n output.end()\n}\n"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { Readable } from 'node:stream';
|
|
2
|
-
import type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core';
|
|
3
|
-
/**
|
|
4
|
-
* Download a remote file as a Node.js Readable stream.
|
|
5
|
-
*
|
|
6
|
-
* @param params File download parameters
|
|
7
|
-
*/
|
|
8
|
-
export declare function downloadAsNodeStream(client: ITelegramClient, location: FileDownloadLocation, params?: FileDownloadParameters): Readable;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.downloadAsNodeStream = downloadAsNodeStream;
|
|
4
|
-
const methods_js_1 = require("@mtcute/core/methods.js");
|
|
5
|
-
const stream_utils_js_1 = require("../utils/stream-utils.js");
|
|
6
|
-
/**
|
|
7
|
-
* Download a remote file as a Node.js Readable stream.
|
|
8
|
-
*
|
|
9
|
-
* @param params File download parameters
|
|
10
|
-
*/
|
|
11
|
-
function downloadAsNodeStream(client, location, params) {
|
|
12
|
-
return (0, stream_utils_js_1.webStreamToNode)((0, methods_js_1.downloadAsStream)(client, location, params));
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=download-node-stream.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"download-node-stream.js","sourceRoot":"","sources":["../../../src/methods/download-node-stream.ts"],"names":[],"mappings":";;AAYA,oDAMC;AAfD,wDAA0D;AAE1D,8DAA0D;AAE1D;;;;GAIG;AACH,SAAgB,oBAAoB,CAChC,MAAuB,EACvB,QAA8B,EAC9B,MAA+B;IAE/B,OAAO,IAAA,iCAAe,EAAC,IAAA,6BAAgB,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;AACtE,CAAC","sourcesContent":["import type { Readable } from 'node:stream'\n\nimport type { FileDownloadLocation, FileDownloadParameters, ITelegramClient } from '@mtcute/core'\nimport { downloadAsStream } from '@mtcute/core/methods.js'\n\nimport { webStreamToNode } from '../utils/stream-utils.js'\n\n/**\n * Download a remote file as a Node.js Readable stream.\n *\n * @param params File download parameters\n */\nexport function downloadAsNodeStream(\n client: ITelegramClient,\n location: FileDownloadLocation,\n params?: FileDownloadParameters,\n): Readable {\n return webStreamToNode(downloadAsStream(client, location, params))\n}\n"]}
|
package/cjs/methods.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
if (typeof globalThis !== 'undefined' && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
|
|
3
|
-
globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true
|
|
4
|
-
console.warn("[@mtcute/node] CommonJS support is deprecated and will be removed soon. Please consider switching to ESM, it's "+(new Date()).getFullYear()+" already.")
|
|
5
|
-
console.warn("[@mtcute/node] Learn more about switching to ESM: https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c")
|
|
6
|
-
}
|
|
7
|
-
"use strict";
|
|
8
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
-
if (k2 === undefined) k2 = k;
|
|
10
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
-
}
|
|
14
|
-
Object.defineProperty(o, k2, desc);
|
|
15
|
-
}) : (function(o, m, k, k2) {
|
|
16
|
-
if (k2 === undefined) k2 = k;
|
|
17
|
-
o[k2] = m[k];
|
|
18
|
-
}));
|
|
19
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
-
};
|
|
22
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.downloadAsNodeStream = exports.downloadToFile = void 0;
|
|
24
|
-
var download_file_js_1 = require("./methods/download-file.js");
|
|
25
|
-
Object.defineProperty(exports, "downloadToFile", { enumerable: true, get: function () { return download_file_js_1.downloadToFile; } });
|
|
26
|
-
var download_node_stream_js_1 = require("./methods/download-node-stream.js");
|
|
27
|
-
Object.defineProperty(exports, "downloadAsNodeStream", { enumerable: true, get: function () { return download_node_stream_js_1.downloadAsNodeStream; } });
|
|
28
|
-
__exportStar(require("@mtcute/core/methods.js"), exports);
|
|
29
|
-
//# sourceMappingURL=methods.js.map
|
package/cjs/methods.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/methods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,+DAA2D;AAAlD,kHAAA,cAAc,OAAA;AACvB,6EAAwE;AAA/D,+HAAA,oBAAoB,OAAA;AAC7B,0DAAuC","sourcesContent":["export { downloadToFile } from './methods/download-file.js'\nexport { downloadAsNodeStream } from './methods/download-node-stream.js'\nexport * from '@mtcute/core/methods.js'\n"]}
|
package/cjs/package.json
DELETED
package/cjs/sqlite/driver.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Options } from 'better-sqlite3';
|
|
2
|
-
import type { ISqliteDatabase } from '@mtcute/core';
|
|
3
|
-
import { BaseSqliteStorageDriver } from '@mtcute/core';
|
|
4
|
-
export interface SqliteStorageDriverOptions {
|
|
5
|
-
/**
|
|
6
|
-
* By default, WAL mode is enabled, which
|
|
7
|
-
* significantly improves performance.
|
|
8
|
-
* [Learn more](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/performance.md)
|
|
9
|
-
*
|
|
10
|
-
* However, you might encounter some issues,
|
|
11
|
-
* and if you do, you can disable WAL by passing `true`
|
|
12
|
-
*
|
|
13
|
-
* @default false
|
|
14
|
-
*/
|
|
15
|
-
disableWal?: boolean;
|
|
16
|
-
/**
|
|
17
|
-
* Additional options to pass to `better-sqlite3`
|
|
18
|
-
*/
|
|
19
|
-
options?: Options;
|
|
20
|
-
}
|
|
21
|
-
export declare class SqliteStorageDriver extends BaseSqliteStorageDriver {
|
|
22
|
-
readonly filename: string;
|
|
23
|
-
readonly params?: SqliteStorageDriverOptions | undefined;
|
|
24
|
-
constructor(filename?: string, params?: SqliteStorageDriverOptions | undefined);
|
|
25
|
-
_createDatabase(): ISqliteDatabase;
|
|
26
|
-
}
|
package/cjs/sqlite/driver.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.SqliteStorageDriver = void 0;
|
|
7
|
-
const better_sqlite3_1 = __importDefault(require("better-sqlite3"));
|
|
8
|
-
const core_1 = require("@mtcute/core");
|
|
9
|
-
class SqliteStorageDriver extends core_1.BaseSqliteStorageDriver {
|
|
10
|
-
filename;
|
|
11
|
-
params;
|
|
12
|
-
constructor(filename = ':memory:', params) {
|
|
13
|
-
super();
|
|
14
|
-
this.filename = filename;
|
|
15
|
-
this.params = params;
|
|
16
|
-
}
|
|
17
|
-
_createDatabase() {
|
|
18
|
-
const db = (0, better_sqlite3_1.default)(this.filename, {
|
|
19
|
-
...this.params?.options,
|
|
20
|
-
verbose: this._log.mgr.level >= 5 ? this._log.verbose : undefined,
|
|
21
|
-
});
|
|
22
|
-
if (!this.params?.disableWal) {
|
|
23
|
-
db.pragma('journal_mode = WAL');
|
|
24
|
-
}
|
|
25
|
-
return db;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
exports.SqliteStorageDriver = SqliteStorageDriver;
|
|
29
|
-
//# sourceMappingURL=driver.js.map
|
package/cjs/sqlite/driver.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"driver.js","sourceRoot":"","sources":["../../../src/sqlite/driver.ts"],"names":[],"mappings":";;;;;;AACA,oEAAoC;AAEpC,uCAAsD;AAqBtD,MAAa,mBAAoB,SAAQ,8BAAuB;IAE/C;IACA;IAFb,YACa,WAAW,UAAU,EACrB,MAA+C;QAExD,KAAK,EAAE,CAAA;QAHE,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAyC;IAG5D,CAAC;IAED,eAAe;QACX,MAAM,EAAE,GAAG,IAAA,wBAAO,EAAC,IAAI,CAAC,QAAQ,EAAE;YAC9B,GAAG,IAAI,CAAC,MAAM,EAAE,OAAO;YACvB,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,IAAI,CAAC,CAAC,CAAC,CAAE,IAAI,CAAC,IAAI,CAAC,OAA8B,CAAC,CAAC,CAAC,SAAS;SAC5F,CAAC,CAAA;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,UAAU,EAAE,CAAC;YAC3B,EAAE,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAA;QACnC,CAAC;QAED,OAAO,EAAqB,CAAA;IAChC,CAAC;CACJ;AApBD,kDAoBC","sourcesContent":["import type { Options } from 'better-sqlite3'\nimport sqlite3 from 'better-sqlite3'\nimport type { ISqliteDatabase } from '@mtcute/core'\nimport { BaseSqliteStorageDriver } from '@mtcute/core'\n\nexport interface SqliteStorageDriverOptions {\n /**\n * By default, WAL mode is enabled, which\n * significantly improves performance.\n * [Learn more](https://github.com/JoshuaWise/better-sqlite3/blob/master/docs/performance.md)\n *\n * However, you might encounter some issues,\n * and if you do, you can disable WAL by passing `true`\n *\n * @default false\n */\n disableWal?: boolean\n\n /**\n * Additional options to pass to `better-sqlite3`\n */\n options?: Options\n}\n\nexport class SqliteStorageDriver extends BaseSqliteStorageDriver {\n constructor(\n readonly filename = ':memory:',\n readonly params?: SqliteStorageDriverOptions | undefined,\n ) {\n super()\n }\n\n _createDatabase(): ISqliteDatabase {\n const db = sqlite3(this.filename, {\n ...this.params?.options,\n verbose: this._log.mgr.level >= 5 ? (this._log.verbose as Options['verbose']) : undefined,\n })\n\n if (!this.params?.disableWal) {\n db.pragma('journal_mode = WAL')\n }\n\n return db as ISqliteDatabase\n }\n}\n"]}
|
package/cjs/sqlite/index.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseSqliteStorage } from '@mtcute/core';
|
|
2
|
-
import type { SqliteStorageDriverOptions } from './driver.js';
|
|
3
|
-
export { SqliteStorageDriver } from './driver.js';
|
|
4
|
-
export declare class SqliteStorage extends BaseSqliteStorage {
|
|
5
|
-
readonly filename: string;
|
|
6
|
-
readonly params?: SqliteStorageDriverOptions | undefined;
|
|
7
|
-
constructor(filename?: string, params?: SqliteStorageDriverOptions | undefined);
|
|
8
|
-
}
|
package/cjs/sqlite/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.SqliteStorage = exports.SqliteStorageDriver = void 0;
|
|
4
|
-
const core_1 = require("@mtcute/core");
|
|
5
|
-
const driver_js_1 = require("./driver.js");
|
|
6
|
-
var driver_js_2 = require("./driver.js");
|
|
7
|
-
Object.defineProperty(exports, "SqliteStorageDriver", { enumerable: true, get: function () { return driver_js_2.SqliteStorageDriver; } });
|
|
8
|
-
class SqliteStorage extends core_1.BaseSqliteStorage {
|
|
9
|
-
filename;
|
|
10
|
-
params;
|
|
11
|
-
constructor(filename = ':memory:', params) {
|
|
12
|
-
super(new driver_js_1.SqliteStorageDriver(filename, params));
|
|
13
|
-
this.filename = filename;
|
|
14
|
-
this.params = params;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.SqliteStorage = SqliteStorage;
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
package/cjs/sqlite/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/sqlite/index.ts"],"names":[],"mappings":";;;AAAA,uCAAgD;AAGhD,2CAAiD;AAEjD,yCAAiD;AAAxC,gHAAA,mBAAmB,OAAA;AAE5B,MAAa,aAAc,SAAQ,wBAAiB;IAEnC;IACA;IAFb,YACa,WAAW,UAAU,EACrB,MAA+C;QAExD,KAAK,CAAC,IAAI,+BAAmB,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;QAHvC,aAAQ,GAAR,QAAQ,CAAa;QACrB,WAAM,GAAN,MAAM,CAAyC;IAG5D,CAAC;CACJ;AAPD,sCAOC","sourcesContent":["import { BaseSqliteStorage } from '@mtcute/core'\n\nimport type { SqliteStorageDriverOptions } from './driver.js'\nimport { SqliteStorageDriver } from './driver.js'\n\nexport { SqliteStorageDriver } from './driver.js'\n\nexport class SqliteStorage extends BaseSqliteStorage {\n constructor(\n readonly filename = ':memory:',\n readonly params?: SqliteStorageDriverOptions | undefined,\n ) {\n super(new SqliteStorageDriver(filename, params))\n }\n}\n"]}
|