jsext

package module
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2023 License: GPL-2.0 Imports: 5 Imported by: 11

README

JSExt!

Golang Wasm extension for easy JS interop.

Installation

Easily install with the following command:

go get github.com/Nigel2392/jsext@vX.X.X.X

Please check the tags for the latest version, we use an unconventional versioning system, which pkg.go.dev does not like.

Live Demo

You can find our live demo on this URL: nigel2392.github.io/jsext/

Features

JSExt provides a few features to make it easier to interact with Javascript.

  • Easy to use JS interop, wrapping the default syscall/js package.
  • Has a package for token-authentication using JWT tokens from an API.
  • Provides a message framework for easy communication with eventlisteners between Go and Javascript.
  • Supports page-routing, any url prefixed with the RT_PREFIX (router: by default).
  • Supports easy interaction with the javascript console.
  • Included package to easily create components. These components can be used to easily create reusable components, and support animations (Animation support is limited).
  • Contains predefined components, which can be autogenerated (When using the regular go compiler, not TinyGO).
    • Also contains components for ease of use, such as loaders, menus, tables and more.
  • Supports paginators, check out github.com/Nigel2392/jsext/paginator for more information on how to use the paginators, and what formats they support.

Examples

Examples can be found in the examples folder. There are only a few examples for now, but we will add more in the future.

TinyGO support

JSExt is fully supported by TinyGO, and can be used with the TinyGO compiler. Some features may however work differently with the TinyGO compiler, and the regular go compiler. This is due to the fact that TinyGO does not support the reflect package, HTTP, and some other packages.

To compile the package with TinyGO support, you need to add the following build tags to your project:

tinygo build -tags=tinygo -o <output file> <input file>
Making requests using TinyGo

When making requests when the project is compiled with TinyGO, (when compiling with the tinygo tag), we will automatically resort to using the Javascript fetch api. When the request is made, we wait for the promise in a goroutine, and return the response when it is done using a channel.

Limitations of making requests using TinyGo

Some features are not implemented yet when making requests using TinyGO. These functions mostly have to do with encoding. We can encode certain items, such as slices and maps. This is done using our custom encoder located at github.com/Nigel2392/jsext/requester/fetch/dirtyjson.go. This encoder however is not fully tested, and may very well break on certain inputs.

Creating a project

To easily create projects, it is best to install the jsext cli tool:

$ go install github.com/Nigel2392/jsexttool

Following that, you can easily create an example project with the following command, which will contain a basic example of some jsext functionality:

$ jsexttool -init -n <project name> (optional: -vscode for auto creation of vscode config.)

There is also an option to create a plain project, this will create a project with no example code, but still some basic setup:

$ jsexttool -plain -n <project name> (optional: -vscode for auto creation of vscode config.)
Note:

Both of the jsexttool options provide a some powershell build scripts, which can be used to quickly build the project with tinygo, or the regular go compiler. If the chosen compiler is the normal go compiler, you will need to edit the index.html file to import go's default wasm_exec.js file, instead of the tinygo one. The jsexttool automatically uses the tinygo compiler on setup.

The before mentioned build flags are already set in the build scripts.

There is also a server.go file when initializing the project with the -init flag. This file can be used to quickly serve the project for development.

Binary sizes

When compiling with the regular go compiler, the binary sizes can get pretty big. We do implement a page loader, but this may not be your way to go. This is why we recomment starting out with TinyGO, as the binary sizes are much smaller, but even that could get up to 2MB+ without any optimizations. If you do suffer binary size issues, you can try to use the -ldflags="-s -w" flag when compiling with the regular go compiler. When compiling with TinyGO, you can try to use the -no-debug flag, which will remove debug information from the binary. There are also some great optimization tools for WebAssembly, such as WasmOpt, which can be used to optimize the binary size, or speed. You can find more information about wasm-opt here.

Documentation

Rendered for js/wasm

Index

Constants

This section is empty.

Variables

View Source
var (
	JSExt    Export
	Global   js.Value
	Document js.Value
	Window   js.Value
	Body     Element
	Head     Element
)

Default syscall/js values, some wrapped.

View Source
var Imported = make(map[string]Import)

Imports keeps track of all imported files.

Functions

func Alert added in v1.1.6

func Alert(message string)

func ArrayToSlice added in v1.1.4

func ArrayToSlice(arr js.Value) []interface{}

Convert a js.Value array to a []interface{}.

func Delete added in v1.1.4

func Delete(key string)

Delete a value in the global scope.

func DeleteCookie added in v1.1.4

func DeleteCookie(name string)

Delete a document cookie

func GetCookie added in v1.1.4

func GetCookie(name string) string

Get a document cookie

func InstanceOf

func InstanceOf(value, constructor js.Value) bool

Returns if something is an instance of something else.

func IsMobile added in v1.3.3

func IsMobile() bool

Check if the user agent is mobile.

func ObjectToMap added in v1.1.4

func ObjectToMap(obj js.Value) map[string]interface{}

Convert a js.Value to a map[string]interface{}.

func ObjectToMapT added in v1.3.3

func ObjectToMapT[T any](obj js.Value) map[string]T

Convert a js.Value to a map[string]T.

func RegisterFunc

func RegisterFunc(name string, f JSExtFunc)

Register a function to the global window.

func RemoveImport

func RemoveImport(name string)

Remove an import from the DOM, and remove it from the Imported map.

func Set added in v1.1.4

func Set(key string, value any)

Set a value in the global scope.

