gfront

package module
v0.0.0-...-e056439 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 4 Imported by: 0

README

gfront

Thanks to Webassybly technology, we can develop front-end in Go+ language now.

Inspired of React, go-app and Go+ classfile

Hello, world

JS(React)

index.html

<!DOCTYPE html>
<html>
  <head>
    <script src="https://unpkg.com/react@16/umd/react.development.js"></script>
    <script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
    <script src="https://unpkg.com/babel-standalone@6.26.0/babel.js"></script>
  </head>

  <body>
    <div id="root"></div>
    <script type="text/babel">
      class App extends React.Component {
        render() {
          // JSX:
          return <h1>Hello world!</h1>
          // return React.createElement('h1', 'Hello, React!')
        }
      }
      ReactDOM.render(<App />, document.getElementById('root'))
    </script>
  </body>
</html>
Go+(gfront)

Main.app

route "/", &Hello{}
runWhenOnBrowser

Hello.com

func Render() UI {
    return h1.text("Hello World!")
}

Documentation

Overview

package gfront is a package to build progressive web apps (PWA) with Go programming language and WebAssembly. It uses a declarative syntax that allows creating and dealing with HTML elements only by using Go, and without writing any HTML markup. The package also provides an http.Handler ready to serve all the required resources to run Go-based progressive web apps.

Index

Constants

View Source
const (
	// IsClient reports whether the code is running as a client in the
	// WebAssembly binary (app.wasm).
	IsClient = runtime.GOARCH == "wasm" && runtime.GOOS == "js"

	// IsServer reports whether the code is running on a server for
	// pre-rendering purposes.
	IsServer = runtime.GOARCH != "wasm" || runtime.GOOS != "js"
)
View Source
const (
	GopPackage = true
	Gop_game   = "App"
	Gop_sprite = "Compo"
)

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(s *State)

Broadcast is a state option that broadcasts a state to other browser tabs and windows from the same origin.

func CopyBytesToGo

func CopyBytesToGo(dst []byte, src Value) int

CopyBytesToGo copies bytes from the Uint8Array src to dst. It returns the number of bytes copied, which will be the minimum of the lengths of src and dst.

CopyBytesToGo panics if src is not an Uint8Array.

func CopyBytesToJS

func CopyBytesToJS(dst Value, src []byte) int

CopyBytesToJS copies bytes from src to the Uint8Array dst. It returns the number of bytes copied, which will be the minimum of the lengths of src and dst.

CopyBytesToJS panics if dst is not an Uint8Array.

func Encrypt

func Encrypt(s *State)

Encrypt is a state option that encrypts a state before persisting it in local storage. Encryption is performed only when the Persist option is also set.

func GenerateStaticWebsite

func GenerateStaticWebsite(dir string, h *Handler, pages ...string) error

GenerateStaticWebsite generates the files to run a PWA built with go-app as a static website in the specified directory. Static websites can be used with hosts such as Github Pages.

Note that app.wasm must still be built separately and put into the web directory.

func Getenv

func Getenv(k string) string

Getenv retrieves the value of the environment variable named by the key. It returns the value, which will be empty if the variable is not present.

func Gopt_App_Main

func Gopt_App_Main(index interface{})

func HTMLString

func HTMLString(ui UI) string

HTMLString return an HTML string representation of the given UI element.

func HTMLStringWithIndent

func HTMLStringWithIndent(ui UI) string

HTMLStringWithIndent return an indented HTML string representation of the given UI element.

func Handle

func Handle(actionName string, h ActionHandler)

Handle registers the handler for the given action name. When an action occurs, the handler is executed on its own goroutine.

func KeepBodyClean

func KeepBodyClean() (close func())

KeepBodyClean prevents third-party Javascript libraries to add nodes to the body element.

func Persist

func Persist(s *State)

Persist is a state option that persists a state in local storage.

Be mindful to not use this option as a cache since local storage is limited to 5MB in a lot of web browsers.

func PrintHTML

func PrintHTML(w io.Writer, ui UI)

PrintHTML writes an HTML representation of the UI element into the given writer.

func PrintHTMLWithIndent

func PrintHTMLWithIndent(w io.Writer, ui UI)

PrintHTMLWithIndent writes an idented HTML representation of the UI element into the given writer.

func Route

func Route(path string, c Composer)

Route associates the type of the given component to the given path.

When a page is requested and matches the route, a new instance of the given component is created before being displayed.

func RouteWithRegexp

func RouteWithRegexp(pattern string, c Composer)

RouteWithRegexp associates the type of the given component to the given regular expression pattern.

Patterns use the Go standard regexp format.

When a page is requested and matches the pattern, a new instance of the given component is created before being displayed.

func RunWhenOnBrowser

func RunWhenOnBrowser()

RunWhenOnBrowser starts the app, displaying the component associated with the current URL path.

This call is skipped when the program is not run on a web browser. This allows writing client and server-side code without separation or pre-compilation flags.

Eg:

 func main() {
		// Define app routes.
		app.Route("/", myComponent{})
		app.Route("/other-page", myOtherComponent{})

		// Run the application when on a web browser (only executed on client side).
		app.RunWhenOnBrowser()

		// Launch the server that serves the app (only executed on server side):
		http.Handle("/", &app.Handler{Name: "My app"})
		http.ListenAndServe(":8080", nil)
 }

