class RequestRecorder

Records the Inertia request lifecycle for the devtools extension, holding the per-request collection state and delegating to {SourceLocator}, {PropClassifier}, {@see Collector} and {IncomingEntryBuilder}.

Properties

protected Collector|null $collector

Methods

void
requestStarted(Request $request)

Stamp the request start time.

void
sharedPropsResolved(object $middleware, array $shared)

Scan the share() method source to resolve per-key line numbers.

void
propsShared(array $keys)

Capture the call site of a share() call and associate it with the given prop keys.

void
pageRendering(string $component, Response $response)

Start collecting the page being rendered.

void
sharedPropsExpanded(array $shared)

Mark which of the page's props are shared, once shared property providers have been expanded into the props they provide.

void
propResolved(string $path, mixed $prop)

Record a resolved prop.

void
propRescued(string $path, mixed $prop)

Record a deferred prop whose resolver threw but was rescued (Inertia::defer(rescue: true)).

void
recordProp(string $path, mixed $prop, bool $rescued = false)

Classify the prop and add it to the collector.

void
pageRendered(Request $request, array $page, array $resolvedProps)

Store the collected payload for the rendered page on the request.

void
respondedWith(Request $request, Response $response)

Record the response sent for the request.

void
recordResponse(Request $request, Response $response)

Stamp the DevTools headers on the response and record its entry.

void
setShareSource(array $keys, array $source)

Set the source location for the given shared prop keys.

array
topLevelSharedKeys(array $sharedProps)

Compute the top-level keys of the currently-shared props for DevTools shared-vs-render annotations.

bool
isInitialHtmlResponse(Request $request, Response $response)

Whether this response is the initial load of an Inertia page. A plain HTML page is left alone: the extension reads the tag as devtools being enabled there, and would warn about a missing interceptor registry that was never going to appear.

void
injectDevToolsIdTag(Response $response, string $id, string $basePath)

Render the entry id into the page, along with the path the app is mounted on. A panel that attaches after the initial load has only the DOM to read, and the entry endpoint lives under that same path.

string
resolveOutgoingParentId(bool $isPrefetch, string $id, string|null $batchId)

Resolve the batch root id sent back to the client.

array
resolveLineage(Request $request, string $id)

Resolve the entry's batch id and the outgoing parent id.

Details

at line 30
void requestStarted(Request $request)

Stamp the request start time.

Parameters

Request $request

Return Value

void

at line 44
void sharedPropsResolved(object $middleware, array $shared)

Scan the share() method source to resolve per-key line numbers.

Parameters

object $middleware
array $shared

Return Value

void

at line 70
void propsShared(array $keys)

Capture the call site of a share() call and associate it with the given prop keys.

Parameters

array $keys

Return Value

void

at line 98
void pageRendering(string $component, Response $response)

Start collecting the page being rendered.

Parameters

string $component
Response $response

Return Value

void

at line 123
void sharedPropsExpanded(array $shared)

Mark which of the page's props are shared, once shared property providers have been expanded into the props they provide.

Parameters

array $shared

Return Value

void

at line 131
void propResolved(string $path, mixed $prop)

Record a resolved prop.

Parameters

string $path
mixed $prop

Return Value

void

at line 141
void propRescued(string $path, mixed $prop)

Record a deferred prop whose resolver threw but was rescued (Inertia::defer(rescue: true)).

It is skipped from the response props before normal metadata collection, so it needs its own hook: capture the defer type/group and flag it rescued, with no resolved value.

Parameters

string $path
mixed $prop

Return Value

void

at line 149
protected void recordProp(string $path, mixed $prop, bool $rescued = false)

Classify the prop and add it to the collector.

Parameters

string $path
mixed $prop
bool $rescued

Return Value

void

at line 176
void pageRendered(Request $request, array $page, array $resolvedProps)

Store the collected payload for the rendered page on the request.

Parameters

Request $request
array $page
array $resolvedProps

Return Value

void

at line 210
void respondedWith(Request $request, Response $response)

Record the response sent for the request.

Parameters

Request $request
Response $response

Return Value

void

at line 228
protected void recordResponse(Request $request, Response $response)

Stamp the DevTools headers on the response and record its entry.

Parameters

Request $request
Response $response

Return Value

void

at line 264
protected void setShareSource(array $keys, array $source)

Set the source location for the given shared prop keys.

Parameters

array $keys
array $source

Return Value

void

at line 280
protected array topLevelSharedKeys(array $sharedProps)

Compute the top-level keys of the currently-shared props for DevTools shared-vs-render annotations.

Parameters

array $sharedProps

Return Value

array

at line 298
protected bool isInitialHtmlResponse(Request $request, Response $response)

Whether this response is the initial load of an Inertia page. A plain HTML page is left alone: the extension reads the tag as devtools being enabled there, and would warn about a missing interceptor registry that was never going to appear.

Parameters

Request $request
Response $response

Return Value

bool

at line 324
protected void injectDevToolsIdTag(Response $response, string $id, string $basePath)

Render the entry id into the page, along with the path the app is mounted on. A panel that attaches after the initial load has only the DOM to read, and the entry endpoint lives under that same path.

Parameters

Response $response
string $id
string $basePath

Return Value

void

at line 363
protected string resolveOutgoingParentId(bool $isPrefetch, string $id, string|null $batchId)

Resolve the batch root id sent back to the client.

Parameters

bool $isPrefetch
string $id
string|null $batchId

Return Value

string

at line 377
protected array resolveLineage(Request $request, string $id)

Resolve the entry's batch id and the outgoing parent id.

Parameters

Request $request
string $id

Return Value

array