func SetCookie added in v1.1.4

func SetCookie(name, value string, tim time.Duration) error

Set a document cookie

func SetFavicon

func SetFavicon(url string) error

Set a favicon for the document.

func SliceToInterface

func SliceToInterface(s []string) []interface{}

Convert a slice of strings to a slice of interfaces.

func ToJSFunc

func ToJSFunc(f JSExtFunc) js.Func

Conver to javascript function.

func TypeOf

func TypeOf(value, constructor js.Value) bool

Returns if something is a type of something else.

func UnpackArray added in v1.3.2

func UnpackArray[T Value | js.Value | Element | Style | Event](v js.Value) []T

Unpack a js.value array to a slice.

func WrapFunc

func WrapFunc(f func()) js.Func

Wrap a function, convert it to a js.Func.

Types

type Args

type Args []js.Value

Arguments for wrapped functions.

func (Args) Event

func (a Args) Event() Event

Event returns the first argument as an event.

func (Args) Len

func (a Args) Len() int

Len of arguments.

func (Args) Slice added in v1.1.4

func (a Args) Slice() []interface{}

Return a slice of any.

func (Args) Value

func (a Args) Value() []js.Value

Value returns the arguments as a slice of js.Value.

type Element

type Element js.Value

Element is a wrapper around js.Value.

func CreateElement

func CreateElement(tag string) Element

Create a javascript HTMLElement.

func CreateLink(kv map[string]string) Element

Create a link element.

func GetElementById

func GetElementById(id string) (Element, error)

Get an element by id.

func QuerySelector

func QuerySelector(selector string) (Element, error)

QuerySelector returns the first element that matches the specified selector.

func (Element) AddEventListener

func (e Element) AddEventListener(event string, listener func(this Value, event Event)) Element

AddEventListener adds an event listener to the element.

func (Element) After

func (e Element) After(elements ...Element)

Set elements after the element.

func (Element) Animate added in v1.3.3

func (e Element) Animate(keyframes []interface{}, options map[string]interface{}) Value

Animate the element.

func (Element) Append

func (e Element) Append(elements ...Element)

Append elements to the element.

func (Element) AppendChild

func (e Element) AppendChild(child Element) Element

AppendChild appends a child to the element.

func (Element) AppendChildren

func (e Element) AppendChildren(children []Element) Element

AppendChildren appends multiple children to the element.

func (Element) AppendTo

func (e Element) AppendTo(parent Element)

Append the element to the parent.

func (Element) AssignedSlot

func (e Element) AssignedSlot() Element

Get the assigned slot of the element.

func (Element) Attributes

func (e Element) Attributes() Value

Get attributes of the element.

func (Element) Before

func (e Element) Before(elements ...Element)

Set elements before the element.

func (Element) Call

func (e Element) Call(m string, args ...interface{}) Value

Call calls a method on the element.

func (Element) ChildElementCount

func (e Element) ChildElementCount() int

Get the childElementCount of the element.

func (Element) Children

func (e Element) Children() Value

Get the children of the element.

func (Element) ClassList

func (e Element) ClassList(c ...string) Value

Set multiple classes on the element.

func (Element) ClassName

func (e Element) ClassName() string

Get the className of the element.

func (Element) ClientHeight

func (e Element) ClientHeight() int

Get the clientHeight of the element.

func (Element) ClientLeft

func (e Element) ClientLeft() int

Get the clientLeft of the element.

func (Element) ClientTop

func (e Element) ClientTop() int

Get the clientTop of the element.

func (Element) ClientWidth

func (e Element) ClientWidth() int

Get the clientWidth of the element.

func (Element) Dataset

func (e Element) Dataset() Value

Get the element's dataset.

func (Element) Delete

func (e Element) Delete(p string)

Delete deletes a property from the element.

func (Element) Equal

func (e Element) Equal(other js.Value) bool

Equal returns true if the element is equal to the other js.Value.

func (Element) FirstElementChild

func (e Element) FirstElementChild() Element

Get the element's first child.

func (Element) Get

func (e Element) Get(p string) Value

Get gets a property from the element.

func (Element) GetChildNodes

func (e Element) GetChildNodes() Value

Get the children of the element.

func (Element) GetChildren

func (e Element) GetChildren() Value

Get the children of the element.

func (Element) GetClassList

func (e Element) GetClassList() Value

Get the value of the element.

func (Element) GetElementById

func (e Element) GetElementById(id string) Element

Get an inner element by ID.

func (Element) GetElementsByClassName

func (e Element) GetElementsByClassName(className string) Element

Get an inner element by class name.

func (Element) GetElementsByTagName

func (e Element) GetElementsByTagName(tagName string) Element

Get an inner element by tag name.

func (Element) GetStyleProperty

func (e Element) GetStyleProperty(name string) string

Get the style of an element property.

func (Element) Height

func (e Element) Height() int

Get the clientHeight of the element.

func (Element) Href

func (e Element) Href() string

Get the element's href.

func (Element) ID

func (e Element) ID() string

Get the ID of the element.

func (Element) InnerElement

func (e Element) InnerElement(el Element) Element

SetInnerElement clears the inner HTML and appends the element.

func (Element) InnerHTML

func (e Element) InnerHTML(html string) Element

InnerHTML sets the inner HTML of the element.

func (Element) InnerText

func (e Element) InnerText(text string) Element

InnerText sets the inner text of the element.

func (Element) InsertBefore

func (e Element) InsertBefore(element, before Element)