func TestMatch

func TestMatch(tree UI, d TestUIDescriptor) error

TestMatch looks for the element targeted by the descriptor in the given tree and reports whether it matches with the expected element.

Eg:

tree := app.Div().Body(
    app.H2().Body(
        app.Text("foo"),
    ),
    app.P().Body(
        app.Text("bar"),
    ),
)

// Testing root:
err := app.TestMatch(tree, app.TestUIDescriptor{
    Path:     TestPath(),
    Expected: app.Div(),
})
// OK => err == nil

// Testing h2:
err := app.TestMatch(tree, app.TestUIDescriptor{
    Path:     TestPath(0),
    Expected: app.H3(),
})
// KO => err != nil because we ask h2 to match with h3

// Testing text from p:
err = app.TestMatch(tree, app.TestUIDescriptor{
    Path:     TestPath(1, 0),
    Expected: app.Text("bar"),
})
// OK => err == nil

func TestPath

func TestPath(p ...int) []int

TestPath is a helper function that returns a path to use in a TestUIDescriptor.

Types

type Action

type Action = app.Action

Action represents a custom event that can be propagated across the app. It can contain a payload and be given additional context with tags.

type ActionHandler

type ActionHandler = app.ActionHandler

ActionHandler represents a handler that is executed when an action is created with Context.NewAction().

type AppInstaller

type AppInstaller = app.AppInstaller

AppInstaller is the interface that describes a component that is notified when the application installation state changes.

type AppUpdater

type AppUpdater = app.AppUpdater

AppUpdater is the interface that describes a component that is notified when the application is updated.

type BrowserStorage

type BrowserStorage = app.BrowserStorage

BrowserStorage is the interface that describes a web browser storage.

type BrowserWindow

type BrowserWindow = app.BrowserWindow

BrowserWindow is the interface that describes the browser window.

func Window

func Window() BrowserWindow

Window returns the JavaScript "window" object.

type ClientDispatcher

type ClientDispatcher = app.ClientDispatcher

ClientDispatcher is the interface that describes a dispatcher that emulates a client environment.

func NewClientTester

func NewClientTester(n UI) ClientDispatcher

NewClientTester creates a testing dispatcher that simulates a client environment. The given UI element is mounted upon creation.

type Compo

type Compo = app.Compo

Compo represents the base struct to use in order to build a component.

type Composer

type Composer = app.Composer

Composer is the interface that describes a customized, independent and reusable UI element.

Satisfying this interface is done by embedding app.Compo into a struct and implementing the Render function.

Example:

type Hello struct {
    app.Compo
}

func (c *Hello) Render() app.UI {
    return app.Text("hello")
}

type Condition

type Condition struct {
	app.Condition
}

Condition represents a control structure that displays nodes depending on a given expression.

func If

func If(expr bool, elems ...UI) *Condition

If returns a condition that filters the given elements according to the given expression.

func (*Condition) Else

func (c *Condition) Else(elems ...UI) *Condition

func (*Condition) ElseIf

func (c *Condition) ElseIf(expr bool, elems ...UI) *Condition

type Context

type Context = app.Context

Context is the interface that describes a context tied to a UI element.

A context provides mechanisms to deal with the browser, the current page, navigation, concurrency, and component communication.

It is canceled when its associated UI element is dismounted.

type Dismounter

type Dismounter = app.Dismounter

Dismounter is the interface that describes a component that can perform additional actions when dismounted.

type Dispatch

type Dispatch = app.Dispatch

Dispatch represents an operation executed on the UI goroutine.

type DispatchMode

type DispatchMode = app.DispatchMode

DispatchMode represents how a dispatch is processed.

const (
	// A dispatch mode where the dispatched operation is enqueued to be executed
	// as soon as possible and its associated UI element is updated at the end
	// of the current update cycle.
	Update DispatchMode = iota

	// A dispatch mode that schedules the dispatched operation to be executed
	// after the current update frame.
	Defer

	// A dispatch mode where the dispatched operation is enqueued to be executed
	// as soon as possible.
	Next
)

type Dispatcher

type Dispatcher = app.Dispatcher

Dispatcher is the interface that describes an environment that synchronizes UI instructions and UI elements lifecycle.

type Environment

type Environment = app.Environment

Environment describes the environment variables to pass to the progressive web app.

type Event

type Event = app.Event

Event is the interface that describes a javascript event.

type EventHandler

type EventHandler func(ctx Context, e Event)

EventHandler represents a function that can handle HTML events. They are always called on the UI goroutine.

type Func

type Func = app.Func

Func is the interface that describes a wrapped Go function to be called by JavaScript.

func FuncOf

func FuncOf(fn func(this Value, args []Value) interface{}) Func

FuncOf returns a wrapped function.

Invoking the JavaScript function will synchronously call the Go function fn with the value of JavaScript's "this" keyword and the arguments of the invocation. The return value of the invocation is the result of the Go function mapped back to JavaScript according to ValueOf.

A wrapped function triggered during a call from Go to JavaScript gets executed on the same goroutine. A wrapped function triggered by JavaScript's event loop gets executed on an extra goroutine. Blocking operations in the wrapped function will block the event loop. As a consequence, if one wrapped function blocks, other wrapped funcs will not be processed. A blocking function should therefore explicitly start a new goroutine.

