Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddPending ¶
AddPending adds a pending operation for the given runtime
func RemovePending ¶
RemovePending removes a pending operation for the given runtime
Types ¶
type Enqueue ¶
type Enqueue func(func() error)
Enqueue add a job to the job queue.
func EnqueueJob ¶
EnqueueJob returns a function to enqueue jobs for the given runtime
type EventLoop ¶
type EventLoop struct {
// contains filtered or unexported fields
}
EventLoop implements an event loop for asynchronous JavaScript operations
func (*EventLoop) AddPending ¶
func (e *EventLoop) AddPending()
AddPending increments the pending operation counter
func (*EventLoop) Cleanup ¶
func (e *EventLoop) Cleanup(job ...func())
Cleanup add a function to execute when run finish.
func (*EventLoop) EnqueueJob ¶
EnqueueJob return a function Enqueue to add a job to the job queue.
func (*EventLoop) RemovePending ¶
func (e *EventLoop) RemovePending()
RemovePending decrements the pending operation counter
type GlobalModule ¶
type GlobalModule interface { GetGlobalName() string CreateGlobalObject(runtime *sobek.Runtime) sobek.Value }
GlobalModule interface for modules that provide global objects These modules will be automatically available as globals (like fetch, console)
type Module ¶
type Module interface { Name() string Setup(runtime *sobek.Runtime, manager *VMManager) error Cleanup() error IsEnabled(enabledModules map[string]bool) bool }
Module interface defines how modules integrate with the VM
type ModuleCreator ¶
ModuleCreator interface for modules that can create their own objects This replaces the old require override pattern
type ModuleLoader ¶
type ModuleLoader struct {
// contains filtered or unexported fields
}
ModuleLoader provides a global require system for modules Based on a standard loader pattern but simplified for our use case
func NewModuleLoader ¶
func NewModuleLoader() *ModuleLoader
NewModuleLoader creates a new module loader
func (*ModuleLoader) EnableRequire ¶
func (l *ModuleLoader) EnableRequire(rt *sobek.Runtime, enabledModules map[string]bool)
EnableRequire sets up the global require function in the runtime
func (*ModuleLoader) RegisterModule ¶
func (l *ModuleLoader) RegisterModule(module Module)
RegisterModule registers a module with the loader
func (*ModuleLoader) SetupGlobals ¶
func (l *ModuleLoader) SetupGlobals(rt *sobek.Runtime, enabledModules map[string]bool)
SetupGlobals sets up global objects for modules that implement GlobalModule
type ModuleRegistry ¶
type ModuleRegistry struct {
// contains filtered or unexported fields
}
ModuleRegistry manages available modules
func NewModuleRegistry ¶
func NewModuleRegistry() *ModuleRegistry
NewModuleRegistry creates a new module registry
func (*ModuleRegistry) Get ¶
func (r *ModuleRegistry) Get(name string) (Module, bool)
Get retrieves a module by name
func (*ModuleRegistry) GetEnabled ¶
func (r *ModuleRegistry) GetEnabled(enabledModules map[string]bool) []Module
GetEnabled returns all enabled modules based on configuration
func (*ModuleRegistry) List ¶
func (r *ModuleRegistry) List() []string
List returns all registered module names
func (*ModuleRegistry) Register ¶
func (r *ModuleRegistry) Register(module Module)
Register adds a module to the registry
type VM ¶
type VM struct {
// contains filtered or unexported fields
}
VM wraps a Sobek runtime with event loop support
func (*VM) RunString ¶
RunString executes JavaScript code in the VM with event loop support This matches the standard pattern where RunString always uses the event loop
type VMManager ¶
type VMManager struct {
// contains filtered or unexported fields
}
VMManager manages Sobek VM instances
func NewVMManager ¶
NewVMManager creates a new VM manager with specified enabled modules
func (*VMManager) CreateVM ¶
CreateVM creates a new VM instance with all enabled modules Each VM is completely isolated
func (*VMManager) GetEnabledModules ¶
GetEnabledModules returns the list of enabled module names
func (*VMManager) RegisterModule ¶
RegisterModule adds a module to the manager