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

@thehoneyjar/sound-engine

v0.2.4

Published

Shared sound engine for THJ apps with music and effects management

Readme

@thehoneyjar/sound-engine

Shared sound engine for THJ apps with advanced music and effects management.

Features

  • Centralized audio management - Single source of truth for all audio assets
  • Lazy loading - Audio files are loaded on demand with caching
  • Music management - Seamless transitions, crossfades, and background music control
  • Sound effects - Category-based sound variants with fallback support
  • React hooks - Easy integration with useSoundEffects and useMusicState
  • Local storage integration - Respects user sound preferences
  • Performance optimized - Limited concurrent sounds, efficient caching

Usage

Provider Setup

Wrap your application with the SoundEngineProvider once so every component shares the same engine instance, manifest, and configuration.

import { SoundEngineProvider } from "@thehoneyjar/sound-engine";

export function AppShell({ children }: { children: React.ReactNode }) {
  return <SoundEngineProvider>{children}</SoundEngineProvider>;
}

Basic Sound Effects

import { useSoundEffects } from "@thehoneyjar/sound-engine";

function MyComponent() {
  const { playSound } = useSoundEffects();

  return (
    <button
      onMouseEnter={() => playSound("buttonHover")}
      onClick={() => {
        playSound("buttonClickPlay"); // Category-specific sound
        // Do something...
        playSound("success");
      }}
    >
      Click Me
    </button>
  );
}

Music Management

import { useMusicState } from "@thehoneyjar/sound-engine";

function GameScreen() {
  const { playMusic, stopMusic, crossfadeTo, isPlaying } = useMusicState();

  useEffect(() => {
    // Start background music
    playMusic("lobbyMusic", { fadeIn: true });

    return () => {
      // Clean up on unmount
      stopMusic(true); // Fade out
    };
  }, []);

  const handleVictory = () => {
    // Crossfade to victory music
    crossfadeTo("victoryMusic", 1000);
  };

  return <div>Game content...</div>;
}

Pause and Resume Music

New in v0.2.0: Music playback now supports pause/resume with position preservation!

import { useSoundtrackDirector } from "@thehoneyjar/sound-engine";

function MusicPlayer() {
  const { pause, resume, play, status } = useSoundtrackDirector();

  const handlePause = async () => {
    // Pause with fade out (preserves playback position)
    await pause(true);
  };

  const handleResume = async () => {
    // Resume from paused position with fade in
    await resume(true);
  };

  return (
    <div>
      <p>Now Playing: {status.title}</p>
      <p>Status: {status.isPlaying ? "Playing" : "Paused"}</p>
      <button onClick={handlePause}>Pause</button>
      <button onClick={handleResume}>Resume</button>
    </div>
  );
}

Key Differences:

  • pause() - Pauses music and preserves playback position
  • resume() - Continues from paused position
  • stop() - Stops music and resets to beginning
  • play() - Smart: resumes if same track is paused, otherwise starts from beginning

Automatic Resume: When you call play() on a paused track, it automatically resumes from the saved position:

await pause(true);  // Pause at position 45.2 seconds
await play({ fadeIn: true });  // Automatically resumes from 45.2 seconds

Advanced Usage with Tetris Example

import { useSoundEffects } from "@thehoneyjar/sound-engine";

function TetrisGame() {
  const { playSound, playMusic, stopMusic } = useSoundEffects();

  // Different music for different game states
  const updateMusic = async (gameState: string) => {
    switch (gameState) {
      case "menu":
        await playMusic("tetrisIdleMusic");
        break;
      case "playing":
        await playMusic("tetrisDefaultMusic");
        break;
      case "highScore":
        await playMusic("tetrisHighScoreMusic", { fadeIn: true });
        break;
    }
  };

  // Sound effects for game actions
  const handlePieceMove = () => {
    void playSound("tetrisPieceMove");
  };

  const handleLineClear = (lines: number) => {
    if (lines === 4) {
      void playSound("tetris4Lines"); // Special sound for Tetris
    } else {
      void playSound("tetrisLineClear");
    }
  };

  return <div>Tetris game...</div>;
}

Sound Categories

Button sounds support categories for different UI sections:

  • play - Coin/token sound
  • guts - Heavy/impact sound
  • create - Light/magical sound
  • earn - Cash register/cha-ching sound
playSound("buttonClick"); // Default sound
playSound("buttonClickPlay"); // Play section sound
playSound("buttonClickGuts", { volume: 0.5 }); // Guts section at 50% volume

Configuration

You can still imperatively configure the engine, but prefer the provider for React apps:

import { SoundEngineProvider } from "@thehoneyjar/sound-engine";

const config = {
  basePath: "/assets/audio",
  defaultVolume: 0.8,
  preloadSounds: ["buttonClick", "tetrisIdleMusic"],
};

export function AppShell({ children }: { children: React.ReactNode }) {
  return <SoundEngineProvider config={config}>{children}</SoundEngineProvider>;
}

Category Controllers

Landing surfaces use slot-based sounds (hover primary/secondary, press, click). Build a controller with createSoundController and reuse it across interactive elements.

import { useSoundEffects } from "@thehoneyjar/sound-engine";

function CtaButton({ id }: { id: string }) {
  const { createSoundController } = useSoundEffects();
  const controller = useMemo(
    () =>
      createSoundController({
        category: "cta",
        id,
        hoverStrategy: "primaryThenSecondary",
        preload: true,
      }),
    [createSoundController, id],
  );

  return (
    <button
      onMouseEnter={() => controller.hover()}
      onMouseLeave={() => controller.resetHover()}
      onMouseDown={() => controller.press()}
      onClick={() => controller.click()}
    >
      Call to Action
    </button>
  );
}

Available Sounds

Sound Effects

  • Universal: buttonClick, buttonHover, ctaButtonClick, ctaButtonHover
  • Voice: henloVoice
  • Feedback: success, error, notification, coinDrop
  • Piggy Bank: piggyOink, piggyClick, piggyDrag, piggyRelease
  • Tetris: tetrisMenuNav, tetrisMenuSelect, tetrisPieceMove, tetrisPieceRotate, tetrisHardDrop, tetrisLineClear, tetris4Lines, tetrisGameOver

Music Tracks

  • Tetris: tetrisIdleMusic, tetrisDefaultMusic, tetrisHighScoreMusic
  • General: lobbyMusic, gameMenuMusic, victoryMusic, defeatMusic

Adding New Sounds

Extend the default library via the provider. You can register new effects, music tracks, and category slots in one place:

import { SoundEngineProvider } from "@thehoneyjar/sound-engine";

const customLibrary = {
  effects: {
    myNewSound: {
      path: "/sounds/custom/my-new-sound.mp3",
      defaultVolume: 0.42,
      tags: ["custom"],
    },
  },
  categories: {
    custom: {
      slots: {
        click: "myNewSound",
      },
      preload: ["click"],
    },
  },
};

export function AppShell({ children }: { children: React.ReactNode }) {
  return (
    <SoundEngineProvider library={customLibrary}>
      {children}
    </SoundEngineProvider>
  );
}

Publishing

This package is configured for private distribution. Before publishing make sure you are authenticated with the correct registry (npm login --scope @thj). Then use the helpers:

bun run clean
bun run build
npm publish --access restricted

Alternatively, reference a git tag directly:

npm install git+ssh://[email protected]:<org>/henlo-monorepo.git#sound-engine-v0.1.0

The build output is emitted to dist/ and included automatically via the package files field.