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

watermark-kit

v0.1.2

Published

Configurable watermark content generator and target-scoped DOM renderer.

Readme

watermark-kit

独立的水印内容生成器和 DOM 渲染器,支持内置字段、字段注册、自定义取值逻辑、脱敏、当前时间和指定 DOM 容器渲染。

安装

npm install watermark-kit

使用

import {
  createWatermarkGenerator,
  createWatermarkRenderer
} from 'watermark-kit'

const generator = createWatermarkGenerator({
  fields: {
    loginSource: {
      fieldName: '登录来源',
      resolve: { type: 'constant', value: '后台管理' }
    }
  }
})

const userInfo = {
  username: '张三',
  orgName: '技术研发部'
}

const result = await generator.generate({
  enabled: true,
  options: [
    { property: 'username', hideSomeCharacter: true },
    { property: 'orgName' },
    { property: 'loginSource' },
    { property: 'currentTime' }
  ]
}, userInfo)

const renderer = createWatermarkRenderer()
renderer.render(result.content, document.querySelector('#app'))

普通字段默认按 property 从 userInfo 读取。localIp 可以通过配置项的 value 传入已解析的客户端 IP:

{ property: 'localIp', value: '172.30.4.97' }

manualContent 用于直接渲染配置中的 content,不依赖 userInfo:

{ property: 'manualContent', content: 'zqy科技' }

手机号、身份证号和邮箱支持通过 hideSomeCharacter 开启内置脱敏:

options: [
  { property: 'phoneNo', hideSomeCharacter: true },
  { property: 'idNumber', hideSomeCharacter: true },
  { property: 'email', hideSomeCharacter: true }
]

内置字段包括:manualContent、account、username、phoneNo、idNumber、orgName、gender、birthDate、politicalOutlook、nation、post、email、localIp、currentTime。

自定义字段

generator.registerField({
  fieldCode: 'department',
  aliases: ['departmentName'],
  resolve: ({ userInfo }) => userInfo.departmentName
})

也可以使用配置式解析:constant、path、template、time、localIp。

Vue 插件

import { createApp } from 'vue'
import { watermarkGeneratorPlugin, watermarkRendererPlugin } from 'watermark-kit'

const app = createApp(App)
app.use(watermarkGeneratorPlugin)
app.use(watermarkRendererPlugin)

示例

examples/basic.html 可以直接通过静态服务器打开。项目根目录执行:

npx vite --host 127.0.0.1

然后访问 /examples/basic.html。

构建与发布

npm run build
npm run pack:check
npm publish --access public