@mtkruto/browser 0.119.0 → 0.120.0

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 (128) hide show
  1. package/README.md +1 -1
  2. package/esm/0_errors.d.ts.map +1 -1
  3. package/esm/0_errors.js +9 -31
  4. package/esm/3_errors.js +2 -12
  5. package/esm/4_errors.js +2 -12
  6. package/esm/_dnt.polyfills.d.ts +0 -99
  7. package/esm/_dnt.polyfills.d.ts.map +1 -1
  8. package/esm/_dnt.polyfills.js +1 -127
  9. package/esm/client/0_abortable_loop.js +26 -39
  10. package/esm/client/0_storage_operations.js +179 -218
  11. package/esm/client/1_client_plain.js +4 -22
  12. package/esm/client/2_account_manager.js +140 -149
  13. package/esm/client/2_bot_info_manager.js +26 -38
  14. package/esm/client/2_business_connection_manager.js +10 -23
  15. package/esm/client/2_client_encrypted.js +198 -215
  16. package/esm/client/2_file_manager.js +255 -262
  17. package/esm/client/2_network_statistics_manager.js +31 -44
  18. package/esm/client/2_payment_manager.js +7 -20
  19. package/esm/client/2_reaction_manager.js +7 -20
  20. package/esm/client/2_translations_manager.js +101 -111
  21. package/esm/client/2_update_manager.js +750 -745
  22. package/esm/client/3_client_encrypted_pool.js +10 -26
  23. package/esm/client/3_message_manager.js +503 -508
  24. package/esm/client/3_video_chat_manager.js +57 -68
  25. package/esm/client/4_callback_query_manager.js +18 -30
  26. package/esm/client/4_chat_list_manager.js +140 -146
  27. package/esm/client/4_chat_manager.js +161 -169
  28. package/esm/client/4_checklist_manager.js +26 -39
  29. package/esm/client/4_context.js +244 -259
  30. package/esm/client/4_forum_manager.js +67 -73
  31. package/esm/client/4_gift_manager.js +22 -35
  32. package/esm/client/4_inline_query_manager.js +16 -28
  33. package/esm/client/4_link_preview_manager.js +6 -19
  34. package/esm/client/4_poll_manager.js +44 -57
  35. package/esm/client/4_story_manager.js +41 -53
  36. package/esm/client/5_composer.js +13 -26
  37. package/esm/client/6_client.js +866 -896
  38. package/esm/client/6_client_dispatcher.js +308 -325
  39. package/esm/client/7_client_worker.js +16 -29
  40. package/esm/connection/1_connection_tcp.js +55 -82
  41. package/esm/connection/1_connection_web_socket.js +75 -91
  42. package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  43. package/esm/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  44. package/esm/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  45. package/esm/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  46. package/esm/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  47. package/esm/session/0_session_state.js +12 -38
  48. package/esm/session/1_session.js +49 -72
  49. package/esm/session/2_session_encrypted.js +422 -420
  50. package/esm/storage/2_storage_indexed_db.js +26 -44
  51. package/esm/storage/2_storage_local_storage.js +3 -16
  52. package/esm/storage/2_storage_memory.js +24 -41
  53. package/esm/storage/2_storage_session_storage.js +3 -16
  54. package/esm/tl/1_tl_reader.d.ts +1 -1
  55. package/esm/tl/1_tl_reader.d.ts.map +1 -1
  56. package/esm/tl/1_tl_reader.js +95 -103
  57. package/esm/tl/1_tl_writer.js +169 -178
  58. package/esm/transport/0_transport.js +1 -8
  59. package/esm/transport/1_transport_abridged.js +11 -24
  60. package/esm/transport/1_transport_intermediate.js +10 -23
  61. package/esm/utilities/0_mutex.js +4 -19
  62. package/esm/utilities/0_part_stream.js +11 -25
  63. package/esm/utilities/1_crypto.js +42 -53
  64. package/esm/utilities/2_queue.js +29 -47
  65. package/package.json +1 -1
  66. package/script/0_errors.d.ts.map +1 -1
  67. package/script/0_errors.js +9 -31
  68. package/script/3_errors.js +2 -12
  69. package/script/4_errors.js +2 -12
  70. package/script/_dnt.polyfills.d.ts +0 -99
  71. package/script/_dnt.polyfills.d.ts.map +1 -1
  72. package/script/_dnt.polyfills.js +0 -128
  73. package/script/client/0_abortable_loop.js +27 -40
  74. package/script/client/0_storage_operations.js +179 -218
  75. package/script/client/1_client_plain.js +4 -22
  76. package/script/client/2_account_manager.js +140 -149
  77. package/script/client/2_bot_info_manager.js +26 -38
  78. package/script/client/2_business_connection_manager.js +10 -23
  79. package/script/client/2_client_encrypted.js +199 -216
  80. package/script/client/2_file_manager.js +255 -262
  81. package/script/client/2_network_statistics_manager.js +32 -45
  82. package/script/client/2_payment_manager.js +7 -20
  83. package/script/client/2_reaction_manager.js +7 -20
  84. package/script/client/2_translations_manager.js +102 -112
  85. package/script/client/2_update_manager.js +750 -745
  86. package/script/client/3_client_encrypted_pool.js +10 -26
  87. package/script/client/3_message_manager.js +503 -508
  88. package/script/client/3_video_chat_manager.js +57 -68
  89. package/script/client/4_callback_query_manager.js +18 -30
  90. package/script/client/4_chat_list_manager.js +140 -146
  91. package/script/client/4_chat_manager.js +161 -169
  92. package/script/client/4_checklist_manager.js +26 -39
  93. package/script/client/4_context.js +244 -259
  94. package/script/client/4_forum_manager.js +67 -73
  95. package/script/client/4_gift_manager.js +22 -35
  96. package/script/client/4_inline_query_manager.js +16 -28
  97. package/script/client/4_link_preview_manager.js +6 -19
  98. package/script/client/4_poll_manager.js +44 -57
  99. package/script/client/4_story_manager.js +41 -53
  100. package/script/client/5_composer.js +13 -26
  101. package/script/client/6_client.js +866 -896
  102. package/script/client/6_client_dispatcher.js +308 -325
  103. package/script/client/7_client_worker.js +16 -29
  104. package/script/connection/1_connection_tcp.js +55 -82
  105. package/script/connection/1_connection_web_socket.js +75 -91
  106. package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
  107. package/script/deps/jsr.io/@std/async/1.2.0/mux_async_iterator.js +31 -47
  108. package/script/deps/jsr.io/@std/async/1.2.0/tee.js +11 -34
  109. package/script/deps/jsr.io/@std/cache/0.2.2/lru_cache.js +30 -47
  110. package/script/deps/jsr.io/@std/datetime/0.225.7/_date_time_formatter.js +4 -17
  111. package/script/session/0_session_state.js +12 -38
  112. package/script/session/1_session.js +49 -72
  113. package/script/session/2_session_encrypted.js +423 -421
  114. package/script/storage/2_storage_indexed_db.js +26 -44
  115. package/script/storage/2_storage_local_storage.js +3 -16
  116. package/script/storage/2_storage_memory.js +24 -41
  117. package/script/storage/2_storage_session_storage.js +3 -16
  118. package/script/tl/1_tl_reader.d.ts +1 -1
  119. package/script/tl/1_tl_reader.d.ts.map +1 -1
  120. package/script/tl/1_tl_reader.js +96 -104
  121. package/script/tl/1_tl_writer.js +170 -179
  122. package/script/transport/0_transport.js +1 -8
  123. package/script/transport/1_transport_abridged.js +11 -24
  124. package/script/transport/1_transport_intermediate.js +10 -23
  125. package/script/utilities/0_mutex.js +4 -19
  126. package/script/utilities/0_part_stream.js +11 -25
  127. package/script/utilities/1_crypto.js +43 -54
  128. package/script/utilities/2_queue.js +30 -48
