Expand description
TypeScript interpreter for config/manifest generation
§Example
use tsrun::{Runtime, StepResult};
let mut runtime = Runtime::new();
runtime.prepare("1 + 2 * 3", None).unwrap();
// Step until completion
loop {
match runtime.step().unwrap() {
StepResult::Continue => continue,
StepResult::Complete(value) => {
assert_eq!(value.as_number(), Some(7.0));
break;
}
_ => panic!("Unexpected result"),
}
}Re-exports§
pub use error::JsError;pub use gc::Gc;pub use gc::GcStats;pub use gc::Guard;pub use gc::Heap;pub use gc::Reset;pub use string_dict::StringDict;pub use value::CheapClone;pub use value::EnvRef;pub use value::Guarded;pub use value::JsObject;pub use value::JsString;pub use value::JsValue;
Modules§
- api
- Public API for interacting with JavaScript values from Rust.
- ast
- Abstract Syntax Tree types for TypeScript
- compiler
- Bytecode compiler for TypeScript/JavaScript
- error
- Error types for the TypeScript interpreter
- gc
- Mark-and-sweep garbage collection system.
- lexer
- Lexer for TypeScript source code
- parser
- Parser for TypeScript source code
- string_
dict - String dictionary for deduplicating JsString instances.
- value
- JavaScript value representation
Structs§
- Import
Request - A pending import request with context about where it was requested from.
- Internal
Module - Definition of an internal module
- Interpreter
- The interpreter state
- Module
Path - A normalized, absolute module path.
- Native
Module Builder - Builder for creating native internal modules
- Order
- An order is a request for an external effect. The payload is a RuntimeValue that the host interprets to perform side effects. The RuntimeValue keeps the payload alive until the order is fulfilled or dropped.
- OrderId
- Unique identifier for an order
- Order
Response - Response to fulfill an order from the host
- Runtime
- The main runtime for executing TypeScript code
- Runtime
Config - Configuration for creating a Runtime
- Runtime
Value - A JS value with an attached guard that keeps it alive until dropped.
Enums§
- Internal
Export - Definition of an export from an internal module
- Internal
Module Kind - How an internal module is defined
- Step
Result - Result of executing a single step.
Functions§
- create_
eval_ internal_ module - Create the eval:internal module
- js_
value_ to_ json - Convert a JsValue to JSON, with public API for external callers (without circular detection)
- json_
to_ js_ value_ with_ guard - Convert a serde_json value to a JsValue using a provided guard. The guard keeps any created objects alive until it is dropped. This is the preferred method when you need to control the lifetime of the result.
- json_
to_ js_ value_ with_ interp - Convert a serde_json value to a JsValue using the interpreter’s GC space
Type Aliases§
- Internal
Fn - A native function that can be exported from an internal module