Func.Release must be called to free up resources when the function will not be used any more.

type HTMLA

type HTMLA = app.HTMLA

HTMLA is the interface that describes a <a> HTML element.

func A

func A() HTMLA

A returns an HTML element that defines a hyperlink.

type HTMLAddress

type HTMLAddress = app.HTMLAddress

HTMLAddress is the interface that describes a <address> HTML element.

func Address

func Address() HTMLAddress

Address returns an HTML element that defines contact information for the author/owner of a document.

type HTMLArea

type HTMLArea = app.HTMLArea

HTMLArea is the interface that describes a <area> HTML element.

func Area

func Area() HTMLArea

Area returns an HTML element that defines an area inside an image-map.

type HTMLArticle

type HTMLArticle = app.HTMLArticle

HTMLArticle is the interface that describes a <article> HTML element.

func Article

func Article() HTMLArticle

Article returns an HTML element that defines an article.

type HTMLAside

type HTMLAside = app.HTMLAside

HTMLAside is the interface that describes a <aside> HTML element.

func Aside

func Aside() HTMLAside

Aside returns an HTML element that defines content aside from the page content.

type HTMLAudio

type HTMLAudio = app.HTMLAudio

HTMLAudio is the interface that describes a <audio> HTML element.

func Audio

func Audio() HTMLAudio

Audio returns an HTML element that defines sound content.

type HTMLB

type HTMLB = app.HTMLB

HTMLB is the interface that describes a <b> HTML element.

func B

func B() HTMLB

B returns an HTML element that defines bold text.

type HTMLBase

type HTMLBase = app.HTMLBase

HTMLBase is the interface that describes a <base> HTML element.

func Base

func Base() HTMLBase

Base returns an HTML element that specifies the base URL/target for all relative URLs in a document.

type HTMLBdi

type HTMLBdi = app.HTMLBdi

HTMLBdi is the interface that describes a <bdi> HTML element.

func Bdi

func Bdi() HTMLBdi

Bdi returns an HTML element that isolates a part of text that might be formatted in a different direction from other text outside it.

type HTMLBdo

type HTMLBdo = app.HTMLBdo

HTMLBdo is the interface that describes a <bdo> HTML element.

func Bdo

func Bdo() HTMLBdo

Bdo returns an HTML element that overrides the current text direction.

type HTMLBlockquote

type HTMLBlockquote = app.HTMLBlockquote

HTMLBlockquote is the interface that describes a <blockquote> HTML element.

func Blockquote

func Blockquote() HTMLBlockquote

Blockquote returns an HTML element that defines a section that is quoted from another source.

type HTMLBody

type HTMLBody = app.HTMLBody

HTMLBody is the interface that describes a <body> HTML element.

func Body

func Body() HTMLBody

Body returns an HTML element that defines the document's body.

type HTMLBr

type HTMLBr = app.HTMLBr

HTMLBr is the interface that describes a <br> HTML element.

func Br

func Br() HTMLBr

Br returns an HTML element that defines a single line break.

type HTMLButton

type HTMLButton = app.HTMLButton

HTMLButton is the interface that describes a <button> HTML element.

func Button

func Button() HTMLButton

Button returns an HTML element that defines a clickable button.

type HTMLCanvas

type HTMLCanvas = app.HTMLCanvas

HTMLCanvas is the interface that describes a <canvas> HTML element.

func Canvas

func Canvas() HTMLCanvas

Canvas returns an HTML element that is used to draw graphics on the fly.

type HTMLCaption

type HTMLCaption = app.HTMLCaption

HTMLCaption is the interface that describes a <caption> HTML element.

func Caption

func Caption() HTMLCaption

Caption returns an HTML element that defines a table caption.

type HTMLCite

type HTMLCite = app.HTMLCite

HTMLCite is the interface that describes a <cite> HTML element.

func Cite

func Cite() HTMLCite

Cite returns an HTML element that defines the title of a work.

type HTMLCode

type HTMLCode = app.HTMLCode

HTMLCode is the interface that describes a <code> HTML element.

func Code

func Code() HTMLCode

Code returns an HTML element that defines a piece of computer code.

type HTMLCol

type HTMLCol = app.HTMLCol

HTMLCol is the interface that describes a <col> HTML element.

func Col

func Col() HTMLCol

Col returns an HTML element that specifies column properties for each column within a colgroup element.

type HTMLColGroup

type HTMLColGroup = app.HTMLColGroup

HTMLColGroup is the interface that describes a <colgroup> HTML element.

func ColGroup

func ColGroup() HTMLColGroup

ColGroup returns an HTML element that specifies a group of one or more columns in a table for formatting.

type HTMLData

type HTMLData = app.HTMLData

HTMLData is the interface that describes a <data> HTML element.

func Data

func Data() HTMLData

Data returns an HTML element that links the given content with a machine-readable translation.

type HTMLDataList

type HTMLDataList = app.HTMLDataList

HTMLDataList is the interface that describes a <datalist> HTML element.

func DataList

func DataList() HTMLDataList

DataList returns an HTML element that specifies a list of pre-defined options for input controls.

type HTMLDd

type HTMLDd = app.HTMLDd

HTMLDd is the interface that describes a <dd> HTML element.

func Dd

