Help us shape the future of Go! Take the 2026 Go Developer Survey

preview

package
v0.1.54 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package preview serves the page modlock dev opens beside a running mod: it draws every screen the mods show the local player with the game's own drawing on a browser stand-in for Panorama, says what the build and the mods are doing, and passes the page's presses and chat commands to the mods as that player's input. It serves the built mod's layouts as XML, so the page draws a mod's own layouts too.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Input

type Input func(ctx context.Context, in *cli.Input) string

Input passes one of the page's inputs to the mods and returns a line for the creator when no mod received it, or empty.

type Page

type Page struct {
	// contains filtered or unexported fields
}

Page follows the command line's events and serves the preview page from a directory of its files at /. The page opens a websocket at /socket, which carries its state down as JSON cli.Preview messages and the player's input up as JSON cli.Input messages. GET /layout/<mod>/<path> answers with the source of the mod's built layout at path. It serves loopback hosts and its own pages only.

func New

func New(dir, built string, watch bool, input Input) *Page

New returns a page serving the files in dir and the layouts of the mod built in built, and passing input to the mods, for a mod that rebuilds on each save when watch is true. It shows the first player who joins, the stand-in player in the sandbox.

func (*Page) Observe

func (p *Page) Observe(event *cli.Event)

Observe follows one of the command line's events: a build that starts or ends, a mod that starts or stops, or a change to a player's screen.

func (*Page) ServeHTTP

func (p *Page) ServeHTTP(w http.ResponseWriter, request *http.Request)

ServeHTTP serves the page and its socket.

Jump to

Keyboard shortcuts

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