Skip to content

Dev tools · Modules

8 modules · 43 exports · 1 repository · 0 e2e tests · 0 routes

Who imports who · hover a node
Depends onDev tools modulesUsed byLobbyProgression.serverLobbySetlobbiesTournament.servertourna…BrowserState5 exportsConsoleCapture8 exportsEventsRecorder4 exportsPageInspection4 exportsRequestLog.server10 exp…Scenarios.server3 expor…ServerConsole.server5 …ServerConsoleFeed4 expo…Components5 filesRoutes5 filesOther1 file

BrowserState

app/features/dev-tools/core/BrowserState.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 component

Types

type

ParamStatus

no JSDoc:8
export type ParamStatus =
	| "ok"
	/** Not in the URL, the default applies. */
	| "default"
	/** In the URL but equal to the default, the canonical URL leaves it out. */
	| "redundant"
	/** In the URL in another encoding than the canonical one, e.g. compressed. */
	| "non-canonical"
	/** In the URL but failing to decode, so the default applies. */
	| "invalid";
Only used inside the module

Functions & values

function

describeSearchParams

:37

Explains the URL's search params: each definition declaring one of them, in use by the page (read by a mounted component or revalidating a matched route) or passing isPageSource (typically the page's feature folders) with every param's decoded value and status, and the URL's params no loaded definition declares. Definitions in use are grouped into the page's own (page) and those declared outside feature folders (shared), the rest are unused.

export function describeSearchParams({
	search,
	definitions,
	isPageSource,
	isRouteRevalidator,
}: {
	search: string;
	definitions: RegisteredSearchParams[];
	isPageSource: (source: string) => boolean;
	/** Whether a matched route exports the definition's `shouldRevalidate`. */
	isRouteRevalidator: (
		definition: SearchParams.SearchParamsDefinition<any>,
	) => boolean;
})
Unit tests (4)
function

declaredName

:104

The variable a definition is assigned to, read from the served module's code at the line of its define() call e.g. userBuildsSearchParams. Null when the call is not assigned to one.

export function declaredName(moduleCode: string, line: number)
Unit tests (1)
function

describeStorage

:116

Pairs each web storage entry with the persisted state definition owning it (if any loaded definition does) and says whether its value decodes. Definitions with nothing stored are listed apart, their default applies.

export function describeStorage({
	entries,
	definitions,
}: {
	entries: Array<{ storage: "local" | "session"; key: string; raw: string }>;
	definitions: AnyPersistedDefinition[];
})
Unit tests (1)
function

definitionKey

:165

The storage key, or prefix for a keyed family, a definition writes to.

export function definitionKey(definition: AnyPersistedDefinition)

ConsoleCapture

app/features/dev-tools/core/ConsoleCapture.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 module2 components

Types

type

CapturedLevel

no JSDoc:3
export type CapturedLevel = "error" | "warn";
Only used inside the module
type

CapturedSource

no JSDoc:5
export type CapturedSource =
	| "console.error"
	| "console.warn"
	| "uncaught error"
	| "unhandled rejection";
Only used inside the module

Functions & values

function

install

:31

Starts recording console errors & warnings and uncaught errors for the dev toolbar. Installed from entry.client.tsx before hydration, so that hydration mismatches are caught too. Idempotent.

export function install()
function

getSnapshot

:70

Recorded entries, most recently reported first.

export function getSnapshot()
function

subscribe

:75

For useSyncExternalStore. Returns an unsubscribe function.

export function subscribe(listener: () => void)
function

clear

:83

Forgets every recorded entry.

export function clear()
function

isHydrationMessage

:89

Whether the message is React telling the server and client render disagreed.

export function isHydrationMessage(message: string)
Unit tests (1)
function

formatConsoleArgs

:94

Joins console arguments the way the console prints them, filling in %s-style substitutions and dropping %c styles.

export function formatConsoleArgs(args: unknown[])
Unit tests (1)

EventsRecorder

app/features/dev-tools/core/EventsRecorder.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 component

Functions & values

function

install

:19

Starts recording the server events the page's SSE connection receives and its connection state changes. Idempotent.

export function install()
function

getSnapshot

:30

Recorded entries, newest first.

export function getSnapshot()
function

subscribe

:35

For useSyncExternalStore. Returns an unsubscribe function.

export function subscribe(listener: () => void)
function

clear

:43

Forgets every recorded entry.

export function clear()

PageInspection

app/features/dev-tools/core/PageInspection.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 component

Types

interface

FoundPermissions

no JSDoc:3
export interface FoundPermissions {
	/** Where in the loader data the entity is, e.g. `tournament.ctx`. */
	path: string;
	/** A human readable hint of the entity: its name, title or id. */
	label: string | null;
	permissions: Record<string, number[]>;
}
Only used inside the module

Functions & values

function

findPermissions

:15

Every server computed permissions object (a record of permission name to user ids, see docs/dev/permissions.md) found anywhere in the data, outermost first.