func Dd() HTMLDd

Dd returns an HTML element that defines a description/value of a term in a description list.

type HTMLDel

type HTMLDel = app.HTMLDel

HTMLDel is the interface that describes a <del> HTML element.

func Del

func Del() HTMLDel

Del returns an HTML element that defines text that has been deleted from a document.

type HTMLDetails

type HTMLDetails = app.HTMLDetails

HTMLDetails is the interface that describes a <details> HTML element.

func Details

func Details() HTMLDetails

Details returns an HTML element that defines additional details that the user can view or hide.

type HTMLDfn

type HTMLDfn = app.HTMLDfn

HTMLDfn is the interface that describes a <dfn> HTML element.

func Dfn

func Dfn() HTMLDfn

Dfn returns an HTML element that represents the defining instance of a term.

type HTMLDialog

type HTMLDialog = app.HTMLDialog

HTMLDialog is the interface that describes a <dialog> HTML element.

func Dialog

func Dialog() HTMLDialog

Dialog returns an HTML element that defines a dialog box or window.

type HTMLDiv

type HTMLDiv = app.HTMLDiv

HTMLDiv is the interface that describes a <div> HTML element.

func Div

func Div() HTMLDiv

Div returns an HTML element that defines a section in a document.

type HTMLDl

type HTMLDl = app.HTMLDl

HTMLDl is the interface that describes a <dl> HTML element.

func Dl

func Dl() HTMLDl

Dl returns an HTML element that defines a description list.

type HTMLDt

type HTMLDt = app.HTMLDt

HTMLDt is the interface that describes a <dt> HTML element.

func Dt

func Dt() HTMLDt

Dt returns an HTML element that defines a term/name in a description list.

type HTMLEm

type HTMLEm = app.HTMLEm

HTMLEm is the interface that describes a <em> HTML element.

func Em

func Em() HTMLEm

Em returns an HTML element that defines emphasized text.

type HTMLEmbed

type HTMLEmbed = app.HTMLEmbed

HTMLEmbed is the interface that describes a <embed> HTML element.

func Embed

func Embed() HTMLEmbed

Embed returns an HTML element that defines a container for an external (non-HTML) application.

type HTMLFieldSet

type HTMLFieldSet = app.HTMLFieldSet

HTMLFieldSet is the interface that describes a <fieldset> HTML element.

func FieldSet

func FieldSet() HTMLFieldSet

FieldSet returns an HTML element that groups related elements in a form.

type HTMLFigCaption

type HTMLFigCaption = app.HTMLFigCaption

HTMLFigCaption is the interface that describes a <figcaption> HTML element.

func FigCaption

func FigCaption() HTMLFigCaption

FigCaption returns an HTML element that defines a caption for a figure element.

type HTMLFigure

type HTMLFigure = app.HTMLFigure

HTMLFigure is the interface that describes a <figure> HTML element.

func Figure

func Figure() HTMLFigure

Figure returns an HTML element that specifies self-contained content.

type HTMLFooter

type HTMLFooter = app.HTMLFooter

HTMLFooter is the interface that describes a <footer> HTML element.

func Footer() HTMLFooter

Footer returns an HTML element that defines a footer for a document or section.

type HTMLForm

type HTMLForm = app.HTMLForm

HTMLForm is the interface that describes a <form> HTML element.

func Form

func Form() HTMLForm

Form returns an HTML element that defines an HTML form for user input.

type HTMLH1

type HTMLH1 = app.HTMLH1

HTMLH1 is the interface that describes a <h1> HTML element.

func H1

func H1() HTMLH1

H1 returns an HTML element that defines HTML heading.

type HTMLH2

type HTMLH2 = app.HTMLH2

HTMLH2 is the interface that describes a <h2> HTML element.

func H2

func H2() HTMLH2

H2 returns an HTML element that defines HTML heading.

type HTMLH3

type HTMLH3 = app.HTMLH3

HTMLH3 is the interface that describes a <h3> HTML element.

func H3

func H3() HTMLH3

H3 returns an HTML element that defines HTML heading.

type HTMLH4

type HTMLH4 = app.HTMLH4

HTMLH4 is the interface that describes a <h4> HTML element.

func H4

func H4() HTMLH4

H4 returns an HTML element that defines HTML heading.

type HTMLH5

type HTMLH5 = app.HTMLH5

HTMLH5 is the interface that describes a <h5> HTML element.

func H5

func H5() HTMLH5

H5 returns an HTML element that defines HTML heading.

type HTMLH6

type HTMLH6 = app.HTMLH6

HTMLH6 is the interface that describes a <h6> HTML element.

func H6

func H6() HTMLH6

H6 returns an HTML element that defines HTML heading.

type HTMLHead

type HTMLHead = app.HTMLHead

HTMLHead is the interface that describes a <head> HTML element.

func Head() HTMLHead

Head returns an HTML element that defines information about the document.

type HTMLHeader

type HTMLHeader = app.HTMLHeader

HTMLHeader is the interface that describes a <header> HTML element.

func Header() HTMLHeader

Header returns an HTML element that defines a header for a document or section.

type HTMLHr

type HTMLHr = app.HTMLHr

HTMLHr is the interface that describes a <hr> HTML element.

func Hr

func Hr() HTMLHr

