Documentation
¶
Overview ¶
Package nativeapps prepares a private native graphical stack without changing system packages. Callers own user consent, authorization, and application launch.
Index ¶
- Constants
- Variables
- func PrepareInputClient(source, destination string) error
- func SelfTest(parent context.Context, root string) (result error)
- func SystemClientInputPython(ctx context.Context, xpra string, environment []string) (string, error)
- func WriteApplicationLauncher(directory string) (string, error)
- func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, ...) error
- func WriteTransferBundle(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, ...) error
- func XpraApplicationLifetimeArgs() []string
- func XpraNoAudioArgs() []string
- type Artifact
- type ClientInput
- type ClientInputCapability
- type Installation
- type Manager
- func (m *Manager) Cancel(owner, id string) (Status, error)
- func (m *Manager) Close()
- func (m *Manager) CompleteUpload(owner, id string) (Status, error)
- func (m *Manager) Directory() (string, error)
- func (m *Manager) DirectoryFor(digest string) (string, error)
- func (m *Manager) InstallationForProcess(process ProcessIdentity) (*Installation, error)
- func (m *Manager) Package() Package
- func (m *Manager) Plan(ctx context.Context) (TransferPlan, error)
- func (m *Manager) Snapshot(owner string) Status
- func (m *Manager) Start(owner, requestID, source string, uploadSize int64) (Status, error)
- func (m *Manager) Watch() (<-chan struct{}, func())
- func (m *Manager) WriteChunk(owner, id string, offset int64, data []byte) (Status, error)
- type Package
- type ProcessIdentity
- type Status
- type Tools
- type TransferPlan
Examples ¶
Constants ¶
const ClientInputTextLimit = 16000
ClientInputTextLimit bounds one atomic text commit in UTF-8 bytes. Applications must report rejected commits; truncation and automatic retry are forbidden.
const ClientInputVersion = 1
ClientInputVersion is the confirmed-text protocol advertised on Xpra's authenticated connection. Consumers must reject sessions without this version.
Variables ¶
var ErrBusy = errors.New("native preparation is already running")
var ErrForbidden = errors.New("native preparation belongs to another caller")
var ErrInvalid = errors.New("invalid native preparation request")
var ErrUnsupported = errors.New("native graphical components are unavailable for this platform")
Functions ¶
func PrepareInputClient ¶ added in v0.5.0
PrepareInputClient prepares an Xpra HTML5 v20/v21 distribution with exactly one external keyboard owner. It retains the original graphics, pointer and clipboard protocol implementations. The destination must not exist. Neither a failed preparation nor an unsupported source is usable as a client. Consumers serve this directory through the same authenticated Xpra endpoint.
func SelfTest ¶
SelfTest creates only its own virtual display and transient GTK fixture. A successful check proves actual window discovery, rendered pixels, and input; importing a module or starting a process alone is not readiness evidence.
func SystemClientInputPython ¶ added in v0.5.0
func SystemClientInputPython(ctx context.Context, xpra string, environment []string) (string, error)
SystemClientInputPython resolves the interpreter selected by an installed Xpra script, then probes that exact interpreter. It never substitutes the host's unrelated desktop Python or installs missing system dependencies.
func WriteApplicationLauncher ¶ added in v0.3.0
WriteApplicationLauncher installs the Linux GIO launcher in a consumer-owned private directory. Invoke it with the tools' Python, an absolute .desktop file and an absolute receipt path. The atomic receipt reports running, exited or failed. A running receipt confirms process launch, not window/pixel readiness. The launcher restores the host application environment and reaps descendants; closing a window or losing a viewer never terminates the application.
func WriteBundle ¶
func WriteBundle(ctx context.Context, pkg Package, cacheRoot string, output io.Writer, progress func(int64)) error
WriteBundle acquires the exact catalog archives for an offline host. It neither extracts nor executes them; the destination host verifies every original byte. Callers must publish the output only after this function returns successfully.
func WriteTransferBundle ¶ added in v0.4.0
func WriteTransferBundle(ctx context.Context, pkg Package, plan TransferPlan, cacheRoot string, output io.Writer, progress func(int64)) error
WriteTransferBundle accepts only a subset of the supplied trusted recipe. Consumer adapters must resolve pkg from their compiled catalog, not a client. An empty plan needs no bundle: use Manager.Start with source "cache" instead.
func XpraApplicationLifetimeArgs ¶ added in v0.3.0
func XpraApplicationLifetimeArgs() []string
XpraApplicationLifetimeArgs binds an Xpra server to a monitored application child, independently of its viewers and windows. Use a --start-child command that remains alive until the application and its descendants have exited. Consumers still own application authorization, persistence and session policy.
func XpraNoAudioArgs ¶ added in v0.2.1
func XpraNoAudioArgs() []string
XpraNoAudioArgs disables audio support for a silent Xpra 6.x graphics session. Muting the speaker and microphone with "off" still initializes audio codecs; a missing audio backend can then delay every server inventory request. Session ownership, transport, and all other feature choices remain with the host.
Types ¶
type ClientInput ¶ added in v0.5.0
type ClientInput struct{ Launcher, GTKModules, QtPlugins string }
ClientInput is prepared support for one private X11 application session. Launch Launcher with the probed Xpra Python interpreter, normal Xpra arguments and XpraArgs. Start a private session bus first and pass its address explicitly to the application's start environment. These paths contain first-party adapters, never a copied host toolkit or a second input method engine.
func PrepareClientInput ¶ added in v0.5.0
func PrepareClientInput(directory, architecture string) (ClientInput, error)
PrepareClientInput installs the complete input contract into a new absolute private directory. The architecture is the application host's Go architecture.
func (ClientInput) XpraArgs ¶ added in v0.5.0
func (input ClientInput) XpraArgs(baseEnvironment []string) []string
XpraArgs selects client-owned composition in the private application environment. No host desktop input configuration is inherited or modified.
type ClientInputCapability ¶ added in v0.5.0
type ClientInputCapability struct {
Version int `json:"version"`
XpraVersion string `json:"xpra_version"`
}
func ProbeClientInput ¶ added in v0.5.0
func ProbeClientInput(ctx context.Context, python string, environment []string) (ClientInputCapability, error)
ProbeClientInput checks the interpreter and original XIM library before any application is launched. It does not acquire components or require a display. A successful probe does not assert that a particular application has a focused editable input context; that boundary is checked for every submitted commit.
type Installation ¶ added in v0.4.0
type Installation struct {
ID string `json:"id"`
Digest string `json:"digest"`
Architecture string `json:"architecture"`
Contract string `json:"contract"`
Ready bool `json:"ready"`
}
Installation identifies an installed recipe independently of the SDK release. Ready is a lightweight check of its private marker and required tool layout.
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func New ¶
New requires a private state root. Creating a manager never downloads or starts native processes. The optional validator is useful for host-owned qualification; production callers use the built-in graphical self-check by passing nil.
Example ¶
This example compiles in source checks but performs no network operations in tests. A service should retain its manager for the service's entire lifetime.
package main
import (
"context"
"fmt"
"log"
"os"
"path/filepath"
"time"
nativeapps "github.com/floegence/floe-native-apps"
)
func main() {
prepare := func(ctx context.Context, stateRoot, owner, requestID string) (nativeapps.Tools, error) {
pkg, err := nativeapps.NativePackage()
if err != nil {
return nativeapps.Tools{}, err
}
manager, err := nativeapps.New(stateRoot, pkg, nil)
if err != nil {
return nativeapps.Tools{}, err
}
defer manager.Close()
changes, stop := manager.Watch()
defer stop()
if _, err := manager.Start(owner, requestID, "download", 0); err != nil {
return nativeapps.Tools{}, err
}
for {
status := manager.Snapshot(owner)
if status.State == "ready" {
root, err := manager.Directory()
if err != nil {
return nativeapps.Tools{}, err
}
return nativeapps.ResolveTools(root)
}
if !status.Active() {
return nativeapps.Tools{}, fmt.Errorf("preparation %s: %s", status.State, status.ErrorCode)
}
select {
case <-ctx.Done():
return nativeapps.Tools{}, ctx.Err()
case <-changes:
}
}
}
cache, err := os.UserCacheDir()
if err != nil {
log.Fatal(err)
}
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Minute)
defer cancel()
// A real product supplies an authenticated owner and a stable request ID.
tools, err := prepare(ctx, filepath.Join(cache, "floe-native-apps"), "local-user", "prepare-1")
if err != nil {
log.Fatal(err)
}
fmt.Println(tools.Xpra)
}
Output:
func (*Manager) DirectoryFor ¶ added in v0.4.0
DirectoryFor resolves an exact supported installation for a surviving process. It never changes the current installation or prepares another version.
func (*Manager) InstallationForProcess ¶ added in v0.4.0
func (m *Manager) InstallationForProcess(process ProcessIdentity) (*Installation, error)
InstallationForProcess identifies a legacy backend's private loader using kernel evidence. Nil means a system installation outside this manager's root. The caller still owns application authorization and backend identity checks.
func (*Manager) Plan ¶ added in v0.4.0
func (m *Manager) Plan(ctx context.Context) (TransferPlan, error)
Plan verifies archives only on explicit preparation/inspection, never on the normal application-open or status path. It performs no network requests.
type Package ¶
type Package struct {
ID string `json:"id"`
Architecture string `json:"architecture"`
SizeBytes int64 `json:"size_bytes"`
InstalledBytes int64 `json:"installed_bytes"`
Artifacts []Artifact `json:"artifacts"`
}
func ForPlatform ¶
func NativePackage ¶
type ProcessIdentity ¶ added in v0.3.0
type ProcessIdentity struct {
PID int `json:"pid"`
Boot string `json:"boot"`
Started string `json:"started"`
}
ProcessIdentity is an observation of one Linux process generation. Persisting it allows a host to distinguish a surviving native backend from a reused PID after restart. It grants no authorization and must never be used alone to select an application or issue a signal.
func ObserveProcess ¶ added in v0.3.0
func ObserveProcess(pid int) (ProcessIdentity, error)
ObserveProcess reads the kernel's boot and start identity for a live process.
func (ProcessIdentity) Alive ¶ added in v0.3.0
func (p ProcessIdentity) Alive() bool
type Status ¶
type Status struct {
State string `json:"state"`
OperationID string `json:"operation_id,omitempty"`
ReceivedBytes int64 `json:"received_bytes"`
ExpectedBytes int64 `json:"expected_bytes"`
ErrorCode string `json:"error_code,omitempty"`
CanCancel bool `json:"can_cancel"`
Installed *Installation `json:"installed,omitempty"`
UpdateAvailable bool `json:"update_available"`
InstallationErrorCode string `json:"installation_error_code,omitempty"`
}
type Tools ¶
type Tools struct{ Root, Xpra, Python, Xvfb, Xauth, DBus, HTML string }
func ResolveTools ¶
func (Tools) Environment ¶
Environment scopes support-tool overrides. The GIO launcher must restore this small saved map on its AppLaunchContext before starting the user's program. Display and D-Bus addresses are deliberately not restored: those belong to the caller's private graphical session.
type TransferPlan ¶ added in v0.4.0
type TransferPlan struct {
PackageDigest string `json:"package_digest"`
Architecture string `json:"architecture"`
MissingArtifacts []string `json:"missing_artifacts"`
MissingBytes int64 `json:"missing_bytes"`
}
TransferPlan contains only identities from the receiver's trusted catalog. It is a cache observation, not an authorization or a reservation of cache files.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache.
|
Package artifactcache acquires pinned publisher archives into a private, content-addressed cache. |
|
cmd
|
|
|
floe-native-apps
command
floe-native-apps is an explicit qualification and offline acquisition tool.
|
floe-native-apps is an explicit qualification and offline acquisition tool. |