microvium
Version:
A compact, embeddable scripting engine for microcontrollers for executing small scripts written in a subset of JavaScript.
46 lines (45 loc) • 2.26 kB
TypeScript
import * as VM from './virtual-machine';
import * as IL from './il';
import { SnapshotIL } from './snapshot-il';
import { Microvium, ModuleObject, HostImportFunction, HostImportTable, SnapshottingOptions, ModuleSource, MemoryStats } from '../lib';
import { SnapshotClass } from './snapshot';
export interface Globals {
[name: string]: any;
}
/**
* A wrapper for VirtualMachine that automatically marshalls data between the
* host and the VM (something like a membrane to interface to the VM)
*/
export declare class VirtualMachineFriendly implements Microvium {
private vm;
private _global;
private moduleCache;
constructor(resumeFromSnapshot: SnapshotIL | undefined, hostImportMap?: HostImportFunction | HostImportTable, opts?: VM.VirtualMachineOptions);
getMemoryStats(): MemoryStats;
static create(hostImportMap?: HostImportFunction | HostImportTable, opts?: VM.VirtualMachineOptions): VirtualMachineFriendly;
evaluateModule(moduleSource: ModuleSource): ModuleObject;
createSnapshotIL(): SnapshotIL;
createSnapshot(opts?: SnapshottingOptions): SnapshotClass;
stringifyState(): string;
vmExport: (exportID: IL.ExportID, value: any) => void;
vmImport: (id: number, defaultImplementation?: Function | undefined) => any;
resolveExport(exportID: IL.ExportID): any;
garbageCollect(): void;
newObject(): any;
newArray(): any;
setArrayPrototype(value: any): void;
get globalThis(): any;
}
export declare class ValueWrapper implements ProxyHandler<any> {
private vm;
private vmValue;
private nameHint;
private static finalizationGroup;
constructor(vm: VM.VirtualMachine, vmValue: IL.Value, nameHint: string | undefined);
static isWrapped(vm: VM.VirtualMachine, value: any): boolean;
static wrap(vm: VM.VirtualMachine, value: IL.FunctionValue | IL.ResumePoint | IL.ReferenceValue | IL.HostFunctionValue | IL.ClassValue, nameHint: string | undefined): any;
static unwrap(vm: VM.VirtualMachine, value: any): IL.Value;
get(_target: any, p: PropertyKey, receiver: any): any;
set(_target: any, p: PropertyKey, value: any, receiver: any): boolean;
apply(_target: any, thisArg: any, argArray?: any[]): any;
}