### Install Takanawa via vcpkg Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Install the Takanawa port using a local overlay path. ```sh vcpkg install takanawa --overlay-ports=/path/to/takanawa/ports ``` -------------------------------- ### Configure and Start TakanawaDownload in GDScript Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/gdextension.md Demonstrates how to connect signals, configure download parameters, and initiate a download using the TakanawaDownload node. ```gdscript extends Node @onready var download: TakanawaDownload = $TakanawaDownload func _ready() -> void: download.progress.connect(_on_progress) download.speed.connect(_on_speed) download.completed.connect(_on_completed) download.failed.connect(_on_failed) if not download.configure({ "url": "https://example.com/file.bin", "target_path": "user://file.bin", "parallelism": 4, "max_parallel_chunks": 8, "hash": { "kind": "sha256", "expected": "00".repeat(32), }, }): push_error(download.last_error()) return download.start() func _on_progress(snapshot: Dictionary) -> void: print("%s/%s" % [snapshot["downloaded_bytes"], snapshot["content_len"]]) func _on_speed(snapshot: Dictionary) -> void: print("%s B/s" % snapshot["bytes_per_second"]) func _on_completed(snapshot: Dictionary) -> void: print("download complete: ", snapshot) func _on_failed(message: String, snapshot: Dictionary) -> void: push_error("%s: %s" % [message, snapshot]) ``` -------------------------------- ### Install Takanawa NuGet Package Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/csharp.md Add this PackageReference to your .csproj file to include the Takanawa library. ```xml ``` -------------------------------- ### Install Frontend Dependencies Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Install the required npm packages for the Tauri frontend. ```sh pnpm add takanawa-tauri @tauri-apps/api ``` -------------------------------- ### Install takanawa-node via pnpm Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/node.md Install the package using the pnpm package manager. ```sh pnpm add takanawa-node ``` -------------------------------- ### Install Takanawa Capacitor Plugin Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/capacitor.md Commands to add the plugin to a Capacitor project and synchronize native platforms. ```sh pnpm add takanawa-capacitor pnpm exec cap sync ``` -------------------------------- ### Install takanawa-node via npm and yarn Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/node.md Install the package using standard npm or yarn package managers. ```sh npm install takanawa-node yarn add takanawa-node ``` -------------------------------- ### Install Takanawa CMake Package Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Use these commands to install the Takanawa CMake package for standard find_package usage. ```sh cmake -S . -B build -DCMAKE_INSTALL_PREFIX=/opt/takanawa cmake --build build --target install ``` -------------------------------- ### Use Takanawa TypeScript API Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-tauri/README.md Example usage of the downloadToCompletion function and DownloadTask class for managing file downloads. ```ts import { DownloadTask, downloadToCompletion } from 'takanawa-tauri' await downloadToCompletion({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip', parallelism: 4, hash: { kind: 'sha256', expected: '...64 hex characters...' } }) const task = new DownloadTask({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip' }) const progress = await task.addProgressListener((snapshot) => { console.log(snapshot.phase, snapshot.downloadedBytes, snapshot.contentLen) }) const speed = await task.addSpeedListener((snapshot) => { console.log(snapshot.bytesPerSecond, snapshot.receivedBytes) }) await task.start() console.log(await task.snapshot()) await progress.remove() await speed.remove() await task.close() ``` -------------------------------- ### Consume Installed Takanawa Package Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Use find_package to locate and link the installed Takanawa library in your CMake project. ```cmake find_package(Takanawa CONFIG REQUIRED) add_executable(example main.cpp) target_link_libraries(example PRIVATE Takanawa::takanawa) ``` -------------------------------- ### Initialize and Execute Download Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/apple.md Initialize the SDK and configure a download task with progress and speed callbacks. ```swift import Foundation import Takanawa try Takanawa.initialize(maxIo: 4) let download = try TakanawaDownload.create( DownloadConfig( url: "https://example.com/file.zip", targetPath: destination.path, parallelism: 4, hashKind: .sha256, expectedHash: expectedSha256Data ) ) try download.setProgressCallback { snapshot in print("\(snapshot.phase): \(snapshot.downloadedBytes)/\(snapshot.contentLen)") } try download.setSpeedCallback { snapshot in print("\(snapshot.bytesPerSecond) B/s") } try download.start() ``` -------------------------------- ### Initialize and Use Takanawa C# SDK Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Basic implementation for initializing the SDK, downloading a file, and capturing a snapshot. ```csharp using YetAnotherAI.Takanawa; Takanawa.Init(); using var download = TakanawaDownload.Create(new DownloadConfig( url: "https://example.com/file.bin", targetPath: "/tmp/file.bin")); download.Start(); var snapshot = download.Snapshot(); Takanawa.Shutdown(); ``` -------------------------------- ### Initialize and execute download Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/android.md Configure the Takanawa instance and manage download tasks with progress and speed callbacks. ```kotlin import ai.yetanother.takanawa.DownloadConfig import ai.yetanother.takanawa.HashKind import ai.yetanother.takanawa.Takanawa import ai.yetanother.takanawa.TakanawaDownload Takanawa.init(maxIo = 4) val download = TakanawaDownload.create( DownloadConfig( url = "https://example.com/file.zip", targetPath = cacheDir.resolve("file.zip").absolutePath, parallelism = 4, hashKind = HashKind.SHA256, expectedHash = expectedSha256Bytes, ) ) download.setProgressCallback { snapshot -> println("${snapshot.phase}: ${snapshot.downloadedBytes}/${snapshot.contentLen}") } download.setSpeedCallback { snapshot -> println("${snapshot.bytesPerSecond} B/s") } download.start() ``` -------------------------------- ### Run SwiftPM development and release tasks Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Commands for packaging, testing, and generating release manifests for SwiftPM. ```bash mise run package:swiftpm mise run test:swift-integration mise run swiftpm:release-manifest ``` -------------------------------- ### Initialize and configure TakanawaDownload in Godot Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Instantiate a TakanawaDownload node and connect to progress signals using GDScript. ```gdscript var download := TakanawaDownload.new() add_child(download) download.progress.connect(func(snapshot: Dictionary) -> void: print(snapshot["downloaded_bytes"]) ) download.configure({ "url": "https://example.com/file.bin", "target_path": "user://file.bin", }) download.start() ``` -------------------------------- ### Run C# Development Tasks Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/csharp.md Use these commands to verify bindings and package the NuGet library locally. ```sh mise run test:csharp ``` ```sh mise run pack:csharp ``` -------------------------------- ### Implement Takanawa in C# Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Use the NuGet package to manage downloads with progress and speed callbacks. ```csharp using YetAnotherAI.Takanawa; using var download = TakanawaDownload.Create(config); download.SetProgressCallback(snapshot => Console.WriteLine($"{snapshot.Phase}: {snapshot.DownloadedBytes}/{snapshot.ContentLen}")); download.SetSpeedCallback(snapshot => Console.WriteLine($"{snapshot.BytesPerSecond} B/s")); download.Start(); ``` -------------------------------- ### Initialize Takanawa in C++ Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Perform global initialization using the C ABI. Ensure tknw_global_init is called before any download operations. ```cpp #include #include "takanawa.h" int main() { TknwGlobalConfig config{ TKNW_ABI_VERSION, sizeof(TknwGlobalConfig), 0, }; if (tknw_global_init(&config) != TKNW_STATUS_OK) { return 1; } tknw_global_shutdown(); return 0; } ``` -------------------------------- ### Initialize and Execute Takanawa Download Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/csharp.md Initialize the Takanawa engine and configure a download with progress and speed callbacks. Ensure the download object is disposed and Takanawa is shut down after use. ```csharp using YetAnotherAI.Takanawa; Takanawa.Init(maxIo: 4); using var download = TakanawaDownload.Create(new DownloadConfig( url: "https://example.com/file.zip", targetPath: "/tmp/file.zip", parallelism: 4, hashKind: HashKind.Sha256, expectedHash: expectedSha256Bytes)); download.SetProgressCallback(snapshot => { Console.WriteLine($"{snapshot.Phase}: {snapshot.DownloadedBytes}/{snapshot.ContentLen}"); }); download.SetSpeedCallback(snapshot => { Console.WriteLine($"{snapshot.BytesPerSecond} B/s"); }); download.Start(); ``` -------------------------------- ### Perform downloads and track progress Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/node.md Demonstrates using downloadToCompletion for simple tasks and DownloadTask for granular control with progress and speed listeners. ```ts import { DownloadTask, downloadToCompletion } from 'takanawa-node' await downloadToCompletion({ url: 'https://example.com/file.zip', targetPath: '/tmp/file.zip', parallelism: 4, hash: { kind: 'sha256', expected: '...64 hex characters...' } }) const task = new DownloadTask({ url: 'https://example.com/file.zip', targetPath: '/tmp/file.zip' }) const progress = await task.addProgressListener((snapshot) => { console.log(snapshot.phase, snapshot.downloadedBytes, snapshot.contentLen) }) const speed = await task.addSpeedListener((snapshot) => { console.log(snapshot.bytesPerSecond, snapshot.receivedBytes) }) await task.start() console.log(await task.snapshot()) await progress.remove() await speed.remove() await task.close() ``` -------------------------------- ### Takanawa Android SDK Usage Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Demonstrates how to initialize the Takanawa SDK, configure and execute a file download, and shut down the SDK. ```APIDOC ## Takanawa Android SDK ### Description The Takanawa Android SDK allows for managing file downloads within an Android application. It requires initialization before use and should be shut down when finished. ### Initialization `Takanawa.init()` ### Download Management `TakanawaDownload.create(DownloadConfig(url, targetPath))` ### Lifecycle - `download.start()`: Starts the download process. - `download.snapshot()`: Retrieves a snapshot of the current download state. - `Takanawa.shutdown()`: Shuts down the SDK instance. ### Usage Example ```kotlin Takanawa.init() TakanawaDownload.create( DownloadConfig( url = "https://example.com/file.bin", targetPath = "/data/user/0/example/cache/file.bin", ), ).use { download -> download.start() val snapshot = download.snapshot() } Takanawa.shutdown() ``` ``` -------------------------------- ### Build Godot GDExtension locally Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Commands to package and distribute the desktop GDExtension. ```sh mise run package:gdextension-desktop mise run dist:gdextension ``` -------------------------------- ### Run local development commands Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/rust.md Execute tests and build the CLI client from the repository root. ```sh cargo test --workspace ``` ```sh cargo build -p takanawa-cli ``` -------------------------------- ### Build and Test Commands Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/apple.md Use these commands for local development and integration testing. ```sh mise run package:apple ``` ```sh mise run package:swiftpm ``` ```sh mise run test:swift-integration ``` -------------------------------- ### Build the package Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-node/README.md Command to build the native Node-API addon and TypeScript wrappers. ```sh pnpm --filter takanawa-node build ``` -------------------------------- ### Build GDExtension Locally Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/gdextension.md Commands for running tests and packaging the GDExtension for desktop platforms. ```sh cargo test -p takanawa-gdextension --locked mise run package:gdextension-desktop mise run dist:gdextension ``` -------------------------------- ### Initialize and use Takanawa Android Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Basic lifecycle management and download configuration for the Android SDK. ```kotlin Takanawa.init() TakanawaDownload.create( DownloadConfig( url = "https://example.com/file.bin", targetPath = "/data/user/0/example/cache/file.bin", ), ).use { download -> download.start() val snapshot = download.snapshot() } Takanawa.shutdown() ``` -------------------------------- ### Build and test takanawa-node locally Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/node.md Commands to build the native addon and run tests within the monorepo. ```sh pnpm --filter takanawa-node build ``` ```sh pnpm --filter takanawa-node test ``` -------------------------------- ### Run tests Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/getting-started.md Execute the test suite for the workspace. ```sh mise run test ``` -------------------------------- ### Download Files with Takanawa Capacitor Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/capacitor.md Demonstrates both the direct download-to-completion utility and the granular DownloadTask API for progress tracking. ```ts import { DownloadTask, downloadToCompletion } from 'takanawa-capacitor' await downloadToCompletion({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip', parallelism: 4, hash: { kind: 'sha256', expected: '...64 hex characters...' } }) const task = new DownloadTask({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip' }) const progress = await task.addProgressListener((snapshot) => { console.log(snapshot.phase, snapshot.downloadedBytes, snapshot.contentLen) }) await task.start() console.log(await task.snapshot()) await progress.remove() await task.close() ``` -------------------------------- ### Run Development Commands Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Commands for building the JS package and running Rust plugin tests. ```sh pnpm --filter takanawa-tauri test ``` ```sh cargo test -p tauri-plugin-takanawa ``` -------------------------------- ### Configure CMake with vcpkg Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Configure your project using the vcpkg toolchain and the required overlay ports path. ```sh cmake -S . -B build \ -DCMAKE_TOOLCHAIN_FILE=/path/to/vcpkg/scripts/buildsystems/vcpkg.cmake \ -DVCPKG_OVERLAY_PORTS=/path/to/takanawa/ports ``` -------------------------------- ### Configure App Capability Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Enable necessary permissions in the app capability file. ```json { "permissions": ["takanawa:default", "core:event:default"] } ``` -------------------------------- ### Generate local Rust documentation Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Build documentation for the workspace using Cargo. ```sh cargo doc --workspace --all-features --no-deps ``` -------------------------------- ### Build distributable artifacts Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/getting-started.md Build all available distributable artifacts for the current machine. ```sh mise run package ``` -------------------------------- ### Configure SwiftPM Dependency Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/apple.md Add the Takanawa repository as a dependency in your Package.swift file. ```swift .package(url: "https://github.com/yet-another-ai/takanawa.git", exact: "{{ takanawaVersion }}") ``` -------------------------------- ### Publish to Maven local Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Command to publish the Android library to the local Maven repository. ```sh mise run publish:android-local ``` -------------------------------- ### Implement Takanawa in Swift Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Configure progress and speed callbacks for the SwiftPM package. ```swift let download = try TakanawaDownload.create(config) try download.setProgressCallback { snapshot in print("\(snapshot.phase): \(snapshot.downloadedBytes)/\(snapshot.contentLen)") } try download.setSpeedCallback { snapshot in print("\(snapshot.bytesPerSecond) B/s") } try download.start() ``` -------------------------------- ### Build GDExtension for Mobile Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/gdextension.md Commands for packaging the GDExtension for Android and iOS platforms. ```sh mise run package:gdextension-android mise run package:gdextension-ios ``` -------------------------------- ### Configure Cargo dependencies Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/rust.md Add the required Takanawa crates to your Cargo.toml file. ```toml [dependencies] takanawa-core = "{{ takanawaVersion }}" takanawa-http = "{{ takanawaVersion }}" ``` ```toml [dependencies] takanawa-core = { path = "../takanawa/crates/takanawa-core" } takanawa-http = { path = "../takanawa/crates/takanawa-http" } ``` -------------------------------- ### Android development commands Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/android.md Commands for building the AAR, publishing to Maven local, and running SDK tests. ```sh mise run package:android-aar ``` ```sh ./gradlew :takanawa-android:publishToMavenLocal ``` ```sh ./gradlew -Ptakanawa.skipRustBuild=true :takanawa-android:test ``` -------------------------------- ### Generate C header file Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Use the mise task runner to generate the public C header from the FFI crate. ```sh mise run header ``` -------------------------------- ### Link C/C++ Library with CMake Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Integrate the Takanawa C ABI library into a CMake project. ```cmake add_subdirectory(path/to/takanawa) target_link_libraries(app PRIVATE Takanawa::takanawa) ``` -------------------------------- ### Sync project version Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Command to update the release version across the workspace. ```sh mise run version:sync ``` -------------------------------- ### Register Tauri Plugin Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Initialize the plugin within the Tauri builder configuration. ```rust tauri::Builder::default() .plugin(takanawa_tauri::init()) .run(tauri::generate_context!()) .expect("error while running Tauri application"); ``` -------------------------------- ### Build and Test Capacitor Plugin Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/capacitor.md Commands for building the JS package and running native unit tests for Android and iOS. ```sh pnpm --filter takanawa-capacitor test ``` ```sh ./gradlew -Ptakanawa.skipRustBuild=true :takanawa-capacitor:test ``` ```sh mise run test:capacitor-ios ``` -------------------------------- ### downloadToCompletion Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-capacitor/README.md Initiates a file download and waits for it to complete. This function handles the entire lifecycle of the download task. ```APIDOC ## downloadToCompletion ### Description Downloads a file from a URL to a specified target path and waits for completion. ### Parameters - **url** (string) - Required - The source URL of the file. - **targetPath** (string) - Required - The local file system path to save the download. - **parallelism** (number) - Optional - Number of parallel connections. - **hash** (object) - Optional - Verification hash object containing `kind` (e.g., 'sha256') and `expected` (64 hex characters). ``` -------------------------------- ### Run CMake Integration Tests Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Execute the smoke fixture for CMake integration. ```sh mise run test:cmake-integration ``` -------------------------------- ### CMake Configuration for Takanawa Integration Source: https://github.com/yet-another-ai/takanawa/blob/main/fixtures/cmake-integration/CMakeLists.txt Defines the project requirements, adds the Takanawa source directory, and sets up a smoke test executable with C++17 support and library linking. ```cmake cmake_minimum_required(VERSION 3.21) project(takanawa_cmake_integration LANGUAGES CXX) add_subdirectory("../.." takanawa-build) add_executable(takanawa_cpp_smoke main.cpp) target_compile_features(takanawa_cpp_smoke PRIVATE cxx_std_17) target_link_libraries(takanawa_cpp_smoke PRIVATE Takanawa::takanawa) if(WIN32 AND BUILD_SHARED_LIBS) add_custom_command(TARGET takanawa_cpp_smoke POST_BUILD COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "$" VERBATIM ) endif() ``` -------------------------------- ### Add Rust Plugin Dependency Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Add the plugin crate to your src-tauri/Cargo.toml file. ```toml [dependencies] takanawa-tauri = { package = "tauri-plugin-takanawa", version = "{{ takanawaVersion }}" } ``` -------------------------------- ### Add Takanawa to vcpkg Manifest Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Include Takanawa as a dependency in your project's vcpkg.json file. ```json { "dependencies": [ "takanawa" ] } ``` -------------------------------- ### Run workspace checks Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/getting-started.md Execute the full suite of workspace checks for repository contributors. ```sh mise run check ``` -------------------------------- ### Add Rust plugin dependency Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-tauri/README.md Add the Takanawa plugin to your Cargo.toml file. ```toml [dependencies] takanawa-tauri = { package = "tauri-plugin-takanawa", version = "0.8.3" } ``` -------------------------------- ### Add Takanawa Product Dependency Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/apple.md Specify the Takanawa product in your target dependencies. ```swift .product(name: "Takanawa", package: "takanawa") ``` -------------------------------- ### Release to Maven Central Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Gradle command used by the CI pipeline to publish Android native libraries to Maven Central. ```sh ./gradlew -Ptakanawa.skipRustBuild=true :takanawa-android:publishAndReleaseToMavenCentral ``` -------------------------------- ### downloadToCompletion Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-node/README.md Performs a complete file download operation to a specified target path with optional parallelism and hash verification. ```APIDOC ## downloadToCompletion ### Description Downloads a file from a URL to a local path, verifying the integrity of the file using a specified hash algorithm. ### Parameters - **url** (string) - Required - The source URL of the file. - **targetPath** (string) - Required - The local filesystem path where the file will be saved. - **parallelism** (number) - Optional - Number of concurrent connections for the download. - **hash** (object) - Optional - Verification object containing `kind` (sha1, sha256, sha512, md5, crc32) and `expected` (hex string). ### Example ```ts await downloadToCompletion({ url: 'https://example.com/file.zip', targetPath: '/tmp/file.zip', parallelism: 4, hash: { kind: 'sha256', expected: '...64 hex characters...' } }) ``` ``` -------------------------------- ### Configure CMake for Takanawa Package Consumption Source: https://github.com/yet-another-ai/takanawa/blob/main/fixtures/cmake-package-consumer/CMakeLists.txt Sets the minimum CMake version, defines the project, finds the Takanawa package, and links it to an executable. ```cmake cmake_minimum_required(VERSION 3.21) project(takanawa_cmake_package_consumer LANGUAGES CXX) find_package(Takanawa CONFIG REQUIRED) add_executable(takanawa_cpp_package_smoke ../cmake-integration/main.cpp) target_link_libraries(takanawa_cpp_package_smoke PRIVATE Takanawa::takanawa) ``` -------------------------------- ### DownloadTask Source: https://github.com/yet-another-ai/takanawa/blob/main/packages/takanawa-node/README.md A class for managing granular download operations, including progress and speed monitoring. ```APIDOC ## DownloadTask ### Description Represents a download task that allows for event listener registration and manual control over the download lifecycle. ### Methods - **addProgressListener(callback)**: Registers a listener for download progress updates. - **addSpeedListener(callback)**: Registers a listener for download speed updates. - **start()**: Initiates the download process. - **snapshot()**: Returns the current state of the download task. - **close()**: Closes the task and releases resources. ### Example ```ts const task = new DownloadTask({ url: '...', targetPath: '...' }); await task.addProgressListener((snapshot) => { ... }); await task.start(); await task.close(); ``` ``` -------------------------------- ### Build local Android AAR Source: https://github.com/yet-another-ai/takanawa/blob/main/README.md Command to build and verify the local Android Archive. ```sh mise run package:android-aar ``` -------------------------------- ### Takanawa .part File Layout Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/part-format.md The file structure consists of a content byte array followed by two fixed-size metadata slots. ```text [content bytes, length = content_len] [metadata slot 0, length = aligned_slot_size] [metadata slot 1, length = aligned_slot_size] ``` -------------------------------- ### Implement Takanawa in Android Kotlin Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/api/index.md Add the dependency and configure progress/speed callbacks for the Android SDK. ```kotlin dependencies { implementation("ai.yetanother:takanawa-android:{{ takanawaVersion }}") } val download = TakanawaDownload.create(config) download.setProgressCallback { snapshot -> println("${snapshot.phase}: ${snapshot.downloadedBytes}/${snapshot.contentLen}") } download.setSpeedCallback { snapshot -> println("${snapshot.bytesPerSecond} B/s") } download.start() ``` -------------------------------- ### Integrate Takanawa via CMake Subdirectory Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/c-cpp.md Add Takanawa as a subdirectory in your CMake project to consume the library directly from source. ```cmake cmake_minimum_required(VERSION 3.21) project(example LANGUAGES CXX) add_subdirectory(path/to/takanawa) add_executable(example main.cpp) target_link_libraries(example PRIVATE Takanawa::takanawa) ``` -------------------------------- ### Download Task Usage Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/tauri.md Perform file downloads and manage progress listeners using the DownloadTask API. ```ts import { DownloadTask, downloadToCompletion } from 'takanawa-tauri' await downloadToCompletion({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip', parallelism: 4, hash: { kind: 'sha256', expected: '...64 hex characters...' } }) const task = new DownloadTask({ url: 'https://example.com/file.zip', targetPath: '/path/to/file.zip' }) const progress = await task.addProgressListener((snapshot) => { console.log(snapshot.phase, snapshot.downloadedBytes, snapshot.contentLen) }) await task.start() console.log(await task.snapshot()) await progress.remove() await task.close() ``` -------------------------------- ### Add Android dependency Source: https://github.com/yet-another-ai/takanawa/blob/main/docs/guide/android.md Include the Takanawa Android AAR in your app or library module's build configuration. ```kotlin dependencies { implementation("ai.yetanother:takanawa-android:{{ takanawaVersion }}") } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.