Docs/Download SDK

Download SDK

Universal Developer

Download SDK

Overview

The Download SDK is the typed renderer entrypoint for Download Center tasks. It supports application updates, resource prefetching, plugin downloads, task history, maintenance, and progress subscriptions without exposing raw IPC.

Runtime contract

  • useDownloadSdk() creates a typed SDK over TuffTransport.
  • Download Center in the main process owns scheduling and task state.
  • The renderer sends commands and subscribes to push events; it does not own a duplicate task store.
  • metadata.hidden marks internal tasks so ordinary download views and notifications can suppress them; Developer Mode may still expose them.

Operations

The current SDK includes task add/pause/resume/cancel/retry/remove operations, bulk pause/resume/cancel, task and history queries, file actions, notification settings, maintenance, statistics, migration status, and lifecycle subscriptions.

Usage

EXAMPLE.TYPESCRIPT
import { useDownloadSdk } from '@talex-touch/utils/renderer'

const download = useDownloadSdk()
const result = await download.addTask({
  url: 'https://example.com/file.zip',
  destination: '/path/to/save',
  filename: 'file.zip',
  priority: 50,
  module: 'resource_download',
  metadata: { hidden: true }
})

if (!result.success) {
  throw new Error(result.error || 'Download failed')
}

Subscriptions return cleanup functions. Register them with the owning Vue lifecycle, or use the scoped helper where appropriate.

Best practices

  • Set meaningful priority and module values for scheduling and diagnostics.
  • Batch or debounce task creation instead of flooding the queue.
  • Handle failed operation responses and expose an appropriate retry path.
  • Unsubscribe from task events when the owning view or composable is disposed.
  • Use release/download routes through the update service contract; do not bypass Download Center from the renderer.