Skip to main content

Crate brep_script_core

Crate brep_script_core 

Source
Expand description

The interpreter core: evaluate one script, call one global function with one JSON argument, and hand back its JSON result or its refusal.

This crate depends on Boa and serde_json and nothing else — no file system, no network, no store. That is deliberate: the operator chose Boa so the same interpreter runs inside the CAD app, including its wasm build (plm-cad-integration-todo §3 S11). It was the PLM’s scripting::engine module and is still reached under that name there. Everything that reaches outside the interpreter is installed by the caller through call’s install argument: the server’s bindings are in BREP_plm/src/scripting/host.rs, the CAD app’s in BREP_app/src/scripting.rs.

§A fresh interpreter per call

Every call builds a new Context, evaluates the file, and drops it. No state leaks from one hook call into the next, a script edited on disk is simply the script the next call evaluates, and a Context (which is not Send) never has to cross a thread.

§What is bounded, honestly

Boa’s RuntimeLimits bound three things, and they are set here:

  • each LOOP may run at most LOOP_ITERATION_LIMIT iterations — an infinite while (true) throws instead of hanging;
  • call depth is at most RECURSION_LIMIT — runaway recursion throws;
  • the VM stack size.

There is NO wall-clock limit: Boa cannot pre-empt a running script. A script of many individually-bounded loops can still run long, and a script blocked inside a host function (an HTTP call, a child process) is bounded only by that host function’s own timeout.

Re-exports§

pub use boa_engine;

Modules§

modules
In-memory ESM execution, separate from the legacy global-function hook API.

Structs§

Failure
A call that threw, failed to parse, or named a function the file does not define. message is what a person reads: for throw new Error("x") it is x, for throw "x" it is x.
Success
A call that returned.

Constants§

LOOP_ITERATION_LIMIT
The most iterations any one loop may run before it throws.
RECURSION_LIMIT
The deepest call stack a script may build before it throws.

Functions§

call
Evaluate source (named file in messages), then call the global function function with input as its single argument.
describe
The message a person should read for error.
text_of
One argument as the text a log line shows: strings verbatim, everything else as JSON.

Type Aliases§

Logs
Lines a script wrote through console.log, kept for the caller — the test run shows them, and a failing hook’s log goes to the server log.