internal

package
v0.0.0-...-b47709e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package internal contains the types and util funcs common to the chromedp-gen command.

Index

Constants

View Source
const (
	// Base64EncodedParamName is the base64encoded variable name in command
	// return values when they are optionally base64 encoded.
	Base64EncodedParamName = "base64Encoded"

	// Base64EncodedDescriptionPrefix is the prefix for command return
	// description prefix when base64 encoded.
	Base64EncodedDescriptionPrefix = "Base64-encoded"
)

Variables

View Source
var (
	FlagPkg      = FlagSet.String("pkg", "github.com/rjeczalik/chromedp/cdp", "output package")
	FlagFile     = FlagSet.String("file", "protocol.json", "path to chrome protocol.json")
	FlagDep      = FlagSet.Bool("dep", false, "toggle deprecated API generation")
	FlagExp      = FlagSet.Bool("exp", true, "toggle experimental API generation")
	FlagRedirect = FlagSet.Bool("redirect", false, "toggle redirect API generation")
	FlagNoRemove = FlagSet.Bool("noremove", false, "toggle to not remove existing package directory")
)

The application flags.

View Source
var (
	DomainTypePrefix     = ""
	DomainTypeSuffix     = ""
	TypePrefix           = ""
	TypeSuffix           = ""
	EventMethodPrefix    = "Event"
	EventMethodSuffix    = ""
	CommandMethodPrefix  = "Command"
	CommandMethodSuffix  = ""
	EventTypePrefix      = "Event"
	EventTypeSuffix      = ""
	CommandTypePrefix    = ""
	CommandTypeSuffix    = "Params"
	CommandReturnsPrefix = ""
	CommandReturnsSuffix = "Returns"
	OptionFuncPrefix     = "With"
	OptionFuncSuffix     = ""
)

Prefix and suffix values.

FlagSet is the set of application flags.

Functions

func CDPTypeList

func CDPTypeList() []string

CDPTypeList returns the list of internal types.

func CleanDesc

func CleanDesc(s string) string

CleanDesc cleans comments / descriptions of "<code>" and "</code>" strings and "`" characters, and fixes common misspellings.

func ForceCamel

func ForceCamel(s string) string

ForceCamel forces camel case specific to go.

func ForceCamelWithFirstLower

func ForceCamelWithFirstLower(s string) string

ForceCamelWithFirstLower forces the first portion to be lower case.

func IsCDPType

func IsCDPType(dtyp DomainType, typ string) bool

IsCDPType determines if the specified domain and typ constitute an internal type.

func SetCDPTypes

func SetCDPTypes(types map[string]bool)

SetCDPTypes sets the internal types.

Types

type Bool

type Bool bool

Bool provides a type for handling incorrectly quoted boolean values in the protocol.json file.

func (Bool) Bool

func (b Bool) Bool() bool

Bool returns the bool as a Go bool.

func (Bool) MarshalJSON

func (b Bool) MarshalJSON() ([]byte, error)

MarshalJSON marshals the bool into its corresponding JSON representation.

func (*Bool) UnmarshalJSON

func (b *Bool) UnmarshalJSON(buf []byte) error

UnmarshalJSON unmarshals a possibly quoted string representation of a bool (ie, true, "true", false, "false").

type Domain

type Domain struct {
	// Domain is the name of the domain.
	Domain DomainType `json:"domain,omitempty"`

	// Description is the domain description.
	Description string `json:"description,omitempty"`

	// Experimental indicates whether or not the domain is experimental.
	Experimental Bool `json:"experimental,omitempty"`

	// Deprecated indicates whether or not the domain is deprecated.
	Deprecated Bool `json:"deprecated,omitempty"`

	// Types are the list of types in the domain.
	Types []*Type `json:"types,omitempty"`

	// Commands are the list of command types in the domain.
	Commands []*Type `json:"commands,omitempty"`

	// Events is the list of events types in the domain.
	Events []*Type `json:"events,omitempty"`
}

Domain represents a Chrome Debugging Protocol domain.

func (*Domain) DomainType

func (d *Domain) DomainType() string

DomainType returns the name of the type to use for the domain.

func (*Domain) GetDescription

func (d *Domain) GetDescription() string

GetDescription returns the formatted description of the domain.

func (*Domain) PackageImportAlias

func (d *Domain) PackageImportAlias() string

PackageImportAlias returns the Go import package name alias to use for the domain, or the empty string.

func (*Domain) PackageName

func (d *Domain) PackageName() string

PackageName returns the Go package name to use for the domain.

func (*Domain) PackageRefName

func (d *Domain) PackageRefName() string

PackageRefName returns the Go package name to use for the domain.

func (*Domain) String

func (d *Domain) String() string

Strings satisfies stringer.

type DomainType

type DomainType string

DomainType is the Chrome domain type.