Insert the element before the before element.

func (Element) JSValue

func (e Element) JSValue() js.Value

JSValue returns the underlying js.Value.

func (Element) MapDataset added in v1.1.5

func (e Element) MapDataset() map[string]string

Return the element's dataset as map

func (Element) ParentElement

func (e Element) ParentElement() Element

Get the parentElement

func (Element) Prepend

func (e Element) Prepend(elements ...Element)

Append the element to the parent.

func (Element) Remove

func (e Element) Remove()

Remove the element.

func (Element) RemoveChild

func (e Element) RemoveChild(child Element) Element

RemoveChild removes a child from the element.

func (Element) RemoveChildren

func (e Element) RemoveChildren(children []Element) Element

RemoveChildren removes multiple children from the element.

func (Element) RemoveEventListener

func (e Element) RemoveEventListener(event string, listener func(this Value, event Event)) Element

RemoveEventListener removes an event listener from the element.

func (Element) ReplaceChild

func (e Element) ReplaceChild(element, before Element)

Replace the element with the before element.

func (Element) ScrollHeight

func (e Element) ScrollHeight() int

Get the scroll height of the element.

func (Element) ScrollIntoView

func (e Element) ScrollIntoView(center bool)

Scroll the element into view.

func (Element) ScrollIntoViewIfNeeded

func (e Element) ScrollIntoViewIfNeeded(center bool)

Scroll the element into view if needed.

func (Element) ScrollLeft

func (e Element) ScrollLeft() int

Get the scroll left of the element.

func (Element) ScrollTo

func (e Element) ScrollTo(x, y int)

Set the sccrollTo of the element.

func (Element) ScrollTop

func (e Element) ScrollTop() int

Get the scroll top of the element.

func (Element) ScrollWidth

func (e Element) ScrollWidth() int

Get the scroll width of the element.

func (Element) Set

func (e Element) Set(p string, v interface{}) Element

Set sets a property on the element.

func (Element) SetAttribute

func (e Element) SetAttribute(name, value string) Element

Remove removes the element from the DOM.

func (Element) SetClassName

func (e Element) SetClassName(className string) Element

Set the className of the element.

func (Element) SetID

func (e Element) SetID(id string) Element

Set the ID of the element.

func (Element) Style

func (e Element) Style() Style

Get the style of the element.

func (Element) StyleProperty

func (e Element) StyleProperty(name, value string) Element

Set the style of an element property.

func (Element) Value

func (e Element) Value() Value

Value returns as a Value(js.Value) wrapper.

func (Element) Width

func (e Element) Width() int

Get the clientWidth of the element.

type Elements

type Elements []Element

Defines multiple elements. This is a wrapper around a slice of []Element(js.Value).

func GetElementsByClassName added in v1.3.2

func GetElementsByClassName(class string) (Elements, error)

Get an element by class name.

func GetElementsByTagName added in v1.3.2

func GetElementsByTagName(tag string) (Elements, error)

Get an element by tag name.

func QuerySelectorAll

func QuerySelectorAll(selector string) (Elements, error)

QuerySelectorAll returns all elements that match the specified selector.

func (Elements) AddEventListener

func (e Elements) AddEventListener(event string, listener func(this Value, event Event)) Elements

AddEventListener adds an event listener to all elements in the slice.

func (Elements) Len

func (e Elements) Len() int

Get the length of the slice.

func (Elements) RemoveEventListener

func (e Elements) RemoveEventListener(event string, listener func(this Value, event Event)) Elements

RemoveEventListener removes an event listener from all elements in the slice.

func (Elements) Value

func (e Elements) Value() []js.Value

Return all inner js.Value in the slice.

type Event

type Event js.Value

Wrapper for javascript events to make life easier.

func (Event) Bubbles

func (e Event) Bubbles() bool

Bubbles returns true if the event bubbles.

func (Event) Call

func (e Event) Call(m string, args ...interface{}) js.Value

func (Event) Cancelable

func (e Event) Cancelable() bool

Cancelable returns true if the event is cancelable.

func (Event) Composed

func (e Event) Composed() bool

Composed returns true if the event is composed.

func (Event) ComposedPath

func (e Event) ComposedPath() []js.Value

ComposedPath returns the composed path of the event.

func (Event) CurrentTarget

func (e Event) CurrentTarget() Value

CurrentTarget returns the current target of the event.

func (Event) DefaultPrevented

func (e Event) DefaultPrevented() bool

DefaultPrevented returns true if the default action of the event has been prevented.

func (Event) Delete

func (e Event) Delete(p string)

func (Event) Equal

func (e Event) Equal(other js.Value) bool

func (Event) EventPhase

func (e Event) EventPhase() int

EventPhase returns the event phase of the event.

func (Event) Get

func (e Event) Get(p string) js.Value

Default js.Value methods

func (Event) InitEvent

func (e Event) InitEvent(eventType string, bubbles bool, cancelable bool)

InitEvent initializes the event.

func (Event) IsTrusted

func (e Event) IsTrusted() bool

IsTrusted returns true if the event is trusted.

func (Event) JSValue

func (e Event) JSValue() js.Value

Returns the js.Value of the event.

func (Event) PreventDefault

func (e Event) PreventDefault()

PreventDefault prevents the default action of the event.

func (Event) Set

func (e Event) Set(p string, x interface{})

InitCustomEvent initializes the custom event.

func (Event) StopImmediatePropagation

func (e Event) StopImmediatePropagation()