Hr returns an HTML element that defines a thematic change in the content.

type HTMLHtml

type HTMLHtml = app.HTMLHtml

HTMLHtml is the interface that describes a <html> HTML element.

func Html

func Html() HTMLHtml

Html returns an HTML element that defines the root of an HTML document.

type HTMLI

type HTMLI = app.HTMLI

HTMLI is the interface that describes a <i> HTML element.

func I

func I() HTMLI

I returns an HTML element that defines a part of text in an alternate voice or mood.

type HTMLIFrame

type HTMLIFrame = app.HTMLIFrame

HTMLIFrame is the interface that describes a <iframe> HTML element.

func IFrame

func IFrame() HTMLIFrame

IFrame returns an HTML element that defines an inline frame.

type HTMLImg

type HTMLImg = app.HTMLImg

HTMLImg is the interface that describes a <img> HTML element.

func Img

func Img() HTMLImg

Img returns an HTML element that defines an image.

type HTMLInput

type HTMLInput = app.HTMLInput

HTMLInput is the interface that describes a <input> HTML element.

func Input

func Input() HTMLInput

Input returns an HTML element that defines an input control.

type HTMLIns

type HTMLIns = app.HTMLIns

HTMLIns is the interface that describes a <ins> HTML element.

func Ins

func Ins() HTMLIns

Ins returns an HTML element that defines a text that has been inserted into a document.

type HTMLKbd

type HTMLKbd = app.HTMLKbd

HTMLKbd is the interface that describes a <kbd> HTML element.

func Kbd

func Kbd() HTMLKbd

Kbd returns an HTML element that defines keyboard input.

type HTMLLabel

type HTMLLabel = app.HTMLLabel

HTMLLabel is the interface that describes a <label> HTML element.

func Label

func Label() HTMLLabel

Label returns an HTML element that defines a label for an input element.

type HTMLLegend

type HTMLLegend = app.HTMLLegend

HTMLLegend is the interface that describes a <legend> HTML element.

func Legend

func Legend() HTMLLegend

Legend returns an HTML element that defines a caption for a fieldset element.

type HTMLLi

type HTMLLi = app.HTMLLi

HTMLLi is the interface that describes a <li> HTML element.

func Li

func Li() HTMLLi

Li returns an HTML element that defines a list item.

type HTMLLink = app.HTMLLink

HTMLLink is the interface that describes a <link> HTML element.

func Link() HTMLLink

Link returns an HTML element that defines the relationship between a document and an external resource (most used to link to style sheets).

type HTMLMain

type HTMLMain = app.HTMLMain

HTMLMain is the interface that describes a <main> HTML element.

func Main

func Main() HTMLMain

Main returns an HTML element that specifies the main content of a document.

type HTMLMap

type HTMLMap = app.HTMLMap

HTMLMap is the interface that describes a <map> HTML element.

func Map

func Map() HTMLMap

Map returns an HTML element that defines a client-side image-map.

type HTMLMark

type HTMLMark = app.HTMLMark

HTMLMark is the interface that describes a <mark> HTML element.

func Mark

func Mark() HTMLMark

Mark returns an HTML element that defines marked/highlighted text.

type HTMLMeta

type HTMLMeta = app.HTMLMeta

HTMLMeta is the interface that describes a <meta> HTML element.

func Meta

func Meta() HTMLMeta

Meta returns an HTML element that .

type HTMLMeter

type HTMLMeter = app.HTMLMeter

HTMLMeter is the interface that describes a <meter> HTML element.

func Meter

func Meter() HTMLMeter

Meter returns an HTML element that defines a scalar measurement within a known range (a gauge).

type HTMLNav

type HTMLNav = app.HTMLNav

HTMLNav is the interface that describes a <nav> HTML element.

func Nav() HTMLNav

Nav returns an HTML element that defines navigation links.

type HTMLNoScript

type HTMLNoScript = app.HTMLNoScript

HTMLNoScript is the interface that describes a <noscript> HTML element.

func NoScript

func NoScript() HTMLNoScript

NoScript returns an HTML element that defines an alternate content for users that do not support client-side scripts.

type HTMLObject

type HTMLObject = app.HTMLObject

HTMLObject is the interface that describes a <object> HTML element.

func Object

func Object() HTMLObject

Object returns an HTML element that defines an embedded object.

type HTMLOl

type HTMLOl = app.HTMLOl

HTMLOl is the interface that describes a <ol> HTML element.

func Ol

func Ol() HTMLOl

Ol returns an HTML element that defines an ordered list.

type HTMLOptGroup

type HTMLOptGroup = app.HTMLOptGroup

HTMLOptGroup is the interface that describes a <optgroup> HTML element.

func OptGroup

func OptGroup() HTMLOptGroup

OptGroup returns an HTML element that defines a group of related options in a drop-down list.

type HTMLOption

type HTMLOption = app.HTMLOption

HTMLOption is the interface that describes a <option> HTML element.

func Option

func Option() HTMLOption

Option returns an HTML element that defines an option in a drop-down list.

type HTMLOutput

type HTMLOutput = app.HTMLOutput

HTMLOutput is the interface that describes a <output> HTML element.

func Output

func Output() HTMLOutput

Output returns an HTML element that .

type HTMLP

type HTMLP = app.HTMLP

HTMLP is the interface that describes a <p> HTML element.

