web

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2024 License: BSD-3-Clause Imports: 18 Imported by: 0

README

Web compilation

This code is extensively based on maxence-charriere/go-app.

MIT License (Copyright (c) 2016 Maxence Charriere)

Documentation

Index

Constants

View Source
const (
	// DefaultAppWorkersJS is the default template used in [MakeAppWorkerJS] to generate app-worker.js.
	DefaultAppWorkerJS = "" /* 2731-byte string literal not displayed */

	// WASMExecJSGoCurrent is the wasm_exec.js file for the current version of Go.
	WASMExecJSGoCurrent = "" /* 18065-byte string literal not displayed */

	// AppJS is the string used for [AppJSTmpl].
	AppJS = "" /* 9450-byte string literal not displayed */

	// ManifestJSON is the string used for [ManifestJSONTmpl].
	ManifestJSON = "" /* 663-byte string literal not displayed */

	// AppCSS is the string used for app.css.
	AppCSS = "" /* 2113-byte string literal not displayed */

	// IndexHTML is the string used for [IndexHTMLTmpl].
	IndexHTML = "" /* 1987-byte string literal not displayed */

)

Variables

View Source
var AppJSTmpl = template.Must(template.New("app.js").Parse(AppJS))

AppJSTmpl is the template used in MakeAppJS to build the app.js file

View Source
var IndexHTMLTmpl = template.Must(template.New("index.html").Parse(IndexHTML))

IndexHTMLTmpl is the template used in MakeIndexHTML to build the index.html file

View Source
var ManifestJSONTmpl = template.Must(template.New("manifest.webmanifest").Parse(ManifestJSON))

ManifestJSONTmpl is the template used in MakeManifestJSON to build the mainfest.webmanifest file

Functions

func Build

func Build(c *config.Config) error

Build builds an app for web using the given configuration information.

func MakeAppJS

func MakeAppJS(c *config.Config) ([]byte, error)

MakeAppJS exectues AppJSTmpl based on the given configuration information.

func MakeAppWorkerJS

func MakeAppWorkerJS(c *config.Config) ([]byte, error)

MakeWorkerJS executes [config.Config.Web.ServiceWorkerTemplate]. If it empty, it sets it to DefaultAppWorkerJS.

func MakeFiles

func MakeFiles(c *config.Config) error

MakeFiles makes the necessary static web files based on the given configuration information.

func MakeIndexHTML

func MakeIndexHTML(c *config.Config) ([]byte, error)

MakeIndexHTML exectues IndexHTMLTmpl based on the given configuration information.

func MakeManifestJSON

func MakeManifestJSON(c *config.Config) ([]byte, error)

MakeManifestJSON exectues ManifestJSONTmpl based on the given configuration information.

func Serve

func Serve(c *config.Config) error

Serve serves the build output directory on the default network address at the config port.

func WASMExecJS

func WASMExecJS() string

WASMExecJS returns the wasm_exec.js file appropriate for the Go verison being used.

Types

type AppJSData

type AppJSData struct {
	Env                     string
	LoadingLabel            string
	Wasm                    string
	WasmContentLengthHeader string
	WorkerJS                string
	AutoUpdateInterval      int64
}

AppJSData is the data passed to AppJSTmpl

type AppWorkerJSData

type AppWorkerJSData struct {
	Version          string
	ResourcesToCache string
}

AppWorkerJSData is the data passed to [config.Config.Web.ServiceWorkerTemplate]

type IndexHTMLData

type IndexHTMLData struct {
	Author                 string
	Desc                   string
	Keywords               []string
	ThemeColor             string
	Title                  string
	Image                  string
	VanityURL              string
	GithubVanityRepository string
}

IndexHTMLData is the data passed to IndexHTMLTmpl

type ManifestJSONData

type ManifestJSONData struct {
	ShortName       string
	Name            string
	Description     string
	DefaultIcon     string
	LargeIcon       string
	SVGIcon         string
	BackgroundColor string
	ThemeColor      string
	Scope           string
	StartURL        string
}

ManifestJSONData is the data passed to ManifestJSONTmpl

Jump to

Keyboard shortcuts

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