@mtcute/core 0.12.1 → 0.12.5
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/cjs/highlevel/client.d.ts +8 -0
- package/cjs/highlevel/client.js +16 -14
- package/cjs/highlevel/client.js.map +1 -1
- package/cjs/highlevel/methods/_init.js +16 -14
- package/cjs/highlevel/methods/_init.js.map +1 -1
- package/cjs/highlevel/methods/bots/get-callback-answer.d.ts +11 -0
- package/cjs/highlevel/methods/bots/get-callback-answer.js +10 -2
- package/cjs/highlevel/methods/bots/get-callback-answer.js.map +1 -1
- package/cjs/network/client.d.ts +2 -7
- package/cjs/network/client.js +3 -3
- package/cjs/network/client.js.map +1 -1
- package/cjs/network/network-manager.js +1 -1
- package/cjs/network/session-connection.js +1 -1
- package/cjs/network/session-connection.js.map +1 -1
- package/cjs/platform.js +3 -7
- package/cjs/platform.js.map +1 -1
- package/esm/highlevel/client.d.ts +8 -0
- package/esm/highlevel/client.js +16 -14
- package/esm/highlevel/client.js.map +1 -1
- package/esm/highlevel/methods/_init.js +16 -14
- package/esm/highlevel/methods/_init.js.map +1 -1
- package/esm/highlevel/methods/bots/get-callback-answer.d.ts +11 -0
- package/esm/highlevel/methods/bots/get-callback-answer.js +10 -2
- package/esm/highlevel/methods/bots/get-callback-answer.js.map +1 -1
- package/esm/network/client.d.ts +2 -7
- package/esm/network/client.js +3 -3
- package/esm/network/client.js.map +1 -1
- package/esm/network/network-manager.js +1 -1
- package/esm/network/session-connection.js +1 -1
- package/esm/network/session-connection.js.map +1 -1
- package/esm/platform.js +3 -7
- package/esm/platform.js.map +1 -1
- package/package.json +1 -1
package/cjs/platform.js
CHANGED
|
@@ -9,14 +9,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
9
9
|
exports.getPlatform = exports.setPlatform = void 0;
|
|
10
10
|
const tl_runtime_1 = require("@mtcute/tl-runtime");
|
|
11
11
|
const errors_js_1 = require("./types/errors.js");
|
|
12
|
-
// eslint-disable-next-line
|
|
13
|
-
const globalObject = (0, eval)('this');
|
|
14
12
|
// NB: when using with some bundlers (e.g. vite) re-importing this module will not return the same object
|
|
15
13
|
// so we need to store the platform in a global object to be able to survive hot-reloads etc.
|
|
16
14
|
// try to use Symbol if available, otherwise fallback to a string
|
|
17
15
|
const platformKey = typeof Symbol !== 'undefined' ? Symbol.for('mtcute.platform') : '__MTCUTE_PLATFORM__';
|
|
18
|
-
// eslint-disable-next-line
|
|
19
|
-
let _platform =
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
let _platform = globalThis?.[platformKey] ?? null;
|
|
20
18
|
function setPlatform(platform) {
|
|
21
19
|
if (_platform) {
|
|
22
20
|
if (_platform.constructor !== platform.constructor) {
|
|
@@ -27,9 +25,7 @@ function setPlatform(platform) {
|
|
|
27
25
|
_platform = platform;
|
|
28
26
|
tl_runtime_1.TlBinaryReader.platform = platform;
|
|
29
27
|
tl_runtime_1.TlBinaryWriter.platform = platform;
|
|
30
|
-
|
|
31
|
-
globalObject[platformKey] = platform;
|
|
32
|
-
}
|
|
28
|
+
globalThis[platformKey] = platform;
|
|
33
29
|
}
|
|
34
30
|
exports.setPlatform = setPlatform;
|
|
35
31
|
function getPlatform() {
|
package/cjs/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":";;;AAAA,mDAAgF;AAGhF,iDAAsD;AAiBtD,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":";;;AAAA,mDAAgF;AAGhF,iDAAsD;AAiBtD,yGAAyG;AACzG,6FAA6F;AAC7F,iEAAiE;AACjE,MAAM,WAAW,GAAG,OAAO,MAAM,KAAK,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,qBAAqB,CAAA;AAEzG,2BAA2B;AAC3B,IAAI,SAAS,GAA0B,UAAkB,EAAE,CAAC,WAAW,CAAC,IAAI,IAAI,CAAA;AAEhF,SAAgB,WAAW,CAAC,QAAuB;IAC/C,IAAI,SAAS,EAAE,CAAC;QACZ,IAAI,SAAS,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;YACjD,MAAM,IAAI,8BAAkB,CAAC,yCAAyC,CAAC,CAAA;QAC3E,CAAC;QAED,OAAM;IACV,CAAC;IAED,SAAS,GAAG,QAAQ,CAAA;IACpB,2BAAc,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAClC,2BAAc,CAAC,QAAQ,GAAG,QAAQ,CAGjC;IAAC,UAAkB,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAA;AAChD,CAAC;AAfD,kCAeC;AAED,SAAgB,WAAW;IACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,8BAAkB,CAAC,wDAAwD,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC;AAND,kCAMC","sourcesContent":["import { ITlPlatform, TlBinaryReader, TlBinaryWriter } from '@mtcute/tl-runtime'\n\nimport { UploadFileLike } from './highlevel/types/files/utils.js'\nimport { MtUnsupportedError } from './types/errors.js'\nimport { MaybePromise } from './types/index.js'\n\nexport interface ICorePlatform extends ITlPlatform {\n beforeExit(fn: () => void): () => void\n log(color: number, level: number, tag: string, fmt: string, args: unknown[]): void\n getDefaultLogLevel(): number | null\n getDeviceModel(): string\n normalizeFile?(file: UploadFileLike): MaybePromise<{\n file?: UploadFileLike\n fileSize?: number\n fileName?: string\n } | null>\n onNetworkChanged?(fn: (connected: boolean) => void): () => void\n isOnline?(): boolean\n}\n\n// NB: when using with some bundlers (e.g. vite) re-importing this module will not return the same object\n// so we need to store the platform in a global object to be able to survive hot-reloads etc.\n// try to use Symbol if available, otherwise fallback to a string\nconst platformKey = typeof Symbol !== 'undefined' ? Symbol.for('mtcute.platform') : '__MTCUTE_PLATFORM__'\n\n// eslint-disable-next-line\nlet _platform: ICorePlatform | null = (globalThis as any)?.[platformKey] ?? null\n\nexport function setPlatform(platform: ICorePlatform): void {\n if (_platform) {\n if (_platform.constructor !== platform.constructor) {\n throw new MtUnsupportedError('Platform may not be changed at runtime!')\n }\n\n return\n }\n\n _platform = platform\n TlBinaryReader.platform = platform\n TlBinaryWriter.platform = platform\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ;(globalThis as any)[platformKey] = platform\n}\n\nexport function getPlatform(): ICorePlatform {\n if (!_platform) {\n throw new MtUnsupportedError('Platform is not set! Have you instantiated the client?')\n }\n\n return _platform\n}\n"]}
|
|
@@ -50,6 +50,14 @@ type TelegramClientOptions = ((PartialOnly<Omit<BaseTelegramClientOptions, 'stor
|
|
|
50
50
|
}) | {
|
|
51
51
|
client: ITelegramClient;
|
|
52
52
|
}) & {
|
|
53
|
+
/**
|
|
54
|
+
* If true, all API calls will be wrapped with `tl.invokeWithoutUpdates`,
|
|
55
|
+
* effectively disabling the server-sent events for the clients.
|
|
56
|
+
* May be useful in some cases.
|
|
57
|
+
*
|
|
58
|
+
* @default false
|
|
59
|
+
*/
|
|
60
|
+
disableUpdates?: boolean;
|
|
53
61
|
updates?: Omit<ParsedUpdateHandlerParams, 'onUpdate'>;
|
|
54
62
|
/**
|
|
55
63
|
* If `true`, the updates that were handled by some {@link Conversation}
|
package/esm/highlevel/client.js
CHANGED
|
@@ -254,20 +254,22 @@ export class TelegramClient extends EventEmitter {
|
|
|
254
254
|
this.log = this._client.log;
|
|
255
255
|
// @ts-expect-error codegen
|
|
256
256
|
this.storage = this._client.storage;
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
257
|
+
if (!opts.disableUpdates) {
|
|
258
|
+
const skipConversationUpdates = opts.skipConversationUpdates ?? true;
|
|
259
|
+
const { messageGroupingInterval } = opts.updates ?? {};
|
|
260
|
+
this._client.onUpdate(makeParsedUpdateHandler({
|
|
261
|
+
messageGroupingInterval,
|
|
262
|
+
onUpdate: (update) => {
|
|
263
|
+
if (Conversation.handleUpdate(this, update) && skipConversationUpdates)
|
|
264
|
+
return;
|
|
265
|
+
this.emit('update', update);
|
|
266
|
+
this.emit(update.name, update.data);
|
|
267
|
+
},
|
|
268
|
+
onRawUpdate: (update, peers) => {
|
|
269
|
+
this.emit('raw_update', update, peers);
|
|
270
|
+
},
|
|
271
|
+
}));
|
|
272
|
+
}
|
|
271
273
|
}
|
|
272
274
|
withParams(params) {
|
|
273
275
|
return withParams(this, params);
|