@adpt/core
Version:
AdaptJS core library
53 lines • 1.66 kB
TypeScript
/// <reference types="node" />
import * as vm from "vm";
import { ChainableHost } from "./hosts";
export interface Extensions {
[ext: string]: any;
}
export interface RequireCache {
[abspath: string]: NodeModule;
}
interface Modules {
[abspath: string]: VmModule;
}
export declare class VmModule {
id: string;
private vmContext;
host: ChainableHost;
parent?: VmModule | undefined;
extensions: Extensions;
requireCache: RequireCache;
_compile: (content: string, filename: string) => any;
ctxModule: NodeModule;
vmModules: Modules;
private hostModCache;
constructor(id: string, vmContext: vm.Context | undefined, host: ChainableHost, parent?: VmModule | undefined);
/**
* Init that happens only once per VmContext, after the context's VM has
* been created. This should be called on the "main" module for the context
* ONLY.
* @param ctx The vm context where the DOM code will run.
*/
initMain(ctx: vm.Context): void;
requireResolve(request: string, options?: {
paths?: string[];
}): string;
require(modName: string): any;
registerExt(ext: string, func: (mod: VmModule, fileName: string) => void): void;
private loadHostMod;
private requireHostMod;
private requireBuiltin;
private runJsonModule;
private runJsModule;
private runJs;
}
export declare class VmContext {
vmGlobal: any;
filename: string;
host: ChainableHost;
mainModule: VmModule;
constructor(vmGlobal: any, dirname: string, filename: string, host: ChainableHost);
run(jsText: string): any;
}
export {};
//# sourceMappingURL=context.d.ts.map