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

@oldzy/conduit-electron-adapter

v1.0.7

Published

Electron IPC adapter for @oldzy/conduit - enables seamless communication between main and renderer processes

Downloads

762

Readme

Conduit Electron Adapter

Electron IPC adapter for @oldzy/conduit, enabling seamless communication between Electron's main and renderer processes.

Features

  • 🔌 IPC-based communication between main and renderer processes
  • 🎯 Request/Response pattern with UUID tracking
  • 📡 Separate handlers for simple and streaming responses
  • 🚫 Request cancellation support
  • 💉 Automatic dependency injection for Electron App and IpcMain
  • 🔄 AbortController integration for async operations
  • 🔒 Type-safe with TypeScript generics

Installation

npm install @oldzy/conduit-electron-adapter

Usage

Main Process

import { Application } from '@oldzy/conduit';
import { ElectronAdapter } from '@oldzy/conduit-electron-adapter';

const app = new Application();
const electronAdapter = new ElectronAdapter();

app.useAdapter(electronAdapter);

// Register your handlers...
await app.build();

Preload Script

Configure your Electron window to use the preload script:

import { BrowserWindow } from 'electron';
import path from 'path';

// Use require.resolve to get the preload path from node_modules
const preloadPath = require.resolve('@oldzy/conduit-electron-adapter/preload');

const mainWindow = new BrowserWindow({
  webPreferences: {
    preload: preloadPath,
    contextIsolation: true,
    nodeIntegration: false
  }
});

The preload script automatically:

  • Exposes conduit to the renderer via contextBridge
  • Handles all IPC listeners for streaming, errors, and cancellation
  • Manages request timeout (30 seconds)
  • Cleans up listeners automatically

Renderer Process

// Simple request/response (for SimpleHandler)
const response = await window.conduit.send<GetUserResponse>({
  uuid: crypto.randomUUID(),
  type: 'GET_USER',
  userId: '123'
});
console.log(response.userName);

// Streaming request (for StreamingHandler)
await window.conduit.stream<LogChunkResponse>(
  {
    uuid: crypto.randomUUID(),
    type: 'STREAM_LOGS',
    filename: 'app.log'
  },
  (chunk) => {
    console.log('Received chunk:', chunk.line);
  }
);

// Cancel a request
await window.conduit.cancel('request-uuid');

API

ElectronAdapter (Main Process)

The adapter automatically:

  • Registers conduit:send IPC handler for simple requests (SimpleHandler)
  • Registers conduit:stream IPC handler for streaming requests (StreamingHandler)
  • Registers conduit:cancel IPC handler for cancelling requests
  • Injects ElectronApp (app instance) and IpcMain into the service container
  • Manages streaming responses via IPC events
  • Handles request cancellation with AbortController

IConduitService (Renderer Process)

The window.conduit object is automatically typed when you import the package:

import '@oldzy/conduit-electron-adapter';

// Now window.conduit is fully typed!
const response = await window.conduit.send<MyResponse>(request);
interface IConduitService {
  send: <TResponse extends BaseResponse>(
    request: BaseRequest
  ) => Promise<TResponse>;
  stream: <TResponse extends BaseResponse>(
    request: BaseRequest,
    onData: (response: TResponse) => void
  ) => Promise<void>;
  cancel: (requestUuid: string) => Promise<void>;
}

Methodstimeout (30s) and cleanup

  • cancel(requestUuid) - Cancel a pending request by UUID

Important: Use send() for SimpleHandler and stream() for StreamingHandler. Using the wrong method will result in an error.

IPC Channels

Internal channels (handled automatically by the preload script):

  • conduit:send - Send a simple request (invoke) - returns response

  • conduit:stream - Start a streaming request (invoke) - sends chunks via eventsuest (invoke) - sends chunks via eventsd cleanup

  • cancel(requestUuid) - Cancel a pending request by UUID

Important: Use send() for SimpleHandler and stream() for StreamingHandler. Using the wrong method will result in an error.

  • cancel(requestUuid) - Cancel a pending request by UUID

IPC Channels

Internal channels (handled automatically by the preload script):

  • conduit:send - Send a request (invoke)
  • conduit:cancel - Cancel a pending request (invoke)
  • conduit:response:data:{uuid} - Streaming response data (listener)
  • conduit:response:complete:{uuid} - Stream completed (listener)
  • conduit:response:error:{uuid} - Error occurred (listener)
  • conduit:response:cancelled:{uuid} - Request was cancelled (listener)

Types

interface ErrorResponse {
class ErrorResponse extends BaseResponse {
  constructor(
    public requestUuid: string,
    public error: string,
    public stack?: string
  );
}

Note: The window.conduit type is automatically available when you import the package in your TypeScript files.

License

MIT