StopImmediatePropagation stops the immediate propagation of the event.

func (Event) StopPropagation

func (e Event) StopPropagation()

StopPropagation stops the propagation of the event.

func (Event) Target

func (e Event) Target() Value

ReturnValue returns the return value of the event.

func (Event) TimeStamp

func (e Event) TimeStamp() int

TimeStamp returns the time stamp of the event.

func (Event) Type

func (e Event) Type() string

Type returns the type of the event.

func (Event) Value

func (e Event) Value() Value

Returns the jsext.Value of the event.

type Export

type Export Value

Export resembles an object bound to the DOM window. This object contains methods to be called from JS.

var Runtime Export = Export(Eval("new EventTarget();"))

See js.go.init() for the initialization of this variable onto the global export object.

func NewExport

func NewExport() Export

NewExport returns a new Export.

func (Export) Call

func (e Export) Call(name string, args ...interface{}) Value

Call a function on the export's js.Value.

func (Export) Get

func (e Export) Get(name string) Value

Get a value from the export's js.Value.

func (Export) JSExt added in v1.1.4

func (e Export) JSExt() Value

Return the jsext.Value of the export.

func (Export) Register

func (e Export) Register(name string)

Register the export to the global window.

func (Export) RegisterTo

func (e Export) RegisterTo(name string, to Value)

RegisterTo registers the export to another jsext.Value.

func (Export) RegisterToExport

func (e Export) RegisterToExport(name string, to Export)

RegisterToExport registers the export to another export.

func (Export) Remove

func (e Export) Remove(name string)

Remove a value from the export's js.Value.

func (Export) Set

func (e Export) Set(name string, value interface{})

Set a value on the export's js.Value.

func (Export) SetFunc

func (e Export) SetFunc(name string, f func())

SetFunc sets a function on the export's js.Value.

func (Export) SetFuncWithArgs

func (e Export) SetFuncWithArgs(name string, f JSExtFunc)

SetMultiple sets multiple functions on the export's js.Value.

func (Export) SetMultipleWithArgs

func (e Export) SetMultipleWithArgs(fns map[string]JSExtFunc)

SetMultiple sets multiple functions on the export's js.Value.

func (Export) Value

func (e Export) Value() js.Value

Value returns the js.Value of the export.

type Import

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

Import is a file that has been imported into the DOM.

func ImportCSS added in v1.3.2

func ImportCSS(name, selector string, src ...string) Import

Import a single css block into the Global jsext style element.

func ImportLink(name, src, typ, rel string) Import

Import a link

func ImportScript

func ImportScript(name, src, typ string) Import

Import a script

func ScriptBlock

func ScriptBlock(name, code string) Import

Import a script block for use with raw sourcecode.

func StyleBlock

func StyleBlock(name, code string) Import

Import a style block for use with raw sourcecode.

func (Import) JSValue

func (i Import) JSValue() js.Value

JSValue returns the js.Value of the import.

func (Import) Remove

func (i Import) Remove()

Remove an import.

func (Import) Value

func (i Import) Value() Value

Value returns the jsext.Value of the import.

type JSExtEventFunc

type JSExtEventFunc func(this Value, event Event) interface{}

type JSExtFunc

type JSExtFunc func(this Value, args Args) interface{}

func (JSExtFunc) FromJSFunc

func (f JSExtFunc) FromJSFunc(fun JSFunc) JSExtFunc

Convert from javascript function.

func (JSExtFunc) ToJSFunc

func (f JSExtFunc) ToJSFunc() js.Func

Convert to javascript function.

type JSFunc

type JSFunc func(this js.Value, args []js.Value) interface{}

Default functions, wrapped.

type Style added in v1.1.5

type Style js.Value

func (Style) AlignContent added in v1.1.5

func (s Style) AlignContent(str ...string) string

func (Style) AlignItems added in v1.1.5

func (s Style) AlignItems(str ...string) string

func (Style) AlignSelf added in v1.1.5

func (s Style) AlignSelf(str ...string) string

func (Style) Animation added in v1.1.5

func (s Style) Animation(str ...string) string

func (Style) AnimationDelay added in v1.1.5

func (s Style) AnimationDelay(str ...string) string

func (Style) AnimationDirection added in v1.1.5

func (s Style) AnimationDirection(str ...string) string

func (Style) AnimationDuration added in v1.1.5

func (s Style) AnimationDuration(str ...string) string

func (Style) AnimationFillMode added in v1.1.5

func (s Style) AnimationFillMode(str ...string) string

func (Style) AnimationIterationCount added in v1.1.5

func (s Style) AnimationIterationCount(str ...string) string

func (Style) AnimationName added in v1.1.5

func (s Style) AnimationName(str ...string) string

func (Style) AnimationPlayState added in v1.1.5

func (s Style) AnimationPlayState(str ...string) string

func (Style) AnimationTimingFunction added in v1.1.5

func (s Style) AnimationTimingFunction(str ...string) string

func (Style) BackfaceVisibility added in v1.1.5

func (s Style) BackfaceVisibility(str ...string) string

func (Style) Background added in v1.1.5

func (s Style) Background(str ...string) string

func (Style) BackgroundAttachment added in v1.1.5

func (s Style) BackgroundAttachment(str ...string) string

func (Style) BackgroundClip added in v1.1.5

func (s Style) BackgroundClip(str ...string) string

func (Style) BackgroundColor added in v1.1.5

func (s Style) BackgroundColor(str ...string) string

