@mtkruto/node 0.67.1 → 0.68.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.
- package/esm/0_errors.js +2 -6
- package/esm/3_errors.js +2 -12
- package/esm/3_transport.d.ts +3 -3
- package/esm/3_transport.js +3 -3
- package/esm/3_types.d.ts +8 -7
- package/esm/3_types.d.ts.map +1 -1
- package/esm/3_types.js +8 -7
- package/esm/4_errors.js +2 -12
- package/esm/_dnt.polyfills.d.ts +99 -0
- package/esm/_dnt.polyfills.d.ts.map +1 -1
- package/esm/_dnt.polyfills.js +127 -1
- package/esm/_dnt.test_polyfills.d.ts.map +1 -0
- package/esm/client/0_filters_test.d.ts.map +1 -1
- package/esm/client/0_markdown_test.d.ts.map +1 -1
- package/esm/client/0_params.d.ts +2 -0
- package/esm/client/0_params.d.ts.map +1 -1
- package/esm/client/0_password.d.ts +5 -5
- package/esm/client/0_password.d.ts.map +1 -1
- package/esm/client/0_password_test.d.ts.map +1 -1
- package/esm/client/0_storage_operations.js +143 -155
- package/esm/client/0_storage_operations_test.d.ts.map +1 -1
- package/esm/client/0_utilities.d.ts +1 -1
- package/esm/client/0_utilities_test.d.ts.map +1 -1
- package/esm/client/1_client_plain.js +4 -22
- package/esm/client/1_composer.js +8 -21
- package/esm/client/2_account_manager.js +85 -97
- package/esm/client/2_bot_info_manager.js +26 -38
- package/esm/client/2_business_connection_manager.js +10 -23
- package/esm/client/2_client_encrypted.js +194 -211
- package/esm/client/2_file_manager.d.ts +4 -3
- package/esm/client/2_file_manager.d.ts.map +1 -1
- package/esm/client/2_file_manager.js +268 -224
- package/esm/client/2_file_manager_test.d.ts.map +1 -1
- package/esm/client/2_network_statistics_manager.js +8 -21
- package/esm/client/2_payment_manager.js +7 -20
- package/esm/client/2_reaction_manager.js +7 -20
- package/esm/client/2_translations_manager.js +97 -107
- package/esm/client/2_update_manager.js +764 -759
- package/esm/client/3_client_encrypted_pool.js +10 -26
- package/esm/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/esm/client/3_message_manager.d.ts +1 -1
- package/esm/client/3_message_manager.js +441 -448
- package/esm/client/3_message_manager_test.d.ts.map +1 -1
- package/esm/client/3_video_chat_manager.d.ts +1 -1
- package/esm/client/3_video_chat_manager.js +57 -68
- package/esm/client/4_callback_query_manager.js +18 -30
- package/esm/client/4_chat_list_manager.js +322 -318
- package/esm/client/4_chat_manager.js +118 -131
- package/esm/client/4_forum_manager.js +67 -73
- package/esm/client/4_gift_manager.js +16 -29
- package/esm/client/4_inline_query_manager.js +16 -28
- package/esm/client/4_link_preview_manager.js +6 -19
- package/esm/client/4_poll_manager.js +44 -57
- package/esm/client/4_story_manager.js +41 -53
- package/esm/client/5_client.d.ts +7 -0
- package/esm/client/5_client.d.ts.map +1 -1
- package/esm/client/5_client.js +1271 -1290
- package/esm/connection/1_connection_tcp.node.js +48 -65
- package/esm/connection/1_connection_web_socket.js +75 -91
- package/esm/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/esm/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/esm/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/esm/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/esm/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/esm/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/format.js +70 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/esm/mod.js +2 -12
- package/esm/session/0_session_state.js +12 -38
- package/esm/session/1_session.js +49 -72
- package/esm/session/2_session_encrypted.js +324 -320
- package/esm/storage/1_utilities_test.d.ts.map +1 -1
- package/esm/storage/2_storage_indexed_db.js +26 -44
- package/esm/storage/2_storage_local_storage.node.js +12 -25
- package/esm/storage/2_storage_memory.js +24 -41
- package/esm/storage/2_storage_session_storage.js +3 -16
- package/esm/tl/0_utilities_test.d.ts.map +1 -1
- package/esm/tl/1_tl_reader.js +80 -88
- package/esm/tl/1_tl_reader_test.d.ts.map +1 -1
- package/esm/tl/1_tl_writer.js +155 -164
- package/esm/tl/1_tl_writer_test.d.ts.map +1 -1
- package/esm/tl/2_telegram.d.ts +9 -10
- package/esm/tl/2_telegram.d.ts.map +1 -1
- package/esm/tl/2_telegram.js +10 -10
- package/esm/transport/0_transport.js +1 -8
- package/esm/transport/1_transport_abridged.js +11 -24
- package/esm/transport/1_transport_intermediate.js +10 -23
- package/{script/transport/2_transport_provider.d.ts → esm/transport/1_transport_provider.d.ts} +1 -1
- package/esm/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{script/transport/3_transport_provider_tcp.d.ts → esm/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/esm/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/esm/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +1 -1
- package/esm/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/esm/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/esm/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +1 -1
- package/esm/types/0_upload_progress.d.ts +29 -0
- package/esm/types/0_upload_progress.d.ts.map +1 -0
- package/esm/types/0_upload_progress.js +20 -0
- package/esm/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/esm/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/esm/types/1_sticker.d.ts +1 -1
- package/esm/types/1_sticker.d.ts.map +1 -1
- package/esm/types/2_chat.d.ts.map +1 -1
- package/esm/types/2_poll_answer.d.ts +19 -0
- package/esm/types/2_poll_answer.d.ts.map +1 -1
- package/esm/types/2_poll_answer.js +19 -0
- package/esm/types/2_pre_checkout_query.d.ts.map +1 -1
- package/esm/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/esm/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/esm/types/{3_reply_markup.js → 2_reply_markup.js} +1 -1
- package/esm/types/2_story_interactive_area.d.ts.map +1 -1
- package/esm/types/3_chat_member_updated.d.ts.map +1 -1
- package/esm/types/3_story.d.ts.map +1 -1
- package/esm/types/5_message.d.ts +1 -1
- package/esm/types/5_message.d.ts.map +1 -1
- package/esm/types/5_message.js +1 -1
- package/esm/types/6_inline_query_result.d.ts +1 -1
- package/esm/types/6_inline_query_result.js +1 -1
- package/esm/types/7_update.d.ts +21 -2
- package/esm/types/7_update.d.ts.map +1 -1
- package/esm/utilities/0_bigint_test.d.ts.map +1 -1
- package/esm/utilities/0_buffer.d.ts +1 -1
- package/esm/utilities/0_buffer.d.ts.map +1 -1
- package/esm/utilities/0_buffer_test.d.ts.map +1 -1
- package/esm/utilities/0_hash.d.ts +2 -2
- package/esm/utilities/0_hash.d.ts.map +1 -1
- package/esm/utilities/0_mutex.js +4 -19
- package/esm/utilities/0_part_stream.js +11 -25
- package/esm/utilities/0_part_stream_test.d.ts.map +1 -1
- package/esm/utilities/0_rle.d.ts +2 -2
- package/esm/utilities/0_rle.d.ts.map +1 -1
- package/esm/utilities/0_rle_test.d.ts.map +1 -1
- package/esm/utilities/0_text.d.ts +20 -1
- package/esm/utilities/0_text.d.ts.map +1 -1
- package/esm/utilities/0_text.js +19 -0
- package/esm/utilities/1_auth.d.ts +1 -1
- package/esm/utilities/1_auth.d.ts.map +1 -1
- package/esm/utilities/1_base64.d.ts +1 -1
- package/esm/utilities/1_base64.d.ts.map +1 -1
- package/esm/utilities/1_base64_test.d.ts.map +1 -1
- package/esm/utilities/1_crypto.js +42 -53
- package/esm/utilities/1_crypto_test.d.ts.map +1 -1
- package/esm/utilities/1_logger.d.ts +2 -2
- package/esm/utilities/1_math_test.d.ts.map +1 -1
- package/esm/utilities/2_queue.js +29 -47
- package/package.json +1 -1
- package/script/0_errors.js +2 -6
- package/script/2_tl.js +17 -7
- package/script/3_errors.js +2 -12
- package/script/3_transport.d.ts +3 -3
- package/script/3_transport.js +3 -3
- package/script/3_types.d.ts +8 -7
- package/script/3_types.d.ts.map +1 -1
- package/script/3_types.js +8 -7
- package/script/4_constants.js +17 -7
- package/script/4_errors.js +2 -12
- package/script/_dnt.polyfills.d.ts +99 -0
- package/script/_dnt.polyfills.d.ts.map +1 -1
- package/script/_dnt.polyfills.js +128 -0
- package/script/_dnt.test_polyfills.d.ts.map +1 -0
- package/script/client/0_filters_test.d.ts.map +1 -1
- package/script/client/0_markdown_test.d.ts.map +1 -1
- package/script/client/0_params.d.ts +2 -0
- package/script/client/0_params.d.ts.map +1 -1
- package/script/client/0_password.d.ts +5 -5
- package/script/client/0_password.d.ts.map +1 -1
- package/script/client/0_password.js +17 -7
- package/script/client/0_password_test.d.ts.map +1 -1
- package/script/client/0_storage_operations.js +143 -155
- package/script/client/0_storage_operations_test.d.ts.map +1 -1
- package/script/client/0_utilities.d.ts +1 -1
- package/script/client/0_utilities_test.d.ts.map +1 -1
- package/script/client/1_client_plain.js +4 -22
- package/script/client/1_composer.js +8 -21
- package/script/client/2_account_manager.js +85 -97
- package/script/client/2_bot_info_manager.js +26 -38
- package/script/client/2_business_connection_manager.js +10 -23
- package/script/client/2_client_encrypted.js +195 -212
- package/script/client/2_file_manager.d.ts +4 -3
- package/script/client/2_file_manager.d.ts.map +1 -1
- package/script/client/2_file_manager.js +285 -231
- package/script/client/2_file_manager_test.d.ts.map +1 -1
- package/script/client/2_network_statistics_manager.js +8 -21
- package/script/client/2_payment_manager.js +7 -20
- package/script/client/2_reaction_manager.js +7 -20
- package/script/client/2_translations_manager.js +98 -108
- package/script/client/2_update_manager.js +764 -759
- package/script/client/3_client_encrypted_pool.js +10 -26
- package/script/client/3_client_encrypted_pool_test.d.ts.map +1 -1
- package/script/client/3_message_manager.d.ts +1 -1
- package/script/client/3_message_manager.js +441 -448
- package/script/client/3_message_manager_test.d.ts.map +1 -1
- package/script/client/3_video_chat_manager.d.ts +1 -1
- package/script/client/3_video_chat_manager.js +57 -68
- package/script/client/4_callback_query_manager.js +18 -30
- package/script/client/4_chat_list_manager.js +322 -318
- package/script/client/4_chat_manager.js +118 -131
- package/script/client/4_forum_manager.js +67 -73
- package/script/client/4_gift_manager.js +16 -29
- package/script/client/4_inline_query_manager.js +16 -28
- package/script/client/4_link_preview_manager.js +6 -19
- package/script/client/4_poll_manager.js +44 -57
- package/script/client/4_story_manager.js +41 -53
- package/script/client/5_client.d.ts +7 -0
- package/script/client/5_client.d.ts.map +1 -1
- package/script/client/5_client.js +1271 -1290
- package/script/connection/1_connection_tcp.node.js +48 -65
- package/script/connection/1_connection_web_socket.js +92 -98
- package/script/deps/jsr.io/@roj/tgcrypto/1.0.1/dist/tgcrypto.js +3 -11
- package/script/deps/jsr.io/@std/assert/1.0.13/equal.js +17 -7
- package/script/deps/jsr.io/@std/assert/1.0.13/equals.js +4 -4
- package/script/deps/jsr.io/@std/async/1.0.13/delay.js +17 -7
- package/script/deps/jsr.io/@std/async/1.0.13/mux_async_iterator.js +31 -47
- package/script/deps/jsr.io/@std/async/1.0.13/tee.js +11 -34
- package/script/deps/jsr.io/@std/datetime/0.225.5/_date_time_formatter.js +4 -17
- package/script/deps/jsr.io/@std/internal/1.0.10/build_message.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/diff_str.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts +29 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/format.js +106 -0
- package/script/deps/jsr.io/@std/internal/1.0.10/styles.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +17 -7
- package/script/deps/jsr.io/@std/internal/1.0.10/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/path/1.1.0/_os.js +17 -7
- package/script/mod.js +19 -19
- package/script/session/0_session_state.js +12 -38
- package/script/session/1_session.js +66 -79
- package/script/session/2_session_encrypted.js +325 -321
- package/script/storage/1_utilities_test.d.ts.map +1 -1
- package/script/storage/2_storage_indexed_db.js +26 -44
- package/script/storage/2_storage_local_storage.node.js +12 -25
- package/script/storage/2_storage_memory.js +24 -41
- package/script/storage/2_storage_session_storage.js +3 -16
- package/script/tl/0_utilities_test.d.ts.map +1 -1
- package/script/tl/1_tl_reader.js +81 -89
- package/script/tl/1_tl_reader_test.d.ts.map +1 -1
- package/script/tl/1_tl_writer.js +156 -165
- package/script/tl/1_tl_writer_test.d.ts.map +1 -1
- package/script/tl/2_telegram.d.ts +9 -10
- package/script/tl/2_telegram.d.ts.map +1 -1
- package/script/tl/2_telegram.js +32 -10
- package/script/transport/0_obfuscation.js +17 -7
- package/script/transport/0_transport.js +1 -8
- package/script/transport/1_transport_abridged.js +11 -24
- package/script/transport/1_transport_intermediate.js +10 -23
- package/{esm/transport/2_transport_provider.d.ts → script/transport/1_transport_provider.d.ts} +1 -1
- package/script/transport/{2_transport_provider.d.ts.map → 1_transport_provider.d.ts.map} +1 -1
- package/{esm/transport/3_transport_provider_tcp.d.ts → script/transport/2_transport_provider_tcp.d.ts} +2 -2
- package/script/transport/{3_transport_provider_tcp.d.ts.map → 2_transport_provider_tcp.d.ts.map} +1 -1
- package/script/transport/{3_transport_provider_tcp.js → 2_transport_provider_tcp.js} +3 -3
- package/script/transport/{3_transport_provider_web_socket.d.ts → 2_transport_provider_web_socket.d.ts} +2 -2
- package/script/transport/2_transport_provider_web_socket.d.ts.map +1 -0
- package/script/transport/{3_transport_provider_web_socket.js → 2_transport_provider_web_socket.js} +2 -2
- package/script/types/0_upload_progress.d.ts +29 -0
- package/script/types/0_upload_progress.d.ts.map +1 -0
- package/script/types/0_upload_progress.js +21 -0
- package/script/types/{2_inline_keyboard_button.d.ts → 1_inline_keyboard_button.d.ts} +1 -1
- package/script/types/{2_inline_keyboard_button.d.ts.map → 1_inline_keyboard_button.d.ts.map} +1 -1
- package/script/types/1_sticker.d.ts +1 -1
- package/script/types/1_sticker.d.ts.map +1 -1
- package/script/types/2_chat.d.ts.map +1 -1
- package/script/types/2_poll_answer.d.ts +19 -0
- package/script/types/2_poll_answer.d.ts.map +1 -1
- package/script/types/2_poll_answer.js +19 -0
- package/script/types/2_pre_checkout_query.d.ts.map +1 -1
- package/script/types/{3_reply_markup.d.ts → 2_reply_markup.d.ts} +2 -2
- package/script/types/{3_reply_markup.d.ts.map → 2_reply_markup.d.ts.map} +1 -1
- package/script/types/{3_reply_markup.js → 2_reply_markup.js} +3 -3
- package/script/types/2_story_interactive_area.d.ts.map +1 -1
- package/script/types/3_chat_member_updated.d.ts.map +1 -1
- package/script/types/3_story.d.ts.map +1 -1
- package/script/types/5_message.d.ts +1 -1
- package/script/types/5_message.d.ts.map +1 -1
- package/script/types/5_message.js +2 -2
- package/script/types/6_inline_query_result.d.ts +1 -1
- package/script/types/6_inline_query_result.js +4 -4
- package/script/types/7_update.d.ts +21 -2
- package/script/types/7_update.d.ts.map +1 -1
- package/script/utilities/0_bigint.js +17 -7
- package/script/utilities/0_bigint_test.d.ts.map +1 -1
- package/script/utilities/0_buffer.d.ts +1 -1
- package/script/utilities/0_buffer.d.ts.map +1 -1
- package/script/utilities/0_buffer_test.d.ts.map +1 -1
- package/script/utilities/0_env.js +17 -7
- package/script/utilities/0_hash.d.ts +2 -2
- package/script/utilities/0_hash.d.ts.map +1 -1
- package/script/utilities/0_hash.js +17 -7
- package/script/utilities/0_misc.js +17 -7
- package/script/utilities/0_mutex.js +4 -19
- package/script/utilities/0_part_stream.js +11 -25
- package/script/utilities/0_part_stream_test.d.ts.map +1 -1
- package/script/utilities/0_rle.d.ts +2 -2
- package/script/utilities/0_rle.d.ts.map +1 -1
- package/script/utilities/0_rle_test.d.ts.map +1 -1
- package/script/utilities/0_text.d.ts +20 -1
- package/script/utilities/0_text.d.ts.map +1 -1
- package/script/utilities/0_text.js +19 -0
- package/script/utilities/1_auth.d.ts +1 -1
- package/script/utilities/1_auth.d.ts.map +1 -1
- package/script/utilities/1_auth.js +17 -7
- package/script/utilities/1_base64.d.ts +1 -1
- package/script/utilities/1_base64.d.ts.map +1 -1
- package/script/utilities/1_base64_test.d.ts.map +1 -1
- package/script/utilities/1_crypto.js +60 -61
- package/script/utilities/1_crypto_test.d.ts.map +1 -1
- package/script/utilities/1_logger.d.ts +2 -2
- package/script/utilities/1_math_test.d.ts.map +1 -1
- package/script/utilities/2_queue.js +30 -48
- package/esm/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/format.js +0 -37
- package/esm/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/esm/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/esm/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/build_message.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/diff_str.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts +0 -2
- package/script/deps/jsr.io/@std/internal/1.0.9/format.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/format.js +0 -63
- package/script/deps/jsr.io/@std/internal/1.0.9/styles.d.ts.map +0 -1
- package/script/deps/jsr.io/@std/internal/1.0.9/types.d.ts.map +0 -1
- package/script/transport/3_transport_provider_web_socket.d.ts.map +0 -1
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.js +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/esm/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/esm/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/esm/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/build_message.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/diff_str.js +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/styles.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.d.ts +0 -0
- /package/script/deps/jsr.io/@std/internal/{1.0.9 → 1.0.10}/types.js +0 -0
- /package/script/transport/{2_transport_provider.js → 1_transport_provider.js} +0 -0
- /package/script/types/{2_inline_keyboard_button.js → 1_inline_keyboard_button.js} +0 -0
|
@@ -15,25 +15,24 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
var _FileManager_instances, _a, _FileManager_c, _FileManager_Lupload, _FileManager_UPLOAD_MAX_CHUNK_SIZE, _FileManager_DOWNLOAD_MAX_CHUNK_SIZE, _FileManager_BIG_FILE_THRESHOLD, _FileManager_uploadStream, _FileManager_uploadBuffer, _FileManager_uploadPart, _FileManager_handleError, _FileManager_getFileContents, _FileManager_CUSTOM_EMOJI_TTL;
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var _a;
|
|
37
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
37
|
exports.FileManager = void 0;
|
|
39
38
|
/**
|
|
@@ -63,39 +62,58 @@ const _2_tl_js_1 = require("../2_tl.js");
|
|
|
63
62
|
const _3_transport_js_1 = require("../3_transport.js");
|
|
64
63
|
const _3_types_js_1 = require("../3_types.js");
|
|
65
64
|
const _4_constants_js_1 = require("../4_constants.js");
|
|
65
|
+
const _4_errors_js_1 = require("../4_errors.js");
|
|
66
66
|
const _0_utilities_js_1 = require("./0_utilities.js");
|
|
67
67
|
class FileManager {
|
|
68
|
+
#c;
|
|
69
|
+
#Lupload;
|
|
70
|
+
static #UPLOAD_MAX_CHUNK_SIZE = 512 * _1_utilities_js_1.kilobyte;
|
|
71
|
+
static #DOWNLOAD_MAX_CHUNK_SIZE = 1 * _1_utilities_js_1.megabyte;
|
|
72
|
+
static #BIG_FILE_THRESHOLD = 10 * _1_utilities_js_1.megabyte;
|
|
68
73
|
constructor(c) {
|
|
69
|
-
|
|
70
|
-
_FileManager_c.set(this, void 0);
|
|
71
|
-
_FileManager_Lupload.set(this, void 0);
|
|
72
|
-
__classPrivateFieldSet(this, _FileManager_c, c, "f");
|
|
74
|
+
this.#c = c;
|
|
73
75
|
const L = (0, _1_utilities_js_1.getLogger)("FileManager").client(c.id);
|
|
74
|
-
|
|
76
|
+
this.#Lupload = L.branch("upload");
|
|
77
|
+
}
|
|
78
|
+
#progressIds = new Set();
|
|
79
|
+
getProgressId() {
|
|
80
|
+
let id;
|
|
81
|
+
do {
|
|
82
|
+
id = (0, _1_utilities_js_1.getRandomId)();
|
|
83
|
+
} while (id === 0n || this.#progressIds.has(id));
|
|
84
|
+
this.#progressIds.add(id);
|
|
85
|
+
return Promise.resolve(String(id));
|
|
75
86
|
}
|
|
76
87
|
async upload(file, params, checkName, allowStream = true) {
|
|
77
|
-
|
|
88
|
+
if (params?.progressId !== undefined && !this.#progressIds.has(BigInt(params.progressId))) {
|
|
89
|
+
throw new _0_errors_js_1.InputError("Invalid progressId.");
|
|
90
|
+
}
|
|
91
|
+
if (params?.progressId !== undefined) {
|
|
92
|
+
this.#progressIds.delete(BigInt(params.progressId));
|
|
93
|
+
}
|
|
94
|
+
let { size, name, contents } = await _a.#getFileContents(file, params, allowStream);
|
|
78
95
|
if (checkName) {
|
|
79
96
|
name = checkName(name);
|
|
80
97
|
}
|
|
81
98
|
if (size == 0 || size < -1) {
|
|
82
99
|
throw new _0_errors_js_1.InputError("Invalid file size.");
|
|
83
100
|
}
|
|
84
|
-
const poolSize = await
|
|
85
|
-
const chunkSize = params?.chunkSize ??
|
|
86
|
-
_a.validateChunkSize(chunkSize,
|
|
87
|
-
const
|
|
88
|
-
const
|
|
101
|
+
const poolSize = await this.#c.getUploadPoolSize();
|
|
102
|
+
const chunkSize = params?.chunkSize ?? _a.#UPLOAD_MAX_CHUNK_SIZE;
|
|
103
|
+
_a.validateChunkSize(chunkSize, _a.#UPLOAD_MAX_CHUNK_SIZE);
|
|
104
|
+
const mustTrackProgress = params?.progressId !== undefined;
|
|
105
|
+
const fileId = params?.progressId !== undefined ? BigInt(params.progressId) : (0, _1_utilities_js_1.getRandomId)();
|
|
106
|
+
const isBig = contents instanceof Uint8Array ? contents.length > _a.#BIG_FILE_THRESHOLD : true;
|
|
89
107
|
const whatIsUploaded = contents instanceof Uint8Array ? (isBig ? "big file" : "file") + " of size " + size : "stream";
|
|
90
|
-
|
|
108
|
+
this.#Lupload.debug("uploading " + whatIsUploaded + " with chunk size of " + chunkSize + " and pool size of " + poolSize + " and file ID of " + fileId);
|
|
91
109
|
let result;
|
|
92
110
|
if (contents instanceof Uint8Array) {
|
|
93
|
-
result = await
|
|
111
|
+
result = await this.#uploadBuffer(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
|
|
94
112
|
}
|
|
95
113
|
else {
|
|
96
|
-
result = await
|
|
114
|
+
result = await this.#uploadStream(contents, fileId, mustTrackProgress, chunkSize, poolSize, params?.signal);
|
|
97
115
|
}
|
|
98
|
-
|
|
116
|
+
this.#Lupload.debug(`[${fileId}] uploaded ` + result.parts + " part(s)");
|
|
99
117
|
if (result.small) {
|
|
100
118
|
return { _: "inputFile", id: fileId, name, parts: result.parts, md5_checksum: "" };
|
|
101
119
|
}
|
|
@@ -103,20 +121,222 @@ class FileManager {
|
|
|
103
121
|
return { _: "inputFileBig", id: fileId, name, parts: result.parts };
|
|
104
122
|
}
|
|
105
123
|
}
|
|
124
|
+
async #uploadStream(stream, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
|
|
125
|
+
let part;
|
|
126
|
+
let promises = new Array();
|
|
127
|
+
let ms = 0.05;
|
|
128
|
+
let uploaded = 0;
|
|
129
|
+
for await (part of (0, _1_utilities_js_1.iterateReadableStream)(stream.pipeThrough(new _1_utilities_js_1.PartStream(chunkSize)))) {
|
|
130
|
+
if (!part.small && part.part > 0) {
|
|
131
|
+
await (0, _0_deps_js_1.delay)(ms);
|
|
132
|
+
ms = Math.max(ms * .8, 0.003);
|
|
133
|
+
}
|
|
134
|
+
promises.push(this.#uploadPart(fileId, part.totalParts, !part.small, part.part, part.bytes, signal).then(() => {
|
|
135
|
+
if (mustTrackProgress) {
|
|
136
|
+
uploaded += part.bytes.length;
|
|
137
|
+
this.#c.handleUpdate({
|
|
138
|
+
uploadProgress: {
|
|
139
|
+
id: String(fileId),
|
|
140
|
+
uploaded,
|
|
141
|
+
total: 0,
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}));
|
|
146
|
+
if (promises.length == poolSize * _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION) {
|
|
147
|
+
await Promise.all(promises);
|
|
148
|
+
promises = [];
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
await Promise.all(promises);
|
|
152
|
+
return { small: part.small, parts: part.totalParts };
|
|
153
|
+
}
|
|
154
|
+
async #uploadBuffer(buffer, fileId, mustTrackProgress, chunkSize, poolSize, signal) {
|
|
155
|
+
const isBig = buffer.byteLength > _a.#BIG_FILE_THRESHOLD;
|
|
156
|
+
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
157
|
+
let promises = new Array();
|
|
158
|
+
let started = false;
|
|
159
|
+
let ms = 0.05;
|
|
160
|
+
let uploaded = 0;
|
|
161
|
+
main: for (let part = 0; part < partCount;) {
|
|
162
|
+
for (let i = 0; i < poolSize; ++i) {
|
|
163
|
+
for (let i = 0; i < _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION; ++i) {
|
|
164
|
+
const start = part * chunkSize;
|
|
165
|
+
const end = start + chunkSize;
|
|
166
|
+
const bytes = buffer.subarray(start, end);
|
|
167
|
+
if (!bytes.length) {
|
|
168
|
+
break main;
|
|
169
|
+
}
|
|
170
|
+
if (!started) {
|
|
171
|
+
started = true;
|
|
172
|
+
}
|
|
173
|
+
else if (isBig && part > 0) {
|
|
174
|
+
await (0, _0_deps_js_1.delay)(ms);
|
|
175
|
+
ms = Math.max(ms * .8, 0.003);
|
|
176
|
+
}
|
|
177
|
+
promises.push(this.#uploadPart(fileId, partCount, isBig, part++, bytes, signal).then(() => {
|
|
178
|
+
if (mustTrackProgress) {
|
|
179
|
+
uploaded += bytes.length;
|
|
180
|
+
this.#c.handleUpdate({
|
|
181
|
+
uploadProgress: {
|
|
182
|
+
id: String(fileId),
|
|
183
|
+
uploaded,
|
|
184
|
+
total: buffer.length,
|
|
185
|
+
},
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
}));
|
|
189
|
+
if (promises.length == poolSize * _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION) {
|
|
190
|
+
await Promise.all(promises);
|
|
191
|
+
promises = [];
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
await Promise.all(promises);
|
|
196
|
+
promises = [];
|
|
197
|
+
}
|
|
198
|
+
await Promise.all(promises);
|
|
199
|
+
return { small: !isBig, parts: partCount };
|
|
200
|
+
}
|
|
201
|
+
async #uploadPart(fileId, partCount, isBig, index, bytes, signal) {
|
|
202
|
+
let retryIn = 1;
|
|
203
|
+
let errorCount = 0;
|
|
204
|
+
while (true) {
|
|
205
|
+
try {
|
|
206
|
+
signal?.throwIfAborted();
|
|
207
|
+
this.#Lupload.debug(`[${fileId}] uploading part ` + (index + 1));
|
|
208
|
+
if (isBig) {
|
|
209
|
+
await this.#c.invoke({ _: "upload.saveBigFilePart", file_id: fileId, file_part: index, bytes: bytes, file_total_parts: partCount }, { type: "upload" });
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
await this.#c.invoke({ _: "upload.saveFilePart", file_id: fileId, bytes: bytes, file_part: index }, { type: "upload" });
|
|
213
|
+
}
|
|
214
|
+
this.#Lupload.debug(`[${fileId}] uploaded part ` + (index + 1));
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
signal?.throwIfAborted();
|
|
219
|
+
this.#Lupload.debug(`[${fileId}] failed to upload part ` + (index + 1));
|
|
220
|
+
++errorCount;
|
|
221
|
+
if (errorCount > 20) {
|
|
222
|
+
retryIn = 0;
|
|
223
|
+
errorCount = 20;
|
|
224
|
+
}
|
|
225
|
+
await this.#handleError(err, retryIn, `[${fileId}-${index + 1}]`);
|
|
226
|
+
retryIn += 2;
|
|
227
|
+
if (retryIn > 11) {
|
|
228
|
+
retryIn = 11;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
async #handleError(err, retryIn, logPrefix) {
|
|
234
|
+
if (retryIn > 0) {
|
|
235
|
+
this.#Lupload.warning(`${logPrefix} retrying in ${retryIn} seconds`);
|
|
236
|
+
await (0, _0_deps_js_1.delay)(retryIn * _0_deps_js_1.SECOND);
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
throw err;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
static async #getFileContents(source, params, allowStream) {
|
|
243
|
+
let name = params?.fileName?.trim() || "file";
|
|
244
|
+
let contents;
|
|
245
|
+
let size = -1;
|
|
246
|
+
if (source instanceof Uint8Array) {
|
|
247
|
+
contents = source;
|
|
248
|
+
size = source.byteLength;
|
|
249
|
+
}
|
|
250
|
+
else if (source instanceof ReadableStream) {
|
|
251
|
+
if (!allowStream) {
|
|
252
|
+
throw new _0_errors_js_1.InputError("Streamed upload not allowed.");
|
|
253
|
+
}
|
|
254
|
+
contents = source;
|
|
255
|
+
}
|
|
256
|
+
else if (typeof source === "object" && source != null && (Symbol.iterator in source || Symbol.asyncIterator in source)) {
|
|
257
|
+
if (!allowStream) {
|
|
258
|
+
throw new _0_errors_js_1.InputError("Streamed upload not allowed.");
|
|
259
|
+
}
|
|
260
|
+
contents = new ReadableStream({
|
|
261
|
+
pull: Symbol.asyncIterator in source
|
|
262
|
+
? async (controller) => {
|
|
263
|
+
const { value, done } = await source.next();
|
|
264
|
+
done ? controller.close() : controller.enqueue(value);
|
|
265
|
+
}
|
|
266
|
+
: (controller) => {
|
|
267
|
+
const { value, done } = source.next();
|
|
268
|
+
done ? controller.close() : controller.enqueue(value);
|
|
269
|
+
},
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
let url;
|
|
274
|
+
try {
|
|
275
|
+
url = new URL(source).toString();
|
|
276
|
+
}
|
|
277
|
+
catch {
|
|
278
|
+
let path_;
|
|
279
|
+
if (typeof source === "string") {
|
|
280
|
+
if ((0, _0_deps_js_1.isAbsolute)(source)) {
|
|
281
|
+
path_ = source;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
// @ts-ignore: lib
|
|
285
|
+
path_ = join(dntShim.Deno.cwd(), source);
|
|
286
|
+
}
|
|
287
|
+
url = (0, _0_deps_js_1.toFileUrl)(path_).toString();
|
|
288
|
+
name = (0, _0_deps_js_1.basename)(path_);
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
291
|
+
(0, _0_deps_js_1.unreachable)();
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
const response = await fetch(url);
|
|
295
|
+
if (response.body == null) {
|
|
296
|
+
throw new _0_errors_js_1.InputError("Invalid response");
|
|
297
|
+
}
|
|
298
|
+
if (name == "file") {
|
|
299
|
+
const contentType = response.headers.get("content-type")?.split(";")[0].trim();
|
|
300
|
+
if (contentType) {
|
|
301
|
+
name += (0, _0_deps_js_1.extension)(contentType);
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
const maybeFileName = new URL(response.url).pathname.split("/")
|
|
305
|
+
.filter((v) => v)
|
|
306
|
+
.slice(-1)[0]
|
|
307
|
+
.trim();
|
|
308
|
+
if (maybeFileName) {
|
|
309
|
+
name += (0, _0_deps_js_1.extension)((0, _0_deps_js_1.extname)(maybeFileName));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
const contentLength = Number(response.headers.get("content-length"));
|
|
314
|
+
if (!isNaN(contentLength)) {
|
|
315
|
+
size = contentLength;
|
|
316
|
+
}
|
|
317
|
+
if (allowStream) {
|
|
318
|
+
contents = response.body;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
contents = new Uint8Array(await response.arrayBuffer());
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return { size: params?.fileSize ? params.fileSize : size, name, contents };
|
|
325
|
+
}
|
|
106
326
|
async *downloadInner(location, dcId, params) {
|
|
107
327
|
const signal = params?.signal;
|
|
108
328
|
signal?.throwIfAborted();
|
|
109
329
|
const id = "id" in location ? location.id : "photo_id" in location ? location.photo_id : null;
|
|
110
|
-
if (id != null &&
|
|
111
|
-
const file = await
|
|
330
|
+
if (id != null && this.#c.storage.supportsFiles) {
|
|
331
|
+
const file = await this.#c.storage.getFile(id);
|
|
112
332
|
const partOffset = file == null ? 0 : params?.offset ? Math.ceil(10 / file[1]) - 1 : 0;
|
|
113
333
|
if (file != null && file[0] > 0) {
|
|
114
|
-
yield*
|
|
334
|
+
yield* this.#c.storage.iterFileParts(id, file[0], partOffset, signal);
|
|
115
335
|
return;
|
|
116
336
|
}
|
|
117
337
|
}
|
|
118
|
-
const chunkSize = params?.chunkSize ??
|
|
119
|
-
_a.validateChunkSize(chunkSize,
|
|
338
|
+
const chunkSize = params?.chunkSize ?? _a.#DOWNLOAD_MAX_CHUNK_SIZE;
|
|
339
|
+
_a.validateChunkSize(chunkSize, _a.#DOWNLOAD_MAX_CHUNK_SIZE);
|
|
120
340
|
if (params?.offset !== undefined) {
|
|
121
341
|
_a.validateOffset(params.offset);
|
|
122
342
|
}
|
|
@@ -131,18 +351,18 @@ class FileManager {
|
|
|
131
351
|
let retryIn = 1;
|
|
132
352
|
let errorCount = 0;
|
|
133
353
|
try {
|
|
134
|
-
const file = await
|
|
354
|
+
const file = await this.#c.invoke({ _: "upload.getFile", location, offset, limit }, { dc, type: "download" });
|
|
135
355
|
signal?.throwIfAborted();
|
|
136
356
|
if (_2_tl_js_1.Api.is("upload.file", file)) {
|
|
137
357
|
yield file.bytes;
|
|
138
358
|
if (id != null) {
|
|
139
|
-
await
|
|
359
|
+
await this.#c.storage.saveFilePart(id, part, file.bytes);
|
|
140
360
|
signal?.throwIfAborted();
|
|
141
361
|
}
|
|
142
362
|
++part;
|
|
143
363
|
if (file.bytes.length < limit) {
|
|
144
364
|
if (id != null) {
|
|
145
|
-
await
|
|
365
|
+
await this.#c.storage.setFilePartCount(id, part + 1, chunkSize);
|
|
146
366
|
signal?.throwIfAborted();
|
|
147
367
|
}
|
|
148
368
|
break;
|
|
@@ -166,7 +386,7 @@ class FileManager {
|
|
|
166
386
|
retryIn = 0;
|
|
167
387
|
errorCount = 0;
|
|
168
388
|
}
|
|
169
|
-
await
|
|
389
|
+
await this.#handleError(err, retryIn, `[${id}-${part + 1}]`);
|
|
170
390
|
signal?.throwIfAborted();
|
|
171
391
|
retryIn += 2;
|
|
172
392
|
if (retryIn > 11) {
|
|
@@ -209,7 +429,7 @@ class FileManager {
|
|
|
209
429
|
(0, _0_deps_js_1.unreachable)();
|
|
210
430
|
}
|
|
211
431
|
const big = fileId_.location.source.type == _3_types_js_1.PhotoSourceType.ChatPhotoBig;
|
|
212
|
-
const peer = await
|
|
432
|
+
const peer = await this.#c.getInputPeer(Number(fileId_.location.source.chatId));
|
|
213
433
|
const location = { _: "inputPeerPhotoFileLocation", big: big ? true : undefined, peer, photo_id: fileId_.location.id };
|
|
214
434
|
yield* this.downloadInner(location, fileId_.dcId, params);
|
|
215
435
|
break;
|
|
@@ -253,17 +473,28 @@ class FileManager {
|
|
|
253
473
|
}
|
|
254
474
|
}
|
|
255
475
|
async getStickerSetName(inputStickerSet, hash = 0) {
|
|
256
|
-
const maybeStickerSetName = await
|
|
476
|
+
const maybeStickerSetName = await this.#c.messageStorage.getStickerSetName(inputStickerSet.id, inputStickerSet.access_hash);
|
|
257
477
|
if (maybeStickerSetName != null && Date.now() - maybeStickerSetName[1].getTime() < _4_constants_js_1.STICKER_SET_NAME_TTL) {
|
|
258
478
|
return maybeStickerSetName[0];
|
|
259
479
|
}
|
|
260
480
|
else {
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
481
|
+
try {
|
|
482
|
+
const stickerSet = await this.#c.invoke({ _: "messages.getStickerSet", stickerset: inputStickerSet, hash });
|
|
483
|
+
const name = _2_tl_js_1.Api.as("messages.stickerSet", stickerSet).set.short_name;
|
|
484
|
+
await this.#c.messageStorage.updateStickerSetName(inputStickerSet.id, inputStickerSet.access_hash, name);
|
|
485
|
+
return name;
|
|
486
|
+
}
|
|
487
|
+
catch (err) {
|
|
488
|
+
if (err instanceof _4_errors_js_1.StickersetInvalid) {
|
|
489
|
+
return undefined;
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
throw err;
|
|
493
|
+
}
|
|
494
|
+
}
|
|
265
495
|
}
|
|
266
496
|
}
|
|
497
|
+
static #CUSTOM_EMOJI_TTL = 30 * _0_deps_js_1.MINUTE;
|
|
267
498
|
async getCustomEmojiStickers(id) {
|
|
268
499
|
id = Array.isArray(id) ? id : [id];
|
|
269
500
|
if (!id.length) {
|
|
@@ -272,8 +503,8 @@ class FileManager {
|
|
|
272
503
|
const stickers = new Array();
|
|
273
504
|
let shouldFetch = false;
|
|
274
505
|
for (const id_ of id) {
|
|
275
|
-
const maybeDocument = await
|
|
276
|
-
if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <=
|
|
506
|
+
const maybeDocument = await this.#c.messageStorage.getCustomEmojiDocument(BigInt(id_));
|
|
507
|
+
if (maybeDocument != null && Date.now() - maybeDocument[1].getTime() <= _a.#CUSTOM_EMOJI_TTL) {
|
|
277
508
|
const document_ = maybeDocument[0];
|
|
278
509
|
const fileId_ = {
|
|
279
510
|
type: _3_types_js_1.FileType.Document,
|
|
@@ -294,9 +525,9 @@ class FileManager {
|
|
|
294
525
|
if (!shouldFetch) {
|
|
295
526
|
return stickers;
|
|
296
527
|
}
|
|
297
|
-
const documents_ = (await
|
|
528
|
+
const documents_ = (await this.#c.invoke({ _: "messages.getCustomEmojiDocuments", document_id: id.map(BigInt) })).map((v) => _2_tl_js_1.Api.as("document", v));
|
|
298
529
|
for (const [i, document_] of documents_.entries()) {
|
|
299
|
-
await
|
|
530
|
+
await this.#c.messageStorage.setCustomEmojiDocument(document_.id, document_);
|
|
300
531
|
const fileId_ = {
|
|
301
532
|
type: _3_types_js_1.FileType.Document,
|
|
302
533
|
dcId: document_.dc_id,
|
|
@@ -312,181 +543,4 @@ class FileManager {
|
|
|
312
543
|
}
|
|
313
544
|
}
|
|
314
545
|
exports.FileManager = FileManager;
|
|
315
|
-
_a = FileManager
|
|
316
|
-
let part;
|
|
317
|
-
let promises = new Array();
|
|
318
|
-
let ms = 0.05;
|
|
319
|
-
for await (part of (0, _1_utilities_js_1.iterateReadableStream)(stream.pipeThrough(new _1_utilities_js_1.PartStream(chunkSize)))) {
|
|
320
|
-
if (!part.small && part.part > 0) {
|
|
321
|
-
await (0, _0_deps_js_1.delay)(ms);
|
|
322
|
-
ms = Math.max(ms * .8, 0.003);
|
|
323
|
-
}
|
|
324
|
-
promises.push(__classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadPart).call(this, fileId, part.totalParts, !part.small, part.part, part.bytes, signal));
|
|
325
|
-
if (promises.length == poolSize * _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION) {
|
|
326
|
-
await Promise.all(promises);
|
|
327
|
-
promises = [];
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
await Promise.all(promises);
|
|
331
|
-
return { small: part.small, parts: part.totalParts };
|
|
332
|
-
}, _FileManager_uploadBuffer = async function _FileManager_uploadBuffer(buffer, fileId, chunkSize, poolSize, signal) {
|
|
333
|
-
const isBig = buffer.byteLength > __classPrivateFieldGet(_a, _a, "f", _FileManager_BIG_FILE_THRESHOLD);
|
|
334
|
-
const partCount = Math.ceil(buffer.byteLength / chunkSize);
|
|
335
|
-
let promises = new Array();
|
|
336
|
-
let started = false;
|
|
337
|
-
let ms = 0.05;
|
|
338
|
-
main: for (let part = 0; part < partCount;) {
|
|
339
|
-
for (let i = 0; i < poolSize; ++i) {
|
|
340
|
-
for (let i = 0; i < _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION; ++i) {
|
|
341
|
-
const start = part * chunkSize;
|
|
342
|
-
const end = start + chunkSize;
|
|
343
|
-
const bytes = buffer.subarray(start, end);
|
|
344
|
-
if (!bytes.length) {
|
|
345
|
-
break main;
|
|
346
|
-
}
|
|
347
|
-
if (!started) {
|
|
348
|
-
started = true;
|
|
349
|
-
}
|
|
350
|
-
else if (isBig && part > 0) {
|
|
351
|
-
await (0, _0_deps_js_1.delay)(ms);
|
|
352
|
-
ms = Math.max(ms * .8, 0.003);
|
|
353
|
-
}
|
|
354
|
-
promises.push(__classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_uploadPart).call(this, fileId, partCount, isBig, part++, bytes, signal));
|
|
355
|
-
if (promises.length == poolSize * _0_utilities_js_1.UPLOAD_REQUEST_PER_CONNECTION) {
|
|
356
|
-
await Promise.all(promises);
|
|
357
|
-
promises = [];
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
await Promise.all(promises);
|
|
362
|
-
promises = [];
|
|
363
|
-
}
|
|
364
|
-
await Promise.all(promises);
|
|
365
|
-
return { small: !isBig, parts: partCount };
|
|
366
|
-
}, _FileManager_uploadPart = async function _FileManager_uploadPart(fileId, partCount, isBig, index, bytes, signal) {
|
|
367
|
-
let retryIn = 1;
|
|
368
|
-
let errorCount = 0;
|
|
369
|
-
while (true) {
|
|
370
|
-
try {
|
|
371
|
-
signal?.throwIfAborted();
|
|
372
|
-
__classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] uploading part ` + (index + 1));
|
|
373
|
-
if (isBig) {
|
|
374
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "upload.saveBigFilePart", file_id: fileId, file_part: index, bytes: bytes, file_total_parts: partCount }, { type: "upload" });
|
|
375
|
-
}
|
|
376
|
-
else {
|
|
377
|
-
await __classPrivateFieldGet(this, _FileManager_c, "f").invoke({ _: "upload.saveFilePart", file_id: fileId, bytes: bytes, file_part: index }, { type: "upload" });
|
|
378
|
-
}
|
|
379
|
-
__classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] uploaded part ` + (index + 1));
|
|
380
|
-
break;
|
|
381
|
-
}
|
|
382
|
-
catch (err) {
|
|
383
|
-
signal?.throwIfAborted();
|
|
384
|
-
__classPrivateFieldGet(this, _FileManager_Lupload, "f").debug(`[${fileId}] failed to upload part ` + (index + 1));
|
|
385
|
-
++errorCount;
|
|
386
|
-
if (errorCount > 20) {
|
|
387
|
-
retryIn = 0;
|
|
388
|
-
errorCount = 20;
|
|
389
|
-
}
|
|
390
|
-
await __classPrivateFieldGet(this, _FileManager_instances, "m", _FileManager_handleError).call(this, err, retryIn, `[${fileId}-${index + 1}]`);
|
|
391
|
-
retryIn += 2;
|
|
392
|
-
if (retryIn > 11) {
|
|
393
|
-
retryIn = 11;
|
|
394
|
-
}
|
|
395
|
-
}
|
|
396
|
-
}
|
|
397
|
-
}, _FileManager_handleError = async function _FileManager_handleError(err, retryIn, logPrefix) {
|
|
398
|
-
if (retryIn > 0) {
|
|
399
|
-
__classPrivateFieldGet(this, _FileManager_Lupload, "f").warning(`${logPrefix} retrying in ${retryIn} seconds`);
|
|
400
|
-
await (0, _0_deps_js_1.delay)(retryIn * _0_deps_js_1.SECOND);
|
|
401
|
-
}
|
|
402
|
-
else {
|
|
403
|
-
throw err;
|
|
404
|
-
}
|
|
405
|
-
}, _FileManager_getFileContents = async function _FileManager_getFileContents(source, params, allowStream) {
|
|
406
|
-
let name = params?.fileName?.trim() || "file";
|
|
407
|
-
let contents;
|
|
408
|
-
let size = -1;
|
|
409
|
-
if (source instanceof Uint8Array) {
|
|
410
|
-
contents = source;
|
|
411
|
-
size = source.byteLength;
|
|
412
|
-
}
|
|
413
|
-
else if (source instanceof ReadableStream) {
|
|
414
|
-
if (!allowStream) {
|
|
415
|
-
throw new _0_errors_js_1.InputError("Streamed upload not allowed.");
|
|
416
|
-
}
|
|
417
|
-
contents = source;
|
|
418
|
-
}
|
|
419
|
-
else if (typeof source === "object" && source != null && (Symbol.iterator in source || Symbol.asyncIterator in source)) {
|
|
420
|
-
if (!allowStream) {
|
|
421
|
-
throw new _0_errors_js_1.InputError("Streamed upload not allowed.");
|
|
422
|
-
}
|
|
423
|
-
contents = new ReadableStream({
|
|
424
|
-
pull: Symbol.asyncIterator in source
|
|
425
|
-
? async (controller) => {
|
|
426
|
-
const { value, done } = await source.next();
|
|
427
|
-
done ? controller.close() : controller.enqueue(value);
|
|
428
|
-
}
|
|
429
|
-
: (controller) => {
|
|
430
|
-
const { value, done } = source.next();
|
|
431
|
-
done ? controller.close() : controller.enqueue(value);
|
|
432
|
-
},
|
|
433
|
-
});
|
|
434
|
-
}
|
|
435
|
-
else {
|
|
436
|
-
let url;
|
|
437
|
-
try {
|
|
438
|
-
url = new URL(source).toString();
|
|
439
|
-
}
|
|
440
|
-
catch {
|
|
441
|
-
let path_;
|
|
442
|
-
if (typeof source === "string") {
|
|
443
|
-
if ((0, _0_deps_js_1.isAbsolute)(source)) {
|
|
444
|
-
path_ = source;
|
|
445
|
-
}
|
|
446
|
-
else {
|
|
447
|
-
// @ts-ignore: lib
|
|
448
|
-
path_ = join(dntShim.Deno.cwd(), source);
|
|
449
|
-
}
|
|
450
|
-
url = (0, _0_deps_js_1.toFileUrl)(path_).toString();
|
|
451
|
-
name = (0, _0_deps_js_1.basename)(path_);
|
|
452
|
-
}
|
|
453
|
-
else {
|
|
454
|
-
(0, _0_deps_js_1.unreachable)();
|
|
455
|
-
}
|
|
456
|
-
}
|
|
457
|
-
const response = await fetch(url);
|
|
458
|
-
if (response.body == null) {
|
|
459
|
-
throw new _0_errors_js_1.InputError("Invalid response");
|
|
460
|
-
}
|
|
461
|
-
if (name == "file") {
|
|
462
|
-
const contentType = response.headers.get("content-type")?.split(";")[0].trim();
|
|
463
|
-
if (contentType) {
|
|
464
|
-
name += (0, _0_deps_js_1.extension)(contentType);
|
|
465
|
-
}
|
|
466
|
-
else {
|
|
467
|
-
const maybeFileName = new URL(response.url).pathname.split("/")
|
|
468
|
-
.filter((v) => v)
|
|
469
|
-
.slice(-1)[0]
|
|
470
|
-
.trim();
|
|
471
|
-
if (maybeFileName) {
|
|
472
|
-
name += (0, _0_deps_js_1.extension)((0, _0_deps_js_1.extname)(maybeFileName));
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
const contentLength = Number(response.headers.get("content-length"));
|
|
477
|
-
if (!isNaN(contentLength)) {
|
|
478
|
-
size = contentLength;
|
|
479
|
-
}
|
|
480
|
-
if (allowStream) {
|
|
481
|
-
contents = response.body;
|
|
482
|
-
}
|
|
483
|
-
else {
|
|
484
|
-
contents = new Uint8Array(await response.arrayBuffer());
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return { size: params?.fileSize ? params.fileSize : size, name, contents };
|
|
488
|
-
};
|
|
489
|
-
_FileManager_UPLOAD_MAX_CHUNK_SIZE = { value: 512 * _1_utilities_js_1.kilobyte };
|
|
490
|
-
_FileManager_DOWNLOAD_MAX_CHUNK_SIZE = { value: 1 * _1_utilities_js_1.megabyte };
|
|
491
|
-
_FileManager_BIG_FILE_THRESHOLD = { value: 10 * _1_utilities_js_1.megabyte };
|
|
492
|
-
_FileManager_CUSTOM_EMOJI_TTL = { value: 30 * _0_deps_js_1.MINUTE };
|
|
546
|
+
_a = FileManager;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2_file_manager_test.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager_test.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"2_file_manager_test.d.ts","sourceRoot":"","sources":["../../src/client/2_file_manager_test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,2BAA2B,CAAC"}
|