@mtcute/core 0.16.1 → 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.
Files changed (52) hide show
  1. package/README.md +2 -3
  2. package/cjs/highlevel/client.d.ts +1 -0
  3. package/cjs/highlevel/client.js.map +1 -1
  4. package/cjs/highlevel/methods/auth/run.d.ts +1 -0
  5. package/cjs/highlevel/methods/auth/run.js +1 -0
  6. package/cjs/highlevel/methods/auth/run.js.map +1 -1
  7. package/cjs/highlevel/methods/files/normalize-input-media.js +1 -1
  8. package/cjs/highlevel/methods/files/normalize-input-media.js.map +1 -1
  9. package/cjs/highlevel/types/media/video.d.ts +1 -0
  10. package/cjs/highlevel/types/media/video.js +3 -0
  11. package/cjs/highlevel/types/media/video.js.map +1 -1
  12. package/cjs/highlevel/types/messages/message-action.d.ts +15 -1
  13. package/cjs/highlevel/types/messages/message-action.js +9 -0
  14. package/cjs/highlevel/types/messages/message-action.js.map +1 -1
  15. package/cjs/highlevel/types/peers/user.d.ts +4 -0
  16. package/cjs/highlevel/types/peers/user.js +8 -0
  17. package/cjs/highlevel/types/peers/user.js.map +1 -1
  18. package/cjs/highlevel/types/stories/interactive/index.d.ts +3 -2
  19. package/cjs/highlevel/types/stories/interactive/index.js +5 -1
  20. package/cjs/highlevel/types/stories/interactive/index.js.map +1 -1
  21. package/cjs/highlevel/types/stories/interactive/weather.d.ts +15 -0
  22. package/cjs/highlevel/types/stories/interactive/weather.js +30 -0
  23. package/cjs/highlevel/types/stories/interactive/weather.js.map +1 -0
  24. package/cjs/highlevel/worker/protocol.js +4 -0
  25. package/cjs/highlevel/worker/protocol.js.map +1 -1
  26. package/cjs/network/network-manager.js +1 -1
  27. package/esm/highlevel/client.d.ts +1 -0
  28. package/esm/highlevel/client.js.map +1 -1
  29. package/esm/highlevel/methods/auth/run.d.ts +1 -0
  30. package/esm/highlevel/methods/auth/run.js +1 -0
  31. package/esm/highlevel/methods/auth/run.js.map +1 -1
  32. package/esm/highlevel/methods/files/normalize-input-media.js +1 -1
  33. package/esm/highlevel/methods/files/normalize-input-media.js.map +1 -1
  34. package/esm/highlevel/types/media/video.d.ts +1 -0
  35. package/esm/highlevel/types/media/video.js +3 -0
  36. package/esm/highlevel/types/media/video.js.map +1 -1
  37. package/esm/highlevel/types/messages/message-action.d.ts +15 -1
  38. package/esm/highlevel/types/messages/message-action.js +9 -0
  39. package/esm/highlevel/types/messages/message-action.js.map +1 -1
  40. package/esm/highlevel/types/peers/user.d.ts +4 -0
  41. package/esm/highlevel/types/peers/user.js +8 -0
  42. package/esm/highlevel/types/peers/user.js.map +1 -1
  43. package/esm/highlevel/types/stories/interactive/index.d.ts +3 -2
  44. package/esm/highlevel/types/stories/interactive/index.js +4 -1
  45. package/esm/highlevel/types/stories/interactive/index.js.map +1 -1
  46. package/esm/highlevel/types/stories/interactive/weather.d.ts +15 -0
  47. package/esm/highlevel/types/stories/interactive/weather.js +27 -0
  48. package/esm/highlevel/types/stories/interactive/weather.js.map +1 -0
  49. package/esm/highlevel/worker/protocol.js +4 -0
  50. package/esm/highlevel/worker/protocol.js.map +1 -1
  51. package/esm/network/network-manager.js +1 -1
  52. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAElD,cAAc,YAAY,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,GACxB,CAAA;AASD,MAAM,UAAU,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,cAAc;YACf,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACvC,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,oBAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../../types/errors.js'\nimport { PeersIndex } from '../../peers/index.js'\nimport { StoryInteractiveChannelPost } from './channel-post.js'\nimport { StoryInteractiveLocation } from './location.js'\nimport { StoryInteractiveReaction } from './reaction.js'\nimport { StoryInteractiveUrl } from './url.js'\nimport { StoryInteractiveVenue } from './venue.js'\n\nexport * from './input.js'\nexport {\n StoryInteractiveChannelPost,\n StoryInteractiveLocation,\n StoryInteractiveReaction,\n StoryInteractiveUrl,\n StoryInteractiveVenue,\n}\n\nexport type StoryInteractiveElement =\n | StoryInteractiveReaction\n | StoryInteractiveLocation\n | StoryInteractiveVenue\n | StoryInteractiveChannelPost\n | StoryInteractiveUrl\n\nexport function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {\n switch (raw._) {\n case 'mediaAreaSuggestedReaction':\n return new StoryInteractiveReaction(raw)\n case 'mediaAreaGeoPoint':\n return new StoryInteractiveLocation(raw)\n case 'mediaAreaVenue':\n return new StoryInteractiveVenue(raw)\n case 'mediaAreaChannelPost':\n return new StoryInteractiveChannelPost(raw, peers)\n case 'mediaAreaUrl':\n return new StoryInteractiveUrl(raw)\n case 'inputMediaAreaVenue':\n case 'inputMediaAreaChannelPost':\n throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAA;AAElE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,eAAe,CAAA;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAEtD,cAAc,YAAY,CAAA;AAC1B,OAAO,EACH,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,qBAAqB,EACrB,uBAAuB,GAC1B,CAAA;AAUD,MAAM,UAAU,8BAA8B,CAAC,GAAqB,EAAE,KAAiB;IACnF,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC;QACZ,KAAK,4BAA4B;YAC7B,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,mBAAmB;YACpB,OAAO,IAAI,wBAAwB,CAAC,GAAG,CAAC,CAAA;QAC5C,KAAK,gBAAgB;YACjB,OAAO,IAAI,qBAAqB,CAAC,GAAG,CAAC,CAAA;QACzC,KAAK,sBAAsB;YACvB,OAAO,IAAI,2BAA2B,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACtD,KAAK,cAAc;YACf,OAAO,IAAI,mBAAmB,CAAC,GAAG,CAAC,CAAA;QACvC,KAAK,kBAAkB;YACnB,OAAO,IAAI,uBAAuB,CAAC,GAAG,CAAC,CAAA;QAC3C,KAAK,qBAAqB,CAAC;QAC3B,KAAK,2BAA2B;YAC5B,MAAM,IAAI,oBAAoB,CAAC,yBAAyB,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;IACnF,CAAC;AACL,CAAC","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { MtTypeAssertionError } from '../../../../types/errors.js'\nimport { PeersIndex } from '../../peers/index.js'\nimport { StoryInteractiveChannelPost } from './channel-post.js'\nimport { StoryInteractiveLocation } from './location.js'\nimport { StoryInteractiveReaction } from './reaction.js'\nimport { StoryInteractiveUrl } from './url.js'\nimport { StoryInteractiveVenue } from './venue.js'\nimport { StoryInteractiveWeather } from './weather.js'\n\nexport * from './input.js'\nexport {\n StoryInteractiveChannelPost,\n StoryInteractiveLocation,\n StoryInteractiveReaction,\n StoryInteractiveUrl,\n StoryInteractiveVenue,\n StoryInteractiveWeather,\n}\n\nexport type StoryInteractiveElement =\n | StoryInteractiveReaction\n | StoryInteractiveLocation\n | StoryInteractiveVenue\n | StoryInteractiveChannelPost\n | StoryInteractiveUrl\n | StoryInteractiveWeather\n\nexport function _storyInteractiveElementFromTl(raw: tl.TypeMediaArea, peers: PeersIndex): StoryInteractiveElement {\n switch (raw._) {\n case 'mediaAreaSuggestedReaction':\n return new StoryInteractiveReaction(raw)\n case 'mediaAreaGeoPoint':\n return new StoryInteractiveLocation(raw)\n case 'mediaAreaVenue':\n return new StoryInteractiveVenue(raw)\n case 'mediaAreaChannelPost':\n return new StoryInteractiveChannelPost(raw, peers)\n case 'mediaAreaUrl':\n return new StoryInteractiveUrl(raw)\n case 'mediaAreaWeather':\n return new StoryInteractiveWeather(raw)\n case 'inputMediaAreaVenue':\n case 'inputMediaAreaChannelPost':\n throw new MtTypeAssertionError('StoryInteractiveElement', '!input*', raw._)\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import { tl } from '@mtcute/tl';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a weather info