func (Style) BackgroundImage added in v1.1.5

func (s Style) BackgroundImage(str ...string) string

func (Style) BackgroundOrigin added in v1.1.5

func (s Style) BackgroundOrigin(str ...string) string

func (Style) BackgroundPosition added in v1.1.5

func (s Style) BackgroundPosition(str ...string) string

func (Style) BackgroundRepeat added in v1.1.5

func (s Style) BackgroundRepeat(str ...string) string

func (Style) BackgroundSize added in v1.1.5

func (s Style) BackgroundSize(str ...string) string

func (Style) Border added in v1.1.5

func (s Style) Border(str ...string) string

func (Style) BorderBottom added in v1.1.5

func (s Style) BorderBottom(str ...string) string

func (Style) BorderBottomColor added in v1.1.5

func (s Style) BorderBottomColor(str ...string) string

func (Style) BorderBottomLeftRadius added in v1.1.5

func (s Style) BorderBottomLeftRadius(str ...string) string

func (Style) BorderBottomRightRadius added in v1.1.5

func (s Style) BorderBottomRightRadius(str ...string) string

func (Style) BorderBottomStyle added in v1.1.5

func (s Style) BorderBottomStyle(str ...string) string

func (Style) BorderBottomWidth added in v1.1.5

func (s Style) BorderBottomWidth(str ...string) string

func (Style) BorderCollapse added in v1.1.5

func (s Style) BorderCollapse(str ...string) string

func (Style) BorderColor added in v1.1.5

func (s Style) BorderColor(str ...string) string

func (Style) BorderImage added in v1.1.5

func (s Style) BorderImage(str ...string) string

func (Style) BorderImageOutset added in v1.1.5

func (s Style) BorderImageOutset(str ...string) string

func (Style) BorderImageRepeat added in v1.1.5

func (s Style) BorderImageRepeat(str ...string) string

func (Style) BorderImageSlice added in v1.1.5

func (s Style) BorderImageSlice(str ...string) string

func (Style) BorderImageSource added in v1.1.5

func (s Style) BorderImageSource(str ...string) string

func (Style) BorderImageWidth added in v1.1.5

func (s Style) BorderImageWidth(str ...string) string

func (Style) BorderLeft added in v1.1.5

func (s Style) BorderLeft(str ...string) string

func (Style) BorderLeftColor added in v1.1.5

func (s Style) BorderLeftColor(str ...string) string

func (Style) BorderLeftStyle added in v1.1.5

func (s Style) BorderLeftStyle(str ...string) string

func (Style) BorderLeftWidth added in v1.1.5

func (s Style) BorderLeftWidth(str ...string) string

func (Style) BorderRadius added in v1.1.5

func (s Style) BorderRadius(str ...string) string

func (Style) BorderRight added in v1.1.5

func (s Style) BorderRight(str ...string) string

func (Style) BorderRightColor added in v1.1.5

func (s Style) BorderRightColor(str ...string) string

func (Style) BorderRightStyle added in v1.1.5

func (s Style) BorderRightStyle(str ...string) string

func (Style) BorderRightWidth added in v1.1.5

func (s Style) BorderRightWidth(str ...string) string

func (Style) BorderSpacing added in v1.1.5

func (s Style) BorderSpacing(str ...string) string

func (Style) BorderStyle added in v1.1.5

func (s Style) BorderStyle(str ...string) string

func (Style) BorderTop added in v1.1.5

func (s Style) BorderTop(str ...string) string

func (Style) BorderTopColor added in v1.1.5

func (s Style) BorderTopColor(str ...string) string

func (Style) BorderTopLeftRadius added in v1.1.5

func (s Style) BorderTopLeftRadius(str ...string) string

func (Style) BorderTopRightRadius added in v1.1.5

func (s Style) BorderTopRightRadius(str ...string) string

func (Style) BorderTopStyle added in v1.1.5

func (s Style) BorderTopStyle(str ...string) string

func (Style) BorderTopWidth added in v1.1.5

func (s Style) BorderTopWidth(str ...string) string

func (Style) BorderWidth added in v1.1.5

func (s Style) BorderWidth(str ...string) string

func (Style) Bottom added in v1.1.5

func (s Style) Bottom(str ...string) string

func (Style) BoxShadow added in v1.1.5

func (s Style) BoxShadow(str ...string) string

func (Style) BoxSizing added in v1.1.5

func (s Style) BoxSizing(str ...string) string

func (Style) CaptionSide added in v1.1.5

func (s Style) CaptionSide(str ...string) string

func (Style) CaretColor added in v1.1.5

func (s Style) CaretColor(str ...string) string

func (Style) Clear added in v1.1.5

func (s Style) Clear(str ...string) string

func (Style) Clip added in v1.1.5

func (s Style) Clip(str ...string) string

func (Style) Color added in v1.1.5

func (s Style) Color(str ...string) string

func (Style) ColumnCount added in v1.1.5

func (s Style) ColumnCount(str ...string) string

func (Style) ColumnFill added in v1.1.5

func (s Style) ColumnFill(str ...string) string

func (Style) ColumnGap added in v1.1.5

func (s Style) ColumnGap(str ...string) string

func (Style) ColumnRule added in v1.1.5

func (s Style) ColumnRule(str ...string) string

func (Style) ColumnRuleColor added in v1.1.5

func (s Style) ColumnRuleColor(str ...string) string

func (Style) ColumnRuleStyle added in v1.1.5

func (s Style) ColumnRuleStyle(str ...string) string

