@mtcute/core 0.12.2 → 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.js +1 -1
- package/cjs/highlevel/client.js.map +1 -1
- package/cjs/highlevel/methods/_init.js +1 -1
- 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 +1 -2
- 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.js +1 -1
- package/esm/highlevel/client.js.map +1 -1
- package/esm/highlevel/methods/_init.js +1 -1
- 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 +1 -2
- 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/esm/platform.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { TlBinaryReader, TlBinaryWriter } from '@mtcute/tl-runtime';
|
|
2
2
|
import { MtUnsupportedError } from './types/errors.js';
|
|
3
|
-
// eslint-disable-next-line
|
|
4
|
-
const globalObject = (0, eval)('this');
|
|
5
3
|
// NB: when using with some bundlers (e.g. vite) re-importing this module will not return the same object
|
|
6
4
|
// so we need to store the platform in a global object to be able to survive hot-reloads etc.
|
|
7
5
|
// try to use Symbol if available, otherwise fallback to a string
|
|
8
6
|
const platformKey = typeof Symbol !== 'undefined' ? Symbol.for('mtcute.platform') : '__MTCUTE_PLATFORM__';
|
|
9
|
-
// eslint-disable-next-line
|
|
10
|
-
let _platform =
|
|
7
|
+
// eslint-disable-next-line
|
|
8
|
+
let _platform = globalThis?.[platformKey] ?? null;
|
|
11
9
|
export function setPlatform(platform) {
|
|
12
10
|
if (_platform) {
|
|
13
11
|
if (_platform.constructor !== platform.constructor) {
|
|
@@ -18,9 +16,7 @@ export function setPlatform(platform) {
|
|
|
18
16
|
_platform = platform;
|
|
19
17
|
TlBinaryReader.platform = platform;
|
|
20
18
|
TlBinaryWriter.platform = platform;
|
|
21
|
-
|
|
22
|
-
globalObject[platformKey] = platform;
|
|
23
|
-
}
|
|
19
|
+
globalThis[platformKey] = platform;
|
|
24
20
|
}
|
|
25
21
|
export function getPlatform() {
|
|
26
22
|
if (!_platform) {
|
package/esm/platform.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;AAiBtD,
|
|
1
|
+
{"version":3,"file":"platform.js","sourceRoot":"","sources":["../../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAGhF,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAA;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,MAAM,UAAU,WAAW,CAAC,QAAuB;IAC/C,IAAI,SAAS,EAAE,CAAC;QACZ,IAAI,SAAS,CAAC,WAAW,KAAK,QAAQ,CAAC,WAAW,EAAE,CAAC;YACjD,MAAM,IAAI,kBAAkB,CAAC,yCAAyC,CAAC,CAAA;QAC3E,CAAC;QAED,OAAM;IACV,CAAC;IAED,SAAS,GAAG,QAAQ,CAAA;IACpB,cAAc,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAClC,cAAc,CAAC,QAAQ,GAAG,QAAQ,CAGjC;IAAC,UAAkB,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAA;AAChD,CAAC;AAED,MAAM,UAAU,WAAW;IACvB,IAAI,CAAC,SAAS,EAAE,CAAC;QACb,MAAM,IAAI,kBAAkB,CAAC,wDAAwD,CAAC,CAAA;IAC1F,CAAC;IAED,OAAO,SAAS,CAAA;AACpB,CAAC","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"]}
|