/** * CSP-safe expression evaluator for SSR templates. * * Evaluates a tightly scoped subset of JavaScript expressions against a * binding context without using `eval` or `new Function()`. Runs in any * runtime (Bun, Deno, Node, browsers) and is safe under strict CSP without * `'unsafe-eval'`. * * Supported grammar (operator-precedence Pratt parser): * * - Literals: numbers, single/double-quoted strings, `true`, `false`, `null`, * `undefined`. * - Identifiers and member access (`a.b`, `a['b']`, `a[0]`). * - Optional chaining (`a?.b`, `a?.[b]`). * - Unary `!`, `+`, `-`, `typeof`. * - Binary `+`, `-`, `*`, `/`, `%`, `==`, `===`, `!=`, `!==`, `<`, `<=`, * `>`, `>=`, `&&`, `||`, `??`. * - Ternary `cond ? a : b`. * - Parentheses for grouping. * - Function calls `fn(arg1, arg2, ...)` (only on identifiers / member chains * resolved against the context — no arbitrary expression invocation). * * Anything outside this grammar throws a parse error which the caller * converts into the standard SSR fallback (`undefined`). * * @module bquery/ssr * @internal */ import type { BindingContext } from '../view/types'; /** * Evaluates a tightly scoped expression against a binding context. * * Returns `undefined` when the expression cannot be parsed or evaluated. * This matches the behaviour of the previous `new Function()`-based fallback * but never invokes dynamic code generation. * * @param expression - Expression source. * @param context - Binding context whose top-level signal/computed values are * automatically unwrapped. * * @internal */ export declare const evaluateExpression: (expression: string, context: BindingContext) => T; //# sourceMappingURL=expression.d.ts.map