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

@aims-api/ui-sdk

v0.2.0

Published

A React component library to quickly integrate AIMS API features into your frontend application.

Readme

AIMS UI SDK

A React component library to quickly integrate AIMS API features into your frontend application.

Ask a Question

Installation

To work with the package you need to have npm (or other package manager) installed. The library is built for React applications only.

  npm install @aims-api/ui-sdk

Segment Tool component

It fetches data for audio seed, displays waveform, controls playback of audio, and also provides a tool for selecting a segment.

Features

  • Waveform rendering (YouTube, Spotify, SoundCloud, TikTok, Vimeo, Apple Music and internal tracks)
  • Playback control
  • Segment selection

Requirements

  • React 18+
  • Node.js server environment (e.g. Next.js server, Express.js, Hono...) to setup API handlers for your app.
  • Install @aims-api/aims-node to work seamlessly with AIMS API in Node.js environment, used mainly for fetching link and waveform data. The package also provides types that are used in the client components.

Getting Started

Prepare two async handlers for data fetching:

  • getSeed (required) a callback used for feeding the SegmentTool with data. It has to return a promise with the seed data (see required type structure). This callback needs to make a request (see link-info in examples folder) with some private (env) variables to ensure the handler to work as intended. In case of the promise rejection, you need to propagate message about component malfunction to the user.
  • fetchWaveformUrl (optional) during initialization it fetches waveform file from AIMS API, returns a promise with url, which is eventually read and rendered by peaks.js library. If not provided, waveform will be rendered only for sources that provide an audio file - SoundCloud, TikTok, Apple Music, internal tracks.

The component is exported as a React hook useSegmentTool, which returns:

  • component SegmentTool (React UI Component)
  • segmentToolConfig (JS Object)
  type SegmentToolConfig = {
    isAudioPlaying: boolean;
    segmentRange: { from: number | null; to: number | null}
  }
  • togglePlayback (callback to play or pause audio)

It is important to memoize SegmentTool component to avoid unnecessary re-renders. Also have a look at SegmentToolComponentProps type to ensure valid prop structure.

// Only property that matters for memoization is an injected seed. If the value is null, we do not render this component.
const MemoizedSegmentTool = memo(SegmentTool, (prevProps, newProps) => prevProps.seed === newProps.seed)

All useful types are located in /src/types/SegmentTool.ts. They are also exported in root file, so you can work with them as is shown in the example bellow.

// To work with tracks from AIMS search results, we call them internal tracks, set seed properties as following
const internalTrackSeed: DiscoverySearch = {
  input: DiscoveryInputs.INTERNAL,
  title: 'track name' // string,
  internalTrack: {
    id: 'trackId', // string OR number 
    duration: 120, // number OR null
    audioUrl: 'AUDIO_URL', // mp3 or other audio file supported by peaks.js
    waveformUrl: 'WAVEFORM_URL', // optional parameter (if not provided waveform will be calculated from audio
    // file), url to "dat" file is recognized by peaks.js
  }
}

// In order to render uploaded track, you need to upload file into browser and use this seed structure
const uploadedTrackSeed: DiscoverySearch = {
  input: DiscoveryInputs.UPLOAD,
  isSegmentToolAvailable: true,
  title: 'uploaded track' // string,
  uploadInfo: {
    audioUrl: 'AUDIO_URL' // string e.g. 'blob:...',
    format: 'mp3', // string,
    duration: 120 // number OR null,
  },
}

Usage Example

  • Full example is available in /examples/basic including api routes (Next.js notation)
import { ThemeProvider, useSegmentTool, type DiscoverySearch } from '@aims-api/ui-sdk'

/* type DiscoverySearch is located in /src/types/SegmentTool.ts */

const MyComponent = () => {
  const { segmentToolConfig, SegmentTool, togglePlayback } = useSegmentTool()
  const { isAudioPlaying, segmentRange } = segmentToolConfig

  return (
    <>
      <ThemeProvider theme={{
        /* structure corresponds with MUI theming (MUI is not part of this package though), 
        you may also change only one of the colors 
            
            palette: {
              background: {
                default: string (e.g. hex, rgb)
              }
              primary: {
                main: string,
                light: string,
                dark: string,
              }
            }
          */
      }}>
      <SegmentTool
        getSeed={/* () => Promise<DiscoverySearch | null> */}
        fetchWaveformUrl={/* optional, (url: string) => Promise<string> */}
        options={{ // all params are optional
          initialRange: {/* hardcoded range; from: number, to: number */},
          playButtonHidden: {/* hide play button; boolean */},
          playheadInitHidden: {/* hide playhead in its initial position (workaround 
          // with palette.background.default color); boolean */},
          segmentSelectionDisabled={/* disable selecting segment; boolean */}
        }}
      />
      </ThemeProvider>
      <button onClick={togglePlayback}>Play or Pause Audio</button>
      {/* Access configuration */}
      <div>Audio is playing: {isAudioPlaying}</div>
      <div>Selection starts: {segmentRange.from}, ends: {segmentRange.to}</div>
    </>
  )
}

Component state changes aren’t exported because our application does not interact with them. Upon receiving a seed, the waveform component initially displays a skeleton placeholder. Once the waveform data has been processed by the peaks.js library, the waveform appears instantly.

License

See LICENSE and NOTICE for more information.