func P

func P() HTMLP

P returns an HTML element that defines a paragraph.

type HTMLParam

type HTMLParam = app.HTMLParam

HTMLParam is the interface that describes a <param> HTML element.

func Param

func Param() HTMLParam

Param returns an HTML element that defines a parameter for an object.

type HTMLPicture

type HTMLPicture = app.HTMLPicture

HTMLPicture is the interface that describes a <picture> HTML element.

func Picture

func Picture() HTMLPicture

Picture returns an HTML element that defines a container for multiple image resources.

type HTMLPre

type HTMLPre = app.HTMLPre

HTMLPre is the interface that describes a <pre> HTML element.

func Pre

func Pre() HTMLPre

Pre returns an HTML element that defines preformatted text.

type HTMLProgress

type HTMLProgress = app.HTMLProgress

HTMLProgress is the interface that describes a <progress> HTML element.

func Progress

func Progress() HTMLProgress

Progress returns an HTML element that represents the progress of a task.

type HTMLQ

type HTMLQ = app.HTMLQ

HTMLQ is the interface that describes a <q> HTML element.

func Q

func Q() HTMLQ

Q returns an HTML element that defines a short quotation.

type HTMLRp

type HTMLRp = app.HTMLRp

HTMLRp is the interface that describes a <rp> HTML element.

func Rp

func Rp() HTMLRp

Rp returns an HTML element that defines what to show in browsers that do not support ruby annotations.

type HTMLRt

type HTMLRt = app.HTMLRt

HTMLRt is the interface that describes a <rt> HTML element.

func Rt

func Rt() HTMLRt

Rt returns an HTML element that defines an explanation/pronunciation of characters (for East Asian typography).

type HTMLRuby

type HTMLRuby = app.HTMLRuby

HTMLRuby is the interface that describes a <ruby> HTML element.

func Ruby

func Ruby() HTMLRuby

Ruby returns an HTML element that defines a ruby annotation (for East Asian typography).

type HTMLS

type HTMLS = app.HTMLS

HTMLS is the interface that describes a <s> HTML element.

func S

func S() HTMLS

S returns an HTML element that Defines text that is no longer correct.

type HTMLSamp

type HTMLSamp = app.HTMLSamp

HTMLSamp is the interface that describes a <samp> HTML element.

func Samp

func Samp() HTMLSamp

Samp returns an HTML element that defines sample output from a computer program.

type HTMLScript

type HTMLScript = app.HTMLScript

HTMLScript is the interface that describes a <script> HTML element.

func Script

func Script() HTMLScript

Script returns an HTML element that defines a client-side script.

type HTMLSection

type HTMLSection = app.HTMLSection

HTMLSection is the interface that describes a <section> HTML element.

func Section

func Section() HTMLSection

Section returns an HTML element that defines a section in a document.

type HTMLSelect

type HTMLSelect = app.HTMLSelect

HTMLSelect is the interface that describes a <select> HTML element.

func Select

func Select() HTMLSelect

Select returns an HTML element that defines a drop-down list.

type HTMLSmall

type HTMLSmall = app.HTMLSmall

HTMLSmall is the interface that describes a <small> HTML element.

func Small

func Small() HTMLSmall

Small returns an HTML element that defines smaller text.

type HTMLSource

type HTMLSource = app.HTMLSource

HTMLSource is the interface that describes a <source> HTML element.

func Source

func Source() HTMLSource

Source returns an HTML element that .

type HTMLSpan

type HTMLSpan = app.HTMLSpan

HTMLSpan is the interface that describes a <span> HTML element.

func Span

func Span() HTMLSpan

Span returns an HTML element that defines a section in a document.

type HTMLStrong

type HTMLStrong = app.HTMLStrong

HTMLStrong is the interface that describes a <strong> HTML element.

func Strong

func Strong() HTMLStrong

Strong returns an HTML element that defines important text.

type HTMLStyle

type HTMLStyle = app.HTMLStyle

HTMLStyle is the interface that describes a <style> HTML element.

func Style

func Style() HTMLStyle

Style returns an HTML element that defines style information for a document.

type HTMLSub

type HTMLSub = app.HTMLSub

HTMLSub is the interface that describes a <sub> HTML element.

func Sub

func Sub() HTMLSub

Sub returns an HTML element that defines subscripted text.

type HTMLSummary

type HTMLSummary = app.HTMLSummary

HTMLSummary is the interface that describes a <summary> HTML element.

func Summary

func Summary() HTMLSummary

Summary returns an HTML element that defines a visible heading for a details element.

type HTMLSup

type HTMLSup = app.HTMLSup

HTMLSup is the interface that describes a <sup> HTML element.

func Sup

func Sup() HTMLSup

Sup returns an HTML element that defines superscripted text.

type HTMLTBody

type HTMLTBody = app.HTMLTBody

HTMLTBody is the interface that describes a <tbody> HTML element.

func TBody

func TBody() HTMLTBody

TBody returns an HTML element that groups the body content in a table.

type HTMLTFoot

type HTMLTFoot = app.HTMLTFoot

HTMLTFoot is the interface that describes a <tfoot> HTML element.

func TFoot

func TFoot() HTMLTFoot

TFoot returns an HTML element that groups the footer content in a table.

type HTMLTHead

