For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /api/angular-lynx/devtools.md.

DevTools

Renderer counters you can show on screen, and named traces for Lynx's performance timeline. import { LynxDevTools, LynxPerformance, type DevToolsStats, type LynxTraceOptions } from '@blotch/angular-lynx';

Usage

src/app/debug-panel.ts
import { Component, inject } from '@angular/core';
import { LYNX_ELEMENTS, LynxDevTools } from '@blotch/angular-lynx';

@Component({
  selector: 'app-debug-panel',
  imports: [LYNX_ELEMENTS],
  template: `
    <view (bindtap)="devtools.refresh()">
      <text>Change detection runs: {{ devtools.stats().cdCycles }}</text>
      <text>Elements created: {{ devtools.stats().elementCreated }}</text>
    </view>
  `,
})
export class DebugPanel {
  readonly devtools = inject(LynxDevTools);
}

API

LynxDevTools

@Injectable({ providedIn: 'root' })
class LynxDevTools {}

Reads the counters that AngularLynx's renderer keeps. They count only in development builds. In a production build, they stay at 0.

LynxDevTools.stats

readonly stats: Signal<DevToolsStats>;

The counters as a signal. It doesn't update by itself: call refresh() to read new values.

LynxDevTools.refresh()

refresh(): void;

Updates stats with the current counter values.

LynxDevTools.snapshot()

snapshot(): DevToolsStats;

Returns the current counter values once, without a signal.

LynxDevTools.reset()

reset(): void;

Sets every counter to 0 and updates stats.

LynxPerformance

@Injectable({ providedIn: 'root' })
class LynxPerformance {}

Adds your own named traces and marks to the performance recording that Lynx DevTool (the desktop debugger app) captures. Unlike the counters, it works in every build, not only development builds, so you can trace the build you ship. Every method does nothing when Lynx's tracing API isn't available.

In the web preview, the traces go to the browser's performance timeline instead. Each trace becomes a User Timing measure, and each mark a User Timing mark, with the options in its detail. Chrome DevTools shows them in the Performance panel's Timings track.

LynxPerformance.isRecording()

isRecording(): boolean;

Returns true while a recording is running. In the web preview, it always returns true, since the browser's performance timeline is always on.

LynxPerformance.profileStart()

profileStart(name: string, options?: LynxTraceOptions): void;

Starts a named trace. Pair each call with profileEnd(). Traces nest. See LynxTraceOptions for the options.

LynxPerformance.profileEnd()

profileEnd(): void;

Ends the most recently started trace.

LynxPerformance.profileMark()

profileMark(name: string, options?: LynxTraceOptions): void;

Records a single point in time. It takes the same options as profileStart(), so a flowId links a mark to traces too.

LynxPerformance.profileFlowId()

profileFlowId(): number;

Returns a new ID for linking traces, for example across threads. Returns 0 when tracing isn't available.

Types

DevToolsStats

type DevToolsStats = {
  cdCycles: number;
  elementCreated: number;
  elementRemoved: number;
  flushCount: number;
  lastCdDurationMs: number;
};
FieldDescription
cdCyclesChange detection runs since start or the last reset().
elementCreatedLynx elements created.
elementRemovedLynx elements removed.
flushCountTimes the renderer sent a batch of changes to Lynx.
lastCdDurationMsHow long the most recent change detection run took, in milliseconds, including sending its changes to Lynx. Whole milliseconds on a device, finer in the web preview.

LynxTraceOptions

type LynxTraceOptions = {
  flowId?: number;
  flowIds?: number[];
  args?: Record<string, string>;
};

The options of profileStart() and profileMark(), the same as Lynx's own TraceOption.

OptionDescription
flowIdLinks this trace to the others with the same ID, from profileFlowId(). Ignored when flowIds is set.
flowIdsLinks this trace to several flows at once.
argsValues recorded with the trace. Strings only: Lynx drops any other value, so convert numbers with String() first.