static

package
v0.0.0-...-fbcb358 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2026 License: BSD-3-Clause Imports: 20 Imported by: 0

Documentation

Overview

Package static reads and transforms static files.

Index

Constants

View Source
const (
	BundleFile = "bundle.js" // generated file containing bundled JS

	IndexFile = "index.html" // file that initially loads JS

)

Variables

This section is empty.

Functions

func GetFile

func GetFile(p string, staticFS fs.FS, opts ...GetFileOption) ([]byte, error)

GetFile returns the contents of the file at the specified path (without a leading slash) within staticDir.

Files are transformed in various ways:

  • If GetFileMinify(true) is passed, the returned file is minified.
  • If IndexFile is requested, scriptPlaceholder is replaced by BundleFile if minification is performed or by the JS version of bundleEntryPoint otherwise. remotePlayerPlaceholder is also replaced by "true" if GetFileRemotePlayer(true) is passed or by "false" otherwise, and buildTimestampPlaceholder is replaced by the string set via GetFileBuildTimestamp.
  • If BundleFile is requested, bundleEntryPoint and all of its dependencies are returned as a single ES module. The code is minified regardless of whether minification was requested.
  • If a nonexistent .js file is requested, its .ts counterpart is transpiled and returned.

func InlineData

func InlineData(r io.Reader, dir string, staticFS fs.FS) ([]byte, error)

InlineData reads from r and updates const variable declarations requesting inlined data from files in staticFS, e.g. "const HTML_DATA = 'inline(foo.html)'". The inlined data is minified.

Types

type GetFileOption

type GetFileOption func(*getFileConfig)

GetFileOption can be passed to GetFile to configure its behavior.

func GetFileBuildTimestamp

func GetFileBuildTimestamp(ts string) GetFileOption

GetFileBuildTimestamp sets an opaque build timestamp to embed in the code.

func GetFileMinify

func GetFileMinify(minify bool) GetFileOption

GetFileMinify specifies whether minification should be performed. By default, minification is not performed.

func GetFileRemotePlayer

func GetFileRemotePlayer(remote bool) GetFileOption

GetFileRemotePlayer specifies whether the app should use the RemotePlayer class to communicate with a nup-headless instance (rather than LocalPlayer to play using <audio> elements). By default, RemotePlayer is not used.

Jump to

Keyboard shortcuts

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