@mtcute/core 0.16.3 → 0.16.4
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/worker/protocol.js +4 -0
- package/cjs/highlevel/worker/protocol.js.map +1 -1
- package/cjs/network/network-manager.js +1 -1
- package/esm/highlevel/worker/protocol.js +4 -0
- package/esm/highlevel/worker/protocol.js.map +1 -1
- package/esm/network/network-manager.js +1 -1
- package/package.json +2 -2
|
@@ -6,6 +6,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.deserializeResult = exports.serializeResult = void 0;
|
|
7
7
|
const long_1 = __importDefault(require("long"));
|
|
8
8
|
function serializeResult(result) {
|
|
9
|
+
if (ArrayBuffer.isView(result))
|
|
10
|
+
return result;
|
|
9
11
|
if (Array.isArray(result)) {
|
|
10
12
|
return result.map(serializeResult);
|
|
11
13
|
}
|
|
@@ -42,6 +44,8 @@ function serializeResult(result) {
|
|
|
42
44
|
}
|
|
43
45
|
exports.serializeResult = serializeResult;
|
|
44
46
|
function deserializeResult(result) {
|
|
47
|
+
if (ArrayBuffer.isView(result))
|
|
48
|
+
return result;
|
|
45
49
|
if (Array.isArray(result)) {
|
|
46
50
|
return result.map(deserializeResult);
|
|
47
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../src/highlevel/worker/protocol.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAuB;AA+DvB,SAAgB,eAAe,CAAI,MAAS;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAmC,CAAA;IACxE,CAAC;IAED,IAAI,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C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AK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,iBAAiB,CAAiB,CAAA;IACxD,CAAC;IAED,IAAI,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,iEAAiE;YACjE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,MAAsB,CAAA;IACjC,CAAC;IAED,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAgC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC5F,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,cAAI,CAAC,SAAS,CAAC,KAAwB,CAAC,CAAA;YACpE,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnC,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAkC,CAAC,CAAA;YACjF,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAsB,CAAA;AACjC,CAAC;AA7BD,8CA6BC","sourcesContent":["import Long from 'long'\nimport type { Worker as NodeWorker } from 'node:worker_threads'\n\nimport { tl } from '@mtcute/tl'\n\nimport { ConnectionState } from '../client.types.js'\nimport { SerializedError } from './errors.js'\n\nexport type WorkerInboundMessage =\n | {\n type: 'invoke'\n id: number\n target: 'custom' | 'client' | 'storage' | 'storage-self' | 'storage-peers' | 'app-config'\n method: string\n args: SerializedResult<unknown[]>\n void: boolean\n withAbort: boolean\n }\n | {\n type: 'abort'\n id: number\n }\n\nexport type WorkerOutboundMessage =\n | { type: 'server_update'; update: SerializedResult<tl.TypeUpdates> }\n | {\n type: 'update'\n update: SerializedResult<tl.TypeUpdate>\n users: SerializedResult<Map<number, tl.TypeUser>>\n chats: SerializedResult<Map<number, tl.TypeChat>>\n hasMin: boolean\n }\n | { type: 'error'; error: unknown }\n | { type: 'stop' }\n | { type: 'conn_state'; state: ConnectionState }\n | {\n type: 'log'\n color: number\n level: number\n tag: string\n fmt: string\n args: unknown[]\n }\n | {\n type: 'result'\n id: number\n result?: SerializedResult<unknown>\n error?: SerializedError\n }\n\nexport type SomeWorker = NodeWorker | Worker | SharedWorker\n\nexport type SendFn = (message: WorkerInboundMessage) => void\nexport type ClientMessageHandler = (message: WorkerOutboundMessage) => void\n\nexport type RespondFn = (message: WorkerOutboundMessage) => void\nexport type WorkerMessageHandler = (message: WorkerInboundMessage, respond: RespondFn) => void\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WorkerCustomMethods = Record<string, (...args: any[]) => Promise<any>>\n\nexport type SerializedResult<T> = { __serialized__: T }\n\nexport function serializeResult<T>(result: T): SerializedResult<T> {\n if (ArrayBuffer.isView(result)) return result as unknown as SerializedResult<T>\n\n if (Array.isArray(result)) {\n return result.map(serializeResult) as unknown as SerializedResult<T>\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n result.set(key, serializeResult(value))\n }\n\n return result as unknown as SerializedResult<T>\n }\n\n if (result && typeof result === 'object') {\n // replace Long instances with a special object\n const newResult: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(result)) {\n if (Long.isLong(value)) {\n // eslint-disable-next-line\n newResult[key] = {\n __type: 'long',\n low: value.low,\n high: value.high,\n unsigned: value.unsigned,\n }\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n newResult[key] = serializeResult(value)\n } else {\n newResult[key] = value\n }\n }\n\n return newResult as unknown as SerializedResult<T>\n }\n\n return result as unknown as SerializedResult<T>\n}\n\nexport function deserializeResult<T>(result: SerializedResult<T>): T {\n if (ArrayBuffer.isView(result)) return result as unknown as T\n\n if (Array.isArray(result)) {\n return result.map(deserializeResult) as unknown as T\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n result.set(key, deserializeResult(value))\n }\n\n return result as unknown as T\n }\n\n if (result && typeof result === 'object') {\n for (const [key, value] of Object.entries(result)) {\n if (value && typeof value === 'object' && (value as Record<string, string>).__type === 'long') {\n // eslint-disable-next-line\n ;(result as any)[key] = Long.fromValue(value as unknown as Long)\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n ;(result as any)[key] = deserializeResult(value as SerializedResult<unknown>)\n }\n }\n }\n\n return result as unknown as T\n}\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import Long from 'long';
|
|
2
2
|
export function serializeResult(result) {
|
|
3
|
+
if (ArrayBuffer.isView(result))
|
|
4
|
+
return result;
|
|
3
5
|
if (Array.isArray(result)) {
|
|
4
6
|
return result.map(serializeResult);
|
|
5
7
|
}
|
|
@@ -35,6 +37,8 @@ export function serializeResult(result) {
|
|
|
35
37
|
return result;
|
|
36
38
|
}
|
|
37
39
|
export function deserializeResult(result) {
|
|
40
|
+
if (ArrayBuffer.isView(result))
|
|
41
|
+
return result;
|
|
38
42
|
if (Array.isArray(result)) {
|
|
39
43
|
return result.map(deserializeResult);
|
|
40
44
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../src/highlevel/worker/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AA+DvB,MAAM,UAAU,eAAe,CAAI,MAAS;IACxC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,C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AAG,CAAC,iBAAiB,CAAiB,CAAA;IACxD,CAAC;IAED,IAAI,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,iEAAiE;YACjE,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,MAAsB,CAAA;IACjC,CAAC;IAED,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAgC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC5F,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAwB,CAAC,CAAA;YACpE,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnC,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAkC,CAAC,CAAA;YACjF,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAsB,CAAA;AACjC,CAAC","sourcesContent":["import Long from 'long'\nimport type { Worker as NodeWorker } from 'node:worker_threads'\n\nimport { tl } from '@mtcute/tl'\n\nimport { ConnectionState } from '../client.types.js'\nimport { SerializedError } from './errors.js'\n\nexport type WorkerInboundMessage =\n | {\n type: 'invoke'\n id: number\n target: 'custom' | 'client' | 'storage' | 'storage-self' | 'storage-peers' | 'app-config'\n method: string\n args: SerializedResult<unknown[]>\n void: boolean\n withAbort: boolean\n }\n | {\n type: 'abort'\n id: number\n }\n\nexport type WorkerOutboundMessage =\n | { type: 'server_update'; update: SerializedResult<tl.TypeUpdates> }\n | {\n type: 'update'\n update: SerializedResult<tl.TypeUpdate>\n users: SerializedResult<Map<number, tl.TypeUser>>\n chats: SerializedResult<Map<number, tl.TypeChat>>\n hasMin: boolean\n }\n | { type: 'error'; error: unknown }\n | { type: 'stop' }\n | { type: 'conn_state'; state: ConnectionState }\n | {\n type: 'log'\n color: number\n level: number\n tag: string\n fmt: string\n args: unknown[]\n }\n | {\n type: 'result'\n id: number\n result?: SerializedResult<unknown>\n error?: SerializedError\n }\n\nexport type SomeWorker = NodeWorker | Worker | SharedWorker\n\nexport type SendFn = (message: WorkerInboundMessage) => void\nexport type ClientMessageHandler = (message: WorkerOutboundMessage) => void\n\nexport type RespondFn = (message: WorkerOutboundMessage) => void\nexport type WorkerMessageHandler = (message: WorkerInboundMessage, respond: RespondFn) => void\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WorkerCustomMethods = Record<string, (...args: any[]) => Promise<any>>\n\nexport type SerializedResult<T> = { __serialized__: T }\n\nexport function serializeResult<T>(result: T): SerializedResult<T> {\n if (Array.isArray(result)) {\n return result.map(serializeResult) as unknown as SerializedResult<T>\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n result.set(key, serializeResult(value))\n }\n\n return result as unknown as SerializedResult<T>\n }\n\n if (result && typeof result === 'object') {\n // replace Long instances with a special object\n const newResult: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(result)) {\n if (Long.isLong(value)) {\n // eslint-disable-next-line\n newResult[key] = {\n __type: 'long',\n low: value.low,\n high: value.high,\n unsigned: value.unsigned,\n }\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n newResult[key] = serializeResult(value)\n } else {\n newResult[key] = value\n }\n }\n\n return newResult as unknown as SerializedResult<T>\n }\n\n return result as unknown as SerializedResult<T>\n}\n\nexport function deserializeResult<T>(result: SerializedResult<T>): T {\n if (Array.isArray(result)) {\n return result.map(deserializeResult) as unknown as T\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n result.set(key, deserializeResult(value))\n }\n\n return result as unknown as T\n }\n\n if (result && typeof result === 'object') {\n for (const [key, value] of Object.entries(result)) {\n if (value && typeof value === 'object' && (value as Record<string, string>).__type === 'long') {\n // eslint-disable-next-line\n ;(result as any)[key] = Long.fromValue(value as unknown as Long)\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n ;(result as any)[key] = deserializeResult(value as SerializedResult<unknown>)\n }\n }\n }\n\n return result as unknown as T\n}\n"]}
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../../src/highlevel/worker/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,MAAM,CAAA;AA+DvB,MAAM,UAAU,eAAe,CAAI,MAAS;IACxC,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC;QAAE,OAAO,MAAwC,CAAA;IAE/E,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxB,OAAO,MAAM,CAAC,GAAG,CAAC,eAAe,CAAmC,CAAA;IACxE,CAAC;IAED,IAAI,MAAM,YAAY,GAAG,EAAE,CAAC;QACxB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,EAAE,EAAE,CAAC;YAC1C,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,CAAC,CAAA;QAC3C,CAAC;QAED,OAAO,MAAwC,CAAA;IACnD,CAAC;IAED,IAAI,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QACvC,+CAA+C;QAC/C,MAAM,SAAS,GAA4B,EAAE,CAAA;QAE7C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YACh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CAAC,MAAM,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAK,KAAgC,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;gBAC5F,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAwB,CAAC,CAAA;YACpE,CAAC;iBAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBACnC,2BAA2B;gBAC3B,CAAC;gBAAC,MAAc,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,KAAkC,CAAC,CAAA;YACjF,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,MAAsB,CAAA;AACjC,CAAC","sourcesContent":["import Long from 'long'\nimport type { Worker as NodeWorker } from 'node:worker_threads'\n\nimport { tl } from '@mtcute/tl'\n\nimport { ConnectionState } from '../client.types.js'\nimport { SerializedError } from './errors.js'\n\nexport type WorkerInboundMessage =\n | {\n type: 'invoke'\n id: number\n target: 'custom' | 'client' | 'storage' | 'storage-self' | 'storage-peers' | 'app-config'\n method: string\n args: SerializedResult<unknown[]>\n void: boolean\n withAbort: boolean\n }\n | {\n type: 'abort'\n id: number\n }\n\nexport type WorkerOutboundMessage =\n | { type: 'server_update'; update: SerializedResult<tl.TypeUpdates> }\n | {\n type: 'update'\n update: SerializedResult<tl.TypeUpdate>\n users: SerializedResult<Map<number, tl.TypeUser>>\n chats: SerializedResult<Map<number, tl.TypeChat>>\n hasMin: boolean\n }\n | { type: 'error'; error: unknown }\n | { type: 'stop' }\n | { type: 'conn_state'; state: ConnectionState }\n | {\n type: 'log'\n color: number\n level: number\n tag: string\n fmt: string\n args: unknown[]\n }\n | {\n type: 'result'\n id: number\n result?: SerializedResult<unknown>\n error?: SerializedError\n }\n\nexport type SomeWorker = NodeWorker | Worker | SharedWorker\n\nexport type SendFn = (message: WorkerInboundMessage) => void\nexport type ClientMessageHandler = (message: WorkerOutboundMessage) => void\n\nexport type RespondFn = (message: WorkerOutboundMessage) => void\nexport type WorkerMessageHandler = (message: WorkerInboundMessage, respond: RespondFn) => void\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type WorkerCustomMethods = Record<string, (...args: any[]) => Promise<any>>\n\nexport type SerializedResult<T> = { __serialized__: T }\n\nexport function serializeResult<T>(result: T): SerializedResult<T> {\n if (ArrayBuffer.isView(result)) return result as unknown as SerializedResult<T>\n\n if (Array.isArray(result)) {\n return result.map(serializeResult) as unknown as SerializedResult<T>\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n result.set(key, serializeResult(value))\n }\n\n return result as unknown as SerializedResult<T>\n }\n\n if (result && typeof result === 'object') {\n // replace Long instances with a special object\n const newResult: Record<string, unknown> = {}\n\n for (const [key, value] of Object.entries(result)) {\n if (Long.isLong(value)) {\n // eslint-disable-next-line\n newResult[key] = {\n __type: 'long',\n low: value.low,\n high: value.high,\n unsigned: value.unsigned,\n }\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n newResult[key] = serializeResult(value)\n } else {\n newResult[key] = value\n }\n }\n\n return newResult as unknown as SerializedResult<T>\n }\n\n return result as unknown as SerializedResult<T>\n}\n\nexport function deserializeResult<T>(result: SerializedResult<T>): T {\n if (ArrayBuffer.isView(result)) return result as unknown as T\n\n if (Array.isArray(result)) {\n return result.map(deserializeResult) as unknown as T\n }\n\n if (result instanceof Map) {\n for (const [key, value] of result.entries()) {\n // eslint-disable-next-line @typescript-eslint/no-unsafe-argument\n result.set(key, deserializeResult(value))\n }\n\n return result as unknown as T\n }\n\n if (result && typeof result === 'object') {\n for (const [key, value] of Object.entries(result)) {\n if (value && typeof value === 'object' && (value as Record<string, string>).__type === 'long') {\n // eslint-disable-next-line\n ;(result as any)[key] = Long.fromValue(value as unknown as Long)\n } else if (typeof value === 'object') {\n // eslint-disable-next-line\n ;(result as any)[key] = deserializeResult(value as SerializedResult<unknown>)\n }\n }\n }\n\n return result as unknown as T\n}\n"]}
|
|
@@ -255,7 +255,7 @@ export class NetworkManager {
|
|
|
255
255
|
_: 'initConnection',
|
|
256
256
|
deviceModel,
|
|
257
257
|
systemVersion: '1.0',
|
|
258
|
-
appVersion: '0.16.
|
|
258
|
+
appVersion: '0.16.4',
|
|
259
259
|
systemLangCode: 'en',
|
|
260
260
|
langPack: '', // "langPacks are for official apps only"
|
|
261
261
|
langCode: 'en',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mtcute/core",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.4",
|
|
4
4
|
"description": "Type-safe library for MTProto (Telegram API)",
|
|
5
5
|
"author": "alina sireneva <alina@tei.su>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
}
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@mtcute/tl": "^185.
|
|
37
|
+
"@mtcute/tl": "^185.1.0",
|
|
38
38
|
"@mtcute/tl-runtime": "^0.16.0",
|
|
39
39
|
"@mtcute/file-id": "^0.16.0",
|
|
40
40
|
"@types/events": "3.0.0",
|