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

@liquid-svg-glass/core

v0.0.1

Published

Framework-agnostic core utilities for creating SVG liquid glass effects

Downloads

24

Readme

@liquid-svg-glass/core

Liquid SVG Glass Core

TypeScript Framework Agnostic Pure Functions Zero Dependencies

Framework-agnostic utilities for creating liquid glass effects using SVG filters

📚 Documentation🎨 React Components🔬 Technical Deep Dive

📦 Installation

npm install @liquid-svg-glass/core
# or
yarn add @liquid-svg-glass/core
# or
pnpm add @liquid-svg-glass/core
# or
bun add @liquid-svg-glass/core

🎯 Overview

The @liquid-svg-glass/core package provides framework-agnostic utilities for generating SVG displacement maps and filters that create realistic liquid glass effects. It's designed as a pure TypeScript library with no external dependencies, making it suitable for any JavaScript environment.

✨ Features

  • 🔧 Pure Functions: All utilities are pure functions with no side effects
  • 📐 TypeScript First: Full type definitions for excellent developer experience
  • 🎨 SVG Generation: Create complex SVG filters programmatically
  • 🚀 Zero Dependencies: Lightweight and fast with no external dependencies
  • 🔬 Debug Support: Built-in debug logging for development
  • 📱 Universal: Works in browsers, Node.js, and any JavaScript runtime

📖 API Reference

generateDisplacementMap(geometry, visual)

The main utility function that generates SVG displacement maps for liquid glass effects.

import { generateDisplacementMap } from '@liquid-svg-glass/core';

const result = generateDisplacementMap(
  {
    width: 300,
    height: 200,
    radius: 24
  },
  {
    scale: 60,
    r: 50,
    g: 55,
    b: 45,
    x: 'R',
    y: 'G',
    blur: 0.5
  }
);

// Returns:
// {
//   svgContent: string;    // Complete SVG markup
//   dataUri: string;       // Data URI for use in CSS/filters
//   filterAttributes: {    // Attributes for filter configuration
//     scale: number;
//     xChannelSelector: string;
//     yChannelSelector: string;
//   }
// }

Type Definitions

GeometryConfig

interface GeometryConfig {
  width: number;   // Width in pixels
  height: number;  // Height in pixels
  radius: number;  // Border radius in pixels
}

VisualConfig

interface VisualConfig {
  scale: number;           // Displacement intensity (-1000 to 1000)
  r: number;               // Red channel value (0-255)
  g: number;               // Green channel value (0-255)
  b: number;               // Blue channel value (0-255)
  x: 'R' | 'G' | 'B';     // Channel for X displacement
  y: 'R' | 'G' | 'B';     // Channel for Y displacement
  blur?: number;          // Optional blur amount
}

GlassConfig

interface GlassConfig {
  geometry: GeometryConfig;
  visual: VisualConfig;
}

Debug Utilities

import { beautyLog } from '@liquid-svg-glass/core';

// Pretty console logging with styled output
beautyLog({
  title: 'Glass Effect',
  type: 'info',
  message: 'Configuration applied',
  data: { scale: 60, blur: 15 }
});

💡 Usage Examples

Basic SVG Filter Generation

import { generateDisplacementMap } from '@liquid-svg-glass/core';

// Generate a displacement map for a glass panel
const glassPanel = generateDisplacementMap(
  { width: 400, height: 100, radius: 20 },
  { scale: 50, r: 60, g: 70, b: 50, x: 'R', y: 'B' }
);

// Use in HTML/CSS
const style = `
  .glass-element {
    backdrop-filter: url('${glassPanel.dataUri}');
  }
`;

Custom Visual Effects

// Subtle effect for UI elements
const subtleGlass = generateDisplacementMap(
  { width: 200, height: 60, radius: 30 },
  { scale: 30, r: 40, g: 45, b: 35, x: 'R', y: 'G', blur: 0.3 }
);

// Intense effect for hero sections
const intenseGlass = generateDisplacementMap(
  { width: 800, height: 400, radius: 0 },
  { scale: 120, r: 80, g: 90, b: 70, x: 'G', y: 'B', blur: 1.0 }
);

Integration with Vanilla JavaScript

<div id="glass-container">
  <p>Content with glass effect</p>
</div>

<script type="module">
  import { generateDisplacementMap } from '@liquid-svg-glass/core';
  
  const { dataUri } = generateDisplacementMap(
    { width: 300, height: 150, radius: 15 },
    { scale: 45, r: 55, g: 60, b: 50, x: 'R', y: 'G' }
  );
  
  const container = document.getElementById('glass-container');
  container.style.backdropFilter = `url('${dataUri}')`;
</script>

🔧 Advanced Configuration

Understanding Scale Values

  • Positive values (1-1000): Standard displacement direction
  • Negative values (-1-1000): Inverted displacement effect
  • Zero: No displacement (transparent glass)

Channel Selection Strategy

  • x: 'R', y: 'G': Classic chromatic aberration
  • x: 'G', y: 'B': Cooler, tech-oriented effect
  • x: 'R', y: 'B': Warmer, organic distortion

Performance Tips

  1. Memoize Results: Cache generated SVGs when parameters don't change
  2. Optimize Blur: Lower blur values render faster
  3. Reasonable Scales: Keep scale values under 200 for most UI elements
  4. Reuse Filters: Generate once, apply to multiple elements

🏗️ Architecture

The core package follows these principles:

  • Pure Functions: No side effects or state mutations
  • Composable: Small, focused functions that work together
  • Type Safe: Comprehensive TypeScript definitions
  • Tree Shakeable: Import only what you need

🤝 Contributing

See the main repository README for contribution guidelines.

📄 License

MIT License - see LICENSE for details.

🔗 Links