Add Store MSIX packaging and dark/light theme for 2.9.0.
EOF Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
//go:build !windows
|
||||
|
||||
package update
|
||||
|
||||
// IsStorePackaged is false outside Windows (no Microsoft Store / MSIX package identity).
|
||||
func IsStorePackaged() bool { return false }
|
||||
@@ -0,0 +1,49 @@
|
||||
//go:build windows
|
||||
|
||||
package update
|
||||
|
||||
import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
|
||||
"golang.org/x/sys/windows"
|
||||
)
|
||||
|
||||
const (
|
||||
appModelErrorNoPackage = 15700 // APPMODEL_ERROR_NO_PACKAGE
|
||||
errorInsufficientBuffer = 122 // ERROR_INSUFFICIENT_BUFFER
|
||||
)
|
||||
|
||||
var (
|
||||
storeOnce sync.Once
|
||||
storePackaged bool
|
||||
)
|
||||
|
||||
// IsStorePackaged reports whether this process has an MSIX / Store package identity.
|
||||
// Store builds must not self-update (Store owns updates).
|
||||
func IsStorePackaged() bool {
|
||||
storeOnce.Do(func() {
|
||||
storePackaged = detectStorePackage()
|
||||
})
|
||||
return storePackaged
|
||||
}
|
||||
|
||||
func detectStorePackage() bool {
|
||||
mod := windows.NewLazySystemDLL("kernel32.dll")
|
||||
proc := mod.NewProc("GetCurrentPackageFullName")
|
||||
if err := proc.Find(); err != nil {
|
||||
return false
|
||||
}
|
||||
var n uint32
|
||||
r, _, _ := proc.Call(uintptr(unsafe.Pointer(&n)), 0)
|
||||
switch r {
|
||||
case appModelErrorNoPackage:
|
||||
return false
|
||||
case errorInsufficientBuffer:
|
||||
return true
|
||||
case 0:
|
||||
return n > 0
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
+19
-12
@@ -18,7 +18,7 @@ import (
|
||||
|
||||
// CurrentVersion is the product/semver used for update eligibility (feed "version").
|
||||
// Keep major.minor.patch only — no build suffix here.
|
||||
const CurrentVersion = "2.8.0"
|
||||
const CurrentVersion = "2.9.0"
|
||||
|
||||
// BuildNumber is the monotonic build within CurrentVersion (Windows FileVersion 4th part,
|
||||
// macOS CFBundleVersion suffix, Android versionCode low digits). Bump on every release build.
|
||||
@@ -64,17 +64,18 @@ type Manifest struct {
|
||||
|
||||
// Status is returned to the UI / CLI.
|
||||
type Status struct {
|
||||
Current string `json:"current"`
|
||||
Latest string `json:"latest,omitempty"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
SHA256 string `json:"sha256,omitempty"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
Available bool `json:"available"`
|
||||
Mandatory bool `json:"mandatory"`
|
||||
Checking bool `json:"checking,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
ManifestURL string `json:"manifest_url"`
|
||||
Current string `json:"current"`
|
||||
Latest string `json:"latest,omitempty"`
|
||||
Notes string `json:"notes,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
SHA256 string `json:"sha256,omitempty"`
|
||||
Platform string `json:"platform,omitempty"`
|
||||
Available bool `json:"available"`
|
||||
Mandatory bool `json:"mandatory"`
|
||||
Checking bool `json:"checking,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
ManifestURL string `json:"manifest_url"`
|
||||
StoreManaged bool `json:"store_managed,omitempty"` // MSIX / Microsoft Store — no in-app updates
|
||||
}
|
||||
|
||||
// PlatformKey is "GOOS-GOARCH", e.g. windows-amd64, darwin-arm64.
|
||||
@@ -192,6 +193,12 @@ func Check(ctx context.Context, manifestURL string) (Status, error) {
|
||||
}
|
||||
key := PlatformKey()
|
||||
st := Status{Current: DisplayVersion(), ManifestURL: manifestURL, Platform: key}
|
||||
if IsStorePackaged() {
|
||||
st.StoreManaged = true
|
||||
st.Available = false
|
||||
st.Notes = "Обновления через Microsoft Store"
|
||||
return st, nil
|
||||
}
|
||||
|
||||
m, err := fetchManifest(ctx, manifestURL)
|
||||
if err != nil {
|
||||
|
||||
@@ -20,6 +20,9 @@ const finishUpdateFlag = "--navis-finish-update"
|
||||
|
||||
// Apply downloads the new build and replaces the running Navis.exe after this process exits.
|
||||
func Apply(ctx context.Context, manifestURL string) (string, error) {
|
||||
if IsStorePackaged() {
|
||||
return "", fmt.Errorf("обновления устанавливаются через Microsoft Store")
|
||||
}
|
||||
latest, _, _, exe, tmp, err := prepareDownload(ctx, manifestURL)
|
||||
if err != nil {
|
||||
return "", err
|
||||
|
||||
Reference in New Issue
Block a user