Documentation ¶
Index ¶
- Variables
- func Call(runtime *goja.Runtime, function JavaScriptFunc, this any, arguments ...any) (value any, err error)
- func CreateEarlyBindExtension(context *Context) goja.Value
- func CreateLateBindExtension(context *Context) goja.Value
- func GetAndCall(runtime *goja.Runtime, object *goja.Object, name string, this any, ...) (value any, err error)
- func HandlePanic(r any) error
- func ToObject(runtime *goja.Runtime, value any) *goja.Object
- func ToObjectFromValue(runtime *goja.Runtime, value goja.Value) *goja.Object
- type Bind
- type Context
- type CreateExtensionFunc
- type CreateResolverFunc
- type EarlyBind
- type Environment
- func (self *Environment) AddModule(url exturl.URL, module *Module)
- func (self *Environment) Call(function JavaScriptFunc, this any, arguments ...any) (any, error)
- func (self *Environment) ClearCache()
- func (self *Environment) GetAndCall(object *goja.Object, name string, this any, arguments ...any) (any, error)
- func (self *Environment) NewChild() *Environment
- func (self *Environment) NewContext(url exturl.URL, parent *Context) *Context
- func (self *Environment) NewModule() *Module
- func (self *Environment) Release() error
- func (self *Environment) RequireID(id string) (*goja.Object, error)
- func (self *Environment) RequireURL(url exturl.URL) (*goja.Object, error)
- func (self *Environment) StartWatcher() error
- func (self *Environment) StopWatcher() error
- func (self *Environment) Watch(path string) error
- type Extension
- type FileAPI
- func (self FileAPI) Download(sourceUrl string, targetPath string) error
- func (self FileAPI) Exec(name string, arguments ...string) (string, error)
- func (self FileAPI) JoinFilePath(elements ...string) string
- func (self FileAPI) TemporaryDirectory(pattern string, directory string) (string, error)
- func (self FileAPI) TemporaryFile(pattern string, directory string) (string, error)
- type JavaScriptFunc
- type LateBind
- type Module
- type OnFileModifiedFunc
- type PrecompileFunc
- type ResolveFunc
- type ThreadSafeObject
- func (self *ThreadSafeObject) Delete(key string) bool
- func (self *ThreadSafeObject) Get(key string) goja.Value
- func (self *ThreadSafeObject) Has(key string) bool
- func (self *ThreadSafeObject) Keys() []string
- func (self *ThreadSafeObject) NewDynamicObject(runtime *goja.Runtime) *goja.Object
- func (self *ThreadSafeObject) Set(key string, value goja.Value) bool
- type TranscribeAPI
- func (self TranscribeAPI) Atob(b64 string) ([]byte, error)
- func (self TranscribeAPI) Btoa(bytes []byte) string
- func (self TranscribeAPI) BytesToString(bytes []byte) string
- func (self TranscribeAPI) Decode(code []byte, format string, all bool) (ard.Value, error)
- func (self TranscribeAPI) Encode(value any, format string, indent string, writer io.Writer) (string, error)
- func (self TranscribeAPI) NewXMLDocument() *etree.Document
- func (self TranscribeAPI) StringToBytes(string_ string) []byte
- func (self TranscribeAPI) ValidateFormat(code []byte, format string) error
- type UtilAPI
- func (self UtilAPI) DeepCopy(value ard.Value) ard.Value
- func (self UtilAPI) DeepEquals(a ard.Value, b ard.Value) bool
- func (self UtilAPI) Go(value goja.Value) error
- func (self UtilAPI) Hash(value ard.Value) (string, error)
- func (self UtilAPI) IsType(value ard.Value, type_ string) (bool, error)
- func (self UtilAPI) Mutex() util.RWLocker
- func (self UtilAPI) Now() time.Time
- func (self UtilAPI) Once(name string, value goja.Value) error
- func (self UtilAPI) Printf(format string, args ...any)
- func (self UtilAPI) Sprintf(format string, args ...any) string
Constants ¶
This section is empty.
Variables ¶
var DromedaryCaseMapper dromedaryCaseMapper
Functions ¶
func CreateEarlyBindExtension ¶
(CreateExtensionFunc signature)
func CreateLateBindExtension ¶
(CreateExtensionFunc signature)
func GetAndCall ¶ added in v0.1.10
func HandlePanic ¶ added in v0.1.11
Call with a recover() value. If it's an error, then it will be returned. A *goja.Exception will be unwrapped and returned.
Otherwise, will re-panic the value.
This function is useful for cases in which Goja indicates errors by panicing instead of returning an error.
Usage:
func MyFunc() (err error) { defer func() { if err_ := HandlePanic(recover()); err_ != nil { err = err_ } }() // do something that can panic }
Types ¶
type Context ¶
type Context struct { Environment *Environment Parent *Context Module *Module Resolve ResolveFunc Extensions []goja.Value }
type CreateExtensionFunc ¶
type CreateResolverFunc ¶
type CreateResolverFunc func(url exturl.URL, context *Context) ResolveFunc
type Environment ¶
type Environment struct { Runtime *goja.Runtime URLContext *exturl.Context BasePaths []exturl.URL Extensions []Extension Modules *goja.Object Precompile PrecompileFunc CreateResolver CreateResolverFunc OnFileModified OnFileModifiedFunc Log commonlog.Logger Lock sync.Mutex // contains filtered or unexported fields }
func NewEnvironment ¶
func NewEnvironment(urlContext *exturl.Context, basePaths []exturl.URL) *Environment
func (*Environment) Call ¶
func (self *Environment) Call(function JavaScriptFunc, this any, arguments ...any) (any, error)
func (*Environment) ClearCache ¶
func (self *Environment) ClearCache()
func (*Environment) GetAndCall ¶ added in v0.1.10
func (*Environment) NewChild ¶
func (self *Environment) NewChild() *Environment
func (*Environment) NewContext ¶
func (self *Environment) NewContext(url exturl.URL, parent *Context) *Context
func (*Environment) NewModule ¶
func (self *Environment) NewModule() *Module
func (*Environment) Release ¶
func (self *Environment) Release() error
func (*Environment) RequireURL ¶
func (*Environment) StartWatcher ¶ added in v0.1.10
func (self *Environment) StartWatcher() error
func (*Environment) StopWatcher ¶
func (self *Environment) StopWatcher() error
func (*Environment) Watch ¶
func (self *Environment) Watch(path string) error
type Extension ¶
type Extension struct { Name string Create CreateExtensionFunc }
type FileAPI ¶
type FileAPI struct {
// contains filtered or unexported fields
}
func NewFileAPI ¶
func (FileAPI) JoinFilePath ¶
func (FileAPI) TemporaryDirectory ¶
type JavaScriptFunc ¶
type JavaScriptFunc = func(goja.FunctionCall) goja.Value
This is returned type when calling Export() on a goja.FunctionCall.
type OnFileModifiedFunc ¶ added in v0.1.10
type PrecompileFunc ¶
type ResolveFunc ¶
type ThreadSafeObject ¶
type ThreadSafeObject struct {
// contains filtered or unexported fields
}
func NewThreadSafeObject ¶
func NewThreadSafeObject() *ThreadSafeObject
func (*ThreadSafeObject) Delete ¶
func (self *ThreadSafeObject) Delete(key string) bool
(goja.DynamicObject interface)
func (*ThreadSafeObject) Get ¶
func (self *ThreadSafeObject) Get(key string) goja.Value
(goja.DynamicObject interface)
func (*ThreadSafeObject) Has ¶
func (self *ThreadSafeObject) Has(key string) bool
(goja.DynamicObject interface)
func (*ThreadSafeObject) Keys ¶
func (self *ThreadSafeObject) Keys() []string
(goja.DynamicObject interface)
func (*ThreadSafeObject) NewDynamicObject ¶
func (self *ThreadSafeObject) NewDynamicObject(runtime *goja.Runtime) *goja.Object
func (*ThreadSafeObject) Set ¶
func (self *ThreadSafeObject) Set(key string, value goja.Value) bool
(goja.DynamicObject interface)
type TranscribeAPI ¶
type TranscribeAPI struct{}
func (TranscribeAPI) Atob ¶
func (self TranscribeAPI) Atob(b64 string) ([]byte, error)
Decode base64 to bytes
func (TranscribeAPI) Btoa ¶
func (self TranscribeAPI) Btoa(bytes []byte) string
Encode bytes as base64
func (TranscribeAPI) BytesToString ¶
func (self TranscribeAPI) BytesToString(bytes []byte) string
Another way to achieve this in JavaScript: String.fromCharCode.apply(null, bytes)
func (TranscribeAPI) Decode ¶
func (self TranscribeAPI) Decode(code []byte, format string, all bool) (ard.Value, error)
func (TranscribeAPI) NewXMLDocument ¶
func (self TranscribeAPI) NewXMLDocument() *etree.Document
func (TranscribeAPI) StringToBytes ¶
func (self TranscribeAPI) StringToBytes(string_ string) []byte
func (TranscribeAPI) ValidateFormat ¶
func (self TranscribeAPI) ValidateFormat(code []byte, format string) error