func (Style) ColumnRuleWidth added in v1.1.5

func (s Style) ColumnRuleWidth(str ...string) string

func (Style) ColumnSpan added in v1.1.5

func (s Style) ColumnSpan(str ...string) string

func (Style) ColumnWidth added in v1.1.5

func (s Style) ColumnWidth(str ...string) string

func (Style) Columns added in v1.1.5

func (s Style) Columns(str ...string) string

func (Style) CounterIncrement added in v1.1.5

func (s Style) CounterIncrement(str ...string) string

func (Style) CounterReset added in v1.1.5

func (s Style) CounterReset(str ...string) string

func (Style) CssFloat added in v1.1.5

func (s Style) CssFloat(str ...string) string

func (Style) Cursor added in v1.1.5

func (s Style) Cursor(str ...string) string

func (Style) Direction added in v1.1.5

func (s Style) Direction(str ...string) string

func (Style) Display added in v1.1.5

func (s Style) Display(str ...string) string

func (Style) EmptyCells added in v1.1.5

func (s Style) EmptyCells(str ...string) string

func (Style) Filter added in v1.1.5

func (s Style) Filter(str ...string) string

func (Style) Flex added in v1.1.5

func (s Style) Flex(str ...string) string

func (Style) FlexBasis added in v1.1.5

func (s Style) FlexBasis(str ...string) string

func (Style) FlexDirection added in v1.1.5

func (s Style) FlexDirection(str ...string) string

func (Style) FlexFlow added in v1.1.5

func (s Style) FlexFlow(str ...string) string

func (Style) FlexGrow added in v1.1.5

func (s Style) FlexGrow(str ...string) string

func (Style) FlexShrink added in v1.1.5

func (s Style) FlexShrink(str ...string) string

func (Style) FlexWrap added in v1.1.5

func (s Style) FlexWrap(str ...string) string

func (Style) Font added in v1.1.5

func (s Style) Font(str ...string) string

func (Style) FontFamily added in v1.1.5

func (s Style) FontFamily(str ...string) string

func (Style) FontSize added in v1.1.5

func (s Style) FontSize(str ...string) string

func (Style) FontSizeAdjust added in v1.1.5

func (s Style) FontSizeAdjust(str ...string) string

func (Style) FontStyle added in v1.1.5

func (s Style) FontStyle(str ...string) string

func (Style) FontVariant added in v1.1.5

func (s Style) FontVariant(str ...string) string

func (Style) FontWeight added in v1.1.5

func (s Style) FontWeight(str ...string) string

func (Style) Get added in v1.1.5

func (s Style) Get(key string) js.Value

func (Style) Height added in v1.1.5

func (s Style) Height(str ...string) string

func (Style) Isolation added in v1.1.5

func (s Style) Isolation(str ...string) string

func (Style) JSExt added in v1.1.5

func (s Style) JSExt() Value

func (Style) JustifyContent added in v1.1.5

func (s Style) JustifyContent(str ...string) string

func (Style) Left added in v1.1.5

func (s Style) Left(str ...string) string

func (Style) LetterSpacing added in v1.1.5

func (s Style) LetterSpacing(str ...string) string

func (Style) LineHeight added in v1.1.5

func (s Style) LineHeight(str ...string) string

func (Style) ListStyle added in v1.1.5

func (s Style) ListStyle(str ...string) string

func (Style) ListStyleImage added in v1.1.5

func (s Style) ListStyleImage(str ...string) string

func (Style) ListStylePosition added in v1.1.5

func (s Style) ListStylePosition(str ...string) string

func (Style) ListStyleType added in v1.1.5

func (s Style) ListStyleType(str ...string) string

func (Style) Margin added in v1.1.5

func (s Style) Margin(str ...string) string

func (Style) MarginBottom added in v1.1.5

func (s Style) MarginBottom(str ...string) string

func (Style) MarginLeft added in v1.1.5

func (s Style) MarginLeft(str ...string) string

func (Style) MarginRight added in v1.1.5

func (s Style) MarginRight(str ...string) string

func (Style) MarginTop added in v1.1.5

func (s Style) MarginTop(str ...string) string

func (Style) MaxHeight added in v1.1.5

func (s Style) MaxHeight(str ...string) string

func (Style) MaxWidth added in v1.1.5

func (s Style) MaxWidth(str ...string) string

func (Style) MinHeight added in v1.1.5

func (s Style) MinHeight(str ...string) string

func (Style) MinWidth added in v1.1.5

func (s Style) MinWidth(str ...string) string

func (Style) ObjectFit added in v1.1.5

func (s Style) ObjectFit(str ...string) string

func (Style) ObjectPosition added in v1.1.5

func (s Style) ObjectPosition(str ...string) string

func (Style) Opacity added in v1.1.5

func (s Style) Opacity(str ...string) string

func (Style) Order added in v1.1.5

func (s Style) Order(str ...string) string

func (Style) Orphans added in v1.1.5

func (s Style) Orphans(str ...string) string

func (Style) Outline added in v1.1.5

func (s Style) Outline(str ...string) string

func (Style) OutlineColor added in v1.1.5

func (s Style) OutlineColor(str ...string) string

func (Style) OutlineOffset added in v1.1.5

func (s Style) OutlineOffset(str ...string) string

func (Style) OutlineStyle added in v1.1.5

func (s Style) OutlineStyle(str ...string) string

func (Style) OutlineWidth added in v1.1.5

func (s Style) OutlineWidth(str ...string) string

