Skip to main content

Module route

Module route 

Source
Expand description

Shared routing preamble + named-tab dispatch for the page-evaluating CLI commands (eval, fetch, storage).

These commands all accept the unified <browser>[/<tab>] positional plus a mutually-exclusive --target <regex> and fan out into the same three routing paths, picked by (tab_name, target):

  1. named-tab (<browser>/<tab>, no --target) — resolve <tab> in the tabs table via the engine-agnostic TabBackend and run the op under with_named_tab_recovery, so a tab that dies between resolve and op is recovered once. Requires a registered browser. See run_named_tab.
  2. bare browser (no --target) — the per-command default. This arm differs per command (scratch tab for eval/storage, origin-bound attach for fetch, plus an external-endpoint fallback), so it stays in each command rather than here.
  3. target-regex (--target <regex>) — legacy PageSession::attach against a user tab matching the URL regex. Also per-command (it differs in await-promise flags / timeouts), so it stays in each command.

The genuinely shared pieces — the preamble (parse, mutual-exclusion check, browser resolution, registry handle, BiDi lock) and the named-tab arm — live here so the three commands cannot drift on them. The per-command variation (the JS expression, the await-promise flag, the timeout, and the bare-browser arm) is supplied by the caller.

Structs§

Route
Outcome of the shared routing preamble. Holds everything the per-command dispatch needs: the resolved browser, the open Registry handle, the held BiDi lock guard (RAII — released when this struct drops), and the parsed (tab_name, browser_only) from the positional.

Functions§

preamble
Run the shared preamble: parse the <browser>[/<tab>] positional, enforce the <tab> / --target mutual exclusion (in ONE place with ONE message), resolve the browser, record trace.browser/trace.engine, open the registry, and acquire the BiDi lock if applicable.
run_named_tab
The named-tab routing arm, identical across eval/fetch/storage: resolve the registered browser name, open its TabBackend, and run the caller’s op against the named tab under with_named_tab_recovery (which recovers once if the tab dies between resolve and op).