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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gitnestr/electron-git-bridge

v0.1.5

Published

Electron bridge for Git repository management in the Gitnestr SDK

Readme

@gitnestr/electron-git-bridge

The Electron (main process) component of the Gitnestr SDK, responsible for reading Git repositories from the filesystem and streaming them to the renderer process.

Installation

npm install @gitnestr/electron-git-bridge

Usage

import { GitBridge } from '@gitnestr/electron-git-bridge';

// Initialize with repository path
const bridge = new GitBridge('/path/to/repository', {
  maxRepoSize: 1024 * 1024 * 1024, // 1GB
  chunkSize: 1024 * 1024, // 1MB
  excludePatterns: ['node_modules/**'],
  includeGitHistory: true
});

// Validate repository
const validation = await bridge.validateRepo();
if (!validation.isValid) {
  console.error('Invalid repository:', validation.errors);
  return;
}

// Get repository metadata
const metadata = await bridge.getMetadata();
console.log('Repository info:', {
  path: metadata.path,
  size: metadata.size,
  branches: metadata.branches,
  head: metadata.head,
  remotes: metadata.remotes
});

// Stream repository to renderer
for await (const chunk of bridge.streamRepository()) {
  if ('manifest' in chunk) {
    // Send manifest first
    mainWindow.webContents.send('repo-metadata', {
      ...metadata,
      manifest: chunk.manifest
    });
  } else {
    // Send file chunks
    mainWindow.webContents.send('repo-chunk', chunk);
  }
}

API Reference

Constructor

constructor(repoPath: string, options?: GitBridgeOptions)

Creates a new GitBridge instance.

  • repoPath: Path to the Git repository on disk
  • options: Optional configuration object

Options

interface GitBridgeOptions {
  maxRepoSize?: number;      // Maximum repository size (default: 1GB)
  chunkSize?: number;        // Size of transfer chunks (default: 1MB)
  excludePatterns?: string[]; // Glob patterns to exclude (default: ['node_modules/**'])
  includeGitHistory?: boolean; // Include .git directory (default: true)
}

Methods

validateRepo

async validateRepo(): Promise<ValidationResult>

Validates the repository path and checks:

  • Directory exists
  • Is a Git repository
  • Size within limits
  • Read permissions

Returns:

interface ValidationResult {
  isValid: boolean;
  errors?: string[];
}

getMetadata

async getMetadata(): Promise<GitRepository>

Gets repository metadata including:

  • Repository path
  • Total size
  • Branches
  • HEAD reference
  • Remote configurations

Returns:

interface GitRepository {
  path: string;
  size: number;
  branches: string[];
  head: string;
  remotes: string[];
}

streamRepository

async *streamRepository(): AsyncGenerator<FileChunk | { manifest: TransferManifest }>

Streams the repository content as chunks. Yields:

  1. First, a manifest containing file list
  2. Then, file chunks for each file

Types:

interface TransferManifest {
  totalFiles: number;
  files: string[];
}

interface FileChunk {
  index: number;
  totalChunks: number;
  data: Uint8Array;
  path: string;
}

Error Handling

The package uses the GitBridgeError class for error handling:

try {
  await bridge.validateRepo();
} catch (error) {
  if (error instanceof GitBridgeError) {
    console.error('Error code:', error.code);
    console.error('Message:', error.message);
    console.error('Details:', error.details);
  }
}

Error codes:

  • INVALID_REPOSITORY: Repository validation failed
  • TRANSFER_ERROR: Error during file transfer
  • INTERNAL_ERROR: Unexpected internal error

Example

See the example directory in the root package for a complete working example.