Skip to content

Core Modules

akib-cdda edited this page Nov 11, 2026 · 4 revisions

Core Modules

The pure helpers in src/core that are not the engine itself: settings validation, strict file checking (issues, codes, did-you-mean), the template and expression languages, conditions, CSV, reports, workflow import/export, the script format and auto-layout, the Playwright exporter, the recorder converter, schedules, URLs, locator syntax, ARIA snapshot templates, schema migrations and the network/environment contracts. Read the section for the module you are about to use or change. All of them are browser-free and unit-tested in Node (tests/core/).

Source: config.ts, template.ts, expression.ts, condition.ts, text.ts, csv.ts, report.ts, suite.ts, library.ts, samples.ts, playwright.ts, playwrightRuntime.ts, recording.ts, schedule.ts, url.ts, urlPattern.ts, locatorSyntax.ts, migrate.ts, issues.ts, check.ts, suggest.ts, script.ts, layout.ts, network.ts, pixelDiff.ts, visual.ts, ariaSnapshot.ts

config

Block settings: defaults, coercion, template rendering, validation.

Export Notes
ValidationMode = 'design' | 'run' design: what the user typed (a templated URL is accepted if non-empty; broken {{ }} reported). run: final values.
withDefaults(def, raw) { ...def.defaultConfig, ...raw }, number fields given as non-empty strings become numbers. No rendering.
validateConfig(def, config, mode = 'run'): string[] One message per bad field (rules below). In design mode, also templateErrors for every templated string field.
resolveConfig<C>(def, raw, input): { config, errors } withDefaults, then renders templated text/url/selector/locator fields and templated rows columns against input, then validates in run mode. Rows are normalised to string cells.

Field rules: text/selector/locator/url required means non-blank; url must pass normalizeHttpUrl (deferred in design mode when templated). number must be finite and within min/max. boolean must be a boolean. select must be one of the options. rows: array; required means at least one non-blank row; every filled row needs its first column. workflow: required means a non-blank id.

Called by: the engine (resolveConfig before every step and for start/onTimer), validate.ts, tests.

template

The {{…}} language in settings. Plain paths are read directly; anything else goes to the expression evaluator.

Export Notes
hasTemplate(text) Any {{…}} token.
getPath(data, path) a.b[0].c, optional $json. prefix ($json alone = whole payload). Own properties only.
resolveToken(token, data) Path regex ^\$?[\w-]+(?:\.[\w$-]+|\[\d+\])*$ (dashes allowed: {{my-key}}) → getPath; otherwise evaluate. An ExpressionError gives ''.
render(template, data) Every token replaced by toText(value): missing → '', objects → JSON.
templateErrors(template) Parse errors of non-path tokens, for design-mode validation.

Gotcha: a path with a dash ({{my-key}}) is a path, but inside an expression my-key is subtraction. secret.* is available because the engine adds secret to the render data (never to the payload).

expression

A safe interpreter (no eval, forbidden in MV3) for {{ … }}, Transform and Filter. The supported syntax is listed in the file header; rationale in ARCHITECTURE: Data and scraping.

Export Notes
class ExpressionError Syntax or evaluation error.
parseExpression(source) Tokenize + parse; AST cached by trimmed source (cache cleared past 500 entries). Unknown function names fail at parse time.
evaluate(source, scope) Parse (cached) and interpret against scope (the payload).
toNumber(value) Numbers as-is, booleans 1/0, strings read like a person ("1,250" → 1250, "$9.99" → 9.99), else NaN.
toText(value) '' for null/undefined, JSON for objects.

Semantics worth knowing:

  • Identifiers resolve to own properties of the payload; $json is the payload itself. true, false, null are literals. .length works on strings and arrays.
  • + adds when both sides read as numbers ("1,250" + 10 = 1260), otherwise concatenates.
  • ==/=== compare as text (1 == "1" is true). <, > compare numerically when both read as numbers, else by localeCompare.
  • &&, || short-circuit and return an operand; an empty array is falsy. ?? only for null/undefined.
  • String escapes: only \n, \t, \\, \', \"; any other backslash is kept, so '/#(\d+)/' works.
  • Regex arguments (matches, extract, replace) accept /re/flags or a bare pattern.
  • now() and today() read the clock from the evaluation context (EvalEnv.now, third argument of evaluate / render / resolveConfig); the engine and the data blocks pass Host.now, so tests with FakeHost's fixed clock get fixed dates. Without one, the system clock.