const (
	DomainAccessibility        DomainType = "Accessibility"
	DomainAnimation            DomainType = "Animation"
	DomainApplicationCache     DomainType = "ApplicationCache"
	DomainAudits               DomainType = "Audits"
	DomainBrowser              DomainType = "Browser"
	DomainCSS                  DomainType = "CSS"
	DomainCacheStorage         DomainType = "CacheStorage"
	DomainConsole              DomainType = "Console"
	DomainDOM                  DomainType = "DOM"
	DomainDOMDebugger          DomainType = "DOMDebugger"
	DomainDOMSnapshot          DomainType = "DOMSnapshot"
	DomainDOMStorage           DomainType = "DOMStorage"
	DomainDatabase             DomainType = "Database"
	DomainDebugger             DomainType = "Debugger"
	DomainDeviceOrientation    DomainType = "DeviceOrientation"
	DomainEmulation            DomainType = "Emulation"
	DomainHAR                  DomainType = "HAR"
	DomainHeadlessExperimental DomainType = "HeadlessExperimental"
	DomainHeapProfiler         DomainType = "HeapProfiler"
	DomainIO                   DomainType = "IO"
	DomainIndexedDB            DomainType = "IndexedDB"
	DomainInput                DomainType = "Input"
	DomainInspector            DomainType = "Inspector"
	DomainLayerTree            DomainType = "LayerTree"
	DomainLog                  DomainType = "Log"
	DomainMemory               DomainType = "Memory"
	DomainNetwork              DomainType = "Network"
	DomainOverlay              DomainType = "Overlay"
	DomainPage                 DomainType = "Page"
	DomainPerformance          DomainType = "Performance"
	DomainProfiler             DomainType = "Profiler"
	DomainRuntime              DomainType = "Runtime"
	DomainSchema               DomainType = "Schema"
	DomainSecurity             DomainType = "Security"
	DomainServiceWorker        DomainType = "ServiceWorker"
	DomainStorage              DomainType = "Storage"
	DomainSystemInfo           DomainType = "SystemInfo"
	DomainTarget               DomainType = "Target"
	DomainTethering            DomainType = "Tethering"
	DomainTracing              DomainType = "Tracing"
)

DomainType values.

func (DomainType) MarshalJSON

func (dt DomainType) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (DomainType) String

func (dt DomainType) String() string

String satisfies Stringer.

func (*DomainType) UnmarshalJSON