5
+ */
6
+ export declare class StoryInteractiveWeather extends StoryInteractiveArea {
7
+ readonly raw: tl.RawMediaAreaWeather;
8
+ readonly type: "weather";
9
+ constructor(raw: tl.RawMediaAreaWeather);
10
+ /** Emoji representing the weather */
11
+ get emoji(): string;
12
+ /** Temperature in Celsius */
13
+ get temperature(): number;
14
+ get color(): number;
15
+ }
@@ -0,0 +1,27 @@
1
+ import { makeInspectable } from '../../../utils/index.js';
2
+ import { StoryInteractiveArea } from './base.js';
3
+ /**
4
+ * Interactive element containing a weather info
5
+ */
6
+ class StoryInteractiveWeather extends StoryInteractiveArea {
7
+ raw;
8
+ type = 'weather';
9
+ constructor(raw) {
10
+ super(raw);
11
+ this.raw = raw;
12
+ }
13
+ /** Emoji representing the weather */
14
+ get emoji() {
15
+ return this.raw.emoji;
16
+ }
17
+ /** Temperature in Celsius */
18
+ get temperature() {
19
+ return this.raw.temperatureC;
20
+ }
21
+ get color() {
22
+ return this.raw.color;
23
+ }
24
+ }
25
+ const StoryInteractiveWeather$1 = /*#__PURE__*/makeInspectable(StoryInteractiveWeather, );
26
+ //# sourceMappingURL=weather.js.map
27
+ export { StoryInteractiveWeather$1 as StoryInteractiveWeather }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"weather.js","sourceRoot":"","sources":["../../../../../../src/highlevel/types/stories/interactive/weather.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD;;GAEG;AACH,MAAM,OAAO,uBAAwB,SAAQ,oBAAoB;IAGxC;IAFZ,IAAI,GAAG,SAAkB,CAAA;IAElC,YAAqB,GAA2B;QAC5C,KAAK,CAAC,GAAG,CAAC,CAAA;QADO,QAAG,GAAH,GAAG,CAAwB;IAEhD,CAAC;IAED,qCAAqC;IACrC,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;IAED,6BAA6B;IAC7B,IAAI,WAAW;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAAA;IAChC,CAAC;IAED,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,CAAA;IACzB,CAAC;CACJ;AAED,eAAe,CAAC,uBAAuB,CAAC,CAAA","sourcesContent":["import { tl } from '@mtcute/tl'\n\nimport { makeInspectable } from '../../../utils/index.js'\nimport { StoryInteractiveArea } from './base.js'\n\n/**\n * Interactive element containing a weather info\n */\nexport class StoryInteractiveWeather extends StoryInteractiveArea {\n readonly type = 'weather' as const\n\n constructor(readonly raw: tl.RawMediaAreaWeather) {\n super(raw)\n }\n\n /** Emoji representing the weather */\n get emoji(): string {\n return this.raw.emoji\n }\n\n /** Temperature in Celsius */\n get temperature(): number {\n return this.raw.temperatureC\n }\n\n get color(): number {\n return this.raw.color\n }\n}\n\nmakeInspectable(StoryInteractiveWeather)\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,eA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,MAA2B;IAC5D,IAAI,KAAK,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,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,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Q,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 (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.1',
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.1",
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": "^184.0.0",
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",