Called by: template.ts, blocks/dataCommon.ts (Transform, Filter).

condition

Comparisons for If, Switch (each case), Repeat until/while, Assert and Filter. Operands are strings already rendered from templates.

Export Notes
Clause { left, operator, right }, Condition { match: 'all' | 'any', clauses }
OPERATORS equals, not-equals, contains, not-contains, starts-with, ends-with, matches (regex, /re/flags or bare), greater, greater-equal, less, less-equal (numbers via parseNumber; false if either side is not a number), empty, not-empty, true (true/yes/on/1), false (anything else).
OPERATOR_OPTIONS { value, label }[] for select fields.
operatorLabel(value), describeClause(clause) Readable text for summaries.
parseNumber(text) Like toNumber but returns null for non-numbers.
testClause(clause) Throws for an unknown operator or invalid regex (the step fails with that message).
testCondition(condition) No clauses = true.

text

normalizeText(text) collapses whitespace (Watch Element compares normalised text so layout changes do not count). truncate(text, max = 80) ends with … when cut.

csv

Export Notes
parseCsv(text, delimiter = ',') RFC 4180 (quoted cells with "", delimiters and newlines inside quotes; CRLF/LF/CR). Rows of only blank cells are dropped.
csvToObjects(text) Delimiter guessed from the first line (,, ; or tab, whichever splits most). First row = keys (blank header → columnN); cells trimmed.
toCsv(rows) Columns = every key in first-seen order; non-objects become { value }; objects in cells as JSON; ends with \n.

Called by: Data Table, Download, the editor's Data page.

report

Test reports from RunRecords (see Core Engine: Run records).

