Package io.karatelabs.js
Class Engine
java.lang.Object
io.karatelabs.js.Engine
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectReturns the user-visible bindings as an auto-unwrapping Map.Returns the raw user-visible bindings map without auto-unwrapping.Returns the hidden ("root") bindings — the entries injected viaputRootBinding(java.lang.String, java.lang.Object)plus the lazy built-in cache.booleanTrue once this engine has been poisoned — seepoisoned.static NodeParses JS source text into an ASTNodewithout evaluating it.voidvoidputRootBinding(String name, Object value) voidvoidsetAsyncDrainTimeout(Duration timeout) How longEngine.evalmay keep draining async work before it gives up, cancels the scope and throwsEngineTimeoutException.voidsetAsyncRejectionWarnOnly(boolean warnOnly) Downgrade unhandled promise rejections from "fail the eval" (the default) to a warning on theconsoleconsumer and SLF4J.<T> voidsetDebugSupport(RunInterceptor<T> interceptor, DebugPointFactory<T> factory) voidsetExternalBridge(ExternalBridge bridge) voidsetListener(ContextListener listener) voidsetOnConsoleLog(Consumer<String> onConsoleLog)
-
Field Details
-
DEBUG
public static boolean DEBUG
-
-
Constructor Details
-
Engine
public Engine()
-
-
Method Details
-
setAsyncDrainTimeout
How longEngine.evalmay keep draining async work before it gives up, cancels the scope and throwsEngineTimeoutException. Off by default — cooperative interrupt (and karate-ext'sSandbox.TimeBox) remain the outer bound. -
setAsyncRejectionWarnOnly
public void setAsyncRejectionWarnOnly(boolean warnOnly) Downgrade unhandled promise rejections from "fail the eval" (the default) to a warning on theconsoleconsumer and SLF4J. Covers the eval's own result too: a script whose completion value is a rejected promise returns the rejection reason instead of throwing. -
isPoisoned
public boolean isPoisoned()True once this engine has been poisoned — seepoisoned. -
eval
-
eval
-
eval
-
eval
-
parse
Parses JS source text into an ASTNodewithout evaluating it. Exposed for tools (linters, formatters, AST patchers) that need source positions and structure but not execution. -
evalWith
-
evalWith
-
evalWith
-
get
-
put
-
putRootBinding
-
remove
-
setOnConsoleLog
-
getBindings
Returns the user-visible bindings as an auto-unwrapping Map. Values retrieved via get() are automatically converted (JsDate → Date, undefined → null, etc.). Hidden entries (putRootBinding-injected, lazy built-ins) are filtered out. -
getRawBindings
Returns the raw user-visible bindings map without auto-unwrapping. Hidden entries are filtered out. Used for internal engine operations that need raw JS values. -
getRootContext
-
getRootBindings
Returns the hidden ("root") bindings — the entries injected viaputRootBinding(java.lang.String, java.lang.Object)plus the lazy built-in cache. Used by hosts (e.g. Karate's ScenarioRuntime) to inherit hidden state into a callee. -
setListener
-
setExternalBridge
-
setDebugSupport
-
getInterceptor
-
getPointFactory
-
evalRaw
-