func (dt *DomainType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

type HandlerType

type HandlerType string

HandlerType are the handler targets for commands and events.

const (
	HandlerTypeBrowser  HandlerType = "browser"
	HandlerTypeRenderer HandlerType = "renderer"
)

HandlerType values.

func (HandlerType) MarshalJSON

func (ht HandlerType) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (HandlerType) String

func (ht HandlerType) String() string

String satisfies stringer.

func (*HandlerType) UnmarshalJSON

func (ht *HandlerType) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

type ProtocolInfo

type ProtocolInfo struct {
	// Version contains the protocol version information.
	Version *Version `json:"version,omitempty"`

	// Domains lists the available domains in the protocol.
	Domains []*Domain `json:"domains,omitempty"`
}

ProtocolInfo holds information about the Chrome Debugging Protocol.

type TimestampType

type TimestampType int

TimestampType are the various timestamp subtypes.

const (
	TimestampTypeMillisecond TimestampType = 1 + iota
	TimestampTypeSecond
	TimestampTypeMonotonic
)

TimestampType values.

type Type

type Type struct {
	// Type is the provided type enum.
	Type TypeEnum `json:"type,omitempty"`

	// ID is the ID of the type when type is an object.
	ID string `json:"id,omitempty"`

	// Name is the type name.
	Name string `json:"name,omitempty"`

	// Description is the type description.
	Description string `json:"description,omitempty"`

	// Optional indicates if the type is optional. Used for commands and event parameters.
	Optional Bool `json:"optional,omitempty"`

	// Deprecated indicates if the type is deprecated. Used for commands and event parameters.
	Deprecated Bool `json:"deprecated,omitempty"`

	// Enum are the enum values for the type (only used when type is string --
	// a non empty slice marks the type as a "enum").
	Enum []string `json:"enum,omitempty"`

	// Ref is the ID of a referenced type when type points to another type.
	Ref string `json:"$ref,omitempty"`

	// Items is the type of contained values in the array when type is array.
	Items *Type `json:"items,omitempty"`

	// Properties are the properties of the object when type is object.
	Properties []*Type `json:"properties,omitempty"`

	// Parameters is the command or event parameters.
	Parameters []*Type `json:"parameters,omitempty"`

	// Returns is the return value types.
	Returns []*Type `json:"returns,omitempty"`

	// MinItems is the minimum number of items when type is array.
	MinItems int64 `json:"minItems,omitempty"`

	// MaxItems is the maximum number of items when type is array.
	MaxItems int64 `json:"maxItems,omitempty"`

	// Handlers are the listed handlers for the command or event.
	Handlers []HandlerType `json:"handlers,omitempty"`

	// Redirect is the redirect value for the command or event.
	Redirect DomainType `json:"redirect,omitempty"`

	// TimestampType is the timestamp subtype.
	TimestampType TimestampType `json:"-"`

	// NoExpose toggles whether or not to expose the type.
	NoExpose bool `json:"-"`

	// NoResolve toggles not resolving the type to a domain (ie, for special internal types).
	NoResolve bool `json:"-"`

	// EnumValueNameMap is a map to override the generated enum value name.
	EnumValueNameMap map[string]string `json:"-"`

	// EnumBitMask toggles it as a bit mask enum for TypeInteger enums.
	EnumBitMask bool `json:"-"`

	// Extra will be added as output after the the type is emitted.
	Extra string `json:"-"`
}

Type represents a type available to the domain.

func (*Type) Base64EncodedRetParam

func (t *Type) Base64EncodedRetParam() *Type

Base64EncodedRetParam returns the base64 encoded return parameter, or nil if no parameters are base64 encoded.

func (*Type) CamelName

func (t *Type) CamelName() string

CamelName returns the CamelCase name of the type.

func (*Type) CommandMethodType

func (t *Type) CommandMethodType(d *Domain) string

CommandMethodType returns the method type of the event.

func (*Type) CommandReturnsType

func (t *Type) CommandReturnsType() string

CommandReturnsType returns the type of the command return type.

func (*Type) CommandType

func (t *Type) CommandType() string

CommandType returns the type of the command.

func (*Type) EmptyRetList

func (t *Type) EmptyRetList(d *Domain, domains []*Domain) string

EmptyRetList returns a list of the empty return values.

func (*Type) EnumValueName

func (t *Type) EnumValueName(v string) string

EnumValueName returns the name for a enum value.

func (*Type) EnumValues

func (t *Type) EnumValues() []string

EnumValues returns enum values for the type.

func (*Type) EventMethodType

func (t *Type) EventMethodType(d *Domain) string

EventMethodType returns the method type of the event.

func (*Type) EventType

func (t *Type) EventType() string

EventType returns the type of the event.

func (*Type) GetDescription

func (t *Type) GetDescription() string

GetDescription returns the cleaned description for the type.

func (*Type) GoEmptyValue

func (t *Type) GoEmptyValue(d *Domain, domains []*Domain) string

GoEmptyValue returns the empty Go value for the type.

func (*Type) GoName

func (t *Type) GoName(noExposeOverride bool) string

GoName returns the Go name.

func (*Type) GoType

func (t *Type) GoType(d *Domain, domains []*Domain) string

GoType returns the Go type for the type.

func (*Type) GoTypeDef

func (t *Type) GoTypeDef(d *Domain, domains []*Domain, extra []*Type, noExposeOverride, omitOnlyWhenOptional bool) string

GoTypeDef returns the Go type definition for the type.

func (Type) IDorName

func (t Type) IDorName() string

IDorName returns either the ID or the Name for the type.

func (*Type) ParamList

func (t *Type) ParamList(d *Domain, domains []*Domain, all bool) string

ParamList returns the list of parameters.

func (*Type) ProtoName

func (t *Type) ProtoName(d *Domain) string

ProtoName returns the protocol name of the type.

func (*Type) ResolveType

func (t *Type) ResolveType(d *Domain, domains []*Domain) (DomainType, *Type, string)

ResolveType resolves the type relative to the Go domain.

Returns the DomainType of the underlying type, the underlying type (or the original passed type if not a reference) and the fully qualified name type name.

func (*Type) RetNameList

func (t *Type) RetNameList(valname string, d *Domain, domains []*Domain) string

RetNameList returns a <valname>.<name> list for a command's return list.

func (*Type) RetTypeList

func (t *Type) RetTypeList(d *Domain, domains []*Domain) string

RetTypeList returns a list of the return types.

func (Type) String

func (t Type) String() string

String satisfies stringer.

func (*Type) TypeName

func (t *Type) TypeName(prefix, suffix string) string

TypeName returns the type name using the supplied prefix and suffix.

type TypeEnum

type TypeEnum string

TypeEnum is the Chrome domain type enum.

const (
	TypeAny       TypeEnum = "any"
	TypeArray     TypeEnum = "array"
	TypeBoolean   TypeEnum = "boolean"
	TypeInteger   TypeEnum = "integer"
	TypeNumber    TypeEnum = "number"
	TypeObject    TypeEnum = "object"
	TypeString    TypeEnum = "string"
	TypeTimestamp TypeEnum = "timestamp"
)

TypeEnum values.

func (TypeEnum) GoEmptyValue

func (te TypeEnum) GoEmptyValue() string

GoEmptyValue returns the Go empty value for the TypeEnum.

func (TypeEnum) GoType

func (te TypeEnum) GoType() string

GoType returns the Go type for the TypeEnum.

func (TypeEnum) MarshalJSON

func (te TypeEnum) MarshalJSON() ([]byte, error)

MarshalJSON satisfies json.Marshaler.

func (TypeEnum) String

func (te TypeEnum) String() string

String satisfies stringer.

func (*TypeEnum) UnmarshalJSON

func (te *TypeEnum) UnmarshalJSON(buf []byte) error

UnmarshalJSON satisfies json.Unmarshaler.

type Version

type Version struct {
	// Major is the version major.
	Major string `json:"major,omitempty"`

	// Minor is the version minor.
	Minor string `json:"minor,omitempty"`
}

Version holds information about the protocol version.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL