NativeScript / NativeScript/docs

Document hooking into the Network panel of DevTools (for plugins)

Abierto
#38 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
JavaScript
Estrellas
17
Forks
31
Merge medio
8 h 51 min
PR fusionados (30 d)
2

Descripción

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 the global.__inspector object 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.__inspector object is available, and whether the DevTools are connected, as shown above. Build a ResponseData-compliant object, as declared in the debugger module. ResponseData contains 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)
    

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza localizando la documentación actual de Debugging y las interfaces actuales de debugger.ts a las que se hace referencia en el contenido antiguo. Revisa los callbacks del panel Network y sustituye los enlaces y ejemplos obsoletos por las indicaciones más recientes de la API principal. Se considera terminado cuando exista una guía independiente para autores de plugins que explique correctamente el ciclo de vida actual de las solicitudes y las respuestas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
devtools, javascript, typescript
Área
developer-experience, documentation, networking
Tipo de issue
Documentación
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.