wasmengine

package
v0.3.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: Apache-2.0 Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package wasmengine composes the services the browser engine serves (agni issue 178). It is separate from cmd/agni-wasm, which only bridges it to JavaScript, so the composition builds and is tested natively, against the server's, without a browser.

Index

Constants

View Source
const BrowserMount = "local"

BrowserMount is the mount a page puts dropped files in (agni issue 854). Its files exist only in the visitor's browser, and a `.zip` in it reads as the folder it was made from.

View Source
const Namespace = "agni"

Namespace is the global the wasm build's exports live under, globalThis.agni.

Variables

This section is empty.

Functions

func Build

func Build(root fs.FS) (http.Handler, error)

Build composes the engine over root, whose top-level directories are the mounts, which is how goapplib's wasmhost holds them, with nothing kept past the worker.

func BuildWith

func BuildWith(o Options) func(fs.FS) (http.Handler, error)

BuildWith is Build with options, the rebuild function cmd/agni-wasm hands the host.

func StoreVersion

func StoreVersion() string

StoreVersion names this build for the persistent tier: the commit, the uncommitted changes when there are any, and the layout of what is stored. It is empty, which persists nothing, for a build that cannot say what it was built from, since one could read a file differently from another and share a name with it.

func WithheldPlaceholder added in v0.3.0

func WithheldPlaceholder(sha256 string) []byte

WithheldPlaceholder is the placeholder for a held-back file whose content hash is sha256, as ListDesignFiles spells it.

Types

type Engine

type Engine struct {
	// Handler serves the Connect API, as `agni serve` does at the same paths.
	Handler http.Handler
	// Paths are the service paths Handler answers.
	Paths []string
	// Warnings are the legitimate absences agni.New reports, such as no datasheet corpus.
	Warnings []string
	// Cache is the design cache every service reads through, for its counters.
	Cache *service.DesignCache
}

Engine is one composition over one mount table. The browser rebuilds it when a mount changes, which is cheaper to reason about than services caching a project tree that moved under them.

func New

func New(ms ...fshost.Mount) (*Engine, error)

func NewWith

func NewWith(o Options, ms ...fshost.Mount) (*Engine, error)

NewWith is New with options.

type Options

type Options struct {
	// Store keeps every parsed design, drawing and board past the worker, so another worker over the
	// same files (a reload, a second lane, a lane's replacement) restores them rather than reading
	// them again (agni issue 911). In the browser it is wasmhost.BrowserCache. Nil keeps nothing.
	Store service.BlobStore
	// Version names the engine that wrote what Store holds. Empty means StoreVersion().
	Version string
	// CollectBetweenRequests is set by a caller that has turned the Go collector's automatic cycles
	// off (debug.SetGCPercent(-1)), as cmd/agni-wasm does. The engine then collects after a request
	// when the heap has doubled since its last collection, and likewise as each file opens, as well as
	// after each layer it loads, so never in the middle of evaluating (agni issue 1010). A native caller leaves it off, since its collector
	// runs concurrently on other cores and is cheap there.
	CollectBetweenRequests bool
}

Options configures an engine beyond its mount table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL