NativeScript / NativeScript/docs
Document hooking into the Network panel of DevTools (for plugins)
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 17
- Forks
- 31
- Avg merge
- 8h 51m
- Merged PRs (30d)
- 2
Description
There are global APIs to list Netowork requests in the DevTools Network panel, we should document these in a guide for plugin authors. This used to be part of the "Debugging" docs, however it doesn't quite fit there.
The content itself needs to be reviewed and updated to reflect latest core (the API is mostly unchanged, but the docs contain old links).
Old content for reference
Network requests in plugins - Note: The following content concerns only plugin authors who wrap and expose Android (Network agent in DevTools not yet supported with a public API in the iOS runtime) http functionalities. To make your http functionality debuggable, there are callbacks you need to call at certain times of the lifecycle of the network request, following a specific protocol. For your convenience, we've exposed callbacks and TypeScript interfaces to facilitate sending information to the Network agent.
- Immediately before making the request:
Check if theglobal.__inspectorobject is available, and whether the DevTools are connected:
if (global.__inspector && global.__inspector.isConnected) {
}
Build a RequestData-compliant object, as declared in the debugger module. RequestData contains the minimum subset of properties needed to display request entries in the Network panel. Finally call to the runtime-exposed callback:
global.__inspector.requestWillBeSent(requestData)
-
When a response is received:
Check if the
global.__inspectorobject is available, and whether the DevTools are connected, as shown above. Build a ResponseData-compliant object, as declared in the debugger module.ResponseDatacontains the minimum subset of properties needed to display the response for a completed request.Build a LoadingFinishedData compliant object, as declared in the debugger module. The object notifies the Network agent that a request has completed, as well as the time spent.
Build a SuccessfulRequestData-compliant object, as declared in the debugger module. The object contains the response data, in a string format, the Id of the original request the response data corresponds to, and information whether the content should be base64-encoded, or not.
Finally call the following runtime-exposed callbacks:
global.__inspector.responseReceived(responseData) global.__inspector.loadingFinished({ requestId: requestIdStr, timestamp: getTimeStamp(), }) global.__inspector.dataForRequestId(successfulRequestData)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the current Debugging documentation and the current debugger.ts interfaces referenced in the old content. Review the Network panel callbacks and replace outdated links and examples with the latest core API guidance. Done means a standalone guide for plugin authors accurately explains the current request and response lifecycle.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- devtools, javascript, typescript
- Domain
- developer-experience, documentation, networking
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100