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

@composy/print-core

v0.0.1

Published

Print functionality library, supporting print preview and area printing

Readme

@composy/print-core

打印功能封装库核心模块,框架无关,支持打印预览、区域打印、批量打印、打印取消等功能。

安装

npm install @composy/print-core

快速开始

import { printElement, printHtml, printUrl, PrintManager } from '@composy/print-core'

// 快捷打印某个元素
await printElement('#my-table', {
  documentTitle: '销售报表',
  pageSize: 'A4',
  orientation: 'landscape',
})

// 打印 HTML 字符串
await printHtml('<h1>标题</h1><p>内容</p>', {
  documentTitle: '打印内容',
})

// 使用 PrintManager
const manager = new PrintManager({
  container: '#content',
  pageSize: 'A4',
  margins: { top: '10mm', right: '10mm', bottom: '10mm', left: '10mm' },
})
await manager.print()
manager.destroy()

API

PrintManager

| 方法 | 说明 | |------|------| | print(overrides?) | 打印容器元素内容 | | printHtml(html, overrides?) | 打印 HTML 字符串 | | printUrl(url, overrides?) | 打印 URL 页面内容 | | printBatch(items, overrides?) | 批量打印多个元素 | | preview(opts?, overrides?) | 打开打印预览窗口 | | cancel() | 取消当前打印 | | setContainer(el) | 设置打印容器 | | setOptions(opts) | 更新配置 | | getOptions() | 获取当前配置 | | setThemeTokens(tokens) | 更新主题 token | | isPrinting() | 是否正在打印 | | isCancelled() | 是否已取消 | | destroy() | 销毁实例 |

便捷 API

| 函数 | 说明 | |------|------| | printElement(el, options?) | 快捷打印某个元素 | | printHtml(html, options?) | 快捷打印 HTML 字符串 | | printUrl(url, options?) | 快捷打印 URL 内容 |

Class 命名空间

所有 DOM class 使用 ldesign-print 前缀:

| Class | 说明 | |-------|------| | ldesign-print-preview-toolbar | 预览工具栏 | | ldesign-print-preview-content | 预览内容区 | | ldesign-print-preview-btn | 预览按钮 | | ldesign-print-preview-btn--close | 预览关闭按钮 |

CSS Token

所有样式通过 --ldesign-print-* CSS 变量控制,颜色默认引用 --color-*,尺寸默认引用 --size-*:

| Token | 默认值 | 说明 | |-------|--------|------| | --ldesign-print-toolbar-bg | var(--color-gray-900) | 工具栏背景色 | | --ldesign-print-toolbar-color | var(--color-gray-0) | 工具栏文字色 | | --ldesign-print-button-bg | var(--color-primary-600) | 按钮背景色 | | --ldesign-print-button-color | var(--color-gray-0) | 按钮文字色 |

构建产物

| 目录 | 格式 | 用途 | |------|------|------| | es/ | ESM | 主入口(module/types) | | esm/ | ESM | 兼容入口 | | lib/ | CJS | CommonJS 入口(main) | | dist/ | UMD | CDN 入口(unpkg/jsdelivr) |

验证命令

# 类型检查
pnpm run type-check

# ESLint
pnpm run lint:check

# 测试
pnpm run test:run

# 构建
pnpm run build