install<R> method

R install<R>(
  1. R body()
)

Runs body in a zone whose print is recorded as well as printed.

A zone rather than a debugPrint override, because debugPrint is only what the framework uses; a demo calls print, and so does anything it depends on. debugPrint ends in print too, so one seam catches both.

And it forwards, always. Swallowing the line to collect it would trade a thing you can see for a thing you can query — and worse, the host reads the VM service URI and the FW-PROBE: lines off this very stream, so a zone that kept them would stop the session starting at all.

Implementation

R install<R>(R Function() body) {
  if (Zone.current[_marker] == true) return body();
  return runZoned(
    body,
    zoneValues: {_marker: true},
    zoneSpecification: ZoneSpecification(
      print: (self, parent, zone, line) {
        // `FW-PROBE:` is the harness talking to itself — the generated
        // entrypoint prints the rendered text every 200ms so a headless check
        // can assert on it. It is not the demo's output, and a console that
        // showed it would show five lines a second of it and nothing else.
        if (!line.startsWith('FW-PROBE:')) _record(line);
        parent.print(zone, line);
      },
    ),
  );
}