Documentation
¶
Overview ¶
Package eval builds JavaScript evaluation helpers for the CDP HTML driver.
Index ¶
- Constants
- type CompiledFunction
- type Function
- func (fn *Function) AsAnonymous() *Function
- func (fn *Function) AsAsync() *Function
- func (fn *Function) AsNamed(name string) *Function
- func (fn *Function) AsSync() *Function
- func (fn *Function) CallOn(id cdpruntime.RemoteObjectID) *Function
- func (fn *Function) Err() error
- func (fn *Function) Length() int
- func (fn *Function) String() string
- func (fn *Function) WithArg(value any) *Function
- func (fn *Function) WithArgRef(id cdpruntime.RemoteObjectID) *Function
- func (fn *Function) WithArgRemoteValue(value RemoteValue) *Function
- func (fn *Function) WithArgSelector(selector drivers.QuerySelector) *Function
- func (fn *Function) WithArgValue(value runtime.Value) *Function
- type FunctionArguments
- type RemoteClassName
- type RemoteObjectType
- type RemoteType
- type RemoteValue
- type Resolver
- func (r *Resolver) SetLoader(loader ValueLoader) *Resolver
- func (r *Resolver) ToElement(ctx context.Context, ref cdpruntime.RemoteObject) (drivers.HTMLElement, error)
- func (r *Resolver) ToProperties(ctx context.Context, id cdpruntime.RemoteObjectID) (*runtime.Array, error)
- func (r *Resolver) ToProperty(ctx context.Context, id cdpruntime.RemoteObjectID, propName string) (runtime.Value, error)
- func (r *Resolver) ToValue(ctx context.Context, ref cdpruntime.RemoteObject) (runtime.Value, error)
- type ReturnType
- type Runtime
- func (rt *Runtime) Call(ctx context.Context, fn *CompiledFunction) error
- func (rt *Runtime) CallElement(ctx context.Context, fn *CompiledFunction) (drivers.HTMLElement, error)
- func (rt *Runtime) CallElements(ctx context.Context, fn *CompiledFunction) (runtime.List, error)
- func (rt *Runtime) CallRef(ctx context.Context, fn *CompiledFunction) (cdpruntime.RemoteObject, error)
- func (rt *Runtime) CallValue(ctx context.Context, fn *CompiledFunction) (runtime.Value, error)
- func (rt *Runtime) Compile(ctx context.Context, fn *Function) (*CompiledFunction, error)
- func (rt *Runtime) ContextID() cdpruntime.ExecutionContextID
- func (rt *Runtime) Eval(ctx context.Context, fn *Function) error
- func (rt *Runtime) EvalElement(ctx context.Context, fn *Function) (runtime.Value, error)
- func (rt *Runtime) EvalElements(ctx context.Context, fn *Function) (*runtime.Array, error)
- func (rt *Runtime) EvalRef(ctx context.Context, fn *Function) (cdpruntime.RemoteObject, error)
- func (rt *Runtime) EvalValue(ctx context.Context, fn *Function) (runtime.Value, error)
- func (rt *Runtime) SetLoader(loader ValueLoader) *Runtime
- type ValueLoader
- type ValueLoaderFn
Constants ¶
View Source
const ( EmptyExecutionContextID = cdpruntime.ExecutionContextID(-1) EmptyObjectID = cdpruntime.RemoteObjectID("") )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CompiledFunction ¶
type CompiledFunction struct {
// contains filtered or unexported fields
}
func CF ¶
func CF(id cdpruntime.ScriptID, src *Function) *CompiledFunction
type Function ¶
type Function struct {
// contains filtered or unexported fields
}
func (*Function) AsAnonymous ¶
func (*Function) CallOn ¶
func (fn *Function) CallOn(id cdpruntime.RemoteObjectID) *Function
func (*Function) Err ¶
Err returns the first error encountered while building the function, or nil if none. Callers that consume a Function (eval / compile paths) should check this before making network calls.
func (*Function) WithArgRef ¶
func (fn *Function) WithArgRef(id cdpruntime.RemoteObjectID) *Function
func (*Function) WithArgRemoteValue ¶
func (fn *Function) WithArgRemoteValue(value RemoteValue) *Function
func (*Function) WithArgSelector ¶
func (fn *Function) WithArgSelector(selector drivers.QuerySelector) *Function
type FunctionArguments ¶
type FunctionArguments []cdpruntime.CallArgument
func (FunctionArguments) MarshalZerologArray ¶
func (args FunctionArguments) MarshalZerologArray(a *zerolog.Array)
type RemoteClassName ¶
type RemoteClassName string
const ( UnknownClassName RemoteClassName = "" DocumentClassName RemoteClassName = "HTMLDocument" )
List of supported remote classses
func ToRemoteClassName ¶
func ToRemoteClassName(ref cdpruntime.RemoteObject) RemoteClassName
type RemoteObjectType ¶
type RemoteObjectType string
const ( UnknownObjectType RemoteObjectType = "" NullObjectType RemoteObjectType = "null" UndefinedObjectType RemoteObjectType = "undefined" ArrayObjectType RemoteObjectType = "array" NodeObjectType RemoteObjectType = "node" RegexpObjectType RemoteObjectType = "regexp" DateObjectType RemoteObjectType = "date" MapObjectType RemoteObjectType = "map" SetObjectType RemoteObjectType = "set" WeakMapObjectType RemoteObjectType = "weakmap" WeakSetObjectType RemoteObjectType = "weakset" IteratorObjectType RemoteObjectType = "iterator" GeneratorObjectType RemoteObjectType = "generator" ErrorObjectType RemoteObjectType = "error" ProxyObjectType RemoteObjectType = "proxy" PromiseObjectType RemoteObjectType = "promise" TypedArrayObjectType RemoteObjectType = "typedarray" ArrayBufferObjectType RemoteObjectType = "arraybuffer" DataViewObjectType RemoteObjectType = "dataview" )
List of possible remote object types
func ToRemoteObjectType ¶
func ToRemoteObjectType(ref cdpruntime.RemoteObject) RemoteObjectType
type RemoteType ¶
type RemoteType string
const ( UnknownType RemoteType = "" UndefinedType RemoteType = "undefined" StringType RemoteType = "string" NumberType RemoteType = "number" BooleanType RemoteType = "boolean" SymbolType RemoteType = "symbol" BigintType RemoteType = "bigint" ObjectType RemoteType = "object" )
List of possible remote types "object", "function", "undefined", "string", "number", "boolean", "symbol", "bigint"
func ToRemoteType ¶
func ToRemoteType(ref cdpruntime.RemoteObject) RemoteType
type RemoteValue ¶
type RemoteValue interface {
RemoteID() cdpruntime.RemoteObjectID
}
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
func (*Resolver) SetLoader ¶
func (r *Resolver) SetLoader(loader ValueLoader) *Resolver
func (*Resolver) ToElement ¶
func (r *Resolver) ToElement(ctx context.Context, ref cdpruntime.RemoteObject) (drivers.HTMLElement, error)
func (*Resolver) ToProperties ¶
func (r *Resolver) ToProperties( ctx context.Context, id cdpruntime.RemoteObjectID, ) (*runtime.Array, error)
func (*Resolver) ToProperty ¶
func (r *Resolver) ToProperty( ctx context.Context, id cdpruntime.RemoteObjectID, propName string, ) (runtime.Value, error)
func (*Resolver) ToValue ¶
func (r *Resolver) ToValue(ctx context.Context, ref cdpruntime.RemoteObject) (runtime.Value, error)
type ReturnType ¶
type ReturnType int
const ( ReturnNothing ReturnType = iota ReturnValue ReturnRef )
func (ReturnType) String ¶
func (rt ReturnType) String() string
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
func New ¶
func New( logger zerolog.Logger, client *cdp.Client, frameID page.FrameID, contextID cdpruntime.ExecutionContextID, ) *Runtime
func (*Runtime) CallElement ¶
func (rt *Runtime) CallElement(ctx context.Context, fn *CompiledFunction) (drivers.HTMLElement, error)
func (*Runtime) CallElements ¶
func (*Runtime) CallRef ¶
func (rt *Runtime) CallRef(ctx context.Context, fn *CompiledFunction) (cdpruntime.RemoteObject, error)
func (*Runtime) ContextID ¶
func (rt *Runtime) ContextID() cdpruntime.ExecutionContextID
func (*Runtime) EvalElement ¶
func (*Runtime) EvalElements ¶
func (*Runtime) EvalRef ¶
func (rt *Runtime) EvalRef(ctx context.Context, fn *Function) (cdpruntime.RemoteObject, error)
func (*Runtime) SetLoader ¶
func (rt *Runtime) SetLoader(loader ValueLoader) *Runtime
type ValueLoader ¶
type ValueLoader interface {
Load(
ctx context.Context,
frameID page.FrameID,
remoteType RemoteObjectType,
remoteClass RemoteClassName,
id cdpruntime.RemoteObjectID,
) (runtime.Value, error)
}
type ValueLoaderFn ¶
type ValueLoaderFn func( ctx context.Context, frameID page.FrameID, remoteType RemoteObjectType, remoteClass RemoteClassName, id cdpruntime.RemoteObjectID, ) (runtime.Value, error)
func (ValueLoaderFn) Load ¶
func (f ValueLoaderFn) Load( ctx context.Context, frameID page.FrameID, remoteType RemoteObjectType, remoteClass RemoteClassName, id cdpruntime.RemoteObjectID, ) (runtime.Value, error)
Click to show internal directories.
Click to hide internal directories.