Documentation
¶
Overview ¶
The v8host packages provides functionality to execute client-side scripts in gost-dom. The engine uses v8, and requires cgo.
This engine is based on tommie's v8go form, which automatically pulls the latest v8 changes from the chromium repo.
An alternate script engine that is implemented in pure go is found in the gojahost package
See also: https://github.com/tommie/v8go
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrIncompatibleType = errors.New("Incompatible type") ErrWrongNoOfArguments = errors.New("Not enough arguments passed") )
var MAX_POOL_SIZE = runtime.NumCPU() * 2
MAX_POOL_SIZE sets a limit to the number of script hosts that will be pooled for reuse. By default Go will run as many tests in parallel as you have CPU cores, so there shouldn't be a reason for a larger pool, but this provides a bit of flexibility.
Functions ¶
Types ¶
type HostOption ¶ added in v0.5.1
type HostOption func(o *hostOptions)
func WithLogger ¶ added in v0.5.1
func WithLogger(logger log.Logger) HostOption
type Keys ¶ added in v0.6.0
type Keys[K, V any] struct { // contains filtered or unexported fields }
type MutationCallback ¶ added in v0.6.0
type MutationCallback struct {
// contains filtered or unexported fields
}
func (MutationCallback) HandleMutation ¶ added in v0.6.0
func (cb MutationCallback) HandleMutation(recs []mutation.Record, obs *mutation.Observer)
type V8ScriptContext ¶
type V8ScriptContext struct {
// contains filtered or unexported fields
}
func (*V8ScriptContext) Clock ¶ added in v0.3.0
func (ctx *V8ScriptContext) Clock() html.Clock
func (*V8ScriptContext) Close ¶
func (ctx *V8ScriptContext) Close()
func (*V8ScriptContext) Compile ¶ added in v0.7.0
func (ctx *V8ScriptContext) Compile(script string) (V8Script, error)
func (*V8ScriptContext) Run ¶
func (ctx *V8ScriptContext) Run(script string) error
type V8ScriptHost ¶
type V8ScriptHost struct {
// contains filtered or unexported fields
}
func New ¶
func New(opts ...HostOption) *V8ScriptHost
func (*V8ScriptHost) Close ¶
func (host *V8ScriptHost) Close()
Close informs that client code is done using this script host. The host will be placed into a pool;
func (*V8ScriptHost) Logger ¶ added in v0.5.1
func (host *V8ScriptHost) Logger() log.Logger
func (*V8ScriptHost) NewContext ¶
func (host *V8ScriptHost) NewContext(w html.Window) html.ScriptContext
NewContext creates a new script context using w as the global window object. Calling with a nil value for w is allowed, but not supported; and any attempt to access the DOM will result in a runtime error.
Source Files
¶
- argument_helper.go
- callback_context.go
- custom_event.go
- document.go
- document_fragment.go
- dom.go
- dom_parser.go
- dom_token_list_generated.go
- element.go
- element_generated.go
- es_wrapper.go
- event.go
- event_generated.go
- event_loop.go
- event_target.go
- form_data.go
- history.go
- history_generated.go
- html_anchor_element_generated.go
- html_document.go
- html_element_generated.go
- html_form_element_generated.go
- html_hyperlink_element_utils_generated.go
- html_input_element_generated.go
- html_or_svgelement.go
- html_or_svgelement_generated.go
- html_template_element_generated.go
- iterator.go
- location.go
- mutation_observer.go
- mutation_observer_generated.go
- mutation_record_generated.go
- named_node_map.go
- node.go
- node_generated.go
- node_list.go
- non_document_type_child_node_generated.go
- package.go
- parent_node.go
- parent_node_generated.go
- pointerevents4_generated.go
- polyfills.go
- script.go
- script_context.go
- script_host.go
- shadow_root.go
- template_builder.go
- uievents.go
- uievents_generated.go
- url.go
- url_generated.go
- v8_array.go
- window.go
- window_generated.go
- xhr_generated.go
- xml_http_request.go