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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@kretep/bgc-viewer-components

v0.2.1

Published

Reusable web components for visualizing biosynthetic gene clusters

Downloads

10

Readme

BGC Viewer Web Components

Framework-agnostic web components for visualizing biosynthetic gene cluster data.

For more details about the project structure and the stand-alone BGC Viewer, have a look at the project's main readme.

Installation

npm install @kretep/bgc-viewer-components d3

Note: D3.js v7+ is a peer dependency and must be installed separately.

Quick Start

Using with ES Modules

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="node_modules/@kretep/bgc-viewer-components/dist/web-components/style.css">
</head>
<body>
  <bgc-region-viewer-container id="viewer"></bgc-region-viewer-container>

  <script src="https://d3js.org/d3.v7.min.js"></script>
  
  <script type="module">
    import { JSONFileProvider } from '@kretep/bgc-viewer-components';
    
    // Load your antiSMASH JSON data
    const response = await fetch('path/to/antismash-output.json');
    const data = await response.json();
    
    // Create a data provider
    const provider = new JSONFileProvider(data);
    
    // Get the viewer element and configure it
    const viewer = document.getElementById('viewer');
    viewer.dataProvider = provider;
    viewer.setAttribute('record-id', data.records[0].id);
  </script>
</body>
</html>

Using with a Bundler (Webpack, Vite, etc.)

import '@kretep/bgc-viewer-components';
import '@kretep/bgc-viewer-components/style.css';

// The web components are now registered and ready to use

Components

<bgc-region-viewer-container>

The main container component that handles data loading and region selection.

Properties:

  • dataProvider - Instance of a data provider (JSONFileProvider or BGCViewerAPIProvider)
  • record-id - ID of the record to display
  • record-data - Full record metadata (optional, for API provider)
  • initial-region-id - ID of region to select initially (optional)

Events:

  • region-changed - Emitted when user selects a different region
  • annotation-clicked - Emitted when user clicks an annotation
  • error - Emitted when an error occurs

Data Providers

JSONFileProvider

Load data directly from antiSMASH JSON output files:

import { JSONFileProvider } from '@kretep/bgc-viewer-components';

const response = await fetch('data.json');
const jsonData = await response.json();
const provider = new JSONFileProvider(jsonData);

BGCViewerAPIProvider

Connect to a BGC Viewer backend API:

import { BGCViewerAPIProvider } from '@kretep/bgc-viewer-components';

const provider = new BGCViewerAPIProvider({
  baseURL: 'http://localhost:5000'
});

TrackViewer

The package also exports a standalone TrackViewer class for creating custom genomic track visualizations with D3.js.

Basic Usage

import { TrackViewer } from '@kretep/bgc-viewer-components';

const viewer = new TrackViewer({
  container: '#viewer-container',
  domain: [0, 100],
  trackHeight: 30
});

viewer.setData({
  tracks: [
    { id: 'genes', label: 'Genes', height: 40 }
  ],
  annotations: [
    {
      id: 'gene1',
      trackId: 'genes',
      type: 'arrow',
      classes: ['gene'],
      label: 'geneA',
      start: 10,
      end: 30,
      direction: 'right'
    }
  ]
});

TrackViewer API

See the TrackViewer TypeScript types for the complete API documentation.

Example

See the demos directory for a complete working example.

Requirements

  • D3.js v7 or higher (peer dependency)
  • Modern browser with Web Components support

Development

Building from Source

# Install dependencies
npm install

# Build web components
npm run build:web-components

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

Project Structure

  • src/components/ - Vue components (RegionViewer, RegionViewerContainer)
  • src/services/dataProviders/ - Data provider implementations
  • src/TrackViewer.ts - TrackViewer class for genomic track visualization
  • src/web-components.ts - Web components entry point
  • dist/web-components/ - Built web components (after build)
  • demos/ - Example usage demonstrations

Running the Demo

See the demo README for instructions on running a demo of the viewer component.

License

Apache-2.0

Links