bridge

package
v1.1.0-beta.3 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package bridge provides the small set of runtime services shared by host modules. It deliberately does not depend on the parent jsruntime package.

Index

Constants

This section is empty.

Variables

View Source
var ErrExecutionTimeout = errors.New("JavaScript execution timeout")

Functions

func ExitCodeFromError

func ExitCodeFromError(err error) (int64, bool)

ExitCodeFromError returns the exit code when err was thrown by process.exit.

func ExitCodeFromValue

func ExitCodeFromValue(value goja.Value) (int64, bool)

ExitCodeFromValue returns the exit code when a rejected Promise carries the process.exit error object.

func RunWithDeadline

func RunWithDeadline(vm *goja.Runtime, deadline time.Time, fn func() error) error

RunWithDeadline interrupts synchronous JavaScript that exceeds deadline.

Types

type ErrorReporter

type ErrorReporter func(*goja.Runtime, string, error)

type ExitRequestedError

type ExitRequestedError struct {
	Code int64
}

ExitRequestedError stops a script turn with the requested process exit code. Code 0 is treated as a normal termination; nonzero codes are surfaced as failures.

func (*ExitRequestedError) Error

func (e *ExitRequestedError) Error() string

type Runtime

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

Runtime is the host-facing service boundary used by JavaScript modules.

func New

func New(loop *eventloop.EventLoop, timeout time.Duration) *Runtime

func (*Runtime) AddResource

func (r *Runtime) AddResource(close func()) uint64

func (*Runtime) CloseResources

func (r *Runtime) CloseResources()

func (*Runtime) Loop

func (r *Runtime) Loop() *eventloop.EventLoop

func (*Runtime) RemoveResource

func (r *Runtime) RemoveResource(id uint64)

func (*Runtime) ResourcesOpen

func (r *Runtime) ResourcesOpen() bool

func (*Runtime) RunJob

func (r *Runtime) RunJob(vm *goja.Runtime, name string, job func() error) error

RunJob executes one asynchronous host callback as a bounded JavaScript turn.

func (*Runtime) RunOnLoop

func (r *Runtime) RunOnLoop(job func(*goja.Runtime)) bool

func (*Runtime) RunTurn

func (r *Runtime) RunTurn(vm *goja.Runtime, job func() error) error

func (*Runtime) SetErrorReporter

func (r *Runtime) SetErrorReporter(report ErrorReporter)

func (*Runtime) SetTurnRunner

func (r *Runtime) SetTurnRunner(run TurnRunner)

func (*Runtime) Timeout

func (r *Runtime) Timeout() time.Duration

type TurnRunner

type TurnRunner func(*goja.Runtime, func() error) error

Jump to

Keyboard shortcuts

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