Documentation
¶
Overview ¶
The gojahost package provides functionality to execute client-scripts in gost-dom. The package is a pure Go implementation by using goja.
The package may not have full ECMAScript support. If this is a problem, the [v8host] proves a v8 engine implementation, but requires CGo.
Index ¶
- func New() html.ScriptHost
- type GojaContext
- func (c *GojaContext) Clock() html.Clock
- func (i *GojaContext) Close()
- func (c *GojaContext) CreateClass(name string, extends js.Class[jsTypeParam], ...) js.Class[jsTypeParam]
- func (c *GojaContext) CreateFunction(name string, cb js.FunctionCallback[jsTypeParam])
- func (i *GojaContext) Eval(str string) (res any, err error)
- func (i *GojaContext) EvalCore(str string) (res any, err error)
- func (i *GojaContext) Export(value any) (res any, err error)
- func (i *GojaContext) Run(str string) error
- func (i *GojaContext) RunFunction(str string, arguments ...any) (res any, err error)
- type ScriptEngineConfigurer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func New ¶
func New() html.ScriptHost
Types ¶
type GojaContext ¶
type GojaContext struct {
// contains filtered or unexported fields
}
func (*GojaContext) Clock ¶ added in v0.3.0
func (c *GojaContext) Clock() html.Clock
func (*GojaContext) Close ¶
func (i *GojaContext) Close()
func (*GojaContext) CreateClass ¶ added in v0.7.2
func (c *GojaContext) CreateClass( name string, extends js.Class[jsTypeParam], cb js.FunctionCallback[jsTypeParam], ) js.Class[jsTypeParam]
func (*GojaContext) CreateFunction ¶ added in v0.7.2
func (c *GojaContext) CreateFunction(name string, cb js.FunctionCallback[jsTypeParam])
func (*GojaContext) Export ¶
func (i *GojaContext) Export(value any) (res any, err error)
Export create a native Go value out of a javascript value. The value argument must be a goja.Value instance.
This function is intended to be used only for test purposes. The value has an [any] type as the tests are not supposed to know the details of the underlying engine.
The value is expected to be the ourput of [RunFunction] or [EvalCore]
An error will be returned if the value is not a goja Value, or the value could not be converted to a native Go object
func (*GojaContext) Run ¶
func (i *GojaContext) Run(str string) error
func (*GojaContext) RunFunction ¶
func (i *GojaContext) RunFunction(str string, arguments ...any) (res any, err error)
type ScriptEngineConfigurer ¶ added in v0.7.2
type ScriptEngineConfigurer struct {
// contains filtered or unexported fields
}
func (*ScriptEngineConfigurer) AddConfigurator ¶ added in v0.7.2
func (c *ScriptEngineConfigurer) AddConfigurator(configurer js.Configurator[jsTypeParam])
Source Files
¶
- base_instance_wrapper.go
- callback_context.go
- document_wrapper.go
- element_wrapper.go
- event.go
- event_loop.go
- event_target.go
- generic_html_element.go
- goja_context.go
- goja_host.go
- goja_initializer.go
- goja_iterator.go
- goja_scope.go
- goja_value_factory.go
- location.go
- node_list.go
- node_wrapper.go
- package.go
- uievents.go
- value.go
- window_wrapper.go