js

package
v0.0.0-...-9c02708 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2025 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

type Engine interface {
	// Run executes a self-contained JavaScript script and returns the result from stdout.
	Run(script string) (string, error)
}

Engine defines the interface for a JavaScript runtime.

type ExternalEngine

type ExternalEngine struct {
	Command string
}

ExternalEngine uses an external command-line JS runtime (node, deno, bun).

func NewExternalEngine

func NewExternalEngine(command string) (*ExternalEngine, error)

NewExternalEngine creates a new engine that shells out to an external command.

func (*ExternalEngine) Run

func (e *ExternalEngine) Run(script string) (string, error)

Run executes a script by piping it to the external runtime's stdin.

type GojaEngine

type GojaEngine struct{}

GojaEngine uses the embedded goja interpreter.

func NewGojaEngine

func NewGojaEngine() *GojaEngine

NewGojaEngine creates a new engine that uses the built-in goja interpreter.

func (*GojaEngine) Run

func (e *GojaEngine) Run(script string) (string, error)

Run executes a script in goja. It captures output by overriding console.log.

func (*GojaEngine) SolveV2Challenge

func (e *GojaEngine) SolveV2Challenge(body, domain string, scriptMatches [][]string, logger *log.Logger) (string, error)

SolveV2Challenge uses the original synchronous method to solve v2 challenges, as goja does not support asynchronous operations like setTimeout without additional setup.

type Runtime

type Runtime string

Runtime represents the name of a supported JavaScript runtime.

const (
	// Goja is the built-in Go-based interpreter (default, recommended).
	Goja Runtime = "goja"
	// Node uses the external Node.js runtime.
	Node Runtime = "node"
	// Deno uses the external Deno runtime.
	Deno Runtime = "deno"
	// Bun uses the external Bun runtime.
	Bun Runtime = "bun"
)

Jump to

Keyboard shortcuts

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