hostlink

package
v0.0.0-...-94fff03 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 1 Imported by: 1 module, 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 hostlink is what a game or tool that runs under an editor host shares with that host, whichever protocol it speaks: the protocol version, the transport interface, the connection to the host page of a browser build, and the settings the host passes (stage, first file, whether it is untitled, asset root, file index). In a browser the settings come from globalThis.weakpixelHost, which the VSCode webview defines before the game starts; natively they come from WPIX_* environment variables.

Both the level editor's bridge (editor/bridge) and the tool shell (editor/toolshell, tools/wpix-editor) build on it. It imports only the standard library, so a tool links neither the bridge nor the level editor. See doc/design/editor-protocol.md#protocol.

Index

Constants

View Source
const (
	// EnvStage is the stage to run, "level" or "prefab" (see [Stage]).
	EnvStage = "WPIX_STAGE"
	// EnvPath is the asset key of the first file (see [Path]).
	EnvPath = "WPIX_PATH"
	// EnvHeadless is "1" to run without a window (see [Headless]).
	EnvHeadless = "WPIX_HEADLESS"
)

Environment variables a native host sets for the game it starts. They are read on every platform except the browser, where the page's script is the host. They do not overlap the WPIX_SCREENSHOT_* variables of the engine.

View Source
const Version = 0

Version is the protocol version, sent in "ready" by the level editor's bridge and by the tool shell. A host refuses a game with a version it does not know. The extension's PROTOCOL_VERSION must equal it.

Variables

This section is empty.

Functions

func AssetBase

func AssetBase() (string, bool)

AssetBase returns false: a native game reads its assets from the game's own FS, not from a host page.

func Files

func Files() []string

Files returns nil: a native game lists its own assets.

func GOD

func GOD() []string

GOD returns nil: a native game registers its own components.

func Headless

func Headless() bool

Headless reports whether WPIX_HEADLESS is "1": the game runs without a window (see editor/host).

func Path

func Path() string

Path returns the WPIX_PATH environment variable, the asset key of the file to open first, "" when it is not set.

func Stage

func Stage() string

Stage returns the WPIX_STAGE environment variable ("level" or "prefab"), "" when it is not set.

func Untitled

func Untitled() bool

Untitled returns false: a native editor opens files on disk; a missing file starts from its kind's starter instead.

Types

type Transport

type Transport interface {
	Send(msg []byte)
}

Transport sends one message to the host. It is called on the game goroutine.

func ConnectPage

func ConnectPage(func(msg []byte)) (Transport, bool)

ConnectPage returns false: outside a browser there is no host page.

Jump to

Keyboard shortcuts

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