NativeScript / NativeScript/docs

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

Ouverte
#38 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Personne n'a encore pris cette issue.

Langage dominant
JavaScript
Étoiles
17
Forks
31
Merge moyen
8 h 51 min
PR mergées (30 j)
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 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)
    

Guide de contribution

Ouvrir le guide de contribution

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Piste de recherche

Commencez par localiser la documentation actuelle de Debugging et les interfaces actuelles de debugger.ts référencées dans l’ancien contenu. Examinez les callbacks du panneau Network et remplacez les liens et exemples obsolètes par les indications les plus récentes concernant l’API principale. Le travail est terminé lorsqu’un guide autonome destiné aux auteurs de plugins explique correctement le cycle de vie actuel des requêtes et des réponses.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
devtools, javascript, typescript
Domaine
developer-experience, documentation, networking
Type d'issue
Documentation
Difficulté
3/5
Temps estimé
1-2 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
45/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.