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

@jeasonduan/smart-report

v0.2.0

Published

Browser-based, framework-independent report renderer and visual designer

Readme

Smart Report

Smart Report is a browser-based, framework-independent TypeScript report engine. It renders JSON report templates and data contexts into printable HTML pages and includes an embeddable visual designer.

The runtime relies on real browser DOM measurement and CSS layout. It is not a server-side renderer and does not generate PDF files directly.

Install

npm install @jeasonduan/smart-report

Import the runtime stylesheet explicitly:

import '@jeasonduan/smart-report/report.css'
import { createReport, type ReportContext, type TemplateConfig } from '@jeasonduan/smart-report'

const template: TemplateConfig = {
  schemaVersion: 1,
  printMode: 'list',
  pages: [
    {
      layout: {
        width: 210,
        height: 297,
        padding: { top: 10, right: 10, bottom: 10, left: 10 },
        colCount: 1,
        rowCount: 1,
      },
      dataContent: {
        rows: [{ cells: [{ type: 'text', value: '{{ data.name }}' }] }],
      },
    },
  ],
}

const source: ReportContext = {
  params: {},
  info: {},
  summary: {},
  data: [{ name: 'Ada Lovelace' }],
}

const report = createReport({ template, source })
report.mount(document.querySelector('#report')!)

Call report.destroy() when the host view is removed. mount(), render(), and update() are synchronous and return page and warning information.

Call report.print() to print only that mounted report instance. During printing, Smart Report temporarily moves the report into an isolated document-level print portal, hides unrelated page content and other report instances, and restores the original DOM afterwards. Calling the browser's Print command directly does not activate this isolation. Only one report can be printed per document at a time; a nested call throws REPORT_PRINT_IN_PROGRESS.

Designer

The designer is a separate entry. Its preview uses the runtime, so load both stylesheets:

import '@jeasonduan/smart-report/report.css'
import '@jeasonduan/smart-report/designer.css'
import { createDesigner } from '@jeasonduan/smart-report/designer'

const designer = createDesigner({
  template,
  controlSize: 'small',
})

designer.mount(document.querySelector('#designer')!)
designer.on('change', ({ template: nextTemplate }) => {
  console.log(nextTemplate)
})

The runtime root does not re-export designer APIs. The designer owns its DOM, dialogs, preview report, messages, and event listeners, so multiple instances can share one page.

The report preview dialog includes a printer button after a preview renders successfully. It calls the preview report's isolated print() lifecycle; use this button instead of the browser's direct Print command when printing from the designer.

Data Modes

  • list: pass one ReportContext; records flow continuously across pages.
  • single: pass one ReportContext; each data record consumes the configured template pages.
  • batch: pass an array of ReportContext objects. Grouping is the caller's responsibility.

Bindings use the restricted form {{ data.field | formatter }}. Formatters and plugin cells are registered per report instance and must run synchronously.

Package Entries

| Entry | Purpose | | --------------------------------------------------------- | ----------------------------------------------------- | | @jeasonduan/smart-report | Runtime API, template types, validation, and bindings | | @jeasonduan/smart-report/designer | Visual designer API | | @jeasonduan/smart-report/report.css | Runtime and print styles | | @jeasonduan/smart-report/designer.css | Designer shell styles | | @jeasonduan/smart-report/schema/report-template.v1.json | Version 1 JSON Schema |

UMD bundles are included under dist/smart-report.umd.cjs and dist/smart-report-designer.umd.cjs, exposing SmartReport and SmartReportDesigner respectively.

Security And Limits

  • Template data is validated against the bundled v1 JSON Schema.
  • Bindings do not execute JavaScript, Liquid tags, prototype-chain paths, or raw HTML.
  • Plugin renderers are the only extension point that may return DOM nodes. Treat plugins as trusted code.
  • Pagination requires browser layout measurements and is unavailable during SSR.
  • Chrome and Edge are the reference browsers for print layout. Firefox and Safari should be tested for each report design.
  • PDF, Excel, charts, images, barcodes, data-source connections, and framework adapters are outside the current v1 scope.

Development

npm ci
npm run check
npm run build
npm run test:package

Detailed Chinese documentation is available in doc/. Formal publishing requires explicit authorization and is not performed by the build scripts.

License

Apache License 2.0. See LICENSE.