package/README.md CHANGED
@@ -48,7 +48,7 @@ console.debug(pong);
48
48
 
49
49
  ```html
50
50
  <script type="module">
51
- import { Client, getRandomId } from "https://esm.sh/jsr/@mtkruto/mtkruto";
51
+ import { Client, getRandomId } from "https://cdn.jsdelivr.net/npm/@mtkruto/browser/esm/mod.js";
52
52
 
53
53
  const client = new Client();
54
54
  await client.connect();
@@ -1 +1 @@
1
- {"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;aAClB,IAAI,EAAE,MAAM;gBAAZ,IAAI,EAAE,MAAM;CAIzC;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAId,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAM3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
1
+ {"version":3,"file":"0_errors.d.ts","sourceRoot":"","sources":["../src/0_errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,8BAAsB,YAAa,SAAQ,KAAK;CAC/C;AAED,qBAAa,eAAgB,SAAQ,YAAY;gBACnC,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,WAAY,SAAQ,YAAY;gBAC/B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,UAAW,SAAQ,YAAY;gBAC9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,KAAK,CAAC;CAIzD;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,IAAI,EAAE,MAAM;CAKzB;AAED,qBAAa,OAAQ,SAAQ,YAAY;;IAC9B,IAAI,SAAa;gBAId,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE;IAM3C,IAAI,eAAe,IAAI,MAAM,CAE5B;IAED,IAAI,IAAI,IAAI,MAAM,EAAE,CAEnB;CACF"}
package/esm/0_errors.js CHANGED
@@ -17,18 +17,6 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
- if (kind === "m") throw new TypeError("Private method is not writable");
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
- };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _TLError_originalMessage, _TLError_path;
32
20
  export class MtkrutoError extends Error {
33
21
  }
34
22
  export class ConnectionError extends MtkrutoError {
@@ -50,36 +38,26 @@ export class InputError extends MtkrutoError {
50
38
  }
51
39
  }
52
40
  export class TransportError extends MtkrutoError {
41
+ code;
53
42
  constructor(code) {
54
43
  super(`Transport error: ${code}`);
55
- Object.defineProperty(this, "code", {
56
- enumerable: true,
57
- configurable: true,
58
- writable: true,
59
- value: code
60
- });
61
44
  this.name = "TransportError";
45
+ this.code = code;
62
46
  }
63
47
  }
64
48
  export class TLError extends MtkrutoError {
49
+ name = "TLError";
50
+ #originalMessage;
51
+ #path;
65
52
  constructor(message, path) {
66
53
  super(`${message}${path.length ? ` at ${path.join(" ")}` : ""}`);
67
- Object.defineProperty(this, "name", {
68
- enumerable: true,
69
- configurable: true,
70
- writable: true,
71
- value: "TLError"
72
- });
73
- _TLError_originalMessage.set(this, void 0);
74
- _TLError_path.set(this, void 0);
75
- __classPrivateFieldSet(this, _TLError_originalMessage, message, "f");
76
- __classPrivateFieldSet(this, _TLError_path, path, "f");
54
+ this.#originalMessage = message;
55
+ this.#path = path;
77
56
  }
78
57
  get originalMessage() {
79
- return __classPrivateFieldGet(this, _TLError_originalMessage, "f");
58
+ return this.#originalMessage;
80
59
  }
81
60
  get path() {
82
- return __classPrivateFieldGet(this, _TLError_path, "f");
61
+ return this.#path;
83
62
  }
84
63
  }
85
- _TLError_originalMessage = new WeakMap(), _TLError_path = new WeakMap();
package/esm/3_errors.js CHANGED
@@ -21,20 +21,10 @@ import { MtkrutoError } from "./0_errors.js";
21
21
  import { repr } from "./2_tl.js";
22
22
  export * from "./0_errors.js";
23
23
  export class TelegramError extends MtkrutoError {
24
+ errorCode;
25
+ errorMessage;
24
26
  constructor(params) {
25
27
  super(`${params.error_code}: ${params.error_message} (${repr(params.call)})`);
26
- Object.defineProperty(this, "errorCode", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
- Object.defineProperty(this, "errorMessage", {
33
- enumerable: true,
34
- configurable: true,
35
- writable: true,
36
- value: void 0
37
- });
38
28
  this.name = "TelegramError";
39
29
  this.errorCode = params.error_code;
40
30
  this.errorMessage = params.error_message;
package/esm/4_errors.js CHANGED
@@ -21,14 +21,9 @@ import { unreachable } from "./0_deps.js";
21
21
  import { map, TelegramError } from "./3_errors.js";
22
22
  export * from "./3_errors.js";
23
23
  export class FloodWait extends TelegramError {
24
+ seconds;
24
25
  constructor(params) {
25
26
  super(params);
26
- Object.defineProperty(this, "seconds", {
27
- enumerable: true,
28
- configurable: true,
29
- writable: true,
30
- value: void 0
31
- });
32
27
  const p = params.error_message.split("_");
33
28
  this.seconds = Number(p[p.length - 1]);
34
29
  if (isNaN(this.seconds)) {
@@ -37,14 +32,9 @@ export class FloodWait extends TelegramError {
37
32
  }
38
33
  }
39
34
  export class Migrate extends TelegramError {
35
+ dc;
40
36
  constructor(params) {
41
37
  super(params);
42
- Object.defineProperty(this, "dc", {
43
- enumerable: true,
44
- configurable: true,
45
- writable: true,
46
- value: void 0
47
- });
48
38
  const p = params.error_message.split("_");
49
39
  this.dc = Number(p[p.length - 1]);
50
40
  if (isNaN(this.dc)) {
@@ -24,103 +24,4 @@ declare global {
24
24
  }
25
25
  }
26
26
  export {};
27
- /**
28
- * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
29
- * but instead of using npm to install additional dependencies,
30
- * this approach manually consolidates cjs/mjs/d.ts into a single file.
31
- *
32
- * Note that this code might be imported multiple times
33
- * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
34
- * or Node.js might dynamically clear the cache and then force a require).
35
- * Therefore, it's important to avoid redundant writes to global objects.
36
- * Additionally, consider that commonjs is used alongside esm,
37
- * so the two ponyfill functions are stored independently in two separate global objects.
38
- */
39
- import { createRequire } from "node:module";
40
- import { type URL } from "node:url";
41
- declare global {
42
- interface ImportMeta {
43
- /** A string representation of the fully qualified module URL. When the
44
- * module is loaded locally, the value will be a file URL (e.g.
45
- * `file:///path/module.ts`).
46
- *
47
- * You can also parse the string as a URL to determine more information about
48
- * how the current module was loaded. For example to determine if a module was
49
- * local or not:
50
- *
51
- * ```ts
52
- * const url = new URL(import.meta.url);
53
- * if (url.protocol === "file:") {
54
- * console.log("this module was loaded locally");
55
- * }
56
- * ```
57
- */
58
- url: string;
59
- /**
60
- * A function that returns resolved specifier as if it would be imported
61
- * using `import(specifier)`.
62
- *
63
- * ```ts
64
- * console.log(import.meta.resolve("./foo.js"));
65
- * // file:///dev/foo.js
66
- * ```
67
- *
68
- * @param specifier The module specifier to resolve relative to `parent`.
69
- * @param parent The absolute parent module URL to resolve from.
70
- * @returns The absolute (`file:`) URL string for the resolved module.
71
- */
72
- resolve(specifier: string, parent?: string | URL | undefined): string;
73
- /** A flag that indicates if the current module is the main module that was
74
- * called when starting the program under Deno.
75
- *
76
- * ```ts
77
- * if (import.meta.main) {
78
- * // this was loaded as the main module, maybe do some bootstrapping
79
- * }
80
- * ```
81
- */
82
- main: boolean;
83
- /** The absolute path of the current module.
84
- *
85
- * This property is only provided for local modules (ie. using `file://` URLs).
86
- *
87
- * Example:
88
- * ```
89
- * // Unix
90
- * console.log(import.meta.filename); // /home/alice/my_module.ts
91
- *
92
- * // Windows
93
- * console.log(import.meta.filename); // C:\alice\my_module.ts
94
- * ```
95
- */
96
- filename: string;
97
- /** The absolute path of the directory containing the current module.
98
- *
99
- * This property is only provided for local modules (ie. using `file://` URLs).
100
- *
101
- * * Example:
102
- * ```
103
- * // Unix
104
- * console.log(import.meta.dirname); // /home/alice
105
- *
106
- * // Windows
107
- * console.log(import.meta.dirname); // C:\alice
108
- * ```
109
- */
110
- dirname: string;
111
- }
112
- }
113
- type NodeRequest = ReturnType<typeof createRequire>;
114
- type NodeModule = NonNullable<NodeRequest["main"]>;
115
- interface ImportMetaPonyfillCommonjs {
116
- (require: NodeRequest, module: NodeModule): ImportMeta;
117
- }
118
- interface ImportMetaPonyfillEsmodule {
119
- (importMeta: ImportMeta): ImportMeta;
120
- }
121
- interface ImportMetaPonyfill extends ImportMetaPonyfillCommonjs, ImportMetaPonyfillEsmodule {
122
- }
123
- export declare let import_meta_ponyfill_commonjs: ImportMetaPonyfillCommonjs;
124
- export declare let import_meta_ponyfill_esmodule: ImportMetaPonyfillEsmodule;
125
- export declare let import_meta_ponyfill: ImportMetaPonyfill;
126
27
  //# sourceMappingURL=_dnt.polyfills.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"_dnt.polyfills.d.ts","sourceRoot":"","sources":["../src/_dnt.polyfills.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,kBAAkB;QAC1B;;;WAGG;QACH,aAAa,CAAC,CAAC,KAAK;YAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAAC,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;YAAC,MAAM,EAAE,CAAC,MAAM,CAAC,EAAE,GAAG,KAAK,IAAI,CAAA;SAAE,CAAC;KAC3H;CACF;AAcD,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,gBAAgB;QACxB,SAAS,CAAC,CAAC,EACP,mBAAmB,EAAE,aAAa,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,G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AK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,EAC/B,OAAO,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;KAC1B;CACF;AAoID,OAAO,EAAE,CAAC;AAAA,OAAO,CAAC,MAAM,CAAC;IACvB,UAAU,KAAK;QACb,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CACF;AAED,OAAO,EAAE,CAAC"}
