Skip to content

v2.0.0

Latest

Choose a tag to compare

@jdesrosiers jdesrosiers released this 19 Nov 22:25

A rewrite of @hyperjump/browser. The documentation is now at https://hyperjump.io/browser/.

What's new

  • Hyperjump sessions. A session holds its configuration and fetches the way a web browser does. Requests belong to it, the way a page load's do. See Hyperjump sessions.
  • Safe with documents you don't control. A session fetches only the URLs its allowRetrieval allows, and headers like credentials go only to the URLs they're for. See What a session can fetch.
  • A stack of layers. Each request goes through layers you choose, like an RFC 9111 HTTP cache and a scheduler, and ends at a transport chosen by URL scheme. Write your own layers. See Layers.
  • Selectors and walks. jrefSelect, jrefVisit, and jrefFind find values in a document and follow only the references they need. See Read values.
  • JSON and JRef parsers with positions. They never throw, recover from syntax errors, and give every value its place in the text. They work as unified plugins too. See Parse JSON and JRef.
  • Registries. A session answers documents your app already has without fetching them. See Registries.
  • Tracing. See what a session fetched and why, as a waterfall or a HAR file. See Tracing.
  • JSON is built in, beside JRef.

Breaking changes

  • A session fetches only the URLs its allowRetrieval allows. By default, that's the working directory in Node.js and the page's origin in a browser.
  • get is browse, which takes a Hyperjump session and gives you a target instead of a Browser. get(url, browser) is browse(session, url, { referencedFrom }).
  • value, typeOf, has, step, iter, values, entries, and keys are the jref functions, like jrefValue and jrefStep. They take the session first, return promises, and aren't curried. jrefValue only gives you a string, number, boolean, or null. There's no length.
  • Media type plugins are in the session's mediaTypes instead of global, and a plugin's parse returns a document whose root is a JSON AST node.
  • URI scheme plugins are fetchers in the transport, like defaultTransport({ "urn:": fetcher(fn) }).
  • The error classes are gone. Errors have a cause.code, like "ERR_HTTP_STATUS", and the URL that failed as their url.
  • @hyperjump/browser/jref is gone. fromJref parses JRef into a tree.
  • It needs Node.js 24 or later, or Chrome 126, Edge 126, Firefox 131, or Safari 18.4 or later.

See Migrate from v1 for each change and what to do about it.