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, targetSha256 }), that patch is downloaded and checked against sha256. It is applied to the installed library, and the result must match targetSha256, the SHA-256 of the new version's native library (the file the patch was made to produce). Only then is it staged for the next launch. An entry without targetSha256, as in manifests written for older Ende versions, is not used.
  • onUpdateReady is then invoked. The new version takes effect the next time the app starts.

On the next launch, the staged update is swapped in atomically, with the previous version kept as a backup, and the app restarts into it right away, before any of its code runs. If the new version then fails to start, the launch after that rolls back to the backup, restarts into the previous version, and onRollback is invoked shortly after its autoUpdate call. "Fails to start" means the process ends before the main module has finished evaluating (top-level await included) and the event loop has run once more, or the main module throws, rejects, or leaves a rejection unhandled in that time. Exiting with code 0 counts as a successful start. Updates are applied on macOS and Linux only.

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