# Versions and migration

The SDK's version is `major.minor.patch`. The web SDK, the native library, the bindings and the engine packages are
released together, and the [changelog](changelog.md) lists each release's changes to all of them. Within a major
version nothing you build against breaks for two minor versions. This page says how to read the version, what each
kind of release may change, and how to move from 1.0 to 1.1.

```c
printf("built against %d.%d.%d (ABI %d), running %s\n",
       SONA_VERSION_MAJOR, SONA_VERSION_MINOR, SONA_VERSION_PATCH, SONA_ABI, sona_version());
```

```cpp
std::printf("built against %d.%d.%d (ABI %d), running %s\n",
            SONA_VERSION_MAJOR, SONA_VERSION_MINOR, SONA_VERSION_PATCH, SONA_ABI, sona::version());
```

```csharp
Console.WriteLine($"running {SonaLibrary.Version}");
```

```rust
println!("running {}", version());
```

```python
print("running", sona.version())
```

```sh
sona version
```

## What a release may change

| Release | May add | May change or remove |
|---|---|---|
| Patch (1.1.0 to 1.1.1) | Fixes | Nothing you call |
| Minor (1.1 to 1.2) | Functions, structs, enum values, fields in a struct's `reserved` words, bindings' methods | Marks things deprecated; removes only what was deprecated two minor versions before |
| Major (1.x to 2.0) | Anything | Anything, said in its release notes |

Within 1.x every struct keeps its size and every field its offset; a number (`SONA_*`, an enum value, a result code)
keeps its meaning; every exported function stays. Something deprecated in 1.x still works in 1.x and 1.(x+1) and
goes, at the earliest, in 1.(x+2) ([the stable ABI](guides/abi.md)).

## Checking at run time

A program that loads the library at run time, or a binding, asks which ABI it has before it opens a context:

| Call | Gives |
|---|---|
| `sona_version()` | The library's version as text, `"1.1.0"` |
| `sona_abi_query` | Its `SONA_ABI`, the oldest `SONA_ABI` a caller may be built against, and its version as numbers |
| `sona_struct_size`, `sona_struct_offset` | A struct's size and a field's offset as the library has them |

The bindings make these checks themselves and refuse a library that does not match, with a message, instead of
misreading it. The [stable ABI](guides/abi.md) page has the check in each language.

## From 1.0 to 1.1

1.0 was the web SDK alone. 1.1 adds the native SDK (C and the bindings), the engine packages, the
templates and the tools, and keeps every 1.0 web call working as it was.

On the web:

- `SonaRenderer.create()`, `add`, `play`, `snapshot()`, `glb()` and the camera calls are unchanged.
- The renderer now draws with WebGPU where the browser has it and WebGL2 elsewhere; the pictures are the same. To
  keep WebGL2, ask for it ([WebGPU and WebGL2](guides/web-webgpu.md)).
- New: the avatar editor element, `avatar.update(manifest)`, the wardrobe and colour lists, headless pictures, the
  three.js, Babylon.js and React packages ([the changelog](changelog.md)).

From the web to native: the ideas carry over one for one. A web `scene` is a context (`sona_ctx`), `scene.add` is
`sona_avatar_add_base64`, `avatar.play` is `sona_avatar_play`, and the page's animation frame is your loop's
`sona_update` and `sona_draw`. Items come from the gate through your licence file instead of the bridge
([getting started](getting-started.md)).

## Downloads and versions

A download is one version, stamped for your app. To move to a new version, download again: the new build has its own
build id and licence file, and the old one keeps working until you revoke it ([signed releases](guides/release.md)).

## When a new version is out

The tools tell you. `sona update` asks 360sona and says whether a newer SDK is out, what changed (the
[changelog](changelog.md)) and how to update; with `--json` it gives `current`, `latest` and `newer` for scripts.
Every other `sona` command reminds you once a day, in one line on stderr after its own output, when one is out.
SDK Studio shows the same as a bar under its address bar, and Help > Check for updates asks again.

Updating is two steps:

1. The tools, which bring SDK Studio with them: Setup, or the tools for your system, from your app's page
   (https://360sona.com/devapp.html), or `sona app tools <system>` with your app key.
2. Your SDK, which is made for your app: download it again from the same page, or `sona app download <platform>
   --force`.

The check needs no key and sends no key, app id or account: it reads the server's list of downloads at most once a
day and keeps the answer in your user's cache folder. The reminder never shows in scripts, pipes, `--json`, `--quiet`,
`sona mcp` or when `CI` is set; `SONA_NO_UPDATE_CHECK=1` turns it off everywhere, the Studio's bar included.

## Related

- [The stable ABI and deprecation](guides/abi.md)
- [Changelog](changelog.md)
- [Signed releases](guides/release.md)