type HTMLTHead = app.HTMLTHead

HTMLTHead is the interface that describes a <thead> HTML element.

func THead

func THead() HTMLTHead

THead returns an HTML element that groups the header content in a table

type HTMLTable

type HTMLTable = app.HTMLTable

HTMLTable is the interface that describes a <table> HTML element.

func Table

func Table() HTMLTable

Table returns an HTML element that defines a table.

type HTMLTd

type HTMLTd = app.HTMLTd

HTMLTd is the interface that describes a <td> HTML element.

func Td

func Td() HTMLTd

Td returns an HTML element that defines a cell in a table.

type HTMLTemplate

type HTMLTemplate = app.HTMLTemplate

HTMLTemplate is the interface that describes a <template> HTML element.

func Template

func Template() HTMLTemplate

Template returns an HTML element that defines a template.

type HTMLTextarea

type HTMLTextarea = app.HTMLTextarea

HTMLTextarea is the interface that describes a <textarea> HTML element.

func Textarea

func Textarea() HTMLTextarea

Textarea returns an HTML element that defines a multiline input control (text area).

type HTMLTh

type HTMLTh = app.HTMLTh

HTMLTh is the interface that describes a <th> HTML element.

func Th

func Th() HTMLTh

Th returns an HTML element that defines a header cell in a table.

type HTMLTime

type HTMLTime = app.HTMLTime

HTMLTime is the interface that describes a <time> HTML element.

func Time

func Time() HTMLTime

Time returns an HTML element that defines a date/time.

type HTMLTitle

type HTMLTitle = app.HTMLTitle

HTMLTitle is the interface that describes a <title> HTML element.

func Title

func Title() HTMLTitle

Title returns an HTML element that defines a title for the document.

type HTMLTr

type HTMLTr = app.HTMLTr

HTMLTr is the interface that describes a <tr> HTML element.

func Tr

func Tr() HTMLTr

Tr returns an HTML element that defines a row in a table.

type HTMLU

type HTMLU = app.HTMLU

HTMLU is the interface that describes a <u> HTML element.

func U

func U() HTMLU

U returns an HTML element that defines text that should be stylistically different from normal text.

type HTMLUl

type HTMLUl = app.HTMLUl

HTMLUl is the interface that describes a <ul> HTML element.

func Ul

func Ul() HTMLUl

Ul returns an HTML element that defines an unordered list.

type HTMLVar

type HTMLVar = app.HTMLVar

HTMLVar is the interface that describes a <var> HTML element.

func Var

func Var() HTMLVar

Var returns an HTML element that defines a variable.

type HTMLVideo

type HTMLVideo = app.HTMLVideo

HTMLVideo is the interface that describes a <video> HTML element.

func Video

func Video() HTMLVideo

Video returns an HTML element that defines a video or movie.

type HTMLWbr

type HTMLWbr = app.HTMLWbr

HTMLWbr is the interface that describes a <wbr> HTML element.

func Wbr

func Wbr() HTMLWbr

Wbr returns an HTML element that defines a possible line-break.

type Handler

type Handler = app.Handler

Handler is an HTTP handler that serves an HTML page that loads a Go wasm app and its resources.

type Icon

type Icon = app.Icon

Icon describes a square image that is used in various places such as application icon, favicon or loading icon.

type Initializer

type Initializer = app.Initializer

Initializer is the interface that describes a component that performs initialization instruction before being pre-rendered or mounted.

type Kind

type Kind = app.Kind

Kind represents the specific kind of a user interface element.

const (
	// UndefinedElem represents an undefined UI element.
	UndefinedElem Kind = iota

	// SimpleText represents a simple text element.
	SimpleText

	// HTML represents an HTML element.
	HTML

	// Component represents a customized, independent and reusable UI element.
	Component

	// Selector represents an element that is used to select a subset of
	// elements within a given list.
	Selector

	// RawHTML represents an HTML element obtained from a raw HTML code snippet.
	RawHTML
)

type Mounter

type Mounter = app.Mounter

Mounter is the interface that describes a component that can perform additional actions when mounted.

type MsgHandler

type MsgHandler = app.MsgHandler

MsgHandler represents a handler to listen to messages sent with Context.Post.

type Navigator = app.Navigator

Navigator is the interface that describes a component that can perform additional actions when navigated on.

type Observer

type Observer = app.Observer

Observer is an observer that observes changes for a given state.

type Page

type Page = app.Page

Page is the interface that describes a web page.

type PreRenderCache

type PreRenderCache = app.PreRenderCache

PreRenderCache is the interface that describes a cache that stores pre-rendered resources.

func NewPreRenderLRUCache

func NewPreRenderLRUCache(size int, itemTTL time.Duration, onEvict ...func(path string, i PreRenderedItem)) PreRenderCache

NewPreRenderLRUCache creates an in memory LRU cache that stores items for the given duration. If provided, on eviction functions are called when item are evicted.

type PreRenderedItem

type PreRenderedItem = app.PreRenderedItem

PreRenderedItem represent an item that is stored in a PreRenderCache.

type PreRenderer

type PreRenderer = app.PreRenderer

PreRenderer is the interface that describes a component that performs instruction when it is server-side pre-rendered.

A pre-rendered component helps in achieving SEO friendly content.

type ProxyResource

