@mtcute/web 0.16.0 → 0.16.6

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/README.md CHANGED
@@ -19,9 +19,8 @@ const tg = new TelegramClient({
19
19
  storage: 'my-account'
20
20
  })
21
21
 
22
- tg.run(async (user) => {
23
- console.log(`✨ logged in as ${user.displayName}`)
24
- })
22
+ const self = await tg.start()
23
+ console.log(`✨ logged in as ${self.displayName}`)
25
24
  ```
26
25
 
27
26
  ## Usage with workers
@@ -47,7 +46,6 @@ const worker = new Worker(new URL('./worker.ts', import.meta.url), { type: 'modu
47
46
  const port = new TelegramWorkerPort({ worker })
48
47
  const tg = new TelegramClient({ client: port })
49
48
 
50
- tg.run({}, async (user) => {
51
- console.log(`✨ logged in as ${user.displayName}`)
52
- })
49
+ const self = await tg.start()
50
+ console.log(`✨ logged in as ${user.displayName}`)
53
51
  ```
package/cjs/client.js CHANGED
@@ -33,6 +33,7 @@ class TelegramClient extends client_js_1.TelegramClient {
33
33
  }
34
34
  super({
35
35
  client: new BaseTelegramClient(opts),
36
+ disableUpdates: opts.disableUpdates,
36
37
  });
37
38
  }
38
39
  }
