Documentation
¶
Index ¶
- Variables
- func CallbackErrorf[T any](s js.Scope[T], format string, a ...any) error
- func DecodeAny[T any](_ js.Scope[T], v js.Value[T]) (any, error)
- func DecodeAs[T, U any](s js.Scope[U], v js.Value[U]) (res T, err error)
- func DecodeBoolean[T any](_ js.Scope[T], val js.Value[T]) (bool, error)
- func DecodeByteString[T any](s js.Scope[T], v js.Value[T]) (types.ByteString, error)
- func DecodeDuration[T any](_ js.Scope[T], v js.Value[T]) (time.Duration, error)
- func DecodeEvent[T any](_ js.Scope[T], options js.Object[T], ev *event.Event) error
- func DecodeFunction[T any](s js.Scope[T], v js.Value[T]) (js.Function[T], error)
- func DecodeHTMLElement[T any](s js.Scope[T], v js.Value[T]) (html.HTMLElement, error)
- func DecodeInt[T any](_ js.Scope[T], v js.Value[T]) (int, error)
- func DecodeJsObject[T any](s js.Scope[T], v js.Value[T]) (res js.Object[T], err error)
- func DecodeNativeValue[T, U any](s js.Scope[T], v js.Value[T]) (res U, err error)
- func DecodeNode[T any](s js.Scope[T], v js.Value[T]) (dom.Node, error)
- func DecodeOptions[T, U any](scope js.Scope[T], val js.Value[T], specs Options[T, U]) (opts []U, err error)
- func DecodeRequestBody[T any](s js.Scope[T], val js.Value[T]) (io.Reader, error)
- func DecodeString[T any](s js.Scope[T], v js.Value[T]) (string, error)
- func EncodeAny[T any](scope js.Scope[T], v any) (js.Value[T], error)
- func EncodeBoolean[T any](s js.CallbackScope[T], b bool) (js.Value[T], error)
- func EncodeByteString[T any](scope js.Scope[T], s types.ByteString) (js.Value[T], error)
- func EncodeCallbackErrorf[T any](ctx js.CallbackContext[T], format string, a ...any) (js.Value[T], error)
- func EncodeConstructedValue[T any](s js.CallbackScope[T], val any) (js.Value[T], error)
- func EncodeEntity[T any, U entity.Components](s js.Scope[T], e U) (js.Value[T], error)
- func EncodeEntityScopedWithPrototype[T any](scope js.Scope[T], e entity.Components, protoName string) (js.Value[T], error)
- func EncodeInt[T any](s js.Scope[T], i int) (js.Value[T], error)
- func EncodeNillableString[T any](scope js.CallbackScope[T], s string, hasValue bool) (js.Value[T], error)
- func EncodeNull[T any](s js.CallbackScope[T]) (js.Value[T], error)
- func EncodeNullableString[T any](scope js.CallbackScope[T], s *string) (js.Value[T], error)
- func EncodeOptionalString[T any](scope js.CallbackScope[T], s string) (js.Value[T], error)
- func EncodePromise[T, U any](scope js.Scope[T], prom promise.Promise[U], encoder Encoder[T, U]) (js.Value[T], error)
- func EncodeString[T any](scope js.Scope[T], s string) (js.Value[T], error)
- func GetWindow[T any](scope js.Scope[T]) (html.Window, error)
- func LookupJSPrototype(entity any) string
- func NewOptionsDecoder[T, U any](opts Options[T, U]) func(js.CallbackContext[T], js.Value[T]) ([]U, error)
- func RetrieveEventInit[T, U any](cbCtx js.CallbackContext[U]) (res T, err error)
- func SetJsValue[T any](c entity.Components, v js.Value[T])
- func UnsupportedOptionErrorf[T any](s js.Scope[T], value js.Value[T], webAPI string, key string) error
- func ZeroValue[T any]() (res T)
- type Encoder
- type EventInit
- type OptionDecoder
- type Options
Constants ¶
This section is empty.
Variables ¶
var HtmlElements = map[string]string{}/* 141 elements not displayed */
Functions ¶
func CallbackErrorf ¶ added in v0.8.0
func DecodeAny ¶ added in v0.11.0
DecodeAny returns the native JavaScript value and is used where a Go implementation merely has a slot for client code to store a value. When the client code is JavaScript, the value will be the JavaScript object. One example is the Detail property of a CustomEvent.
func DecodeByteString ¶ added in v0.10.3
func DecodeDuration ¶ added in v0.11.0
func DecodeEvent ¶ added in v0.11.0
func DecodeFunction ¶
func DecodeHTMLElement ¶
func DecodeJsObject ¶ added in v0.11.0
func DecodeNativeValue ¶ added in v0.11.0
func DecodeOptions ¶ added in v0.8.0
func DecodeRequestBody ¶ added in v0.9.3
DecodeRequestBody constructs an io.Reader used for HTTP request bodies for both XMLHttpRequest.send and fetch's RequestInit.body, which supports almost identical values.
Note: Not all valid body types aren't yet supported
func EncodeAny ¶ added in v0.11.0
EncodeAny assumes that value v is a direct JavaScript. See also DecodeAny
func EncodeBoolean ¶
func EncodeByteString ¶ added in v0.10.3
func EncodeCallbackErrorf ¶ added in v0.8.0
func EncodeCallbackErrorf[T any]( ctx js.CallbackContext[T], format string, a ...any, ) (js.Value[T], error)
EncodeCallbackErrorf create callback return values with a specific error message, and logs the error to the logger associated with the script context.
While _uncaught_ JavaScript errors would be logged by default, if the error is caught by JavaScript, the error message will not be logged.
This is particularly valuable for not-implemented methods, as JavaScript code will fail when perfectly valid assumptions about the function are violated.
func EncodeConstructedValue ¶ added in v0.11.0
EncodeConstructedValue is a simple helper for JS constructor callbacks to store the constructed Go value in the JavaScript object, and possibly cache it with the script context.
func EncodeEntity ¶
EncodeEntity gets the JavaScript object that wraps a specific Go object. If a wrapper already has been created, that wrapper is returned; otherwise a new object is created with the correct prototype configured.
func EncodeEntityScopedWithPrototype ¶ added in v0.10.3
func EncodeNillableString ¶
func EncodeNull ¶
func EncodeNullableString ¶
func EncodeOptionalString ¶ added in v0.11.0
func EncodePromise ¶ added in v0.8.0
func EncodePromise[T, U any]( scope js.Scope[T], prom promise.Promise[U], encoder Encoder[T, U], ) (js.Value[T], error)
EncodePromise converts a promise.Promise value to a JavaScript Promise value, using encoder to convert the native fulfilled value to a JavaScript value.
The returned Promise will not settile immediately after a value is received from prom, but will be deferred to run on the "main loop" that the embedder controls.
func LookupJSPrototype ¶
func NewOptionsDecoder ¶ added in v0.8.0
func RetrieveEventInit ¶ added in v0.11.0
func RetrieveEventInit[T, U any](cbCtx js.CallbackContext[U]) (res T, err error)
func SetJsValue ¶ added in v0.11.0
func SetJsValue[T any](c entity.Components, v js.Value[T])
func UnsupportedOptionErrorf ¶ added in v0.8.0
func UnsupportedOptionErrorf[T any]( s js.Scope[T], value js.Value[T], webAPI string, key string, ) error
UnsupportedOptionErrorf is used to detect when script code uses options or arguments that are not yet supported by Gost-DOM.
The primary usage is to identify when a failing test case is failing because of missing functionality in Gost-DOM, rather than an error in the system under test.
The value argument represents a JavaScript function argument keyed option value. If it is not null or undefined, an error is logged and returned. The name of the api is specified in the webAPI, and the unsupported method or option is specified in key.
Types ¶
type OptionDecoder ¶ added in v0.8.0
func OptDecoder ¶ added in v0.8.0
type Options ¶ added in v0.8.0
type Options[T, U any] map[string]OptionDecoder[T, U]