func (Style) Overflow added in v1.1.5

func (s Style) Overflow(str ...string) string

func (Style) OverflowX added in v1.1.5

func (s Style) OverflowX(str ...string) string

func (Style) OverflowY added in v1.1.5

func (s Style) OverflowY(str ...string) string

func (Style) Padding added in v1.1.5

func (s Style) Padding(str ...string) string

func (Style) PaddingBottom added in v1.1.5

func (s Style) PaddingBottom(str ...string) string

func (Style) PaddingLeft added in v1.1.5

func (s Style) PaddingLeft(str ...string) string

func (Style) PaddingRight added in v1.1.5

func (s Style) PaddingRight(str ...string) string

func (Style) PaddingTop added in v1.1.5

func (s Style) PaddingTop(str ...string) string

func (Style) PageBreakAfter added in v1.1.5

func (s Style) PageBreakAfter(str ...string) string

func (Style) PageBreakBefore added in v1.1.5

func (s Style) PageBreakBefore(str ...string) string

func (Style) PageBreakInside added in v1.1.5

func (s Style) PageBreakInside(str ...string) string

func (Style) Perspective added in v1.1.5

func (s Style) Perspective(str ...string) string

func (Style) PerspectiveOrigin added in v1.1.5

func (s Style) PerspectiveOrigin(str ...string) string

func (Style) Position added in v1.1.5

func (s Style) Position(str ...string) string

func (Style) Quotes added in v1.1.5

func (s Style) Quotes(str ...string) string

func (Style) Resize added in v1.1.5

func (s Style) Resize(str ...string) string

func (Style) Right added in v1.1.5

func (s Style) Right(str ...string) string

func (Style) ScrollBehavior added in v1.1.5

func (s Style) ScrollBehavior(str ...string) string

func (Style) Set added in v1.1.5

func (s Style) Set(key string, value interface{})

func (Style) TabSize added in v1.1.5

func (s Style) TabSize(str ...string) string

func (Style) TableLayout added in v1.1.5

func (s Style) TableLayout(str ...string) string

func (Style) TextAlign added in v1.1.5

func (s Style) TextAlign(str ...string) string

func (Style) TextAlignLast added in v1.1.5

func (s Style) TextAlignLast(str ...string) string

func (Style) TextDecoration added in v1.1.5

func (s Style) TextDecoration(str ...string) string

func (Style) TextDecorationColor added in v1.1.5

func (s Style) TextDecorationColor(str ...string) string

func (Style) TextDecorationLine added in v1.1.5

func (s Style) TextDecorationLine(str ...string) string

func (Style) TextDecorationStyle added in v1.1.5

func (s Style) TextDecorationStyle(str ...string) string

func (Style) TextIndent added in v1.1.5

func (s Style) TextIndent(str ...string) string

func (Style) TextOverflow added in v1.1.5

func (s Style) TextOverflow(str ...string) string

func (Style) TextShadow added in v1.1.5

func (s Style) TextShadow(str ...string) string

func (Style) TextTransform added in v1.1.5

func (s Style) TextTransform(str ...string) string

func (Style) Top added in v1.1.5

func (s Style) Top(str ...string) string

func (Style) Transform added in v1.1.5

func (s Style) Transform(str ...string) string

func (Style) TransformOrigin added in v1.1.5

func (s Style) TransformOrigin(str ...string) string

func (Style) TransformStyle added in v1.1.5

func (s Style) TransformStyle(str ...string) string

func (Style) Transition added in v1.1.5

func (s Style) Transition(str ...string) string

func (Style) TransitionDelay added in v1.1.5

func (s Style) TransitionDelay(str ...string) string

func (Style) TransitionDuration added in v1.1.5

func (s Style) TransitionDuration(str ...string) string

func (Style) TransitionProperty added in v1.1.5

func (s Style) TransitionProperty(str ...string) string

func (Style) TransitionTimingFunction added in v1.1.5

func (s Style) TransitionTimingFunction(str ...string) string

func (Style) UnicodeBidi added in v1.1.5

func (s Style) UnicodeBidi(str ...string) string

func (Style) Unset added in v1.1.5

func (s Style) Unset(key string)

func (Style) UserSelect added in v1.1.5

func (s Style) UserSelect(str ...string) string

func (Style) Value added in v1.1.5

func (s Style) Value() js.Value

func (Style) VerticalAlign added in v1.1.5

func (s Style) VerticalAlign(str ...string) string

func (Style) Visibility added in v1.1.5

func (s Style) Visibility(str ...string) string

func (Style) WhiteSpace added in v1.1.5

func (s Style) WhiteSpace(str ...string) string

func (Style) Widows added in v1.1.5

func (s Style) Widows(str ...string) string

func (Style) Width added in v1.1.5

func (s Style) Width(str ...string) string

func (Style) WordBreak added in v1.1.5

func (s Style) WordBreak(str ...string) string

func (Style) WordSpacing added in v1.1.5

func (s Style) WordSpacing(str ...string) string

func (Style) WordWrap added in v1.1.5

func (s Style) WordWrap(str ...string) string

func (Style) ZIndex added in v1.1.5

func (s Style) ZIndex(str ...string) string

type Value

type Value js.Value

Wrapper for javascript values to make life easier.

func BytesToArray added in v1.1.5

func BytesToArray(b []byte) Value

Convert a byte slice to a js.Value array.

func Call added in v1.1.4

func Call(key string, args ...any) Value

Call a function in the global scope.

