playground

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package playground exposes an in-memory compiler suitable for browser playgrounds and WASM wrappers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func UIHTML added in v0.1.5

func UIHTML() string

UIHTML returns a self-contained browser playground shell. It expects wasm_exec.js and gowdk.wasm to be served next to the HTML document.

Types

type Diagnostic

type Diagnostic struct {
	File     string   `json:"file"`
	Code     string   `json:"code,omitempty"`
	Pos      Position `json:"pos"`
	Range    *Range   `json:"range,omitempty"`
	Severity string   `json:"severity"`
	Message  string   `json:"message"`
}

Diagnostic is a source diagnostic safe to serialize to browser clients.

type Position

type Position struct {
	Line   int `json:"line"`
	Column int `json:"column"`
}

Position is a 1-based source location.

type Preview added in v0.1.5

type Preview struct {
	HTMLPath string
	HTML     string
	Token    string
}

Preview is a browser-ready view of a compiled playground result.

type PreviewOptions added in v0.1.5

type PreviewOptions struct {
	AssetPathPrefix string
	ActionPath      string
	MaxCachedBuilds int
}

PreviewOptions configures compiler-owned browser preview rendering.

type PreviewServer added in v0.1.5

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

PreviewServer renders preview HTML from compiler output and serves the generated assets that preview HTML references.

func NewPreviewServer added in v0.1.5

func NewPreviewServer(options PreviewOptions) *PreviewServer

NewPreviewServer creates a preview server for Result values returned by Compile.

func (*PreviewServer) MatchesAssetPath added in v0.1.5

func (server *PreviewServer) MatchesAssetPath(requestPath string) bool

func (*PreviewServer) Render added in v0.1.5

func (server *PreviewServer) Render(result Result) Preview

Render returns preview HTML for the first emitted HTML artifact and registers generated assets so ServeHTTP can return them.

func (*PreviewServer) ServeHTTP added in v0.1.5

func (server *PreviewServer) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type Project

type Project struct {
	Files     map[string]string `json:"files"`
	Config    gowdk.Config      `json:"-"`
	OutputDir string            `json:"outputDir,omitempty"`
}

Project is a browser-compiler input. Files maps project-relative paths to file contents. The current browser compiler accepts .gwdk page, component, and layout files.

type Range

type Range struct {
	Start Position `json:"start"`
	End   Position `json:"end"`
}

Range is a 1-based source range. End is exclusive.

type Result

type Result struct {
	Files       map[string]string `json:"files"`
	HTML        map[string]string `json:"html"`
	CSS         map[string]string `json:"css"`
	Routes      []Route           `json:"routes"`
	Diagnostics []Diagnostic      `json:"diagnostics"`
}

Result is the browser-compiler output.

func Compile

func Compile(project Project) Result

Compile parses, validates, and renders a project at build time without writing files. It is intended for playgrounds; generated apps, binaries, request-time SSR, and action execution remain native/server compiler features.

type Route

type Route struct {
	PageID string `json:"page"`
	Route  string `json:"route"`
	Path   string `json:"path"`
}

Route describes one app-shell HTML route produced by a compile.

Jump to

Keyboard shortcuts

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