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

@cxing/cdg-loader

v1.2.0

Published

CD+G track loading, archive extraction, and worker transport utilities.

Readme

@cxing/cdg-loader

Loads browser-supported media and karaoke inputs (zip/file/url/blob/arrayBuffer) into one normalized track payload.

Use this package when you want a stable pre-player loading contract and metadata extraction.

Install

pnpm add @cxing/cdg-loader

Minimal Usage

import { createLoader } from '@cxing/cdg-loader';

const loader = createLoader();

const loadedTrack = await loader.load({
  input: { kind: 'file', file: selectedFile },
  options: { debug: false },
});

console.log(loadedTrack.trackId);
console.log(loadedTrack.metadata.title, loadedTrack.metadata.artist);
console.log(loadedTrack.mediaKind, loadedTrack.mediaMimeType);
console.log(loadedTrack.audioBuffer, loadedTrack.cdgBytes);

Input Kinds

  • url
  • file
  • blob
  • arrayBuffer

Output Shape

load(...) returns LoadedTrack with:

  • trackId
  • sourceSummary
  • audioBuffer (ArrayBuffer)
  • mediaKind ('audio' | 'video')
  • mediaMimeType (string)
  • audioMimeType (string)
  • hasGraphics (boolean)
  • cdgBytes (Uint8Array | null)
  • metadata (title, artist, album)
  • warnings

audioMimeType is deprecated and retained for backward compatibility. Prefer mediaKind and mediaMimeType in new code.

Browser Codec Support

  • Recommended for broad compatibility: MP4 with H.264 video and AAC audio.
  • WebM is commonly supported in Chrome and Firefox, with more limited Safari support depending on codec details.
  • AVI, MOV, MKV, and similar containers are best-effort only; actual browser support depends on the embedded codecs, not just the file extension.
  • The loader performs browser capability checks, but final decode validation for video happens in @cxing/cdg-player.

Probe API

Use probe(...) to preflight archive structure before full load:

const probe = await loader.probe({
  input: { kind: 'file', file: selectedFile },
});

console.log(probe.karaokeLikely, probe.audioLikely, probe.discoveredEntries);

Public Constants And Functions

All items below are exported from @cxing/cdg-loader and supported for direct developer use.

Loader Creation And Transport

  • createLoader({ debug? }): creates a CdgLoader instance.
  • loadInWorker({ input, options? }): loads input through worker transport.
  • CdgLoader#load({ input, options? }): loads and normalizes media payload.
  • CdgLoader#probe({ input, options? }): probes likely karaoke/media entries without full load.
  • CdgLoader#cancel({ requestId }): cancels one in-flight request.
  • CdgLoader#dispose(): aborts all in-flight requests and clears internal state.

Media Constants

  • SUPPORTED_AUDIO_EXTENSIONS: readonly tuple of recognized audio extensions.
  • SUPPORTED_VIDEO_EXTENSIONS: readonly tuple of recognized video extensions.
  • SUPPORTED_AUDIO_EXTENSION_SET: Set<string> for quick runtime membership checks.
  • SUPPORTED_VIDEO_EXTENSION_SET: Set<string> for quick runtime membership checks.

Public Utility Functions

  • extensionFromName({ name }): returns lowercase extension or null.
  • baseNameFromPath({ name }): strips path segments and returns base file name.
  • stemFromName({ name }): returns file name without extension.
  • inferMimeTypeFromExtension({ extension, kind }): maps extension/kind to best-effort MIME.
  • classifyMediaKind({ mimeType?, extension }): classifies as 'audio', 'video', or null.
  • isLikelySupportedMedia({ name, mimeType? }): returns whether file appears supported.
  • canBrowserPlayMedia({ mimeType, kind }): checks browser canPlayType(...) support signal.
  • fileNameFromInput({ input }): derives display/source name from loader input.
  • metadataFromName({ name }): derives fallback metadata from file naming pattern.

Notes On Utility API Usage

  • These helpers are pure except canBrowserPlayMedia(...), which depends on browser DOM availability.
  • classifyMediaKind(...) uses MIME first and extension fallback second.
  • inferMimeTypeFromExtension(...) is best-effort and should be paired with runtime decode validation in player.

Worker Transport

You can use worker-backed loading via loadInWorker(...) with automatic fallback behavior handled by @cxing/cdg-player.

Docs

  • Loader contract: https://cutterscrossing.com/?path=/docs/documentation-api-loader-contract--docs
  • Migration guide: https://cutterscrossing.com/?path=/docs/documentation-migration-guide--docs