feat(stdlib): seven Rhai utility modules + register_stdlib hook
Adds the v1.1.0 user-visible stdlib: regex, random, time, json, base64, hex, url — each exposed as a `::` namespace mirroring the existing `log::` pattern. Modules register once at engine build via `Engine::register_static_module`, distinct from the stateful service modules (KV, docs, …) that hook into `sdk::register_all` per call. - regex: linear-time, compile-per-call (no cache by design) - random: OsRng only; bytes/string capped to prevent script-side blow-up - time: UTC, ms-since-epoch as canonical i64; RFC 3339 strings for I/O - json: parse/stringify via existing dynamic<->json bridge - base64: standard + URL-safe alphabets, Blob and String inputs - hex: lowercase output, case-insensitive decode - url: RFC 3986 percent-encoding + encode_query for Maps Stdlib registration runs unconditionally — including in the parse-only validate path — so scripts get a uniform surface in both phases. See docs/sdk-shape.md for the stateless-vs-stateful distinction. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -143,6 +143,11 @@ fn build_engine(limits: Limits, logs: Option<Arc<Mutex<Vec<LogEntry>>>>) -> Rhai
|
||||
engine.register_static_module("log", build_log_module(logs).into());
|
||||
}
|
||||
|
||||
// Stateless utility modules — regex::/random::/time::/json::/base64::/
|
||||
// hex::/url::. Always registered, including in the parse-only validate
|
||||
// path, so script authors get consistent surface in both phases.
|
||||
sdk::stdlib::register_stdlib(&mut engine);
|
||||
|
||||
engine
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user