type ProxyResource = app.ProxyResource

ProxyResource is a proxy descriptor that maps a given resource to an URL path.

type RangeLoop

type RangeLoop struct {
	app.RangeLoop
}

RangeLoop represents a control structure that iterates within a slice, an array or a map.

func Range

func Range(src interface{}) *RangeLoop

Range returns a range loop that iterates within the given source. Source must be a slice, an array or a map with strings as keys.

func (*RangeLoop) Map

func (r *RangeLoop) Map(f func(string) UI) *RangeLoop

func (*RangeLoop) Slice

func (r *RangeLoop) Slice(f func(int) UI) *RangeLoop

type Resizer

type Resizer = app.Resizer

Resizer is the interface that describes a component that is notified when the app has been resized or a parent component calls the ResizeContent() method.

type ResourceProvider

type ResourceProvider = app.ResourceProvider

ResourceProvider is the interface that describes a resource provider that tells the Handler how to locate and get the package and static resources.

Package resources are the resource required to operate go-app.

Static resources are resources such as app.wasm, CSS files, images.

The resource provider is used to serve static resources when it satisfies the http.Handler interface.

func CustomProvider

func CustomProvider(path, prefix string) ResourceProvider

CustomProvider returns a resource provider that serves static resources from a local directory located at the given path and prefixes URL paths with the given prefix.

func GitHubPages

func GitHubPages(repoName string) ResourceProvider

GitHubPages returns a resource provider that provides resources from GitHub pages. This provider must only be used to generate static websites with the GenerateStaticWebsite function.

func LocalDir

func LocalDir(root string) ResourceProvider

LocalDir returns a resource provider that serves static resources from a local directory located at the given path.

func RemoteBucket

func RemoteBucket(url string) ResourceProvider

RemoteBucket returns a resource provider that provides resources from a remote bucket such as Amazon S3 or Google Cloud Storage.

type ServerDispatcher

type ServerDispatcher = app.ServerDispatcher

ServerDispatcher is the interface that describes a dispatcher that emulates a server environment.

func NewServerTester

func NewServerTester(n UI) ServerDispatcher

NewServerTester creates a testing dispatcher that simulates a client environment.

type State

type State = app.State

A state represents an observable value available across the app.

type StateOption

type StateOption = app.StateOption

StateOption represents an option applied when a state is set.

func ExpiresAt

func ExpiresAt(t time.Time) StateOption

ExpiresAt returns a state option that sets a state value to its zero value at the given time.

Values persisted to local storage with the Persist option are removed from it.

func ExpiresIn

func ExpiresIn(d time.Duration) StateOption

ExpiresIn returns a state option that sets a state value to its zero value after the given duration.

Values persisted to local storage with the Persist option are removed from it.

type Tag

type Tag = app.Tag

Tag is a key-value pair that adds context to an action.

func T

func T(name string, value interface{}) Tag

T creates a tag with the given name and value. The value is converted to a string.

type Tagger

type Tagger = app.Tagger

Tagger is the interface that describes a collection of tags that gives context to something.

type Tags

type Tags = app.Tags

Tags represent key-value pairs that give context to what they are used with.

type TestUIDescriptor

type TestUIDescriptor = app.TestUIDescriptor

TestUIDescriptor represents a descriptor that describes a UI element and its location from its parents.

type Type

type Type int

Type represents the JavaScript type of a Value.

const (
	TypeUndefined Type = iota
	TypeNull
	TypeBoolean
	TypeNumber
	TypeString
	TypeSymbol
	TypeObject
	TypeFunction
)

Constants that enumerates the JavaScript types.

type UI

type UI = app.UI

UI is the interface that describes a user interface element such as components and HTML elements.

func FilterUIElems

func FilterUIElems(uis ...UI) []UI

FilterUIElems returns a filtered version of the given UI elements where selector elements such as If and Range are interpreted and removed. It also remove nil elements.

It should be used only when implementing components that can accept content with variadic arguments like HTML elements Body method.

func Raw

func Raw(v string) UI

Raw returns a ui element from the given raw value. HTML raw value must have a single root.

It is not recommended to use this kind of node since there is no check on the raw string content.

func Text

func Text(v interface{}) UI

Text creates a simple text element.

type Updater

type Updater = app.Updater

Updater is the interface that describes a component that can do additional instructions when one of its exported fields is modified by its nearest parent component.

type Value

type Value = app.Value

Value is the interface that represents a JavaScript value. On wasm architecture, it wraps the Value from https://golang.org/pkg/syscall/js/ package.

func Null

func Null() Value

Null returns the JavaScript value "null".

func Undefined

func Undefined() Value

Undefined returns the JavaScript value "undefined".

func ValueOf

func ValueOf(x interface{}) Value

ValueOf returns x as a JavaScript value:

| Go                     | JavaScript             |
| ---------------------- | ---------------------- |
| js.Value               | [its value]            |
| js.Func                | function               |
| nil                    | null                   |
| bool                   | boolean                |
| integers and floats    | number                 |
| string                 | string                 |
| []interface{}          | new array              |
| map[string]interface{} | new object             |

Panics if x is not one of the expected types.

type Wrapper

type Wrapper = app.Wrapper

Wrapper is implemented by types that are backed by a JavaScript value.

Jump to

Keyboard shortcuts

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