func Eval

func Eval(script string) Value

Eval evaluates raw javascript code, returns the result as a js.Value.

func EventEmit added in v1.1.4

func EventEmit(name string, args ...interface{}) Value

Emit an event on the global Runtime object.

func EventOn added in v1.1.4

func EventOn(name string, f func(args ...interface{})) Value

Listen for an event on the global Runtime object.

func EventOnMultiple added in v1.1.4

func EventOnMultiple(f func(args ...interface{}), names ...string) []Value

Listen for multiple events on the global Runtime object.

func Get added in v1.1.4

func Get(key string) Value

Get a value from the global scope.

func MapToObject added in v1.1.5

func MapToObject(m map[string]interface{}) Value

Convert a map to a js.Value object.

func New added in v1.1.4

func New(key string, args ...any) Value

New a value in the global scope.

func NewArray

func NewArray() Value

Returns a new array.

func NewDate

func NewDate() Value

Returns a new date object.

func NewObject

func NewObject() Value

Returns a new object.

func Null added in v1.1.4

func Null() Value

Returns a new null value.

func SetInterval

func SetInterval(f JSExtFunc, timeout int) Value

Set an interval on a function.

func SetTimeout

func SetTimeout(f JSExtFunc, timeout int) Value

Set a timeout on a function.

func SliceToArray added in v1.1.5

func SliceToArray(s []any) Value

Convert a slice to a js.Value array.

func Undefined added in v1.1.4

func Undefined() Value

Returns a new undefined value.

func ValueOf

func ValueOf(value any) Value

Returns the value of a property.

func (Value) Add

func (w Value) Add(s ...string)

Add attributes to an element.

func (Value) AppendChild

func (w Value) AppendChild(child Element)

AppendChild inserts a node after another node.

func (Value) Bool

func (w Value) Bool() bool

/////////////////////////////////////////////////////////

js.Value methods.

/////////////////////////////////////////////////////////

func (Value) Call

func (w Value) Call(m string, args ...any) Value

func (Value) Delete

func (w Value) Delete(p string)

func (Value) Equal

func (w Value) Equal(other js.Value) bool

func (Value) Float

func (w Value) Float() float64

func (Value) Get

func (w Value) Get(p string) Value

func (Value) GetElementByClassName

func (w Value) GetElementByClassName(class string) Element

GetElementByClassName returns the first element with the given class name.

func (Value) GetElementById

func (w Value) GetElementById(id string) Element

GetElementById returns the first element with the given id.

func (Value) GetElementByTagName

func (w Value) GetElementByTagName(tag string) Element

GetElementByTagName returns the first element with the given tag name.

func (Value) Index

func (w Value) Index(i int) Value

func (Value) InsertBefore

func (w Value) InsertBefore(child Element, before Element)

InsertBefore inserts a node before another node.

func (Value) InstanceOf

func (w Value) InstanceOf(t js.Value) bool

func (Value) Int

func (w Value) Int() int

func (Value) Invalid

func (w Value) Invalid() bool

Returns false if value is null or undefined.

func (Value) Invoke

func (w Value) Invoke(args ...any) Value

func (Value) IsArray

func (w Value) IsArray() bool

Returns true if the value is undefined.

func (Value) IsBoolean

func (w Value) IsBoolean() bool

Returns true if the value is a boolean.

func (Value) IsElement

func (w Value) IsElement() bool

Returns true if the value is a javascript Element or HTMLElement.

func (Value) IsFunction

func (w Value) IsFunction() bool

Returns true if the value is a javascript function.

func (Value) IsNaN

func (w Value) IsNaN() bool

func (Value) IsNull

func (w Value) IsNull() bool

func (Value) IsNumber

func (w Value) IsNumber() bool

Returns true if the value is a number.

func (Value) IsObject

func (w Value) IsObject() bool

Returns true if the value is an object.

func (Value) IsString

func (w Value) IsString() bool

Returns true if the value is a string.

func (Value) IsUndefined

func (w Value) IsUndefined() bool

func (Value) Length

func (w Value) Length() int

func (Value) New

func (w Value) New(args ...any) Value

func (Value) PrependChild

func (w Value) PrependChild(child Element)

PrependChild inserts a node before another node.

func (Value) QuerySelector

func (w Value) QuerySelector(selector string) Element

Query select inside of the value.

func (Value) QuerySelectorAll

func (w Value) QuerySelectorAll(selector string) Elements

Query select all inside of the value.

func (Value) Remove

func (w Value) Remove(a ...string)

Remove an attribute from an element, or the entire element if no attribute is given.

func (Value) ReplaceChild

func (w Value) ReplaceChild(child Element, before Element)

ReplaceChild replaces the child with the before element.

func (Value) Set

func (w Value) Set(p string, x any)

func (Value) SetIndex

func (w Value) SetIndex(i int, x any)

func (Value) String

func (w Value) String() string

func (Value) ToElement

func (w Value) ToElement() Element

Returns the jsext.Element of the value.

func (Value) Toggle

func (w Value) Toggle(s string)

Toggle an attribute on an element.

func (Value) ToggleCustom

func (w Value) ToggleCustom(s string) bool

Great for values which cannot be addressed with .toggle()

  • Returns the new value

func (Value) Truthy

func (w Value) Truthy() bool

func (Value) Type

func (w Value) Type() js.Type

func (Value) Value

func (w Value) Value() js.Value

Returns the js.Value of the value.

Jump to

Keyboard shortcuts

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