Documentation
¶
Index ¶
- Constants
- Variables
- func BuildCommand(opt *ProcOption) (cmd *exec.Cmd, err error)
- func Chdir(path string) error
- func CompileFileSourceWithMapping(path, source string, ts, entry bool) (*Code, SourceMapping)
- func CompileFileWithMapping(path string, entry bool) (*Code, SourceMapping)
- func CompileJs(js string, entry bool) string
- func CompileSourceWithMapping(name, source string, ts, entry bool) (*Code, SourceMapping)
- func CompileTs(ts string, entry bool) string
- func CreateSymlink(src, dest string) error
- func DumpDefines(path string)
- func Empty[T any]() (v T)
- func EmptyRefer[T any]() *T
- func EnvAppend(key string, value ...string) error
- func EnvAppendPath(key string, value ...string) error
- func EnvExpand(path string) string
- func EnvPrepend(key string, value ...string) error
- func EnvPrependPath(key string, value ...string) error
- func EnvPut(key string, value ...string) error
- func EnvPutPath(key string, value ...string)
- func EnvSet(key string, value ...string) error
- func EnvSetPath(key string, value ...string) error
- func EnvVar(key string) string
- func EvalFile(e *Engine, path string) any
- func EvalFiles(e *Engine, paths ...string) (r []any)
- func Execute(opt *ExecOption) (err error)
- func FieldName(_ reflect.Type, f reflect.StructField) string
- func FileCopy(src, dest string, force *bool) error
- func FileExists(path string) bool
- func FileMove(src, dest string, force *bool) error
- func FromNativeConsole(b *bytes.Buffer) error
- func GetBytesBuffer() *bytes.Buffer
- func GetExecPath() string
- func GetExecutable() string
- func GetExt() string
- func GetName() string
- func GetPathListSeparator() string
- func GetPathSeparator() string
- func GetRoot() string
- func IsAsyncFunction(rt *goja.Runtime, val goja.Value) bool
- func IsDir(path string) bool
- func IsFile(path string) bool
- func IsNullish(v goja.Value) bool
- func IsSymlink(path string) bool
- func Locate(pth string) (string, error)
- func Lookup(cmd string) (p string, err error)
- func MethodName(_ reflect.Type, m reflect.Method) string
- func Mkdir(path string)
- func MkdirAll(path string)
- func ModDefines() []byte
- func ModuleDefines() map[string][]byte
- func ModuleNames() []string
- func NoWindow(cmd *exec.Cmd) *exec.Cmd
- func PathToUrl(path string) *url.URL
- func Put(e *Engine)
- func PutBytesBuffer(buf *bytes.Buffer)
- func Pwd() (string, error)
- func ReadBinaryFile(path string) []byte
- func ReadSymlink(path string) (string, error)
- func ReadTextFile(path string) string
- func Reader[V any, K any](fieldIndex int) func(*V) K
- func ReferOf[T any](v T, x *T)
- func RegisterMod(module Mod) bool
- func RegisterModule(module Module) bool
- func RegisterResource[T io.Closer](e *Engine, v T) T
- func RegisterType[T any]() bool
- func RegisterTypeAlias(src any, target any)
- func RemoveMod(mod string)
- func RemoveModule(module string)
- func RemoveResource[T io.Closer](e *Engine, v T) T
- func Stat(path string) map[string]any
- func Throw(rt *goja.Runtime, err error)
- func ToBytes(data any) ([]byte, error)
- func ToNativeConsole(b *bytes.Buffer) error
- func ToString(data any) (string, error)
- func Transform01[B0, C any](f func() B0, t func(B0) C) func() C
- func Transform02[B0, B1, C any](f func() (B0, B1), t func(B0, B1) C) func() C
- func Transform03[B0, B1, B2, C any](f func() (B0, B1, B2), t func(B0, B1, B2) C) func() C
- func Transform04[B0, B1, B2, B3, C any](f func() (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func() C
- func Transform11[A0, B0, C any](f func(A0) B0, t func(B0) C) func(A0) C
- func Transform12[A0, B0, B1, C any](f func(A0) (B0, B1), t func(B0, B1) C) func(A0) C
- func Transform13[A0, B0, B1, B2, C any](f func(A0) (B0, B1, B2), t func(B0, B1, B2) C) func(A0) C
- func Transform14[A0, B0, B1, B2, B3, C any](f func(A0) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0) C
- func Transform21[A0, A1, B0, C any](f func(A0, A1) B0, t func(B0) C) func(A0, A1) C
- func Transform22[A0, A1, B0, B1, C any](f func(A0, A1) (B0, B1), t func(B0, B1) C) func(A0, A1) C
- func Transform23[A0, A1, B0, B1, B2, C any](f func(A0, A1) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1) C
- func Transform24[A0, A1, B0, B1, B2, B3, C any](f func(A0, A1) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1) C
- func Transform31[A0, A1, A2, B0, C any](f func(A0, A1, A2) B0, t func(B0) C) func(A0, A1, A2) C
- func Transform32[A0, A1, A2, B0, B1, C any](f func(A0, A1, A2) (B0, B1), t func(B0, B1) C) func(A0, A1, A2) C
- func Transform33[A0, A1, A2, B0, B1, B2, C any](f func(A0, A1, A2) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1, A2) C
- func Transform34[A0, A1, A2, B0, B1, B2, B3, C any](f func(A0, A1, A2) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1, A2) C
- func Transform41[A0, A1, A2, A3, B0, C any](f func(A0, A1, A2, A3) B0, t func(B0) C) func(A0, A1, A2, A3) C
- func Transform42[A0, A1, A2, A3, B0, B1, C any](f func(A0, A1, A2, A3) (B0, B1), t func(B0, B1) C) func(A0, A1, A2, A3) C
- func Transform43[A0, A1, A2, A3, B0, B1, B2, C any](f func(A0, A1, A2, A3) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1, A2, A3) C
- func Transform44[A0, A1, A2, A3, B0, B1, B2, B3, C any](f func(A0, A1, A2, A3) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1, A2, A3) C
- func TransformErr01[B0, C any](f func() (B0, error), t func(B0, error) (C, error)) func() (C, error)
- func TransformErr02[B0, B1, C any](f func() (B0, B1, error), t func(B0, B1, error) (C, error)) func() (C, error)
- func TransformErr03[B0, B1, B2, C any](f func() (B0, B1, B2, error), t func(B0, B1, B2, error) (C, error)) func() (C, error)
- func TransformErr04[B0, B1, B2, B3, C any](f func() (B0, B1, B2, B3, error), t func(B0, B1, B2, B3, error) (C, error)) func() (C, error)
- func TransformErr11[A0, B0, C any](f func(A0) (B0, error), t func(B0, error) (C, error)) func(A0) (C, error)
- func TransformErr12[A0, B0, B1, C any](f func(A0) (B0, B1, error), t func(B0, B1, error) (C, error)) func(A0) (C, error)
- func TransformErr13[A0, B0, B1, B2, C any](f func(A0) (B0, B1, B2, error), t func(B0, B1, B2, error) (C, error)) func(A0) (C, error)
- func TransformErr14[A0, B0, B1, B2, B3, C any](f func(A0) (B0, B1, B2, B3, error), t func(B0, B1, B2, B3, error) (C, error)) func(A0) (C, error)
- func TransformErr21[A0, A1, B0, C any](f func(A0, A1) (B0, error), t func(B0, error) (C, error)) func(A0, A1) (C, error)
- func TransformErr22[A0, A1, B0, B1, C any](f func(A0, A1) (B0, B1, error), t func(B0, B1, error) (C, error)) func(A0, A1) (C, error)
- func TransformErr23[A0, A1, B0, B1, B2, C any](f func(A0, A1) (B0, B1, B2, error), t func(B0, B1, B2, error) (C, error)) func(A0, A1) (C, error)
- func TransformErr24[A0, A1, B0, B1, B2, B3, C any](f func(A0, A1) (B0, B1, B2, B3, error), ...) func(A0, A1) (C, error)
- func TransformErr31[A0, A1, A2, B0, C any](f func(A0, A1, A2) (B0, error), t func(B0, error) (C, error)) func(A0, A1, A2) (C, error)
- func TransformErr32[A0, A1, A2, B0, B1, C any](f func(A0, A1, A2) (B0, B1, error), t func(B0, B1, error) (C, error)) func(A0, A1, A2) (C, error)
- func TransformErr33[A0, A1, A2, B0, B1, B2, C any](f func(A0, A1, A2) (B0, B1, B2, error), t func(B0, B1, B2, error) (C, error)) func(A0, A1, A2) (C, error)
- func TransformErr34[A0, A1, A2, B0, B1, B2, B3, C any](f func(A0, A1, A2) (B0, B1, B2, B3, error), ...) func(A0, A1, A2) (C, error)
- func TransformErr41[A0, A1, A2, A3, B0, C any](f func(A0, A1, A2, A3) (B0, error), t func(B0, error) (C, error)) func(A0, A1, A2, A3) (C, error)
- func TransformErr42[A0, A1, A2, A3, B0, B1, C any](f func(A0, A1, A2, A3) (B0, B1, error), t func(B0, B1, error) (C, error)) func(A0, A1, A2, A3) (C, error)
- func TransformErr43[A0, A1, A2, A3, B0, B1, B2, C any](f func(A0, A1, A2, A3) (B0, B1, B2, error), ...) func(A0, A1, A2, A3) (C, error)
- func TransformErr44[A0, A1, A2, A3, B0, B1, B2, B3, C any](f func(A0, A1, A2, A3) (B0, B1, B2, B3, error), ...) func(A0, A1, A2, A3) (C, error)
- func UnRefer[T any](v *T) T
- func ValueString(v goja.Value) string
- func ValuesString(args ...goja.Value) string
- func WdToUrl() *url.URL
- func WriteBinaryFile(path string, data []byte)
- func WriteTextFile(path string, data string)
- type AsyncContext
- type AsyncTracker
- type BaseInitializeModule
- type BaseModResolver
- type BaseResolver
- func (s *BaseResolver) Dir(old *url.URL) *url.URL
- func (s *BaseResolver) Fetch(u *url.URL) (*Source, error)
- func (s *BaseResolver) Load(specifier *url.URL, originalModuleSpecifier string) (*Source, error)
- func (s *BaseResolver) LoadFile(u *url.URL) (*Source, error)
- func (s *BaseResolver) Resolve(pwd *url.URL, specifier string) (*url.URL, error)
- func (s *BaseResolver) ResolveFilePath(pwd *url.URL, moduleSpecifier string) (*url.URL, error)
- type BufferConsole
- func (s *BufferConsole) Assert(cond bool, args ...goja.Value)
- func (s *BufferConsole) Clear()
- func (s BufferConsole) Count(label string)
- func (s BufferConsole) CountReset(label string)
- func (s *BufferConsole) Debug(args ...goja.Value)
- func (s BufferConsole) Dir(v goja.Value)
- func (s *BufferConsole) Error(args ...goja.Value)
- func (s BufferConsole) Group(label string)
- func (s BufferConsole) GroupCollapsed(label string)
- func (s BufferConsole) GroupEnd()
- func (s *BufferConsole) Info(args ...goja.Value)
- func (s *BufferConsole) Log(args ...goja.Value)
- func (s *BufferConsole) Name() string
- func (s *BufferConsole) Print(v ...any)
- func (s BufferConsole) Table(value goja.Value, columns []string)
- func (s BufferConsole) Time(label string)
- func (s BufferConsole) TimeEnd(label string)
- func (s BufferConsole) TimeLog(label string, val ...goja.Value)
- func (s *BufferConsole) Trace(args ...goja.Value)
- func (s *BufferConsole) Warn(args ...goja.Value)
- type CacheSource
- type Chan
- type Code
- type Compiler
- type Console
- func (s *Console) Assert(cond bool, args ...goja.Value)
- func (s *Console) Clear()
- func (s Console) Count(label string)
- func (s Console) CountReset(label string)
- func (s *Console) Debug(args ...goja.Value)
- func (s Console) Dir(v goja.Value)
- func (s *Console) Error(args ...goja.Value)
- func (s Console) Group(label string)
- func (s Console) GroupCollapsed(label string)
- func (s Console) GroupEnd()
- func (s *Console) Info(args ...goja.Value)
- func (s *Console) Log(args ...goja.Value)
- func (s *Console) Name() string
- func (s *Console) Print(v ...any)
- func (s Console) Table(value goja.Value, columns []string)
- func (s Console) Time(label string)
- func (s Console) TimeEnd(label string)
- func (s Console) TimeLog(label string, val ...goja.Value)
- func (s *Console) Trace(args ...goja.Value)
- func (s *Console) Warn(args ...goja.Value)
- type Context
- type ContextResult
- type Engine
- func (s *Engine) BufferConsole(value *bytes.Buffer)
- func (s *Engine) CallConstruct(fn Value, values ...any) (*Object, error)
- func (s *Engine) CallFunction(fn Value, values ...any) (v Value, err error)
- func (s *Engine) CallMethod(fn Value, self Value, values ...any) (v Value, err error)
- func (s *Engine) Callable(fn Value) Callable
- func (s *Engine) Compile(src string, ts, entry bool) *Code
- func (s *Engine) DisableModules(modules ...string) bool
- func (s *Engine) Free()
- func (s *Engine) IsNullish(v Value) bool
- func (s *Engine) LoggerConsole(value *slog.Logger)
- func (s *Engine) NaN() Value
- func (s *Engine) NegInf() Value
- func (s *Engine) NewPromise() (promise *Promise, resolve func(any), reject func(any))
- func (s *Engine) Null() Value
- func (s *Engine) PosInf() Value
- func (s *Engine) Register(mods ...Mod)
- func (s *Engine) RegisterFunction(name string, ctor func(c FunctionCall) Value)
- func (s *Engine) RegisterResources(r io.Closer)
- func (s *Engine) RegisterType(name string, ctor func(v []Value) (any, error))
- func (s *Engine) RegisterTypeRecover(name string, ctor func(v []Value) any)
- func (s *Engine) RemoveResources(r io.Closer)
- func (s *Engine) RunCode(code *Code) (v Value, err error)
- func (s *Engine) RunCodeContext(code *Code, warm time.Duration, ctx cx.Context) (v Value, err error)
- func (s *Engine) RunCodeWithMapping(code *Code, mapping SourceMapping) (v Value, err error)
- func (s *Engine) RunJs(src string) (v Value, err error)
- func (s *Engine) RunJsContext(src string, warm time.Duration, ctx cx.Context) (v Value, err error)
- func (s *Engine) RunString(src string) (v Value, err error)
- func (s *Engine) RunTs(src string) (v Value, err error)
- func (s *Engine) RunTsContext(src string, warm time.Duration, ctx cx.Context) (v Value, err error)
- func (s *Engine) Set(name string, value any)
- func (s *Engine) SetScriptPath(p string)
- func (s *Engine) ToConstructor(ct func(v []Value) (any, error)) func(ConstructorCall) *Object
- func (s *Engine) ToConstructorRecover(ct func(v []Value) any) func(ConstructorCall) *Object
- func (s *Engine) ToInstance(v any, c ConstructorCall) *Object
- func (s *Engine) ToSelfReferConstructor(ct func(ctor Value, v []Value) (any, error)) Value
- func (s *Engine) ToSelfReferRawConstructor(ct func(ctor Value, call ConstructorCall) *Object) Value
- func (s *Engine) ToValues(args ...any) []Value
- func (s *Engine) Undefined() Value
- type EngineFieldMapper
- type EngineModule
- type EsBuild
- type EsTextDecoder
- type EsTextEncoder
- type EventLoop
- func (e *EventLoop) Await() HaltJobs
- func (e *EventLoop) AwaitWithContext(ctx context.Context) HaltJobs
- func (e *EventLoop) ClearInterval(i *Interval)
- func (e *EventLoop) ClearTimeout(t *Timer)
- func (e *EventLoop) RunOnLoop(fn func(*Engine))
- func (e *EventLoop) SetInterval(fn func(engine *Engine), timeout time.Duration) *Interval
- func (e *EventLoop) SetTimeout(fn func(engine *Engine), timeout time.Duration) *Timer
- func (e *EventLoop) StartEventLoop()
- func (e *EventLoop) StopEventLoop() HaltJobs
- func (e *EventLoop) StopEventLoopNoWait() HaltJobs
- func (e *EventLoop) TryStartEventLoop()
- type ExecOption
- type GoChan
- type GoModule
- type GoRecvChan
- type GoSendChan
- type HaltJobs
- type Immediate
- type InitializeMod
- type InitializeModule
- type Interval
- type JsModule
- type JsModuleInstance
- type Maybe
- type Mod
- type ModCache
- type ModResolver
- type Module
- type ProcOption
- type ReadChan
- type ReflectTypeInfo
- type Require
- type Resolver
- type ScriptError
- type Source
- type SourceMap
- type SourceMapping
- type SubProcess
- type Text
- type TextEncoders
- type Timer
- type TopMod
- type TypeDefined
- type TypeId
- type TypeInfo
- type TypeUse
- type TypeUtil
- type WriteChan
Constants ¶
const ModuleRequireConstKey = "_$require"
Variables ¶
var ( TextEncoder = &EsTextEncoder{"utf-8"} TextDecoder = &EsTextDecoder{"utf-8"} )
var ( TypeRegistry map[TypeId]TypeInfo TypeAlias map[TypeId]TypeId )
var (
ColumnMarker = "♦"
)
var (
DumpFrameLastN = 5
)
var (
Encoding encoding.Encoding
)
var (
ErrDisabled = errors.New("required module is disabled")
)
var (
ErrTimeout = errors.New("execution timeout")
)
Functions ¶
func BuildCommand ¶
func BuildCommand(opt *ProcOption) (cmd *exec.Cmd, err error)
func CompileFileSourceWithMapping ¶
func CompileFileSourceWithMapping(path, source string, ts, entry bool) (*Code, SourceMapping)
func CompileFileWithMapping ¶
func CompileFileWithMapping(path string, entry bool) (*Code, SourceMapping)
func CompileSourceWithMapping ¶
func CompileSourceWithMapping(name, source string, ts, entry bool) (*Code, SourceMapping)
func CreateSymlink ¶
func DumpDefines ¶
func DumpDefines(path string)
DumpDefines to path, global.d.ts contains top level types , pkg/name.d.ts contains go modules
func EmptyRefer ¶
func EmptyRefer[T any]() *T
func EnvAppendPath ¶
func EnvPrepend ¶
func EnvPrependPath ¶
func EnvPutPath ¶
func EnvSetPath ¶
func Execute ¶
func Execute(opt *ExecOption) (err error)
func FileExists ¶
func FromNativeConsole ¶
func GetBytesBuffer ¶
func GetExecPath ¶
func GetExecPath() string
func GetExecutable ¶
func GetExecutable() string
func GetPathListSeparator ¶
func GetPathListSeparator() string
func GetPathSeparator ¶
func GetPathSeparator() string
func MethodName ¶
MethodName Returns the JS name for an exported method.
func ModDefines ¶
func ModDefines() []byte
ModDefines dump all possible type define (d.ts format) in registry
func ModuleDefines ¶
ModuleDefines exports Module define as moduleName=>ModuleTypeDefine
func ModuleNames ¶
func ModuleNames() []string
func PutBytesBuffer ¶
func ReadBinaryFile ¶
func ReadSymlink ¶
func ReadTextFile ¶
func RegisterMod ¶
RegisterMod a default global module , returns false if already exists
func RegisterResource ¶
func RegisterType ¶
func RegisterTypeAlias ¶
func RemoveModule ¶
func RemoveModule(module string)
func RemoveResource ¶
func ToNativeConsole ¶
func Transform01 ¶
func Transform01[B0, C any](f func() B0, t func(B0) C) func() C
func Transform02 ¶
func Transform02[B0, B1, C any](f func() (B0, B1), t func(B0, B1) C) func() C
func Transform03 ¶
func Transform03[B0, B1, B2, C any](f func() (B0, B1, B2), t func(B0, B1, B2) C) func() C
func Transform04 ¶
func Transform04[B0, B1, B2, B3, C any](f func() (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func() C
func Transform11 ¶
func Transform11[A0, B0, C any](f func(A0) B0, t func(B0) C) func(A0) C
func Transform12 ¶
func Transform12[A0, B0, B1, C any](f func(A0) (B0, B1), t func(B0, B1) C) func(A0) C
func Transform13 ¶
func Transform13[A0, B0, B1, B2, C any](f func(A0) (B0, B1, B2), t func(B0, B1, B2) C) func(A0) C
func Transform14 ¶
func Transform14[A0, B0, B1, B2, B3, C any](f func(A0) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0) C
func Transform21 ¶
func Transform21[A0, A1, B0, C any](f func(A0, A1) B0, t func(B0) C) func(A0, A1) C
func Transform22 ¶
func Transform22[A0, A1, B0, B1, C any](f func(A0, A1) (B0, B1), t func(B0, B1) C) func(A0, A1) C
func Transform23 ¶
func Transform23[A0, A1, B0, B1, B2, C any](f func(A0, A1) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1) C
func Transform24 ¶
func Transform24[A0, A1, B0, B1, B2, B3, C any](f func(A0, A1) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1) C
func Transform31 ¶
func Transform31[A0, A1, A2, B0, C any](f func(A0, A1, A2) B0, t func(B0) C) func(A0, A1, A2) C
func Transform32 ¶
func Transform32[A0, A1, A2, B0, B1, C any](f func(A0, A1, A2) (B0, B1), t func(B0, B1) C) func(A0, A1, A2) C
func Transform33 ¶
func Transform33[A0, A1, A2, B0, B1, B2, C any](f func(A0, A1, A2) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1, A2) C
func Transform34 ¶
func Transform34[A0, A1, A2, B0, B1, B2, B3, C any](f func(A0, A1, A2) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1, A2) C
func Transform41 ¶
func Transform41[A0, A1, A2, A3, B0, C any](f func(A0, A1, A2, A3) B0, t func(B0) C) func(A0, A1, A2, A3) C
func Transform42 ¶
func Transform42[A0, A1, A2, A3, B0, B1, C any](f func(A0, A1, A2, A3) (B0, B1), t func(B0, B1) C) func(A0, A1, A2, A3) C
func Transform43 ¶
func Transform43[A0, A1, A2, A3, B0, B1, B2, C any](f func(A0, A1, A2, A3) (B0, B1, B2), t func(B0, B1, B2) C) func(A0, A1, A2, A3) C
func Transform44 ¶
func Transform44[A0, A1, A2, A3, B0, B1, B2, B3, C any](f func(A0, A1, A2, A3) (B0, B1, B2, B3), t func(B0, B1, B2, B3) C) func(A0, A1, A2, A3) C
func TransformErr01 ¶
func TransformErr02 ¶
func TransformErr03 ¶
func TransformErr04 ¶
func TransformErr11 ¶
func TransformErr12 ¶
func TransformErr13 ¶
func TransformErr14 ¶
func TransformErr21 ¶
func TransformErr22 ¶
func TransformErr23 ¶
func TransformErr24 ¶
func TransformErr31 ¶
func TransformErr32 ¶
func TransformErr33 ¶
func TransformErr34 ¶
func TransformErr41 ¶
func TransformErr42 ¶
func TransformErr43 ¶
func TransformErr44 ¶
func ValueString ¶
func ValuesString ¶
func WriteBinaryFile ¶
func WriteTextFile ¶
Types ¶
type AsyncContext ¶
type AsyncContext struct {
// contains filtered or unexported fields
}
func (*AsyncContext) String ¶
func (s *AsyncContext) String() string
type AsyncTracker ¶
type AsyncTracker struct {
// contains filtered or unexported fields
}
func (*AsyncTracker) Exited ¶
func (s *AsyncTracker) Exited()
func (*AsyncTracker) Grab ¶
func (s *AsyncTracker) Grab() (trackingObject any)
func (*AsyncTracker) Resumed ¶
func (s *AsyncTracker) Resumed(trackingObject any)
type BaseInitializeModule ¶
type BaseInitializeModule struct {
}
func (*BaseInitializeModule) Exports ¶
func (s *BaseInitializeModule) Exports() map[string]any
type BaseModResolver ¶
type BaseModResolver struct {
// contains filtered or unexported fields
}
type BaseResolver ¶
type BaseResolver struct {
// contains filtered or unexported fields
}
func (*BaseResolver) ResolveFilePath ¶
type BufferConsole ¶
func NewBufferConsole ¶
func NewBufferConsole() *BufferConsole
func NewBufferConsoleOf ¶
func NewBufferConsoleOf(buf *bytes.Buffer) *BufferConsole
func (*BufferConsole) Clear ¶
func (s *BufferConsole) Clear()
func (BufferConsole) CountReset ¶
func (s BufferConsole) CountReset(label string)
func (*BufferConsole) Debug ¶
func (s *BufferConsole) Debug(args ...goja.Value)
func (*BufferConsole) Error ¶
func (s *BufferConsole) Error(args ...goja.Value)
func (BufferConsole) GroupCollapsed ¶
func (s BufferConsole) GroupCollapsed(label string)
func (*BufferConsole) Info ¶
func (s *BufferConsole) Info(args ...goja.Value)
func (*BufferConsole) Log ¶
func (s *BufferConsole) Log(args ...goja.Value)
func (*BufferConsole) Name ¶
func (s *BufferConsole) Name() string
func (*BufferConsole) Print ¶
func (s *BufferConsole) Print(v ...any)
func (*BufferConsole) Trace ¶
func (s *BufferConsole) Trace(args ...goja.Value)
func (*BufferConsole) Warn ¶
func (s *BufferConsole) Warn(args ...goja.Value)
type CacheSource ¶
type Code ¶
func CompileFile ¶
CompileFile entry for whether source is as script or library
func CompileFileSource ¶
func CompileSource ¶
CompileSource compile script source, ts for source is typescript or javascript. entry for whether source is as script or library
type Console ¶
func NewConsole ¶
func (Console) CountReset ¶
func (s Console) CountReset(label string)
func (Console) GroupCollapsed ¶
func (s Console) GroupCollapsed(label string)
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
func (*Context) Rebuild ¶
func (c *Context) Rebuild() api.BuildResult
func (*Context) Serve ¶
func (c *Context) Serve(options api.ServeOptions) (api.ServeResult, error)
type ContextResult ¶
type ContextResult struct {
Context *Context
Err *api.ContextError
}
type Engine ¶
type Engine struct {
*Runtime
*EventLoop
Resources map[io.Closer]struct{}
Debug bool
SourceMap SourceMapping
// contains filtered or unexported fields
}
func NewRawEngine ¶
func (*Engine) BufferConsole ¶
func (*Engine) CallConstruct ¶
func (*Engine) CallFunction ¶
CallFunction invoke a function (without this)
func (*Engine) CallMethod ¶
CallMethod invoke a method (with this)
func (*Engine) DisableModules ¶
DisableModules disable load modules for current engine, modules are the full import path
func (*Engine) LoggerConsole ¶
func (*Engine) NewPromise ¶
NewPromise create new Promise, must use StopEventBusAwait
func (*Engine) RegisterFunction ¶
RegisterFunction create global function
func (*Engine) RegisterResources ¶
func (*Engine) RegisterType ¶
RegisterType create global simple type
func (*Engine) RegisterTypeRecover ¶
func (*Engine) RemoveResources ¶
func (*Engine) RunCode ¶
RunCode execute compiled code. The execution time should control manually, for an automatic timeout control see RunCodeTimeout.
func (*Engine) RunCodeContext ¶
func (s *Engine) RunCodeContext(code *Code, warm time.Duration, ctx cx.Context) (v Value, err error)
RunCodeContext run code with context. If context closed early, the value will be HaltJobs, the error will be ErrTimeout.
func (*Engine) RunCodeWithMapping ¶
func (s *Engine) RunCodeWithMapping(code *Code, mapping SourceMapping) (v Value, err error)
func (*Engine) RunJs ¶
RunJs execute javascript code. Should manual control the execution, for a automatic timeout control see RunJsTimeout.
func (*Engine) RunJsContext ¶
RunJsContext run js source with context. If context closed early, the value will be HaltJobs, the error will be ErrTimeout.
func (*Engine) RunString ¶
RunString execute raw javascript (es5|es6 without import) code. this not support import and some polyfill features.
func (*Engine) RunTs ¶
RunTs execute typescript code. Should manually control the execution, for a automatic timeout control see RunTsTimeout.
func (*Engine) RunTsContext ¶
RunTsContext run Ts source with context. If context closed early, the value will be HaltJobs, the error will be ErrTimeout.
func (*Engine) SetScriptPath ¶
SetScriptPath define current script path to use for imports
func (*Engine) ToConstructor ¶
func (*Engine) ToConstructorRecover ¶
func (*Engine) ToInstance ¶
ToInstance create instance of a value with simple prototype, use for constructor only.
func (*Engine) ToSelfReferConstructor ¶
ToSelfReferConstructor create a Constructor which require use itself. see [ Bytes ]
func (*Engine) ToSelfReferRawConstructor ¶
func (s *Engine) ToSelfReferRawConstructor(ct func(ctor Value, call ConstructorCall) *Object) Value
ToSelfReferRawConstructor create a Constructor which require use itself. see [ Bytes ]
type EngineFieldMapper ¶
type EngineFieldMapper struct{}
func (EngineFieldMapper) FieldName ¶
func (EngineFieldMapper) FieldName(t reflect.Type, f reflect.StructField) string
func (EngineFieldMapper) MethodName ¶
type EngineModule ¶
type EngineModule struct {
}
func (EngineModule) Exports ¶
func (e EngineModule) Exports() map[string]any
func (EngineModule) ExportsWithEngine ¶
func (e EngineModule) ExportsWithEngine(engine *Engine) map[string]any
func (EngineModule) Identity ¶
func (e EngineModule) Identity() string
func (EngineModule) TypeDefine ¶
func (e EngineModule) TypeDefine() []byte
type EsTextDecoder ¶
type EsTextDecoder struct {
Encoding string
}
func (EsTextDecoder) Decode ¶
func (t EsTextDecoder) Decode(v []byte) string
Decode typedArray are impl as bytes in goja
func (EsTextDecoder) EncodeInto ¶
func (t EsTextDecoder) EncodeInto(v string, arr []byte)
type EsTextEncoder ¶
type EsTextEncoder struct {
Encoding string
}
func (EsTextEncoder) Encode ¶
func (t EsTextEncoder) Encode(v string) []byte
func (EsTextEncoder) EncodeInto ¶
func (t EsTextEncoder) EncodeInto(v string, arr []byte)
type EventLoop ¶
type EventLoop struct {
// contains filtered or unexported fields
}
EventLoop process all async events and also as The AsyncContextTracker there will be a background goroutine to monitor the async tasks as call StartEventLoop, or call TryStartEventLoop for not sure current EventLoop have been started. use Await to await all async tasks are finished. use AwaitTimeout to waiting for a fixed duration. use StopEventLoopNoWait to immediate shutdown EventLoop without wait tasks execution. use StopEventLoop wait EventLoop after current tasks execution.
func NewEventLoop ¶
func (*EventLoop) Await ¶
Await all job done, see also AwaitContext, AwaitTimeout and AwaitWithContext .
func (*EventLoop) AwaitWithContext ¶
AwaitWithContext stop with context for a cancelable or with deadline context, see also Await, AwaitTimeout and AwaitContext. should use goroutine to execute script to avoid blocking current thread
func (*EventLoop) ClearInterval ¶
func (*EventLoop) ClearTimeout ¶
func (*EventLoop) SetInterval ¶
func (*EventLoop) SetTimeout ¶
func (*EventLoop) StartEventLoop ¶
func (e *EventLoop) StartEventLoop()
StartEventLoop fail if already started
func (*EventLoop) StopEventLoop ¶
StopEventLoop wait background execution quit (not all tasks) , returns job not executed
func (*EventLoop) StopEventLoopNoWait ¶
StopEventLoopNoWait without wait for background execution finish, the result may not accuracy values
func (*EventLoop) TryStartEventLoop ¶
func (e *EventLoop) TryStartEventLoop()
TryStartEventLoop no effect if already started
type ExecOption ¶
type ExecOption struct {
Sleep time.Duration
Optional bool
Await bool
*ProcOption
}
type GoChan ¶
type GoChan[T any] struct { // contains filtered or unexported fields }
func (*GoChan[T]) AsRecvOnly ¶
func (g *GoChan[T]) AsRecvOnly() GoRecvChan[T]
func (*GoChan[T]) AsSendOnly ¶
func (g *GoChan[T]) AsSendOnly() GoSendChan[T]
type GoRecvChan ¶
type GoRecvChan[T any] struct { // contains filtered or unexported fields }
func (*GoRecvChan[T]) Raw ¶
func (g *GoRecvChan[T]) Raw() <-chan T
func (*GoRecvChan[T]) Recv ¶
func (g *GoRecvChan[T]) Recv(f func(T)) *goja.Promise
func (*GoRecvChan[T]) Stop ¶
func (g *GoRecvChan[T]) Stop() bool
type GoSendChan ¶
type GoSendChan[T any] struct { // contains filtered or unexported fields }
func (*GoSendChan[T]) Close ¶
func (g *GoSendChan[T]) Close()
func (*GoSendChan[T]) Raw ¶
func (g *GoSendChan[T]) Raw() chan<- T
func (*GoSendChan[T]) Send ¶
func (g *GoSendChan[T]) Send(v T)
type HaltJobs ¶
type InitializeMod ¶
type InitializeModule ¶
Module support for import by require, not a global instance as Module
type JsModule ¶
type JsModule interface {
Instance(engine *Engine) JsModuleInstance
}
type JsModuleInstance ¶
type Maybe ¶
func MaybeError ¶
type Mod ¶
type Mod interface {
Name() string
}
Mod is a top level objects that not required to import
type ModResolver ¶
var (
ModLoader ModResolver = &BaseModResolver{cache: map[string]ModCache{}}
)
type Module ¶
type Module interface {
TypeDefined
Identity() string // Identity the full module identity
Exports() map[string]any
}
Module support for import by require, not a global instance as Module
type ProcOption ¶
type ReadChan ¶
func NewChanReadOnly ¶
type ReflectTypeInfo ¶
type ReflectTypeInfo struct {
// contains filtered or unexported fields
}
func (*ReflectTypeInfo) Channel ¶
func (t *ReflectTypeInfo) Channel() any
func (*ReflectTypeInfo) GoChannel ¶
func (t *ReflectTypeInfo) GoChannel() any
func (*ReflectTypeInfo) Id ¶
func (t *ReflectTypeInfo) Id() TypeId
func (*ReflectTypeInfo) Instance ¶
func (t *ReflectTypeInfo) Instance() any
func (*ReflectTypeInfo) Slice ¶
func (t *ReflectTypeInfo) Slice() any
type Require ¶
type Require struct {
*Engine
// contains filtered or unexported fields
}
func (*Require) AddDisabled ¶
func (*Require) GetDisabled ¶
type Resolver ¶
type Resolver interface {
Dir(old *url.URL) *url.URL
Load(specifier *url.URL, originalModuleSpecifier string) (*Source, error)
Resolve(pwd *url.URL, specifier string) (*url.URL, error)
}
var ( GlobalRequiredCache = make(map[*url.URL]*CacheSource) Loader Resolver = &BaseResolver{cache: GlobalRequiredCache} )
type ScriptError ¶
func (ScriptError) Error ¶
func (s ScriptError) Error() string
func (ScriptError) Unwrap ¶
func (s ScriptError) Unwrap() error
type Source ¶
type Source struct {
Data []byte
Path string
URL *url.URL
// contains filtered or unexported fields
}
func (*Source) ResolvePath ¶
type SourceMap ¶
type SourceMapping ¶
func CompileJsWithMapping ¶
func CompileJsWithMapping(name, js string, entry bool) (string, SourceMapping, []byte)
func CompileTsWithMapping ¶
func CompileTsWithMapping(name, ts string, entry bool) (string, SourceMapping, []byte)
func NewSourceMap ¶
func NewSourceMap(bin []byte) (v SourceMapping)
type SubProcess ¶
func OpenProc ¶
func OpenProc(opt *ProcOption) (proc *SubProcess, err error)
type TextEncoders ¶
type TextEncoders struct {
}
func (TextEncoders) Name ¶
func (t TextEncoders) Name() string
func (TextEncoders) Register ¶
func (t TextEncoders) Register(e *Engine)
type TypeDefined ¶
type TypeDefined interface {
TypeDefine() []byte
}
TypeDefined the element with typescript defines
Source Files
¶
- engine.go
- engine_code.go
- engine_errors.go
- engine_eventloop.go
- engine_helper.go
- engine_mapper.go
- engine_mod.go
- engine_module.go
- engine_require.go
- engine_resolver.go
- engine_source_map.go
- initialize.go
- mod_console.go
- mod_mdn_textcodec.go
- module_compiler.go
- module_engine.go
- module_esbuild.go
- module_go.go
- module_go_chan.go
- module_go_type.go
- tracer_no_debug.go
- units_ctx.go
- units_define_helper.go
- units_exec.go
- units_exec_other.go
- units_os.go
- units_pool.go
- units_reflect.go
- units_transformer.go
- utilities.go