NativeScript / NativeScript/docs

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

Aperta
#38 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
JavaScript
Stelle
17
Fork
31
Merge medio
8h 51m
PR unite (30g)
2

Descrizione

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)
    

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia individuando la documentazione attuale di Debugging e le interfacce attuali di debugger.ts a cui fa riferimento il vecchio contenuto. Esamina i callback del pannello Network e sostituisci i link e gli esempi obsoleti con le indicazioni più recenti sull’API principale. Il lavoro è completato quando una guida autonoma per gli autori di plugin spiega accuratamente il ciclo di vita attuale delle richieste e delle risposte.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
devtools, javascript, typescript
Ambito
developer-experience, documentation, networking
Tipo di issue
Documentazione
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.