gojaPlugin

package
v0.0.0-...-add256a Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultOpts = map[string]interface{}{

		"plugins": []interface{}{

			[]interface{}{"transform-es2015-modules-commonjs", map[string]interface{}{"loose": false}},
		},
		"ast":           false,
		"sourceMaps":    false,
		"babelrc":       false,
		"compact":       false,
		"retainLines":   true,
		"highlightCode": false,
	}
)

Functions

This section is empty.

Types

type AgentVU

type AgentVU struct {
	RuntimeField *goja.Runtime
}

func (*AgentVU) Runtime

func (m *AgentVU) Runtime() *goja.Runtime

type ChaiRootModule

type ChaiRootModule struct {
	// contains filtered or unexported fields
}

func (*ChaiRootModule) NewModuleInstance

func (root *ChaiRootModule) NewModuleInstance(vu VU) Instance

type CommModule

type CommModule struct {
	// contains filtered or unexported fields
}

func (*CommModule) Exports

func (mod *CommModule) Exports() Exports

type CompatibilityMode

type CompatibilityMode uint8

CompatibilityMode specifies the JS compatibility mode

const (
	// CompatibilityModeExtended achieves ES6+ compatibility with Babel
	CompatibilityModeExtended CompatibilityMode = iota + 1
	// CompatibilityModeBase is standard goja ES5.1+
	CompatibilityModeBase
)

type Compiler

type Compiler struct {
	Options Options
	// contains filtered or unexported fields
}

A Compiler compiles JavaScript source code (ES5.1 or ES6) into a goja.Program

func NewCompiler

func NewCompiler(logger logrus.FieldLogger) *Compiler

New returns a new Compiler

func (*Compiler) Compile

func (c *Compiler) Compile(src, filename string, isESM bool) (*goja.Program, string, error)

Compile the program in the given CompatibilityMode, wrapping it between pre and post code TODO isESM will be used once goja support ESM modules natively

func (*Compiler) Transform

func (c *Compiler) Transform(src, filename string, inputSrcMap []byte) (code string, srcMap []byte, err error)

Transform the given code into ES5

type Exports

type Exports struct {
	// Default is what will be the `default` export of a module
	Default interface{}
	// Named is the named exports of a module
	Named map[string]interface{}
}

type Instance

type Instance interface {
	Exports() Exports
}

type MochaRootModule

type MochaRootModule struct {
	// contains filtered or unexported fields
}

func (*MochaRootModule) NewModuleInstance

func (root *MochaRootModule) NewModuleInstance(vu VU) Instance

type Module

type Module interface {
	// NewModuleInstance will get modules.VU that should provide the module with a way to interact with the VU
	// This method will be called for *each* require/import and should return an unique instance for each call
	NewModuleInstance(VU) Instance
}

func NewChai

func NewChai() Module

func NewMocha

func NewMocha() Module

type Options

type Options struct {
	CompatibilityMode CompatibilityMode
	SourceMapLoader   func(string) ([]byte, error)
	Strict            bool
}

Options are options to the compiler

type Pool

type Pool struct {
	// contains filtered or unexported fields
}

Pool is a pool of compilers so it can be used easier in parallel tests as they have their own babel.

func (*Pool) Get

func (c *Pool) Get() *Compiler

Get a compiler from the pool.

func (*Pool) Put

func (c *Pool) Put(co *Compiler)

Put a compiler back in the pool.

type VU

type VU interface {
	Runtime() *goja.Runtime
}

Jump to

Keyboard shortcuts

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