본문으로 건너뛰기
cccskills
무료GitHub에 공개

electron-api

Guide for adding new Electron APIs to Wave Terminal. Use when implementing new frontend-to-electron communications via preload/IPC.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

설치 방법 보기

포함된 파일(1)

  • SKILL.md4.5 KB

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Adding Electron APIs

Electron APIs allow the frontend to call Electron main process functionality directly via IPC.

Four Files to Edit

  1. frontend/types/custom.d.ts - TypeScript ElectronApi type
  2. emain/preload.ts - Expose method via contextBridge
  3. emain/emain-ipc.ts - Implement IPC handler
  4. frontend/preview/preview-electron-api.ts - Add a no-op stub to keep the previewElectronApi object in sync with the ElectronApi type

Three Communication Patterns

  1. Sync - ipcRenderer.sendSync() + ipcMain.on() + event.returnValue = ...
  2. Async - ipcRenderer.invoke() + ipcMain.handle()
  3. Fire-and-forget - ipcRenderer.send() + ipcMain.on()

Example: Async Method

1. Define TypeScript Interface

In frontend/types/custom.d.ts:

type ElectronApi = {
    captureScreenshot: (rect: Electron.Rectangle) => Promise<string>; // capture-screenshot
};

2. Expose in Preload

In emain/preload.ts:

contextBridge.exposeInMainWorld("api", {
    captureScreenshot: (rect: Rectangle) => ipcRenderer.invoke("capture-screenshot", rect),
});

3. Implement Handler

In emain/emain-ipc.ts:

electron.ipcMain.handle("capture-screenshot", async (event, rect) => {
    const tabView = getWaveTabViewByWebContentsId(event.sender.id);
    if (!tabView) throw new Error("No tab view found");
    const image = await tabView.webContents.capturePage(rect);
    return `data:image/png;base64,${image.toPNG().toString("base64")}`;
});

4. Add Preview Stub

In frontend/preview/preview-electron-api.ts:

captureScreenshot: (_rect: Electron.Rectangle) => Promise.resolve(""),

5. Call from Frontend

import { getApi } from "@/store/global";

const dataUrl = await getApi().captureScreenshot({ x: 0, y: 0, width: 800, height: 600 });

Example: Sync Method

1. Define

type ElectronApi = {
    getUserName: () => string; // get-user-name
};

2. Preload

getUserName: () => ipcRenderer.sendSync("get-user-name"),

3. Handler (⚠️ MUST set event.returnValue or browser hangs)

electron.ipcMain.on("get-user-name", (event) => {
    event.returnValue = process.env.USER || "unknown";
});

4. Call

import { getApi } from "@/store/global";

const userName = getApi().getUserName(); // blocks until returns

Example: Fire-and-Forget

1. Define

type ElectronApi = {
    openExternal: (url: string) => void; // open-external
};

2. Preload

openExternal: (url) => ipcRenderer.send("open-external", url),

3. Handler

electron.ipcMain.on("open-external", (event, url) => {
    electron.shell.openExternal(url);
});

Example: Event Listener

1. Define

type ElectronApi = {
    onZoomFactorChange: (callback: (zoomFactor: number) => void) => void; // zoom-factor-change
};

2. Preload

onZoomFactorChange: (callback) => 
    ipcRenderer.on("zoom-factor-change", (_event, zoomFactor) => callback(zoomFactor)),

3. Send from Main

webContents.send("zoom-factor-change", newZoomFactor);

Quick Reference

Use Sync when:

  • Getting config/env vars
  • Quick lookups, no I/O
  • ⚠️ CRITICAL: Always set event.returnValue or browser hangs

Use Async when:

  • File operations
  • Network requests
  • Can fail or take time

Use Fire-and-forget when:

  • No return value needed
  • Triggering actions

Electron API vs RPC:

  • Electron API: Native OS features, window management, Electron APIs
  • RPC: Database, backend logic, remote servers

Checklist

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Guide for adding new configuration settings to Wave Terminal. Use when adding a new setting to the configuration system, implementing a new config key, or adding user-customizable settings.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

add-rpc

무료

Guide for adding new RPC calls to Wave Terminal. Use when implementing new RPC commands, adding server-client communication methods, or extending the RPC interface with new functionality.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for adding new wsh commands to Wave Terminal. Use when implementing new CLI commands, adding command-line functionality, or extending the wsh command interface.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for creating and displaying context menus in Wave Terminal. Use when implementing right-click menus, adding context menu items, creating submenus, or handling menu interactions with checkboxes and separators.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Guide for implementing a new view type in Wave Terminal. Use when creating a new view component, implementing the ViewModel interface, registering a new view type in BlockRegistry, or adding a new content type to display within blocks.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

Search and order products online. Compares prices across Polish marketplaces (Allegro, Ceneo, Google Shopping), presents options in a comparison table, and assists with checkout. Handles the full flow: priority selection, research, comparison, cart, and checkout handoff. Triggers on: "order", "buy", "find product", "compare prices", "cheapest", "zamow", "kup", "znajdz produkt", "porownaj ceny", "najtaniej".

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

mits-pl/wove422026년 6월 20일 업데이트

mits-pl의 스킬 모두 보기

이 스킬의 문제 신고