Remote

HTTP client for downloading bundles from a remote server.

HTTP client for downloading bundles from a remote server.

The remote client implements the bundle HTTP protocol, allowing you to:

  • List available bundles
  • Get bundle metadata
  • Download specific versions
  • Track download progress

View source ↗

Constructor

new Remote(endpoint: string, options?: RemoteOptions | null);

Prop

Type

Methods

Prop

Type

Examples

const remote = new Remote('https://updates.example.com');

// List all bundles
const bundles = await remote.listBundles();

// Get current version info
const info = await remote.getInfo('app');
console.log(`Latest version: ${info.version}`);

// Download bundle
const [bundleInfo, bundle, data] = await remote.download('app');

constructor

const remote = new Remote('https://updates.example.com');
// With options
const remote = new Remote('https://updates.example.com', {
  http: { timeout: 60000 },
  onDownload: data => {
    const percent = (data.downloadedBytes / data.totalBytes) * 100;
    console.log(`Progress: ${percent.toFixed(1)}%`);
  },
});

download

const [info, bundle, data] = await remote.download('app');
console.log(`Downloaded ${info.name}@${info.version}`);
console.log(`Size: ${data.length} bytes`);

// Save to file
await writeBundle(bundle, 'app.wvb');

downloadVersion

const [info, bundle, data] = await remote.downloadVersion('app', '1.0.0');
console.log(`Downloaded specific version: ${info.version}`);

getInfo

const info = await remote.getInfo('app');
console.log(`Current version: ${info.version}`);
if (info.integrity) {
  console.log(`Integrity: ${info.integrity}`);
}

listBundles

const bundles = await remote.listBundles();
for (const bundle of bundles) {
  console.log(`${bundle.name}@${bundle.version}`);
}

On this page