Add cdp support for xpath scrapers (#625)

Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
bnkai
2020-08-04 03:42:40 +03:00
committed by GitHub
parent 1b4a9eed36
commit 4373f9bf01
284 changed files with 133250 additions and 54 deletions

1828
vendor/github.com/chromedp/cdproto/webaudio/easyjson.go generated vendored Normal file

File diff suppressed because it is too large Load Diff

122
vendor/github.com/chromedp/cdproto/webaudio/events.go generated vendored Normal file
View File

@@ -0,0 +1,122 @@
package webaudio
// Code generated by cdproto-gen. DO NOT EDIT.
// EventContextCreated notifies that a new BaseAudioContext has been created.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-contextCreated
type EventContextCreated struct {
Context *BaseAudioContext `json:"context"`
}
// EventContextWillBeDestroyed notifies that an existing BaseAudioContext
// will be destroyed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-contextWillBeDestroyed
type EventContextWillBeDestroyed struct {
ContextID GraphObjectID `json:"contextId"`
}
// EventContextChanged notifies that existing BaseAudioContext has changed
// some properties (id stays the same)..
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-contextChanged
type EventContextChanged struct {
Context *BaseAudioContext `json:"context"`
}
// EventAudioListenerCreated notifies that the construction of an
// AudioListener has finished.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioListenerCreated
type EventAudioListenerCreated struct {
Listener *AudioListener `json:"listener"`
}
// EventAudioListenerWillBeDestroyed notifies that a new AudioListener has
// been created.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioListenerWillBeDestroyed
type EventAudioListenerWillBeDestroyed struct {
ContextID GraphObjectID `json:"contextId"`
ListenerID GraphObjectID `json:"listenerId"`
}
// EventAudioNodeCreated notifies that a new AudioNode has been created.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioNodeCreated
type EventAudioNodeCreated struct {
Node *AudioNode `json:"node"`
}
// EventAudioNodeWillBeDestroyed notifies that an existing AudioNode has been
// destroyed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioNodeWillBeDestroyed
type EventAudioNodeWillBeDestroyed struct {
ContextID GraphObjectID `json:"contextId"`
NodeID GraphObjectID `json:"nodeId"`
}
// EventAudioParamCreated notifies that a new AudioParam has been created.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioParamCreated
type EventAudioParamCreated struct {
Param *AudioParam `json:"param"`
}
// EventAudioParamWillBeDestroyed notifies that an existing AudioParam has
// been destroyed.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-audioParamWillBeDestroyed
type EventAudioParamWillBeDestroyed struct {
ContextID GraphObjectID `json:"contextId"`
NodeID GraphObjectID `json:"nodeId"`
ParamID GraphObjectID `json:"paramId"`
}
// EventNodesConnected notifies that two AudioNodes are connected.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-nodesConnected
type EventNodesConnected struct {
ContextID GraphObjectID `json:"contextId"`
SourceID GraphObjectID `json:"sourceId"`
DestinationID GraphObjectID `json:"destinationId"`
SourceOutputIndex float64 `json:"sourceOutputIndex,omitempty"`
DestinationInputIndex float64 `json:"destinationInputIndex,omitempty"`
}
// EventNodesDisconnected notifies that AudioNodes are disconnected. The
// destination can be null, and it means all the outgoing connections from the
// source are disconnected.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-nodesDisconnected
type EventNodesDisconnected struct {
ContextID GraphObjectID `json:"contextId"`
SourceID GraphObjectID `json:"sourceId"`
DestinationID GraphObjectID `json:"destinationId"`
SourceOutputIndex float64 `json:"sourceOutputIndex,omitempty"`
DestinationInputIndex float64 `json:"destinationInputIndex,omitempty"`
}
// EventNodeParamConnected notifies that an AudioNode is connected to an
// AudioParam.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-nodeParamConnected
type EventNodeParamConnected struct {
ContextID GraphObjectID `json:"contextId"`
SourceID GraphObjectID `json:"sourceId"`
DestinationID GraphObjectID `json:"destinationId"`
SourceOutputIndex float64 `json:"sourceOutputIndex,omitempty"`
}
// EventNodeParamDisconnected notifies that an AudioNode is disconnected to
// an AudioParam.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#event-nodeParamDisconnected
type EventNodeParamDisconnected struct {
ContextID GraphObjectID `json:"contextId"`
SourceID GraphObjectID `json:"sourceId"`
DestinationID GraphObjectID `json:"destinationId"`
SourceOutputIndex float64 `json:"sourceOutputIndex,omitempty"`
}

329
vendor/github.com/chromedp/cdproto/webaudio/types.go generated vendored Normal file
View File

@@ -0,0 +1,329 @@
package webaudio
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"errors"
"github.com/chromedp/cdproto/cdp"
"github.com/mailru/easyjson"
"github.com/mailru/easyjson/jlexer"
"github.com/mailru/easyjson/jwriter"
)
// GraphObjectID an unique ID for a graph object (AudioContext, AudioNode,
// AudioParam) in Web Audio API.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-GraphObjectId
type GraphObjectID string
// String returns the GraphObjectID as string value.
func (t GraphObjectID) String() string {
return string(t)
}
// ContextType enum of BaseAudioContext types.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ContextType
type ContextType string
// String returns the ContextType as string value.
func (t ContextType) String() string {
return string(t)
}
// ContextType values.
const (
ContextTypeRealtime ContextType = "realtime"
ContextTypeOffline ContextType = "offline"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ContextType) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ContextType) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ContextType) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ContextType(in.String()) {
case ContextTypeRealtime:
*t = ContextTypeRealtime
case ContextTypeOffline:
*t = ContextTypeOffline
default:
in.AddError(errors.New("unknown ContextType value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ContextType) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ContextState enum of AudioContextState from the spec.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ContextState
type ContextState string
// String returns the ContextState as string value.
func (t ContextState) String() string {
return string(t)
}
// ContextState values.
const (
ContextStateSuspended ContextState = "suspended"
ContextStateRunning ContextState = "running"
ContextStateClosed ContextState = "closed"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ContextState) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ContextState) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ContextState) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ContextState(in.String()) {
case ContextStateSuspended:
*t = ContextStateSuspended
case ContextStateRunning:
*t = ContextStateRunning
case ContextStateClosed:
*t = ContextStateClosed
default:
in.AddError(errors.New("unknown ContextState value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ContextState) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// NodeType enum of AudioNode types.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-NodeType
type NodeType string
// String returns the NodeType as string value.
func (t NodeType) String() string {
return string(t)
}
// ChannelCountMode enum of AudioNode::ChannelCountMode from the spec.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ChannelCountMode
type ChannelCountMode string
// String returns the ChannelCountMode as string value.
func (t ChannelCountMode) String() string {
return string(t)
}
// ChannelCountMode values.
const (
ChannelCountModeClampedMax ChannelCountMode = "clamped-max"
ChannelCountModeExplicit ChannelCountMode = "explicit"
ChannelCountModeMax ChannelCountMode = "max"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ChannelCountMode) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ChannelCountMode) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ChannelCountMode) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ChannelCountMode(in.String()) {
case ChannelCountModeClampedMax:
*t = ChannelCountModeClampedMax
case ChannelCountModeExplicit:
*t = ChannelCountModeExplicit
case ChannelCountModeMax:
*t = ChannelCountModeMax
default:
in.AddError(errors.New("unknown ChannelCountMode value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ChannelCountMode) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ChannelInterpretation enum of AudioNode::ChannelInterpretation from the
// spec.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ChannelInterpretation
type ChannelInterpretation string
// String returns the ChannelInterpretation as string value.
func (t ChannelInterpretation) String() string {
return string(t)
}
// ChannelInterpretation values.
const (
ChannelInterpretationDiscrete ChannelInterpretation = "discrete"
ChannelInterpretationSpeakers ChannelInterpretation = "speakers"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t ChannelInterpretation) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t ChannelInterpretation) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *ChannelInterpretation) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch ChannelInterpretation(in.String()) {
case ChannelInterpretationDiscrete:
*t = ChannelInterpretationDiscrete
case ChannelInterpretationSpeakers:
*t = ChannelInterpretationSpeakers
default:
in.AddError(errors.New("unknown ChannelInterpretation value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *ChannelInterpretation) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ParamType enum of AudioParam types.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ParamType
type ParamType string
// String returns the ParamType as string value.
func (t ParamType) String() string {
return string(t)
}
// AutomationRate enum of AudioParam::AutomationRate from the spec.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-AutomationRate
type AutomationRate string
// String returns the AutomationRate as string value.
func (t AutomationRate) String() string {
return string(t)
}
// AutomationRate values.
const (
AutomationRateARate AutomationRate = "a-rate"
AutomationRateKRate AutomationRate = "k-rate"
)
// MarshalEasyJSON satisfies easyjson.Marshaler.
func (t AutomationRate) MarshalEasyJSON(out *jwriter.Writer) {
out.String(string(t))
}
// MarshalJSON satisfies json.Marshaler.
func (t AutomationRate) MarshalJSON() ([]byte, error) {
return easyjson.Marshal(t)
}
// UnmarshalEasyJSON satisfies easyjson.Unmarshaler.
func (t *AutomationRate) UnmarshalEasyJSON(in *jlexer.Lexer) {
switch AutomationRate(in.String()) {
case AutomationRateARate:
*t = AutomationRateARate
case AutomationRateKRate:
*t = AutomationRateKRate
default:
in.AddError(errors.New("unknown AutomationRate value"))
}
}
// UnmarshalJSON satisfies json.Unmarshaler.
func (t *AutomationRate) UnmarshalJSON(buf []byte) error {
return easyjson.Unmarshal(buf, t)
}
// ContextRealtimeData fields in AudioContext that change in real-time.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-ContextRealtimeData
type ContextRealtimeData struct {
CurrentTime float64 `json:"currentTime"` // The current context time in second in BaseAudioContext.
RenderCapacity float64 `json:"renderCapacity"` // The time spent on rendering graph divided by render quantum duration, and multiplied by 100. 100 means the audio renderer reached the full capacity and glitch may occur.
CallbackIntervalMean float64 `json:"callbackIntervalMean"` // A running mean of callback interval.
CallbackIntervalVariance float64 `json:"callbackIntervalVariance"` // A running variance of callback interval.
}
// BaseAudioContext protocol object for BaseAudioContext.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-BaseAudioContext
type BaseAudioContext struct {
ContextID GraphObjectID `json:"contextId"`
ContextType ContextType `json:"contextType"`
ContextState ContextState `json:"contextState"`
RealtimeData *ContextRealtimeData `json:"realtimeData,omitempty"`
CallbackBufferSize float64 `json:"callbackBufferSize"` // Platform-dependent callback buffer size.
MaxOutputChannelCount float64 `json:"maxOutputChannelCount"` // Number of output channels supported by audio hardware in use.
SampleRate float64 `json:"sampleRate"` // Context sample rate.
}
// AudioListener protocol object for AudioListner.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-AudioListener
type AudioListener struct {
ListenerID GraphObjectID `json:"listenerId"`
ContextID GraphObjectID `json:"contextId"`
}
// AudioNode protocol object for AudioNode.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-AudioNode
type AudioNode struct {
NodeID GraphObjectID `json:"nodeId"`
ContextID GraphObjectID `json:"contextId"`
NodeType cdp.NodeType `json:"nodeType"`
NumberOfInputs float64 `json:"numberOfInputs"`
NumberOfOutputs float64 `json:"numberOfOutputs"`
ChannelCount float64 `json:"channelCount"`
ChannelCountMode ChannelCountMode `json:"channelCountMode"`
ChannelInterpretation ChannelInterpretation `json:"channelInterpretation"`
}
// AudioParam protocol object for AudioParam.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#type-AudioParam
type AudioParam struct {
ParamID GraphObjectID `json:"paramId"`
NodeID GraphObjectID `json:"nodeId"`
ContextID GraphObjectID `json:"contextId"`
ParamType ParamType `json:"paramType"`
Rate AutomationRate `json:"rate"`
DefaultValue float64 `json:"defaultValue"`
MinValue float64 `json:"minValue"`
MaxValue float64 `json:"maxValue"`
}

View File

@@ -0,0 +1,93 @@
// Package webaudio provides the Chrome DevTools Protocol
// commands, types, and events for the WebAudio domain.
//
// This domain allows inspection of Web Audio API.
// https://webaudio.github.io/web-audio-api/.
//
// Generated by the cdproto-gen command.
package webaudio
// Code generated by cdproto-gen. DO NOT EDIT.
import (
"context"
"github.com/chromedp/cdproto/cdp"
)
// EnableParams enables the WebAudio domain and starts sending context
// lifetime events.
type EnableParams struct{}
// Enable enables the WebAudio domain and starts sending context lifetime
// events.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#method-enable
func Enable() *EnableParams {
return &EnableParams{}
}
// Do executes WebAudio.enable against the provided context.
func (p *EnableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandEnable, nil, nil)
}
// DisableParams disables the WebAudio domain.
type DisableParams struct{}
// Disable disables the WebAudio domain.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#method-disable
func Disable() *DisableParams {
return &DisableParams{}
}
// Do executes WebAudio.disable against the provided context.
func (p *DisableParams) Do(ctx context.Context) (err error) {
return cdp.Execute(ctx, CommandDisable, nil, nil)
}
// GetRealtimeDataParams fetch the realtime data from the registered
// contexts.
type GetRealtimeDataParams struct {
ContextID GraphObjectID `json:"contextId"`
}
// GetRealtimeData fetch the realtime data from the registered contexts.
//
// See: https://chromedevtools.github.io/devtools-protocol/tot/WebAudio#method-getRealtimeData
//
// parameters:
// contextID
func GetRealtimeData(contextID GraphObjectID) *GetRealtimeDataParams {
return &GetRealtimeDataParams{
ContextID: contextID,
}
}
// GetRealtimeDataReturns return values.
type GetRealtimeDataReturns struct {
RealtimeData *ContextRealtimeData `json:"realtimeData,omitempty"`
}
// Do executes WebAudio.getRealtimeData against the provided context.
//
// returns:
// realtimeData
func (p *GetRealtimeDataParams) Do(ctx context.Context) (realtimeData *ContextRealtimeData, err error) {
// execute
var res GetRealtimeDataReturns
err = cdp.Execute(ctx, CommandGetRealtimeData, p, &res)
if err != nil {
return nil, err
}
return res.RealtimeData, nil
}
// Command names.
const (
CommandEnable = "WebAudio.enable"
CommandDisable = "WebAudio.disable"
CommandGetRealtimeData = "WebAudio.getRealtimeData"
)