npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@docmaps/widget

v1.12.1

Published

[![npm version](https://badge.fury.io/js/@docmaps%2Fwidget.svg)](https://badge.fury.io/js/@docmaps%2Fwidget)

Downloads

4

Readme

Official Docmaps Widget

npm version

An embeddable widget for displaying Docmaps data, built with Lit and D3.

To see the widget in action, check out the Docmap explorer demo site!

Usage

The widget can be retrieved via CDN, or via NPM if your project already uses NPM.

Retrieving via CDN

You can directly pull in the widget in an HTML file without installing anything like so:

<head>
  <script type='module' src='https://cdn.jsdelivr.net/npm/@docmaps/widget@latest/dist/index.min.js'></script>
</head>
<body>
<docmaps-widget doi='doi-to-render' serverurl='https://example.com'></docmaps-widget>
</body>

Installing with NPM

If your project already uses NPM, you can install the widget like so:

npm install @docmaps/widget

Then, add the widget to your page:

<script>
  import '@docmaps/widget';
</script>

<docmaps-widget doi="doi-to-render" serverurl="https://example.com"></docmaps-widget>

Supported attributes

These attributes can be added to the <docmaps-widget> tag to configure the widget's behavior.

| Attribute | Description | |-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | doi | The DOI of the paper to render | | serverurl | The URL of the server from which the docmap will be fetched. The widget will make a request to this server's GET /docmap_for/doi?subject={doi} endpoint, which must be implemented by the server in accordance with the official Docmaps API spec. |

If you prefer to pass a docmap directly to the widget, you must do so after the widget has been mounted, like so:


<head>
  <script type='module' src='https://cdn.jsdelivr.net/npm/@docmaps/widget@latest/dist/index.min.js'></script>
</head>
<body>
<docmaps-widget id='my-widget'></docmaps-widget>
</body>

<script>
  customElements.whenDefined('docmaps-widget') // wait for the custom docmaps-widget element to be defined
    .then(() => {
      const widgetElement = document.getElementById('my-widget');
      widgetElement.docmap = {
        // docmap here
      };
    });
</script>

For examples of docmaps to feed into the widget here, see the examples directory.

Screenshots

Graph view:

Screenshot of the widget's graph view

Clicking a node opens the detail view:

Screenshot of the widget's detailview

Development

Running the server locally

pnpm run dev

This starts the server on http://localhost:5173

Running the tests

The first time you run the tests, you will need to install browsers for Playwright to use

pnpm run install:browsers

All tests

pnpm run test

Unit tests

pnpm run test:unit

Integration tests

To see the tests run in step-by-step, you can open the Playwright UI like this. The Playwright UI is an amazing tool because it lets you see screenshots of each step of the test, and it automatically reruns the tests when you make changes.

pnpm run test:integration:ui

Alternatively, you can run the tests headlessly and see results in the terminal:

pnpm run test:integration

By default, the tests only run in chromium locally. To run in chromium, firefox, and webkit, you can run:

# Headless
pnpm run test:integration:all-browsers

# With UI
pnpm run test:integration:ui:all-browsers