@sudoo/marked
Version:
JavaScript & TypeScript code runner in JavaScript, safe with marked territory, asynchronous
79 lines (78 loc) • 3.59 kB
TypeScript
/**
* @author WMXPY
* @namespace Marked
* @description Sandbox
*/
import * as EST from "estree";
import { MarkedDebugBreakPoint } from "../debug/break-point/break-point";
import { MarkedDebugInterceptor } from "../debug/interceptor";
import { Evaluator, MarkedResult } from "../declare/evaluate";
import { ISandbox, ISandboxOptions, MarkedMixin, ModuleResolveResult, ModuleResolver, OptionName, SandboxLanguage } from "../declare/sandbox";
import { ScriptLocation } from "../declare/script-location";
import { EST_TYPE } from "../declare/types";
import { IScope, ITrace } from "../declare/variable";
import { Flag } from "../variable/flag";
import { Scope } from "../variable/scope";
import { EvaluateResourceResult } from "./declare";
import { MarkedLogRecorder } from "../log/log-recorder";
import { IMarkedExecuteLog } from "../log/declare";
export declare class Sandbox implements ISandbox {
static fromScratch(language?: SandboxLanguage): Sandbox;
static fromAllEvaluators(language?: SandboxLanguage): Sandbox;
private readonly _language;
private readonly _map;
private readonly _bridgeScope;
private readonly _executeScope;
private readonly _configs;
private readonly _modules;
private readonly _resolvers;
private readonly _cachedExecuter;
private readonly _cachedSource;
private readonly _options;
private readonly _logRecorderSet;
private _debugInterceptor;
private _debugNextStep;
private _count;
private _broke;
private _brokeFlag;
private _skipping;
private _skippingFlag;
private _usingAdditionalArgument;
private _additionalArgument?;
private constructor();
get broke(): boolean;
get count(): number;
get bridgeScope(): Scope;
get executeScope(): Scope;
get usingAdditionalArgument(): boolean;
get additionalArgument(): any;
use(mixin: MarkedMixin): this;
break(): this;
skip(): this;
config(name: string, value?: any): this;
inject(name: string, value: any): this;
module(name: string): any | null;
mount<M extends EST_TYPE>(type: M, evaluator: Evaluator<M>): this;
provide(name: string, value: any): this;
resolver(resolver: ModuleResolver): this;
addLogRecorder(recorder: MarkedLogRecorder): this;
removeLogRecorder(recorder: MarkedLogRecorder): this;
setDebugInterceptor(interceptor: MarkedDebugInterceptor): this;
getOption<T extends OptionName>(name: T): ISandboxOptions[T];
setOption<T extends OptionName>(name: T, value: ISandboxOptions[T]): this;
setAdditionalArgument(value: any): Sandbox;
evaluate(script: string, breakPoints?: Iterable<MarkedDebugBreakPoint>, scriptLocation?: ScriptLocation, scope?: IScope): Promise<MarkedResult>;
protected putExecuteLog(log: IMarkedExecuteLog): this;
protected getSourceCode(scriptLocation: ScriptLocation): string | null;
protected hasDebugInterceptor(): boolean;
protected ensureGetDebugInterceptor(): MarkedDebugInterceptor;
protected setNextStep(nextStep: boolean): this;
protected breakWithFlag(flag: Flag): void;
protected skipWithFlag(flag: Flag): void;
protected getSkippingFlag(): Flag | null;
protected recoverFromBreak(): void;
protected recoverFromSkip(): void;
protected resolveResource(source: string, trace: ITrace): Promise<ModuleResolveResult | null>;
protected evaluateResource(resolveResult: ModuleResolveResult, breakPoints?: Iterable<MarkedDebugBreakPoint>): Promise<EvaluateResourceResult>;
protected execute(node: EST.Node, scope: IScope, trace: ITrace): Promise<any>;
}