/** * @license * Copyright 2026 Steven Roussey * SPDX-License-Identifier: Apache-2.0 * * Seam for running a single regex against a single value. * * The shape screen in `regexSafety.ts` is a heuristic, not a decision * procedure — `^(a?b?)*$` passes it and still backtracks catastrophically. What * contains that is a wall-clock budget at match time, which needs a `vm` and so * cannot live in the browser build. The Node/Bun/Electron entrypoints register * the bounded implementation (see `BoundedRegex.server.ts`); the browser default * matches unbounded, where a hostile pattern blocks that tab rather than the * process hosting a local API. */ /** Runs one compiled regex against one value. */ export interface RegexRunner { /** * The full match followed by its capture groups, or `undefined` when the * pattern did not match. An unmatched optional group stays `undefined` in * place rather than being dropped, so group indices keep their meaning. */ readonly exec: (value: string) => (string | undefined)[] | undefined; /** Every non-empty full match, for a regex carrying the `g` flag. */ readonly execAll: (value: string) => string[]; } export type RegexRunnerFactory = (regex: RegExp) => RegexRunner; /** Plain, unbounded matching on the calling thread. */ export declare const defaultRegexRunnerFactory: RegexRunnerFactory; /** * Register a platform-specific runner factory. The Node/Bun entrypoints call * this at module load time to install the budgeted implementation from * `BoundedRegex.server.ts`. * * Returns the previously registered factory so callers can safely restore it * after a temporary override. */ export declare function registerRegexRunnerFactory(fn: RegexRunnerFactory): RegexRunnerFactory; export declare function getRegexRunnerFactory(): RegexRunnerFactory; /** Restores the default unbounded implementation. */ export declare function resetRegexRunnerFactory(): void;