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

@edsilfer/diff-viewer

v0.1.8

Published

A React library for rendering Git diffs

Downloads

12

Readme

@diff-viewer

Note: This package is open source but currently designed for internal use at Dialectica. It may not yet be production-ready for general external use.

A composable React library for building rich code review UIs. It provides diff viewers, file explorers, activity summaries, contextual commenting, and theming — all integrated, yet modular. Primarily intended for internal use within the Dialectica project.

Try it now or

git clone [email protected]:edsilfer/dialectica.git
cd dialectica ; pnpm install ; pnpm demo

Main features

Installation

npm install @edsilfer/diff-viewer

API

import { DiffViewerConfigProvider, DiffViewer } from '@edsilfer/diff-viewer'

/*
 * Supports for custom toolbar to render diff metadata.
 */
const toolbar = (
  <Toolbar
    loading={loading.metadata}
    pr={metadata}
    isPosting={isPosting}
    comments={pendingComments}
    onSubmitReview={(payload) => onSubmitReview(payload, pendingComments)}
    commentDatastore={commentDs}
    onSearch={setPrUrl}
  />
)

/*
 * Easily display any custom component over the last docked line.
 */
const overlays = [
  {
    unifiedDockIdx: 2,
    splitDockIdx: 1,
    content: <AddButton key="add-button" onClick={() => onCommentEvent(CommentEvent.ADD)} />,
    onDock: onLineDock,
  },
]

/*
 * Easily dock any custom component on a line - perfect for inline comments.
 */
const widgets = [
  {
    content: <CommentWidget key="comment-widget" />,
    line: 10,
    position: 'top',
    filepath: 'src/example.ts',
    side: 'right',
  },
]

return (
  <DiffViewerConfigProvider
    theme={Themes.light}
    fileExplorerConfig={ ... }
    fileListConfig={ ... }
    storage="local"
  >
    <DiffViewer
      diff={diff}
      isMetadataLoading={loading.metadata}
      isDiffLoading={loading.diff}
      onLoadMoreLines={loadMoreLines}
      onLineSelection={onLineSelection}
      highlightedLines={range}
      widgets={widgets}
      toolbar={toolbar}
      overlays={overlays}
    />
  </DiffViewerConfigProvider>
)

Architecture

The@diff-viewer package serves as the core rendering and state layer for visualizing diffs. It receives parsed diffs and renders them through a composition of layout, file, and line components, backed by domain models and theming providers.

---
config:
  layout: fixed
  look: handDrawn
---
flowchart TD
 subgraph subGraph0["Domain Models"]
        C2["Hunk"]
        C1["FileDiff"]
        C3["DiffLine"]
        C["ParsedDiff: Domain Models"]
  end
    A["Raw Git Diff (text)"] --> B["diffparser (3rd-party)"]
    B --> C
    C1 --> C2
    C2 --> C3
    C --> C1 & D["View Models (e.g., HunkListVM)"]
    D --> E["React Components"]
    E --> F["User Actions (click, scroll, search)"]
    F --> G["Hooks & Controllers"] & I["Load More Lines"]
    G --> D & H["Context Providers"]
    I --> J["External Handler (API fetch)"]
    J --> K["Patch Hunk + Re-render"]

Package Structure

packages/diff-viewer
├── src
│   ├── components        # All visual components (DiffViewer, FileList, etc.)
│   ├── models            # FileDiff, LineDiff, ParsedDiff, etc.
│   ├── providers         # Context providers for state, search, etc.
│   ├── hooks             # Reusable internal hooks
│   ├── utils             # Pure helpers and parsing logic
│   └── index.ts          # Main exports
├── vitest.config.ts
├── tsup.config.ts
└── package.json

Contributing

We welcome feedback and improvements. Please open an issue or submit a pull request if you spot something.

Versioning

This package uses semantic versioning. APIs may break between minor versions unless otherwise documented.

License

  • This project is licensed under the GNU AGPLv3.
  • Note: The AGPL license requires source disclosure for any network-based use. Be sure to review its terms before using this in a proprietary environment.