Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

http-component

A set of elements that display HTTP messages the way they travel on the wire: a request line or status line, then headers, then a body. It does not read Vanilla Breeze tokens: it has its own light and dark palettes, which you can override with CSS custom properties.

At a glance

Package@profpowell/http-component 0.3.0
Elements<http-transaction> (also registered as <http-console>), <http-request>, <http-response>, <http-waterfall>, <http-message>
Renders inShadow DOM
Sourcegithub.com/ProfPowell/http-component
Documentationprofpowell.github.io/http-component
LicenceMIT
In Vanilla BreezeNot bundled. Load it yourself.

Install

From a CDN. One script defines every element. There is no stylesheet to load.

Or from npm:

Demo

A request and its response in one <http-transaction>, then four requests on a timeline in <http-waterfall>. All of the data is written in the page; nothing is fetched.

Usage

Show a request and response pair by setting the data property of <http-transaction>. A body is a string; when the Content-Type header is JSON, HTML, CSS or JavaScript the body is syntax highlighted.

Without JavaScript of your own, pass the same objects as JSON in the request and response attributes. Use highlight to mark a part and box to draw a labeled border around it.

Show one message alone with <http-request> or <http-response>. Here the section names have no request- or response- prefix.

Show several requests on a timeline by setting the exchanges property of <http-waterfall>. Each exchange is a request, a response and a timing object in milliseconds.

Reference

Attributes

AttributeApplies toValuesDefaultPurpose
themeAll elementslight, dark, autoautoColor palette. With auto or no value, the element checks the operating system color preference once, when it is added to the page, and rewrites the attribute to light or dark.
requesthttp-transaction, http-requestJSON objectNoneThe request: method, url, and optional httpVersion, headers, body. The data property wins when both are set.
responsehttp-transaction, http-responseJSON objectNoneThe response: status, statusText, and optional httpVersion, headers, body.
highlighthttp-transaction, http-request, http-responseComma-separated section namesNoneMarks the named sections. See the section names below.
boxhttp-transaction, http-request, http-responseComma-separated section namesNoneDraws a labeled border around the named sections.
show-headerhttp-request, http-responsefalse to hideShownShows or hides the "Request" or "Response" title bar.
viewhttp-waterfalllist, duration, waterfallChosen by the element, usually durationDisplay mode. Without the attribute, resources mode starts in waterfall and other modes start in duration.
requestshttp-waterfallJSON array of exchangesNoneThe exchanges to list, as an attribute. The exchanges property does the same from JavaScript.
capturehttp-waterfalltrue or emptyOffRecords every fetch() and XMLHttpRequest call the page makes and lists it.
resourceshttp-waterfallBooleanOffLists the requests the page itself made (document, stylesheets, scripts, images, fonts), read from the browser's Navigation Timing and Resource Timing data. No headers or bodies are available in this mode.
filterhttp-waterfallURL pattern, * as wildcardNoneLimits captured or listed requests to matching URLs.
max-entrieshttp-waterfallNumber100The most exchanges kept.
explorerhttp-waterfallBooleanClosedOpens the request builder, a form that sends a real request and adds the result to the list.

Section names for highlight and box

On http-transactionOn http-request or http-responsePart
request-linerequest-lineThe first line of the request: method, URL and version.
response-linestatus-lineThe first line of the response: version, status code and reason.
request-headers, response-headersheadersAll headers.
request-header:accept, response-header:locationheader:acceptOne header, by name. Case does not matter.
request-body, response-bodybodyThe body.

Methods and properties

MemberApplies toPurpose
datahttp-transactionAn object with request and response. Setting it renders again.
datahttp-request, http-responseThe request or response object.
headers, bodyhttp-messageAn object of header names and values, and a body string. This element shows headers and a body with no first line, and has two slots, before-headers and after-body.
exchangeshttp-waterfallAn array of exchanges, each with request, response and timing (startTime, endTime, duration).
viewhttp-waterfallThe current display mode.
startCapture(), stopCapture()http-waterfallStart or stop recording the page's fetch() and XMLHttpRequest calls.
togglePause()http-waterfallPause or resume recording.
clearExchanges()http-waterfallEmpty the list.
startResources(), stopResources()http-waterfallStart or stop listing the page's own requests.
toggleExplorer()http-waterfallOpen or close the request builder.

Events

All four are fired on <http-waterfall>. They do not bubble, so listen on the element itself.

EventDetailFired when
request-sent{ method, url, headers, body }The request builder sends a request.
response-receivedThe exchange: { request, response, timing }The request builder receives a response.
request-error{ error }The request builder's request fails.
resources-observed{ exchanges }The resources mode adds a batch of entries.

CSS custom properties

Each element declares its colors as custom properties on its own host. These are the main ones. Message elements also define variables for HTTP methods (--method-get, --method-post and so on), status classes (--status-success, --status-redirect, --status-client-error, --status-server-error) and body syntax colors (--json-*, --html-*, --css-*, --js-*).

PropertyApplies toDrives
--bg-primaryhttp-transaction, http-waterfallOuter background.
--bg-secondaryhttp-request, http-response, http-waterfallMessage panel background; secondary surfaces in the waterfall.
--bg-headerhttp-request, http-responseTitle bar background. The title text is always white.
--border-colorAll elementsBorders.
--text-primaryAll elementsMain text.
--text-secondaryhttp-waterfallSizes, durations and other secondary text.
--text-emptyhttp-transaction, http-request, http-responseThe "No data" message.
--header-name, --header-valuehttp-request, http-response, http-messageHeader names and values.
--url-color, --version-colorhttp-requestThe URL and the protocol version in the request line.
--button-primary-bghttp-waterfallPrimary buttons, such as the active view and Send.

The http-component API reference has the full detail.

With Vanilla Breeze

Version 0.3.0 reads no Vanilla Breeze token. Every color is a fixed value in one of two built-in palettes, and the fonts are fixed too (Courier New for messages, the system sans-serif stack for the waterfall).

The palette is chosen in this order:

  1. The theme attribute, when it is light or dark.
  2. Otherwise the operating system color preference, read once when the element is added to the page.

The elements do not look at the data-mode attribute that Vanilla Breeze uses to force light or dark mode. If your page sets data-mode, copy it to the theme attribute yourself:

To use Vanilla Breeze colors, set the component's custom properties on the element from page CSS. A rule in the page wins over the defaults the element sets on itself.

This reaches <http-request> and <http-response> that you write in the page. It does not reach the ones inside <http-transaction> or <http-waterfall>: those live in a shadow tree and set the same properties again on themselves. On <http-transaction> only the outer --bg-primary can be changed this way. For full control of colors, place a request and a response side by side yourself.

Accessibility

↑