惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
J
Java Code Geeks
博客园 - 聂微东
Microsoft Azure Blog
Microsoft Azure Blog
量子位
T
Tailwind CSS Blog
Vercel News
Vercel News
I
InfoQ
Stack Overflow Blog
Stack Overflow Blog
U
Unit 42
Engineering at Meta
Engineering at Meta
L
LangChain Blog
大猫的无限游戏
大猫的无限游戏
D
Docker
博客园_首页
P
Proofpoint News Feed
月光博客
月光博客
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
Martin Fowler
Martin Fowler
腾讯CDC
N
Netflix TechBlog - Medium
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

Hacker News: Show HN

PurrrrrFocus: Pomodoro Timer App - App Store Workflow Engine — Multi-Step Orchestration for Bun RapidPhoto: Pro Photo Editor App - App Store GitHub - DheerG/swarms: Achieve extraordinary results with claude code across a variety of tasks SPICE simulation → oscilloscope → verification with Claude Code — Lucas Gerads Show HN: VCoding – A 5 MB native Windows IDE with no dynamic dependencies Show HN: LLMs don't hallucinate because they're bad at math, it's the format GitHub - Agent-FM/agentfm-core: AgentFM is a peer-to-peer network that turns everyday computers into a decentralized AI supercomputer. AgentFM lets you run massive AI workloads directly across a global mesh of idle CPUs and GPUs. Show HN: Tracking Top US Science Olympiad Alumni over Last 25 Years GitHub - Potarix/agent-hub: One place to talk to all your agents Show HN: Runtime security for AI agents(injection,tool abuse, data exfiltration) GitHub - dubeyKartikay/lazyspotify: Terminal Spotify client for macOS and Linux GitHub - the-banana-tool/king-louie: Easy to use GUI Personal AI Assistant. Win/Linux/Mac. Show HN I made my vacation rental bookable by AI agents–no Airbnb, 0% commission GitHub - basteez/jsf-autoreload: maven plugin to enable hot reload on jsf projects uvm32/hosts/host-gdbstub at main · ringtailsoftware/uvm32 GitHub - labsai/EDDI: Config-driven engine that turns JSON into production-grade AI agents. Multi-agent orchestration, 12+ LLM providers, MCP/A2A protocols, RAG, persistent memory, and enterprise compliance (EU AI Act, GDPR, HIPAA). Built on Quarkus. GitHub - glitchnsec/fortyone-oss: AI Executive Assistant Platform Quickstart | Alien GitHub - muxshed/shed: One stream in, or many. Every destination, simultaneously. No cloud middleman, no per-channel fees, no limits. GitHub - ocrbase-hq/ocrbase: 📄 PDF/IMG ->.MD/JSON Document OCR API for PaddleOCR and GLMOCR. Self-hostable. GitHub - impactjo/home-memory: MCP server that lets your AI assistant remember everything about your home. GitHub - Sets88/dbcls: DbCls is a powerful terminal database client that supports various databases GitHub - neptun2000/heor-agent-mcp GitHub - SeanFDZ/macmind: Single-layer transformer in HyperTalk for the classic Macintosh RollQuation: Math Puzzles - Apps on Google Play GitHub - dropbox/witchcraft Show HN: Agent-cache – Multi-tier LLM/tool/session caching for Valkey and Redis GitHub - opentalon/opentalon: OpenTalon is an open-source platform built from the ground up in Go as a robust alternative to OpenClaw LinkedIn™ 职位抓取工具 - Chrome 应用商店
GitHub - johnyrokita/electron-expose: Generate type-safe ...
jskull · 2026-06-19 · via Hacker News: Show HN

NPM Version NPM License NPM Downloads

Generate type-safe Electron IPC bridges from decorated TypeScript functions.

Electron IPC usually means keeping channel names, main handlers, preload bridges, shared types, and renderer calls in sync. electron-expose generates that bridge from the functions you expose in code, so the renderer gets a typed window.api without the repeated wiring.

One goal: make Electron IPC boring.

Why

  • No manual ipcMain.handle(...) and ipcRenderer.invoke(...) pairing
  • No hand-maintained renderer API types
  • No repeating the same method shape across main, preload, and renderer
  • Type-safe window.api.* calls generated from exposed functions

Mark class methods with decorators:

import { expose } from "electron-expose"

export class CalculatorRoutes {
  @expose("math.calculate")
  calculate(a: number, b: number): number {
    return a + b
  }
}

Or expose standalone functions:

import { exposed } from "electron-expose"

export const getVersion = exposed(
  "system.getVersion",
  async (): Promise<string> => {
    return app.getVersion()
  },
)

Then call the generated API from the renderer:

const answer = await window.api.math.calculate(2, 3)
const version = await window.api.system.getVersion()

Install

Quick Start

Initialize the project:

pnpm electron-expose init

Then expose functions in the main process:

import { expose } from "electron-expose"

export class CalculatorRoutes {
  @expose("math.calculate")
  calculate(a: number, b: number): number {
    return a + b
  }
}

Generate the Electron bridge:

pnpm electron-expose generate

To inspect discovered functions without writing generated files:

pnpm electron-expose list

init is interactive. It can create config, patch detected main/preload files, and enable experimentalDecorators in tsconfig.json.

For CI or setup scripts:

pnpm electron-expose init --yes

Plumb It In

Main process:

import { registerElectronExposeRoutes } from "./generated/electron-expose/main"

registerElectronExposeRoutes()

Preload:

import { exposeElectronApi } from "./generated/electron-expose/preload"

exposeElectronApi()

Renderer:

await window.api.math.calculate(2, 3)

Config

Most projects can start with an empty config:

import { defineConfig } from "electron-expose"

export default defineConfig()

Common options:

import { defineConfig } from "electron-expose"

export default defineConfig({
  root: "src",
  outDir: "src/generated/electron-expose",
  globalApiName: "api",
  routePrefix: "electron-expose",
  rendererGlobal: "src/renderer/global.d.ts",
})

By default, electron-expose scans root for *.ts and *.tsx, then only generates bridge entries for @expose() or exposed(...). Generated/build folders, declaration files, and node_modules are ignored automatically.

For custom layouts:

export default defineConfig({
  include: ["packages/main/src/**/*.ts"],
  exclude: ["**/*.spec.ts"],
})

Exposing Functions

Class methods use decorators:

export class UserRoutes {
  @expose("users.get")
  getUser(id: string): Promise<User> {
    return userService.getUser(id)
  }
}

Classes must be exported and currently need a zero-argument constructor. Decorators are used as build-time markers for electron-expose generate; they are not runtime registration logic.

TypeScript does not allow decorators on top-level functions, so standalone functions use exposed(...):

import { exposed } from "electron-expose"

export const ping = exposed("system.ping", (): string => "pong")

Contributing

Issues, bug reports, and focused pull requests are welcome.

Before opening a pull request, run:

pnpm run check
pnpm run build