@@ -118,130 +118,4 @@ async function fromAsync(items, mapfn, thisArg) {
118
118
  if (!Array.fromAsync) {
119
119
  Array.fromAsync = fromAsync;
120
120
  }
121
- /**
122
- * Based on [import-meta-ponyfill](https://github.com/gaubee/import-meta-ponyfill),
123
- * but instead of using npm to install additional dependencies,
124
- * this approach manually consolidates cjs/mjs/d.ts into a single file.
125
- *
126
- * Note that this code might be imported multiple times
127
- * (for example, both dnt.test.polyfills.ts and dnt.polyfills.ts contain this code;
128
- * or Node.js might dynamically clear the cache and then force a require).
129
- * Therefore, it's important to avoid redundant writes to global objects.
130
- * Additionally, consider that commonjs is used alongside esm,
131
- * so the two ponyfill functions are stored independently in two separate global objects.
132
- */
133
- //@ts-ignore
134
- import { createRequire } from "node:module";
135
- //@ts-ignore
136
- import { fileURLToPath, pathToFileURL } from "node:url";
137
- //@ts-ignore
138
- import { dirname } from "node:path";
139
- const defineGlobalPonyfill = (symbolFor, fn) => {
140
- if (!Reflect.has(globalThis, Symbol.for(symbolFor))) {
141
- Object.defineProperty(globalThis, Symbol.for(symbolFor), {
142
- configurable: true,
143
- get() {
144
- return fn;
145
- },
146
- });
147
- }
148
- };
149
- export let import_meta_ponyfill_commonjs = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-commonjs")) ??
150
- (() => {
151
- const moduleImportMetaWM = new WeakMap();
152
- return (require, module) => {
153
- let importMetaCache = moduleImportMetaWM.get(module);
154
- if (importMetaCache == null) {
155
- const importMeta = Object.assign(Object.create(null), {
156
- url: pathToFileURL(module.filename).href,
157
- main: require.main == module,
158
- resolve: (specifier, parentURL = importMeta.url) => {
159
- return pathToFileURL((importMeta.url === parentURL
160
- ? require
161
- : createRequire(parentURL))
162
- .resolve(specifier)).href;
163
- },
164
- filename: module.filename,
165
- dirname: module.path,
166
- });
167
- moduleImportMetaWM.set(module, importMeta);
168
- importMetaCache = importMeta;
169
- }
170
- return importMetaCache;
171
- };
172
- })());
173
- defineGlobalPonyfill("import-meta-ponyfill-commonjs", import_meta_ponyfill_commonjs);
174
- export let import_meta_ponyfill_esmodule = (Reflect.get(globalThis, Symbol.for("import-meta-ponyfill-esmodule")) ??
175
- ((importMeta) => {
176
- const resolveFunStr = String(importMeta.resolve);
177
- const shimWs = new WeakSet();
178
- //@ts-ignore
179
- const mainUrl = ("file:///" + process.argv[1].replace(/\\/g, "/"))
180
- .replace(/\/{3,}/, "///");
181
- const commonShim = (importMeta) => {
182
- if (typeof importMeta.main !== "boolean") {
183
- importMeta.main = importMeta.url === mainUrl;
184
- }
185
- if (typeof importMeta.filename !== "string") {
186
- importMeta.filename = fileURLToPath(importMeta.url);
187
- importMeta.dirname = dirname(importMeta.filename);
188
- }
189
- };
190
- if (
191
- // v16.2.0+, v14.18.0+: Add support for WHATWG URL object to parentURL parameter.
192
- resolveFunStr === "undefined" ||
193
- // v20.0.0+, v18.19.0+"" This API now returns a string synchronously instead of a Promise.
194
- resolveFunStr.startsWith("async")
195
- // enable by --experimental-import-meta-resolve flag
196
- ) {
197
- import_meta_ponyfill_esmodule = (importMeta) => {
198
- if (!shimWs.has(importMeta)) {
199
- shimWs.add(importMeta);
200
- const importMetaUrlRequire = {
201
- url: importMeta.url,
202
- require: createRequire(importMeta.url),
203
- };
204
- importMeta.resolve = function resolve(specifier, parentURL = importMeta.url) {
205
- return pathToFileURL((importMetaUrlRequire.url === parentURL
206
- ? importMetaUrlRequire.require
207
- : createRequire(parentURL)).resolve(specifier)).href;
208
- };
209
- commonShim(importMeta);
210
- }
211
- return importMeta;
212
- };
213
- }
214
- else {
215
- /// native support
216
- import_meta_ponyfill_esmodule = (importMeta) => {
217
- if (!shimWs.has(importMeta)) {
218
- shimWs.add(importMeta);
219
- commonShim(importMeta);
220
- }
221
- return importMeta;
222
- };
223
- }
224
- return import_meta_ponyfill_esmodule(importMeta);
225
- }));
226
- defineGlobalPonyfill("import-meta-ponyfill-esmodule", import_meta_ponyfill_esmodule);
227
- export let import_meta_ponyfill = ((...args) => {
228
- const _MODULE = (() => {
229
- if (typeof require === "function" && typeof module === "object") {
230
- return "commonjs";
231
- }
232
- else {
233
- // eval("typeof import.meta");
234
- return "esmodule";
235
- }
236
- })();
237
- if (_MODULE === "commonjs") {
238
- //@ts-ignore
239
- import_meta_ponyfill = (r, m) => import_meta_ponyfill_commonjs(r, m);
240
- }
241
- else {
242
- //@ts-ignore
243
- import_meta_ponyfill = (im) => import_meta_ponyfill_esmodule(im);
244
- }
245
- //@ts-ignore
246
- return import_meta_ponyfill(...args);
247
- });
121
+ export {};
@@ -17,53 +17,40 @@
17
17
  * You should have received a copy of the GNU Lesser General Public License