export function findPermissions(data: unknown): FoundPermissions[]
Unit tests (2)
function

jsonByteSize

:54

Size of the value as JSON in bytes, roughly what it weighs on the wire.

export function jsonByteSize(value: unknown)
function

formatBytes

:63

Bytes as a short human readable string, e.g. 12.3 KB.

export function formatBytes(bytes: number)
Unit tests (1)

RequestLog

serverapp/features/dev-tools/core/RequestLog.server.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
2 routes1 module1 component1 other

Types

type

RequestKind

no JSDoc:11
export type RequestKind = "document" | "data" | "action" | "resource";
interface

LoggedRequest

no JSDoc:20
export interface LoggedRequest {
	id: number;
	method: string;
	path: string;
	kind: RequestKind;
	/** `null` while in flight or when handling it threw. */
	status: number | null;
	startedAt: number;
	durationMs: number | null;
	queries: LoggedQuery[];
	/** Queries past `MAX_QUERIES_PER_REQUEST`, counted but not kept. */
	droppedQueryCount: number;
}
Only used inside the module

Functions & values

function

track

:41

Runs handle with every database query it makes recorded against the request, keeping the latest requests in memory.

export async function track(
	request: Request,
	handle: () => Promise<Response>,
): Promise<Response>
Unit tests (4)
function

recordQuery

:77

Records a Kysely log event against the request being tracked, a no-op outside of {@link track}.

export function recordQuery(event: LogEvent)
function

currentPath

:95

Method and path of the request being tracked, null outside of {@link track}.

export function currentPath()
function

describeRequest

:103

Method and path as {@link currentPath} shows them.

export function describeRequest(request: Request)
function

recent

:108

The tracked requests, newest first.

export function recent()
function

clear

:113

Forgets every tracked request.

export function clear()
function

summary

:118

The request without its queries, small enough to list every tracked request at once.

export function summary({
	queries,
	droppedQueryCount,
	...request
}: LoggedRequest)
function

repeatedQueries

:136

Statements the request ran at least REPEATED_QUERY_THRESHOLD times, the tell-tale sign of an N+1. Most repeated first.

export function repeatedQueries(request: Pick<LoggedRequest, "queries">)
Unit tests (1)

Scenarios

serverapp/features/dev-tools/core/Scenarios.server.ts

No overview comment at the top of the file.

Imports
LobbyProgression.serverLobbySetTournament.server
Used by
2 routes

Functions & values

function

list

:1085

Every scenario with its parameters, in the order shown in the dev toolbar.

export function list()
function

run

:1100

Builds the scenario's state out of fresh users through the factories, leaving existing data untouched, with web pushes off. Parameters left out take their default, numbers may come as strings (from the CLI). The server's caches are not refreshed, the caller does that.

export async function run(
	scenarioId: string,
	rawParams: Record<string, unknown> = {},
): Promise<
	| { status: "ok"; result: ScenarioResult }
	| { status: "unknown-scenario" }
	| { status: "invalid-params"; message: string }
>
Unit tests (11)
function

recentRuns

:1134

The latest scenario runs of this server process, newest first.

export function recentRuns()

ServerConsole

serverapp/features/dev-tools/core/ServerConsole.server.ts

No overview comment at the top of the file.

Imports
ConsoleCaptureRequestLog.server
Used by
1 route1 module1 other

Types

interface

ServerConsoleEntry

no JSDoc:11
export interface ServerConsoleEntry {
	id: number;
	level: "error" | "warn";
	message: string;
	/** The request being handled when it was logged, if any. */
	path: string | null;
	/** How many times the identical message was logged. */
	count: number;
	firstAt: number;
	lastAt: number;
}

Functions & values

function

install

:41

Starts recording the dev server's console errors & warnings, which includes errors thrown by loaders and actions. The console is patched once; record is swapped on every call so the latest evaluation of this module (and its request log) does the recording after the dev server re-evaluates modules.

export function install()
Unit tests (8)
function

withRequest

:64

Runs log with what it logs attached to the request, for code React Router calls outside of the request's async context (handleError).

export function withRequest(request: Request, log: () => void)
function

recent

:70

Recorded entries, most recently logged first.

export function recent()
function

clear

:75

Forgets every recorded entry.

export function clear()

ServerConsoleFeed

app/features/dev-tools/core/ServerConsoleFeed.ts

No overview comment at the top of the file.

Imports
no other modules
Used by
1 component

Functions & values

function

install

:16

Starts polling the dev server's console errors & warnings logged since this page loaded, while the tab is visible. Idempotent.

export function install()
function

getSnapshot

:27

Polled entries, most recently logged first.

export function getSnapshot()
function

subscribe

:32

For useSyncExternalStore. Returns an unsubscribe function.

export function subscribe(listener: () => void)
function

clear

:40

Forgets the entries, on the server too, so for every tab.

export async function clear()