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

ai-image-element

v1.0.7

Published

A custom HTML element for AI-generated images with simple configuration

Readme

ai-img-element

一个通过自定义 HTML 标签直接生成 AI 图片的插件。极其易用,不依赖 React/Vue 等框架,支持通过 CDN 或 NPM 引入。

特性

  • 🎨 使用自定义 <ai-img> 标签直接生成 AI 图片
  • 🚀 极简 API,开箱即用
  • 🔧 支持全局配置和提示词
  • 💡 使用 Shadow DOM 封装,样式隔离
  • 📦 支持 NPM 和 CDN 引入
  • 🎯 支持 React、Vue 等任何框架

安装

npm install ai-img-element

使用方法

在 React/Vue 中使用

import { AIImage } from 'ai-img-element';

// 全局初始化
AIImage.config({
  baseUrl: 'https://api.your-service.com',
  globalPrompt: 'masterpiece, high-end aesthetic, 8k resolution, minimalist'
});

在 HTML 中使用

<ai-img 
  prompt="一个具有极简主义风格的科技感蓝色登录框背景" 
  width="800" 
  height="600">
</ai-img>

CDN 引入

<script type="module">
  import { AIImage } from 'https://unpkg.com/ai-img-element/dist/index.esm.js';
  
  AIImage.config({
    baseUrl: 'http://127.0.0.1:5555',
    globalPrompt: 'masterpiece, high quality'
  });
</script>

<ai-img 
  prompt="有考试通过、或者通关成功含义的图标,蓝紫渐变,毛玻璃" 
  width="400" 
  height="300">
</ai-img>

API

AIImage.config(options)

配置全局参数

AIImage.config({
  baseUrl: string;          // 必填:API 服务地址
  globalPrompt?: string;    // 可选:全局提示词前缀
  timeout?: number;         // 可选:请求超时时间(毫秒)
  retryCount?: number;      // 可选:重试次数
});

<ai-img> 标签属性

| 属性 | 类型 | 必填 | 说明 | |------|------|------|------| | prompt | string | 是 | 图片描述提示词 | | width | number | 否 | 图片宽度(默认 400) | | height | number | 否 | 图片高度(默认 300) | | alt | string | 否 | 图片 alt 文本 | | loading | 'lazy' | 'eager' | 否 | 加载方式 |

后端 API 要求

后端需要提供 /api/generate 接口,接收 POST 请求:

{
  "user_input": "图片描述提示词",
  "width": 800,
  "height": 600
}

返回生成的图片(Blob 格式)。

开发

# 安装依赖
npm install

# 开发模式
npm run dev

# 构建
npm run build

License

MIT