Documentation
¶
Index ¶
- Variables
- func CallbackErrorf[T any](ctx js.CallbackContext[T], format string, a ...any) error
- func DecodeAs[T, U any](ctx js.CallbackContext[U], val js.Value[U]) (res T, err error)
- func DecodeBoolean[T any](_ js.CallbackContext[T], val js.Value[T]) (bool, error)
- func DecodeFunction[T any](cbCtx js.CallbackContext[T], val js.Value[T]) (js.Function[T], error)
- func DecodeHTMLElement[T any](ctx js.CallbackContext[T], val js.Value[T]) (html.HTMLElement, error)
- func DecodeInt[T any](_ js.CallbackContext[T], val js.Value[T]) (int, error)
- func DecodeNode[T any](ctx js.CallbackContext[T], val 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 DecodeString[T any](cbCtx js.CallbackContext[T], val js.Value[T]) (string, error)
- func EncodeBoolean[T any](cbCtx js.CallbackScope[T], b bool) (js.Value[T], error)
- func EncodeCallbackErrorf[T any](ctx js.CallbackContext[T], format string, a ...any) (js.Value[T], error)
- func EncodeConstrucedValue[T any](cbCtx js.CallbackScope[T], val any) (js.Value[T], error)
- func EncodeEntity[T any](cbCtx js.CallbackScope[T], e entity.ObjectIder) (js.Value[T], error)
- func EncodeEntityScoped[T any](scope js.Scope[T], e entity.ObjectIder) (js.Value[T], error)
- func EncodeError[T any](scope js.Scope[T], err error) (js.Value[T], error)
- func EncodeInt[T any](cbCtx js.CallbackScope[T], i int) (js.Value[T], error)
- func EncodeNillableString[T any](cbCtx js.CallbackScope[T], s string, hasValue bool) (js.Value[T], error)
- func EncodeNull[T any](cbCtx js.CallbackScope[T]) (js.Value[T], error)
- func EncodeNullableString[T any](cbCtx 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 EncodePromiseFunc[T any](c js.Scope[T], f func() (js.Value[T], error)) (js.Value[T], error)
- func EncodeString[T any](cbCtx js.CallbackScope[T], s string) (js.Value[T], error)
- func EncodeStringScoped[T any](cbCtx js.Scope[T], s string) (js.Value[T], error)
- func LookupJSPrototype(entity entity.ObjectIder) string
- func NewOptionsDecoder[T, U any](opts Options[T, U]) func(js.CallbackContext[T], js.Value[T]) ([]U, error)
- func UnsupportedOptionErrorf[T any](ctx js.CallbackContext[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 DecodeBoolean ¶
func DecodeFunction ¶
func DecodeHTMLElement ¶
func DecodeHTMLElement[T any]( ctx js.CallbackContext[T], val js.Value[T], ) (html.HTMLElement, error)
func DecodeNode ¶
func DecodeOptions ¶ added in v0.8.0
func DecodeString ¶
func EncodeBoolean ¶
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 EncodeConstrucedValue ¶
EncodeConstrucedValue 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 ¶
func EncodeEntity[T any](cbCtx js.CallbackScope[T], e entity.ObjectIder) (js.Value[T], error)
getJSInstance 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 EncodeEntityScoped ¶
TODO: Embed scope in CallbackScope, so only one function is necessary
func EncodeError ¶ added in v0.8.0
func EncodeNillableString ¶
func EncodeNull ¶
func EncodeNullableString ¶
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 EncodePromiseFunc ¶ added in v0.8.0
EncodePromiseFunc returnes a JavaScript Promise that will settle with the result of running function f. Function f must be safe to run concurrently, as it will execute in a separate goroutine.
The promise will not settile immediately after f finishes, but will be deferred to run on the "main loop" that the embedder controls.
func EncodeString ¶
func EncodeStringScoped ¶
TODO: Embed scope in CallbackScope, so only one function is necessary
func LookupJSPrototype ¶
func LookupJSPrototype(entity entity.ObjectIder) string
func NewOptionsDecoder ¶ added in v0.8.0
func UnsupportedOptionErrorf ¶ added in v0.8.0
func UnsupportedOptionErrorf[T any]( ctx js.CallbackContext[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 EventInit ¶
func DecodeEventInit ¶
type OptionDecoder ¶ added in v0.8.0
func OptDecoder ¶ added in v0.8.0
func OptDecoder[T, U, V any](f func(U) V) OptionDecoder[T, V]
type Options ¶ added in v0.8.0
type Options[T, U any] map[string]OptionDecoder[T, U]