18
18
  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19
19
  */
20
- var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
21
- if (kind === "m") throw new TypeError("Private method is not writable");
22
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
23
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
25
- };
26
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
27
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
28
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
29
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
30
- };
31
- var _AbortableLoop_instances, _AbortableLoop_body, _AbortableLoop_onError, _AbortableLoop_controller, _AbortableLoop_loop;
32
20
  import { drop } from "../1_utilities.js";
33
21
  export class AbortableLoop {
22
+ #body;
23
+ #onError;
34
24
  constructor(body, onError) {
35
- _AbortableLoop_instances.add(this);
36
- _AbortableLoop_body.set(this, void 0);
37
- _AbortableLoop_onError.set(this, void 0);
38
- _AbortableLoop_controller.set(this, void 0);
39
- __classPrivateFieldSet(this, _AbortableLoop_body, body, "f");
40
- __classPrivateFieldSet(this, _AbortableLoop_onError, onError, "f");
25
+ this.#body = body;
26
+ this.#onError = onError;
41
27
  }
28
+ #controller;
42
29
  abort() {
43
- __classPrivateFieldGet(this, _AbortableLoop_controller, "f")?.abort();
30
+ this.#controller?.abort();
44
31
  }
45
32
  start() {
46
- if (__classPrivateFieldGet(this, _AbortableLoop_controller, "f") === undefined) {
47
- drop(__classPrivateFieldGet(this, _AbortableLoop_instances, "m", _AbortableLoop_loop).call(this));
33
+ if (this.#controller === undefined) {
34
+ drop(this.#loop());
48
35
  }
49
36
  }
50
- }
51
- _AbortableLoop_body = new WeakMap(), _AbortableLoop_onError = new WeakMap(), _AbortableLoop_controller = new WeakMap(), _AbortableLoop_instances = new WeakSet(), _AbortableLoop_loop = async function _AbortableLoop_loop() {
52
- __classPrivateFieldGet(this, _AbortableLoop_controller, "f")?.abort();
53
- const controller = __classPrivateFieldSet(this, _AbortableLoop_controller, new AbortController(), "f");
54
- try {
55
- do {
56
- try {
57
- await __classPrivateFieldGet(this, _AbortableLoop_body, "f").call(this, this, controller.signal);
58
- }
59
- catch (err) {
60
- if (!controller.signal.aborted) {
61
- __classPrivateFieldGet(this, _AbortableLoop_onError, "f").call(this, this, err);
37
+ async #loop() {
38
+ this.#controller?.abort();
39
+ const controller = this.#controller = new AbortController();
40
+ try {
41
+ do {
42
+ try {
43
+ await this.#body(this, controller.signal);
62
44
  }
63
- }
64
- } while (!controller.signal.aborted);
65
- }
66
- finally {
67
- __classPrivateFieldSet(this, _AbortableLoop_controller, undefined, "f");
45
+ catch (err) {
46
+ if (!controller.signal.aborted) {
47
+ this.#onError(this, err);
48
+ }
49
+ }
50
+ } while (!controller.signal.aborted);
51
+ }
52
+ finally {
53
+ this.#controller = undefined;
54
+ }
68
55
  }
69
- };
56
+ }