js

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2025 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const PackageName = "@ohayocorp/anemos"

Variables

This section is empty.

Functions

func ResolvePath

func ResolvePath(path string, mayNotExist bool) (string, error)

func RunBunCommand

func RunBunCommand(bunCommand BunCommand) error

func RunTsc

func RunTsc(tsconfigPath string) error

func SourceLoader

func SourceLoader(jsRuntime *JsRuntime, path string) ([]byte, error)

func Throw

func Throw(err error)

Types

type BunCommand

type BunCommand struct {
	Description string
	Args        []string
	Cwd         *string
	Stdout      io.Writer
	Stderr      io.Writer
	Stdin       io.Reader
}

type ConstructorRegistration

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

func Constructor

func Constructor(function reflect.Value) *ConstructorRegistration

type DynamicArray

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

func (*DynamicArray) Get

func (d *DynamicArray) Get(index int) sobek.Value

func (*DynamicArray) Len

func (d *DynamicArray) Len() int

func (*DynamicArray) Set

func (d *DynamicArray) Set(index int, value sobek.Value) bool

func (*DynamicArray) SetLen

func (d *DynamicArray) SetLen(newLen int) bool

type DynamicFunction

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

type DynamicObject

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

func (*DynamicObject) Delete

func (d *DynamicObject) Delete(key string) bool

func (*DynamicObject) Get

func (d *DynamicObject) Get(originalKey string) sobek.Value

func (*DynamicObject) Has

func (d *DynamicObject) Has(key string) bool

func (*DynamicObject) Keys

func (d *DynamicObject) Keys() []string

func (*DynamicObject) Set

func (d *DynamicObject) Set(originalKey string, value sobek.Value) bool

type DynamicObjectCustomGetterSetter

type DynamicObjectCustomGetterSetter interface {
	GetKeys(jsRuntime *JsRuntime) []string
	Get(jsRuntime *JsRuntime, key string) (any, bool)
	Set(jsRuntime *JsRuntime, key string, value sobek.Value) bool
}

type DynamicObjectTemplate

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

func NewDynamicObjectTemplate

func NewDynamicObjectTemplate(jsRuntime *JsRuntime, objectType reflect.Type) *DynamicObjectTemplate

func (*DynamicObjectTemplate) Initialize

func (template *DynamicObjectTemplate) Initialize(module *sobek.Object)

func (*DynamicObjectTemplate) NewObject

func (template *DynamicObjectTemplate) NewObject(backingObject reflect.Value) *sobek.Object

type EmbeddedModule

type EmbeddedModule struct {
	ModulePath string
	Files      fs.FS
}

type ExtensionMethodRegistration

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

func ExtensionMethod

func ExtensionMethod(function reflect.Value) *ExtensionMethodRegistration

func (*ExtensionMethodRegistration) JsName

type FieldRegistration

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

func Field

func Field(name string) *FieldRegistration

func (*FieldRegistration) JsName

func (f *FieldRegistration) JsName(name string) *FieldRegistration

type FunctionRegistration

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

func (*FunctionRegistration) JsModule added in v0.2.0

func (f *FunctionRegistration) JsModule(module string) *FunctionRegistration

func (*FunctionRegistration) JsName

type FunctionType

type FunctionType string

type Iterator

type Iterator interface {
	Next(jsRuntime *JsRuntime, index int) IteratorResult
}

type IteratorResult

type IteratorResult struct {
	Value sobek.Value
	Done  bool
}

type JsError

type JsError struct {
	Err error
}

func (JsError) Error

func (e JsError) Error() string

type JsRuntime

type JsRuntime struct {
	MainScriptPath  string
	Registry        *require.Registry
	Runtime         *sobek.Runtime
	Flags           map[string]string
	EmbeddedModules []*EmbeddedModule
	// contains filtered or unexported fields
}

func NewJsRuntime

func NewJsRuntime() *JsRuntime