Export Notes
ReportOptions { blockLabel(type), screenshots?, title? } screenshots maps screenshot id → data URL for the HTML report.
durationOf(run) ms, 0 while running.
summarize(runs): RunSummary total, passed, failed (includes interrupted), other (cancelled or running), durationMs.
toJUnitXml(runs, options) One <testsuite> per workflow name, one <testcase> per run; failed/interrupted → <failure>, cancelled → <skipped>; step lines in <system-out> (failed ones end with [error code]).
toHtmlReport(runs, options) One self-contained HTML page (inline CSS, screenshots embedded); failed steps show their error code; a step with console entries gets a collapsed "Console (n)" block ([level] text (url)). M5.1: a step with trace shows its Before / After pictures when options.screenshots has them (the box drawn over After as percentages of trace.viewport), its URL and network summary; traced runs say "traced" in their meta line.
toJsonReport(runs, now?) JsonReport { $schema, schemaVersion, generatedAt, summary, runs }: Export JSON.
REPORT_SCHEMA_VERSION 1. Raise it when a report field changes meaning or goes away (new optional fields do not need it).
REPORT_SCHEMA_PATH docs/guide/report.schema.json, generated by scripts/reportSchema.ts through npm run guide:sync.
toSuiteJUnit(result, options) Suite report (M4.4): one <testsuite name=suite> (tests = workflows run + skipped, timestamp = start), one <testcase classname=suite name=workflow> per run; a run that did not pass is a <failure message="[code] Block: message" type=code> with every step in the body (no failing step: the run's error, type = run status); workflows skipped by stopOnFailure are <testcase> with <skipped/>.
toSuiteHtml(result, options) toHtmlReport of the suite's runs (one section per workflow) with a suite header (status, workflows, passed / failed / skipped, wall time) and a "not run" section listing skipped workflows. Title Suite: <name>.
toSuiteJson(result, now?) JsonSuiteReport { $schema, schemaVersion, generatedAt, suite: {id?, name, status, startedAt, finishedAt, skipped}, summary: {total, passed, failed, skipped, durationMs}, runs }.
SUITE_REPORT_SCHEMA_VERSION / SUITE_REPORT_SCHEMA_PATH 1 / docs/guide/suite-report.schema.json (same generator, run $defs shared with the run report).

Called by: ReportsPage.tsx; the suite reports by src/browser/suites.ts (suiteReports) and SuitesPage.tsx.

suite

Suites (M4.4): a named, ordered list of workflows run one after the other with one combined report. Types Suite (saved, in bf:suites, workflowIds only), SuiteInput (inline, from the bridge/CLI: optional workflowIds and sources) and SuiteResult live in src/core/bridgeProtocol.ts. Running is runSuite in src/browser/suites.ts (saved ids first, then the compiled sources; invalid → CodedError('config.invalid') before anything runs).

Export Notes
validateSuite(suite, knownWorkflowIds?, base?) Issue[]: suite.invalid, suite.name.missing, suite.id.invalid, suite.workflowIds.invalid, suite.sources.invalid, suite.empty (no ids and no sources), suite.workflow.duplicate, suite.workflow.unknown (only when knownWorkflowIds is given). Paths are JSON Pointers (/workflowIds/2).
validateSuites(suites, knownWorkflowIds?) Each suite's issues (under /<index>) plus suite.id.duplicate, suite.name.duplicate (case-insensitive).
normaliseSuites(value) Lenient read of stored bf:suites: drops non-objects and entries without id, fills "Untitled suite", keeps string ids, stopOnFailure only when true.
createSuite(existing, wanted?) / findSuite(suites, {suiteId?, name?}) New suite with a fresh id and a free name ("Suite 2"); lookup by id, else name (case-insensitive).
moveItem(list, index, ±1) Reorder helper for the Suites page.
isSavedSuite, runPassed, suiteStatus(runs, skipped), skippedNames(names, ranCount), failingStep(run) passed only when every workflow ran with status passed (failed, interrupted, cancelled all fail the suite); the failing step is the last failed one.
buildSuiteResult({suite, startedAt, finishedAt, runs, skipped}) / suiteSummary(result) SuiteResult with computed status (suiteId only for saved suites); counts with skipped apart and wall-time durationMs.

Called by: src/browser/suites.ts, report.ts, SuitesPage.tsx. Tests: tests/core/suite.test.ts, tests/core/suiteReport.test.ts, tests/browser/suites.test.ts.

library

Copy, export and import workflows.

Export Notes
uniqueName(wanted, taken) "Foo", else "Foo 2", "Foo 3"… (case-insensitive).
cloneWorkflow(source, name) Fresh ids for workflow, nodes and edges; disabled; config deep-copied.
duplicateWorkflow(source, existing) Clone named "<name> copy" (made unique).
exportWorkflows(workflows) { format: 'blockflow-workflows', version: 1, workflows } JSON, all enabled: false.
parseImport(text, existing, options?): ImportResult Parses (parseJson). A script file (isScriptFile) goes to parseScriptImport: compiled by compileScriptFile, then the compiled workflows are checked as one export file by checkFile and each issue path is moved back to the author's step (/nodes/3/config/url → /steps/2/open/url, or the shorthand string itself; step settings → …/step/…; a connection → the step it leaves from); Run Workflow may name another script of the file by id or name. Otherwise an export file or one bare workflow is checked by checkFile (below) with the existing workflow ids, laid out with layoutWorkflow when no node has a position. Any error refuses the whole file. Then: renames old config keys (migrateNode), clones with new ids, disables, uniquifies names, and remaps run-workflow config.workflow ids to the imported copies. options: registry (default: the built-in blocks), secrets (names, for secret.unknown).
ImportResult { ok: true, workflows, issues } (issues are warnings/info only) or { ok: false, error, issues } (error = first error's message plus "(and N more problems)").

cloneWorkflow and parseImport keep node.step and edge.sourcePort, so branches and step settings survive duplicate and import (tested in library.test.ts and guideExamples.test.ts).

Called by: Editor.tsx (duplicate, import, export, templates).

issues

The one shape every file checker reports in: strict checking (check.ts), the script compiler and migrations. An LLM (or a person) reads code and path to repair the file.

Export Notes
Issue { level, code, path, message, hint? } level: error (blocks an import), warning (imports, with a banner), info (a note). code: stable, listed in the guide's "Repair" table. path: a JSON Pointer into the file as written (/workflows/0/nodes/3/config/locater, '' = the whole file). hint: how to fix it, often Did you mean "locator"?.
pointer(...parts) RFC 6901 pointer from segments (escapes ~ and /).
hasErrors(issues) Any error?

Not to be confused with validate.ts's editor Issue (nodeId/edgeId, no code or path), which the canvas uses to mark blocks.

check

Strict checking of a workflow file before import, on the raw JSON, so paths and ids are the author's.

Export Notes
checkFile(raw, registry, options?): Issue[] Every problem, in file order. options.workflowIds: saved workflows Run Workflow may call; options.secrets: secret names (without it, secret.unknown is never reported).
parseJson(text) { ok, data } or { ok: false, issues: [json.invalid] } with the parser's position message.
locatorProblem(source) { message, hint? } or null: unclosed quote/bracket, empty step, an unknown engine= prefix (did-you-mean against ENGINES), non-numeric nth=. Templated locators are not checked.
EXPORT_FORMAT 'blockflow-workflows'.

What it checks, by level (codes in the guide's Repair table):

  • error: file.shape (not an object, workflows/nodes/edges not lists, node without string id/type, config/step not objects, schema newer than this build), node.id.duplicate, node.type.unknown, config.key.unknown (also unknown columns in rows settings), config.type, config.required, config.enum, config.value (number out of range, and validate hooks such as a bad Schedule time), config.locator.invalid, config.url.invalid, config.template.invalid, edge.endpoint.missing, edge.port.unknown (including error without onError: "port"), edge.target.no-input (into a block without run), step.key.unknown, step.value, graph.no-start (every block has an input), graph.cycle for a block wired to itself, workflow.call.missing (Run Workflow target not in the file nor saved), and whatever a block's validate hook returns.
  • warning: file.key.unknown (unknown keys on the file, a workflow, a node or an edge; ignored on import), config.template.unsupported ({{…}} in a setting that does not render it), edge.duplicate, graph.cycle (a loop back: allowed, the run's step limit stops it), graph.unreachable, page.no-tab, secret.unknown, graph.no-start for an empty workflow.
  • info: config.key.renamed (an old key such as selector; it is moved on import).

Design points:

  • Legacy keys a block still reads (BlockDefinition.legacyKeys, e.g. Open Tab's newTab) and renamed keys (RENAMED_KEYS) are not unknown. Numeric strings in number settings are accepted (withDefaults coerces them). Values that come from defaults are not checked for syntax, only the author's.
  • Templated values ({{…}}) are checked for template syntax only; URL and locator syntax wait for run time.
  • page.no-tab is a forward "must" analysis over the graph: the tabs certainly open before a block are the intersection over its incoming paths, plus what each block opens (Open Tab: its tab; Wait for Popup: its name; Page Visited and Context Menu: main). An error output carries what the failed block had before it. Disabled blocks neither open nor need a tab. Skipped for a workflow that a Run Workflow in the same file calls (it gets the caller's tabs). A warning, because a sub-workflow saved earlier can also receive tabs.
  • Loops are made with Repeat / For Each / Paginate (they emit on each and await the branch), never with a connection back, so a cycle is a warning (probably a mistake, but the engine tolerates it).
  • Unknown keys get a hint from an alias table first (settings→config, from→source, sourceHandle→sourcePort…), then did-you-mean, else the list of valid keys.

Called by: parseImport (so the editor's Import, templates and tests), tests/core/check.test.ts.

suggest

Did-you-mean.

Export Notes
editDistance(a, b) Damerau-Levenshtein (optimal string alignment): insert, delete, substitute, swap neighbours.
closest(word, candidates, maxDistance = 2) Case-insensitive best match within the distance (1 for words of 3 letters or fewer), or undefined.
didYouMean(word, candidates) Did you mean "x"? or undefined.

Called by: check.ts.

script

The script format (Workflows as Scripts): a workflow as a list of steps, compiled to a graph and back. Needs a BlockRegistry (defaults to createDefaultRegistry()) for block types, ports and default configs.

Export Notes
compileScript(raw, registry?, base?): CompiledScript One script → { workflow?, issues, nodePaths, configPaths, scriptId? }. Node ids are the steps' ids, else s<N> (Nth step top to bottom, skipping author ids); origin = node id. Configs are the defaults plus the author's keys (old keys moved by migrateNode first). Positions from layoutWorkflow. workflow is missing when there are errors. nodePaths / configPaths: node id → JSON Pointer of its step / its config value (/steps/2/true/0, …/click), so other checkers can point into the script. base prefixes every path.
compileScriptFile(raw, registry?) One script, or { format, version, scripts: [...] } (paths under /scripts/N).
decompile(workflow, registry?): Script | null The graph as a script when it is a tree in the format's sense (one start, no fan-out, joins only after an If, no cycles); verified by compiling back and comparing with sameScriptGraph. Uses aliases and shorthands, drops config values equal to the default, keeps origin ids (drops uuids and ids a compile would generate).
sameScriptGraph(a, b, registry, idOf?) Same blocks, configs (with defaults), step settings and wiring by port, nodes matched by id (or idOf).
isScriptFile(data) format: "blockflow-script", or a steps array and no nodes.
continuePort(ports) out, else done, else undefined (If and Switch: their branches rejoin).
didYouMean(word, candidates) Closest candidate within Damerau-Levenshtein distance 2 (its own copy; suggest.ts has the shared one).
SCRIPT_ALIASES, SCRIPT_SHORTHAND Alias → block type; block type → the config key a bare value fills.

Wiring: a step connects to the next from its continue port; lists on other ports (each, onError) end where they end; a block without a continue port (If, Switch) connects the next step from the end of each branch list and from each port that has no list. Ports come from nodePorts(def, { config }) with the step's settings (defaults filled in), so a Switch's branch keys are its case names plus default; an unknown key is edge.port.unknown with a did-you-mean over them. Switch reserves the names a step uses itself (id, step, onError, switch) and out/done (a case named so would turn it into a continue port). Issue codes: script.shape, script.version, script.empty, step.shape, node.type.unknown, node.id.duplicate, edge.port.unknown, step.branch.next, step.onError.conflict (table in Workflows as Scripts).

Called by: parseImport (library.ts), the editor's Export as script, scripts/scriptSchema.ts (generates docs/guide/script.schema.json). Tests: tests/core/script.test.ts, and the guide examples round trip (graph → decompile → compile is the same graph; *.script.json compile to the *.blockflow.json graphs) in guideExamples.test.ts.

layout

Automatic left-to-right layout, pure and deterministic.

Export Notes
layoutGraph(nodes, edges, portRank?) Map node id → {x, y}. Longest-path layers (edges closing a cycle ignored), then per column, left to right, nodes sorted by the average index of their parents plus a slot for the port they hang off (portRank), then rows: parents' average row (rounded up the page) when free, else the next free row. A chain is one row; branches open downwards; nothing overlaps.
layoutWorkflow(workflow, registry?) Every node placed. Ports ranked as the blocks declare them (nodePorts with the node's config: a Switch's cases in row order, default last), or by out, true, each, false, done, error without a registry.
LAYOUT_X, LAYOUT_Y 260 and 140 px.

Called by: compileScript, parseImport (graph files without positions), the editor's Tidy up. Tests: tests/core/layout.test.ts.

migrate

Workflow schema versions (Workflow.schemaVersion) and the steps between them. Version 2 (v0.3) calls every element setting locator: Read Element and Watch Element used selector, Paginate used next.

Export Notes
CURRENT_SCHEMA_VERSION 2.
RENAMED_KEYS Per block type, old config key → new key. Also read by check.ts to report config.key.renamed.
migrateNode(node, renames?) Moves renamed keys (the new key wins when both exist). Same object back when nothing changed. Applied to every imported node whatever the file's version, so old key names are always accepted.
migrateWorkflow(workflow, renames?) Brings an older workflow to the current version; no-op (same object) when current.
migrateWorkflows(list) { workflows, changed }.

Called by: loadWorkflows (src/browser/stores.ts, every read is migrated), migrateStoredWorkflows (the background's onInstalled rewrites bf:workflows once after an update), the background's bf:run-workflow handler and storage-change diff (both sides migrated, so the rewrite restarts nothing), the editor's storage listener, and parseImport. Adding a version: bump the constant, add the step in migrateWorkflow, add v(n-1) fixtures to tests/core/migrate.test.ts.

samples

sampleWorkflows(): two disabled examples created on first install ("open a page every 5 minutes": Timer → Open Tab; "open the page when part of it changes": Watch Element → Open Tab). Called by the background's onInstalled. Note the Open Tab configs use the legacy newTab: true key; openUrl.ts still accepts it.

playwright

Exports a workflow as a Playwright test. See ARCHITECTURE: Harder pages.

Export Notes
ExportOptions { registry, lookup?(id) } lookup resolves Run Workflow targets.
toPlaywrightLocator(locator, base) Per locator step: css → .locator() (>>> dropped, Playwright CSS pierces shadow roots), xpath → .locator('xpath=…'), text/label/placeholder/alt/title → getByX (quoted = exact: true, /re/ = regex), testid → getByTestId, frame → frameLocator, nth → first()/last()/nth(), role → getByRole with name, exact, checked, pressed, expanded, selected, disabled, level, includeHidden; filters → `.filter({ hasText
workflowToPlaywright(workflow, options) Full .spec.ts: one test() with the page, context and request fixtures, a tabs map and a mutable data object; called workflows as functions; helper functions (render, evaluate, listAt, compare, parseRows, urlPattern, retry, waitForResponse, waitForPopup, answerDialogs, fileFromUrl, setField, selectByText, read, peek, extractList, extractTable…) and the inlined runtime appended.

How it walks: from every root, depth-first along edges (Writer.walk); a node already on the current path writes a "loop back … not exported" comment. Each step writes only its own statements; walk wraps them for the step settings: retries → retry(n, async () => …), onError: 'continue' → try/catch that logs, onError: 'port' with an error edge → try/catch running the error branch and an if (okN) around the normal continuation; timeoutSeconds → { timeout } on the action or matcher; disabled → a comment. If → if/else; Switch → const switchValueN = … and an if / else if chain over its cases in order (else for default when connected); For Each, Repeat, Paginate → for loops with each inside and done after (For Each and Repeat times restore the input, Repeat adds iterations). Repeat until/while → for (;;) with the condition (compare on rendered templates, against data as the round left it) checked after (until) or before (while) each round, and max → throw (or break with failAtMax: false). Triggers (a root Timer, Schedule, Page Visited, Context Menu, Watch Element) become comments; a fed Timer is page.waitForTimeout; unknown blocks become // BlockFlow-only: comments. Templates: any {{…}} → render("…", data) (BlockFlow's own template.ts, with { ...data, secret: SECRETS } and SECRETS read from process.env). Assert uses web-first matchers for equals / not-equals / matches (and contains for text), expect.poll around compare for the rest; Assert console-errors becomes a "not exported" comment. Route, HAR Record, Emulate and Clear Site Data are not exported either: each writes // BlockFlow-only: <label> is not exported; implement Playwright routing/context options explicitly. Open Tab where: current/workflow reuses page. Screenshot with compare (M5.3) → await expect(page | locator.first()).toHaveScreenshot("<node id>.png", { fullPage?, threshold?, maxDiffPixelRatio?, mask: [locators] }) (threshold only when not the shared default 0.2); mask rectangles and updateBaseline become // BlockFlow-only: comments. Assert aria-snapshot (M5.4) → await expect(locator.first() | page.locator('body')).toMatchAriaSnapshot(`…`) with the template re-rendered by renderAriaTree(…, { playwright: true }) (refs and locator hints gone; BlockFlow-only states left out with a // BlockFlow-only: [required] … comment); a templated expected is passed as render(…).

playwrightRuntime

The BlockFlow runtime inlined at the end of every exported spec. runtimeSource() reads the source of expression.ts, condition.ts, csv.ts, urlPattern.ts and template.ts with Vite's ?raw import (build time; declared in src/core/raw.d.ts) and wraps each in a closure (const expressionModule = (() => { … return { evaluate, … }; })();) with wrapModule(name, source, known): export dropped, value imports between these modules turned into destructuring, type imports removed (Payload is declared once). An import of any other module throws, so a new dependency in those files fails the unit tests instead of producing a broken spec. Because the text is the real source, the export cannot drift from the extension.

Called by: Editor.tsx (export), tests/core/playwright.test.ts, and the e2e run.

recording

Turns what the recorder (Picker and Recorder) captured into blocks.

Export Notes
RecordedStep click, fill (secret? for passwords), select, check, press, navigated, assert-text, assert-visible.
Recording { startUrl, steps }
tidySteps(steps) Consecutive fills of the same locator keep the last; consecutive navigations keep the last.
recordingToBlocks(recording, origin?): RecordedBlocks Open Tab, then one block per step in a line (240 px apart) wired in sequence. 2+ fills in a run of fill/select/check become one Fill Form (a directly following click becomes its submit). Secret fills become {{secret.password}} and secrets lists password. A navigation becomes Wait For URL with the URL's path.

Called by: Editor.tsx, src/browser/recording.ts, src/dom/recorder.ts (types), src/shared/messages.ts.

schedule

Pure next-fire-time maths for the Schedule block, in local time.

Export Notes
ScheduleSpec { every: 'day', at: 'HH:MM', days: number[] } (0 = Sunday, empty = every day), { every: 'hour', minute }, { every: 'minutes', minutes }.
parseTime(text) "9:30"/"09:30" → { hour, minute } or null.
nextOccurrence(now, spec) First matching time strictly after now, seconds zeroed. minutes aligns to the clock from midnight (00, 10, 20…). Throws for a bad time.
parseDays(text) "mon,wed", "weekdays", "weekends", "every day"/"daily"/"" → day numbers.

The block sets a one-shot timer for the next occurrence and plans the following one when it fires (Scheduling and Timers).

url

normalizeHttpUrl(raw): string | null. Adds https:// when there is no scheme; rejects javascript:, data:, file:, extension and browser pages and anything not http(s) or without a host. Returns URL.href. Used by config.ts (url fields), the picker, and URL-taking blocks.

urlPattern

urlMatches(url, pattern): boolean. /re/flags → regex (throws "Invalid URL pattern" when bad); a pattern with * → glob anchored to the whole URL (* = anything but /, ** = anything); otherwise "URL contains". Empty pattern = false. Used by src/browser/navigation.ts (Wait For URL), the background (Page Visited) and the fake host.

locatorSyntax

String-level locator parsing, shared by the page agent's resolver (Locators) and the Playwright exporter. No DOM.

Export Notes
class LocatorSyntaxError Empty or malformed locator.
LocatorStep { engine, body }
ENGINES css, text, role, label, placeholder, testid, alt, title, xpath, nth, frame, plus FILTERS.
FILTERS has-text, has-not-text, has, has-not, visible: steps that narrow the matches so far.
splitAlternatives(source) / parseLocatorAlternatives(source) A || B split outside quotes and brackets (|| binds loosest); the second also parses each into steps.
parseLocatorSteps(source) One alternative. Splits on >> outside quotes and brackets (leaves the shadow-piercing >>> alone). engine=body for known engines; a bare visible → the visible filter; else //… or (//… → xpath, a double-quoted string → text, anything else → css.
nestedLocator(body), visibleFilter(body) The inner locator of has=/has-not= (unquoted when fully quoted); visible= as a boolean (throws for anything but true/false).
ROLE_OPTIONS, ROLE_STATES, parseRoleSelector(body), roleState(option), unquoteValue(value) role= options parsed once for the resolver, the checker and the exporter: unknown options, bad state values and non-number levels throw LocatorSyntaxError.

network

Browser-free contracts for the M3 Host.network / Host.environment members (Core Engine: The Host interface); types only, no code.

Type Shape
RouteRule { url, method?, action: fulfill/abort/continue/modify/redirect, status?, headers?, body?, redirectUrl?, delayMs? }
RouteOptions / RouteResult { action: add/clear, rules, backend: auto/cdp/dnr } / { rules (count), backend: cdp/dnr }
ConsoleEntry { level, text, timestamp, url? }; also stored on StepRecord.console
HarLog / HarResult { log: { version, creator, entries } } / { recording, har?, truncated? }
EmulateOptions { action: set/clear, device: ''/iphone/pixel/ipad/desktop, width?, height?, deviceScaleFactor?, userAgent?, locale?, timezone?, latitude?, longitude?, accuracy?, colorScheme?, reducedMotion?, offline? }
ClearSiteDataOptions { origins: string[] }

Validation lives with the blocks (parseRouteRules, dnrCompatible, emulateProblems, parseSiteOrigins, see Block Internals); src/browser re-validates with the same functions.

pixelDiff

M5.3 pixel comparison, pure (RGBA in, counts and a diff picture out; the browser decodes PNGs).

Export Notes
pixelDiff(expected, actual, width, height, options?) Both buffers must be width*height*4 bytes (throws otherwise; compare sizes first). Per pixel: byte-equal fast path (Uint32 views when aligned), else a YIQ colour distance of the colours blended onto white against 35215 * threshold² (threshold 0..1, default 0.2). A differing pixel that looks anti-aliased (≤ 2 equal neighbours, both a darker and a brighter neighbour, and that neighbour a solid area in both pictures) counts as antialiasedPixels, not diffPixels, unless includeAA. mask rectangles (image pixels, clipped, fractional edges rounded outward) are skipped. Returns {width, height, diffPixels, antialiasedPixels, maskedPixels, diffRatio (of unmasked pixels), bounds?, diff?}; diff (unless diffImage: false): faded grey copy, red = differs, yellow = anti-aliasing, blue = masked. About 30 ms for 1300×850 in Node (the test bounds it at 1.5 s).
PixelRect, PixelDiffOptions, PixelDiffResult Types.

visual

M5.3 contract between the Screenshot block and Host.visual (Browser Host: visual.ts).

Export Notes
VisualHost { compare(request): Promise<VisualCompareResult> } Host.visual (optional; the block fails with config.invalid without it).
VisualCompareRequest {runId, workflowId, nodeId, tabId, screenshotId, area, locator?, threshold, maxDiffRatio, mask: VisualMask[], updateBaseline, timeoutMs}
VisualCompareResult {status: baseline-saved/baseline-updated/match/mismatch, comparisonId, width, height, diffPixels, diffRatio, baselineId?, diffId?, baselineSize?, missingMasks?}
VisualMask {rect} (CSS pixels from the picture's top-left) or {locator}
parseMaskRows(rows) The block's mask rows {region} → masks + one message per bad row: four numbers = a rectangle (x, y ≥ 0, width, height > 0), else a locator checked with locatorProblem.
parseRect, toImageRect(box, origin, scale), scaleRect, formatRatio Helpers (mask placement, messages).

ariaSnapshot

M5.4: the templates of Assert aria-snapshot, Playwright's toMatchAriaSnapshot semantics over the snapshot op's outline. Template and outline are parsed into the same tree (AriaNode = AriaRole { role, name?, checked?, disabled?, expanded?, level?, pressed?, selected?, url?, extra?, mode?, children, line } or AriaText { text: { raw, normalized }, line }; the root is role: 'fragment').

Export Notes
parseAriaTemplate(text) YAML-like lines - role "name" [state], : value or : + nested lines (two-space indent; the common indent is removed, so a template pasted from a Playwright test works), - text: …, - /url: …, - /children: contain/equal/deep-equal, whole-line # comments, YAML '…'/"…" quoting of a value or of a whole line. Names "…" (JSON escapes, whitespace collapsed) or /regex/ (no flags). States: checked/pressed (true/false/mixed), disabled/expanded/selected (true/false), level. Snapshot annotations are accepted so pasted outline lines work: [ref=…] and a trailing locator=… are dropped, [url=…] = /url, [value=…] = the value, [required]/[password]/[shadow]/[frame]/[cross-origin]/[type=…]/[src=…]/[options=…] go to extra. A parent line needs no trailing : (the outline has none). Throws AriaTemplateError { reason, line, column } (1-based, as written) on anything else, e.g. unknown states, [active]/[invalid] (Playwright states the outline does not record), regex flags, tabs, misaligned siblings, a line nested under a value or a text.
ariaTemplateProblem(text) The error message or null (Assert's validate).
parseAriaOutline(snapshot, elements?) The snapshot op's text → tree; elements gives each ref's exact locator so locator=… is cut exactly (else at the last locator=). Inline text and [value] become a text child (as Playwright shows a field's value); the - … truncated line sets truncated.
matchAriaSnapshot(outline, template) { pass, message, actual }. Playwright's algorithm: one top-level line is searched for anywhere (matchesNodeDeep); several must be direct children, in order, of one node; children by greedy subsequence (containsList) unless /children: equal (same list) or deep-equal. Names exact or regex (search); text equal after normalising, or equal to the raw text, or /regex/; a name or text the outline cut at 100/120 characters ("…") matches by prefix. Unlisted states are not checked; a listed =false passes when the outline shows no such state (it omits false ones), except [expanded=false], which the outline shows. message: the template line that found nothing, the closest node (same role, best name/state/children score) with what differs, or "the order differs", and up to 20 lines of the page node it looked in. actual: the page in template form.
renderAriaTree(root, { playwright? }) Tree → template text (keys and values quoted with Playwright's yamlStringNeedsQuotes rules); with playwright, extra states are left out and returned in dropped. Used for messages, actual and the Playwright export.
normalizeAriaText(text) Zero-width characters dropped, whitespace collapsed, trimmed.

See also

Clone this wiki locally