ci-platforms / darwin amd64 smoke (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
ci-platforms / windows amd64 smoke (push) Skipped
ci / checks (push) Successful in 10m24s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m13s
ci / release (push) Successful in 8m57s
modules/update links aego/update (net/http, TLS, x509, archives) only off js; the web build gets a browser backend with the same section, settings and aego/update API, where Check and Apply fail and State stays idle. A test compares both builds' registrations. depcheck: wasm-runtime and wasm-try variants, update in wasmDenied, wasmDeniedStd (net/http, crypto/tls, crypto/x509, archive/*) with the wasm-reaches-std rule. wasmsize -prev: playground-size and try-size print the change since their last run. Loaders show the compressed download size: wasmGzip in an export's files.json, aego-*-gzip and data-wasm-gzip on the site; docstool writes the .wasm.gz copies. Demo game.wasm 33.9 -> 26.0 MB, gzip 8.07 -> 6.25 MB.
43 lines
1.7 KiB
Go
43 lines
1.7 KiB
Go
package update
|
|
|
|
import "aego/script/bind"
|
|
|
|
func installScript(m *bind.Module, mod *Module) {
|
|
bind.Proc0(m, "Check", func(c *bind.Ctx) {
|
|
if err := mod.Check(); err != nil {
|
|
c.Fail(err.Error())
|
|
}
|
|
}, bind.Doc("Check looks for a newer version on the game's update server in the background; State says what it found."),
|
|
bind.Example("update.Check()"))
|
|
bind.Func0(m, "State", func(c *bind.Ctx) string {
|
|
p, _, _, _ := mod.State()
|
|
return p.String()
|
|
}, bind.Doc("State is idle, checking, upToDate, available, downloading, ready or failed."),
|
|
bind.Example("if update.State() == \"ready\" {"))
|
|
bind.Func0(m, "Version", func(c *bind.Ctx) string {
|
|
_, v, _, _ := mod.State()
|
|
return v
|
|
}, bind.Doc("Version is the newer version the last check found, empty when there is none."),
|
|
bind.Example("label.Text = \"Version \" + update.Version() + \" is ready\""))
|
|
bind.Func0(m, "Notes", func(c *bind.Ctx) string {
|
|
_, _, notes, _ := mod.State()
|
|
return notes
|
|
}, bind.Doc("Notes are the release notes of the newer version."),
|
|
bind.Example("notes.Text = update.Notes()"))
|
|
bind.Func0(m, "Error", func(c *bind.Ctx) string {
|
|
_, _, _, err := mod.State()
|
|
return err
|
|
}, bind.Doc("Error says why the last check or download failed."),
|
|
bind.Example("log.Warn(update.Error())"))
|
|
bind.Proc0(m, "Download", func(c *bind.Ctx) {
|
|
mod.Download()
|
|
}, bind.Doc("Download fetches the newer version in the background; Auto mode does it on its own."),
|
|
bind.Example("update.Download()"))
|
|
bind.Proc0(m, "Apply", func(c *bind.Ctx) {
|
|
if err := mod.Apply(); err != nil {
|
|
c.Fail(err.Error())
|
|
}
|
|
}, bind.Doc("Apply installs the downloaded version and restarts the game on it; save the player's progress first."),
|
|
bind.Example("if update.State() == \"ready\" { update.Apply() }"))
|
|
}
|