package/cjs/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AACA,sDAK+B;AAC/B,0DAAsD;AAEtD,2CAA+C;AAC/C,6CAA2C;AAC3C,+CAA2C;AAC3C,iDAAmD;AAyBnD,MAAa,kBAAmB,SAAQ,8BAAsB;IAC1D,YAAY,IAA+B;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,IAAA,yBAAW,EAAC,IAAI,yBAAW,EAAE,CAAC,CAAA;QAEtD,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,6BAAiB,EAAE;YAC/B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,iCAAkB,EAAE;YACzC,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,qBAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,OAAO,IAAI,IAAI,qBAAU,CAAC,gBAAgB,CAAC;SAC3D,CAAC,CAAA;IACN,CAAC;CACJ;AAdD,gDAcC;AAED;;GAEG;AACH,MAAa,cAAe,SAAQ,0BAAkB;IAClD,YAAY,IAA2B;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,CAAA;YAEX,OAAM;QACV,CAAC;QAED,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;SACvC,CAAC,CAAA;IACN,CAAC;CACJ;AAZD,wCAYC","sourcesContent":["import { ITelegramStorageProvider, PartialOnly } from '@mtcute/core'\nimport {\n BaseTelegramClient as BaseTelegramClientBase,\n BaseTelegramClientOptions as BaseTelegramClientOptionsBase,\n TelegramClient as TelegramClientBase,\n TelegramClientOptions,\n} from '@mtcute/core/client.js'\nimport { setPlatform } from '@mtcute/core/platform.js'\n\nimport { WebCryptoProvider } from './crypto.js'\nimport { IdbStorage } from './idb/index.js'\nimport { WebPlatform } from './platform.js'\nimport { WebSocketTransport } from './websocket.js'\n\nexport type { TelegramClientOptions }\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 IndexedDB database.\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 WebPlatform())\n\n super({\n crypto: new WebCryptoProvider(),\n transport: () => new WebSocketTransport(),\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new IdbStorage(opts.storage) :\n opts.storage ?? new IdbStorage('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 })\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;AACA,sDAK+B;AAC/B,0DAAsD;AAEtD,2CAA+C;AAC/C,6CAA2C;AAC3C,+CAA2C;AAC3C,iDAAmD;AAyBnD,MAAa,kBAAmB,SAAQ,8BAAsB;IAC1D,YAAY,IAA+B;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,IAAA,yBAAW,EAAC,IAAI,yBAAW,EAAE,CAAC,CAAA;QAEtD,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,6BAAiB,EAAE;YAC/B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,iCAAkB,EAAE;YACzC,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,qBAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,OAAO,IAAI,IAAI,qBAAU,CAAC,gBAAgB,CAAC;SAC3D,CAAC,CAAA;IACN,CAAC;CACJ;AAdD,gDAcC;AAED;;GAEG;AACH,MAAa,cAAe,SAAQ,0BAAkB;IAClD,YAAY,IAA2B;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,CAAA;YAEX,OAAM;QACV,CAAC;QAED,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAA;IACN,CAAC;CACJ;AAbD,wCAaC","sourcesContent":["import { ITelegramStorageProvider, PartialOnly } from '@mtcute/core'\nimport {\n BaseTelegramClient as BaseTelegramClientBase,\n BaseTelegramClientOptions as BaseTelegramClientOptionsBase,\n TelegramClient as TelegramClientBase,\n TelegramClientOptions,\n} from '@mtcute/core/client.js'\nimport { setPlatform } from '@mtcute/core/platform.js'\n\nimport { WebCryptoProvider } from './crypto.js'\nimport { IdbStorage } from './idb/index.js'\nimport { WebPlatform } from './platform.js'\nimport { WebSocketTransport } from './websocket.js'\n\nexport type { TelegramClientOptions }\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 IndexedDB database.\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 WebPlatform())\n\n super({\n crypto: new WebCryptoProvider(),\n transport: () => new WebSocketTransport(),\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new IdbStorage(opts.storage) :\n opts.storage ?? new IdbStorage('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 })\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from '@mtcute/core/methods.js';
package/cjs/methods.js ADDED
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ if (typeof globalThis !== 'undefined' && !globalThis._MTCUTE_CJS_DEPRECATION_WARNED) {
3
+ globalThis._MTCUTE_CJS_DEPRECATION_WARNED = true
4
+ console.warn("[@mtcute/web] CommonJS support is deprecated and will be removed soon. Please consider switching to ESM, it's "+(new Date()).getFullYear()+" already.")
5
+ console.warn("[@mtcute/web] 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("@mtcute/core/methods.js"), exports);
24
+ //# sourceMappingURL=methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/methods.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0DAAuC","sourcesContent":["export * from '@mtcute/core/methods.js'\n"]}
package/esm/client.js CHANGED
@@ -29,6 +29,7 @@ export class TelegramClient extends TelegramClientBase {
29
29
  }
30
30
  super({
31
31
  client: new BaseTelegramClient(opts),
32
+ disableUpdates: opts.disableUpdates,
32
33
  });
33
34
  }
34
35
  }
package/esm/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACH,kBAAkB,IAAI,sBAAsB,EAE5C,cAAc,IAAI,kBAAkB,GAEvC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAyBnD,MAAM,OAAO,kBAAmB,SAAQ,sBAAsB;IAC1D,YAAY,IAA+B;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,WAAW,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;QAEtD,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,iBAAiB,EAAE;YAC/B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,kBAAkB,EAAE;YACzC,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,OAAO,IAAI,IAAI,UAAU,CAAC,gBAAgB,CAAC;SAC3D,CAAC,CAAA;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,kBAAkB;IAClD,YAAY,IAA2B;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,CAAA;YAEX,OAAM;QACV,CAAC;QAED,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;SACvC,CAAC,CAAA;IACN,CAAC;CACJ","sourcesContent":["import { ITelegramStorageProvider, PartialOnly } from '@mtcute/core'\nimport {\n BaseTelegramClient as BaseTelegramClientBase,\n BaseTelegramClientOptions as BaseTelegramClientOptionsBase,\n TelegramClient as TelegramClientBase,\n TelegramClientOptions,\n} from '@mtcute/core/client.js'\nimport { setPlatform } from '@mtcute/core/platform.js'\n\nimport { WebCryptoProvider } from './crypto.js'\nimport { IdbStorage } from './idb/index.js'\nimport { WebPlatform } from './platform.js'\nimport { WebSocketTransport } from './websocket.js'\n\nexport type { TelegramClientOptions }\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 IndexedDB database.\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 WebPlatform())\n\n super({\n crypto: new WebCryptoProvider(),\n transport: () => new WebSocketTransport(),\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new IdbStorage(opts.storage) :\n opts.storage ?? new IdbStorage('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 })\n }\n}\n"]}
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EACH,kBAAkB,IAAI,sBAAsB,EAE5C,cAAc,IAAI,kBAAkB,GAEvC,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AAyBnD,MAAM,OAAO,kBAAmB,SAAQ,sBAAsB;IAC1D,YAAY,IAA+B;QACvC,IAAI,CAAC,IAAI,CAAC,YAAY;YAAE,WAAW,CAAC,IAAI,WAAW,EAAE,CAAC,CAAA;QAEtD,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,iBAAiB,EAAE;YAC/B,SAAS,EAAE,GAAG,EAAE,CAAC,IAAI,kBAAkB,EAAE;YACzC,GAAG,IAAI;YACP,OAAO,EACH,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC;gBAC9B,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC;gBAC9B,IAAI,CAAC,OAAO,IAAI,IAAI,UAAU,CAAC,gBAAgB,CAAC;SAC3D,CAAC,CAAA;IACN,CAAC;CACJ;AAED;;GAEG;AACH,MAAM,OAAO,cAAe,SAAQ,kBAAkB;IAClD,YAAY,IAA2B;QACnC,IAAI,QAAQ,IAAI,IAAI,EAAE,CAAC;YACnB,KAAK,CAAC,IAAI,CAAC,CAAA;YAEX,OAAM;QACV,CAAC;QAED,KAAK,CAAC;YACF,MAAM,EAAE,IAAI,kBAAkB,CAAC,IAAI,CAAC;YACpC,cAAc,EAAE,IAAI,CAAC,cAAc;SACtC,CAAC,CAAA;IACN,CAAC;CACJ","sourcesContent":["import { ITelegramStorageProvider, PartialOnly } from '@mtcute/core'\nimport {\n BaseTelegramClient as BaseTelegramClientBase,\n BaseTelegramClientOptions as BaseTelegramClientOptionsBase,\n TelegramClient as TelegramClientBase,\n TelegramClientOptions,\n} from '@mtcute/core/client.js'\nimport { setPlatform } from '@mtcute/core/platform.js'\n\nimport { WebCryptoProvider } from './crypto.js'\nimport { IdbStorage } from './idb/index.js'\nimport { WebPlatform } from './platform.js'\nimport { WebSocketTransport } from './websocket.js'\n\nexport type { TelegramClientOptions }\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 IndexedDB database.\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 WebPlatform())\n\n super({\n crypto: new WebCryptoProvider(),\n transport: () => new WebSocketTransport(),\n ...opts,\n storage:\n typeof opts.storage === 'string' ?\n new IdbStorage(opts.storage) :\n opts.storage ?? new IdbStorage('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 })\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ export * from '@mtcute/core/methods.js';
package/esm/methods.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from '@mtcute/core/methods.js';
2
+ //# sourceMappingURL=methods.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"methods.js","sourceRoot":"","sources":["../../src/methods.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAA","sourcesContent":["export * from '@mtcute/core/methods.js'\n"]}
package/methods.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './esm/methods.js'
package/methods.js ADDED
@@ -0,0 +1 @@
1
+ export * from './esm/methods.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mtcute/web",
3
- "version": "0.16.0",
3
+ "version": "0.16.6",
4
4
  "description": "Meta-package for the web platform",
5
5
  "author": "alina sireneva <alina@tei.su>",
6
6
  "license": "MIT",
@@ -15,10 +15,14 @@
15
15
  "./utils.js": {
16
16
  "import": "./esm/utils.js",
17
17
  "require": "./cjs/utils.js"
18
+ },
19
+ "./methods.js": {
20
+ "import": "./esm/methods.js",
21
+ "require": "./cjs/methods.js"
18
22
  }
19
23
  },
20
24
  "dependencies": {
21
- "@mtcute/core": "^0.16.0",
25
+ "@mtcute/core": "^0.16.6",
22
26
  "@mtcute/wasm": "^0.16.0",
23
27
  "events": "3.2.0"
24
28
  },