func (*JsRuntime) CheckInsideTheMainScriptDirectory

func (jsRuntime *JsRuntime) CheckInsideTheMainScriptDirectory(filePath string) error

func (*JsRuntime) Constructor added in v0.2.0

func (jsRuntime *JsRuntime) Constructor(function reflect.Value) *FunctionRegistration

func (*JsRuntime) Function

func (jsRuntime *JsRuntime) Function(function reflect.Value) *FunctionRegistration

func (*JsRuntime) GetEnv

func (jsRuntime *JsRuntime) GetEnv(key string) *string

func (*JsRuntime) GetStackTrace

func (jsRuntime *JsRuntime) GetStackTrace() []sobek.StackFrame

func (*JsRuntime) InitializeNativeLibraries added in v0.2.0

func (jsRuntime *JsRuntime) InitializeNativeLibraries() error

func (*JsRuntime) MarshalToGo

func (jsRuntime *JsRuntime) MarshalToGo(jsArg sobek.Value, expectedType reflect.Type) (reflect.Value, error)

func (*JsRuntime) MarshalToJs

func (jsRuntime *JsRuntime) MarshalToJs(object reflect.Value) (sobek.Value, error)

func (*JsRuntime) NewDynamicArray

func (jsRuntime *JsRuntime) NewDynamicArray(backingSlice reflect.Value) *sobek.Object

func (*JsRuntime) Run

func (jsRuntime *JsRuntime) Run(script *JsScript, args []string) error

func (*JsRuntime) Type

func (jsRuntime *JsRuntime) Type(objectType reflect.Type) *TypeRegistration

func (*JsRuntime) Variable

func (jsRuntime *JsRuntime) Variable(jsModule, jsName string, value reflect.Value) *VariableRegistration

type JsScript

type JsScript struct {
	Contents string
	FilePath string
}

type MethodRegistration

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

func Method

func Method(name string) *MethodRegistration

func (*MethodRegistration) JsName

func (m *MethodRegistration) JsName(name string) *MethodRegistration

type TypeAlias

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

type TypeConversion

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

type TypeRegistration

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

func (*TypeRegistration) Alias

func (t *TypeRegistration) Alias(module, name string) *TypeRegistration

func (*TypeRegistration) ClearConstructors

func (t *TypeRegistration) ClearConstructors() *TypeRegistration

func (*TypeRegistration) Constructors

func (t *TypeRegistration) Constructors(constructors ...*ConstructorRegistration) *TypeRegistration

func (*TypeRegistration) DisableObjectMapping

func (t *TypeRegistration) DisableObjectMapping() *TypeRegistration

func (*TypeRegistration) ExtensionMethods

func (t *TypeRegistration) ExtensionMethods(extensionMethods ...*ExtensionMethodRegistration) *TypeRegistration

func (*TypeRegistration) Fields

func (t *TypeRegistration) Fields(fields ...*FieldRegistration) *TypeRegistration

func (*TypeRegistration) JsModule added in v0.2.0

func (t *TypeRegistration) JsModule(module string) *TypeRegistration

func (*TypeRegistration) JsName

func (t *TypeRegistration) JsName(name string) *TypeRegistration

func (*TypeRegistration) Methods

func (t *TypeRegistration) Methods(methods ...*MethodRegistration) *TypeRegistration

func (*TypeRegistration) TypeConversion

func (t *TypeRegistration) TypeConversion(converter reflect.Value) *TypeRegistration

type VariableRegistration

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

type WeakMap

type WeakMap[K comparable, V any] struct {
	// contains filtered or unexported fields
}

WeakMap copied from: https://github.com/golang/go/issues/43615#issuecomment-2985815833

func (*WeakMap[K, V]) Load

func (weakMap *WeakMap[K, V]) Load(key K) *V

func (*WeakMap[K, V]) Store

func (weakMap *WeakMap[K, V]) Store(key K, p *V)

Jump to

Keyboard shortcuts

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