Ende.autoUpdate

function · desktop apps only

function Ende.autoUpdate(url: string): void

Start checking a release server for over-the-air updates.

Updates are delivered as binary diffs against the app's native library, so only the bytes that changed between versions are downloaded. On each check, the manifest at <url>/latest.json is fetched and its version compared against Ende.desktopVersion:

  • If publicKey is set, the manifest signature is verified first and an unsigned or invalid manifest is rejected.
  • If the manifest advertises a newer version and lists a patch from the currently running version (under patches[<currentVersion>], as { name, sha256 }), that patch is downloaded, checked against its declared SHA-256, applied, and staged for the next launch.
  • onUpdateReady is then invoked. The new version takes effect the next time the app starts.

The staged update is swapped in atomically on the next launch, with the previous version kept as a backup. If the updated app fails to start, it is automatically rolled back to the backup and onRollback is invoked shortly after the next autoUpdate call.

The release server URL may be passed directly, supplied via AutoUpdateOptions.url, or configured once in ende.json under desktop.release.baseUrl (in which case it can be omitted). A single check runs ~1s after the call; pass interval to keep polling.

Because updates rewrite the app's own library file in place, they only apply where the running process can write to its installed files. This works for self-contained, user-writable installs (a .app bundle or a loose binary in the user's home directory, a writable AppImage next to its data). It does not work for read-only or system-owned installs — an AppImage mounted read-only, or an app installed under /usr from an rpm/deb package owned by root. In those cases the write fails, the failure is logged, and the update is skipped; distribute updates through the system package manager instead.

Only available in apps compiled with ende desktop.

Ende.autoUpdate({
  url: "https://releases.example.com/myapp",
  interval: 60 * 60 * 1000, // hourly
  publicKey: "b64EncodedEd25519PublicKey==",
  onUpdateReady(version) {
    console.log(`v${version} staged; restart to apply`);
  },
  onRollback(reason) {
    console.warn(`update rolled back: ${reason}`);
  },
});

function · desktop apps only

function Ende.autoUpdate(options?: AutoUpdateOptions): void