Files
2nd/10_Wiki/Topic_Programming/Programming & Language/Electron.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

6.3 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-electron Electron 10_Wiki/Topics verified self
Electron Framework
Atom Shell
none A 0.9 applied
desktop
javascript
chromium
nodejs
2026-05-10 pending
language framework
TypeScript/JavaScript Electron 33+

Electron

매 한 줄

"매 Chromium + Node.js를 묶어 web tech 으로 desktop app 을 build". GitHub 이 Atom editor 용으로 만든 framework 가 VS Code, Slack, Discord, Figma desktop, 1Password 의 backbone 이 되었음. 2026 현재 Electron 33+ 가 process model 강화 (utility process), V8 sandbox, ASAR integrity 검사 의 기본화.

매 핵심

매 process model

  • Main process: Node.js runtime, app lifecycle, native API (file, dialog, tray) 의 owner. 매 1 개 instance.
  • Renderer process: Chromium tab 마다 1 개. BrowserWindow content. Sandbox 기본 ON (Electron 20+).
  • Preload script: Renderer 의 isolated world 에서 실행, contextBridge 로 main 과 안전 bridge.
  • Utility process: 매 v22+ 추가. Heavy CPU/IO offload (image decode, ffmpeg).

매 IPC 패턴

  • ipcRenderer.invokeipcMain.handle (Promise-based, 권장).
  • ipcRenderer.sendipcMain.on (fire-and-forget).
  • webContents.sendipcRenderer.on (main → renderer push).
  • contextIsolation: true + nodeIntegration: false 의 mandatory.

매 응용

  1. Editor: VS Code, Atom, Obsidian.
  2. Communication: Slack, Discord, Microsoft Teams.
  3. Design: Figma desktop, Notion.
  4. Crypto/Wallet: 1Password, Exodus.

💻 패턴

Secure preload bridge

// preload.ts
import { contextBridge, ipcRenderer } from 'electron'

contextBridge.exposeInMainWorld('api', {
  readFile: (path: string) => ipcRenderer.invoke('fs:read', path),
  onUpdate: (cb: (v: string) => void) => {
    const listener = (_: unknown, v: string) => cb(v)
    ipcRenderer.on('app:update', listener)
    return () => ipcRenderer.removeListener('app:update', listener)
  },
})

Main IPC handler with validation

// main.ts
import { ipcMain, app } from 'electron'
import { promises as fs } from 'node:fs'
import path from 'node:path'

ipcMain.handle('fs:read', async (_event, requested: string) => {
  const userData = app.getPath('userData')
  const resolved = path.resolve(userData, requested)
  if (!resolved.startsWith(userData)) throw new Error('path traversal')
  return await fs.readFile(resolved, 'utf-8')
})

BrowserWindow secure defaults

import { BrowserWindow } from 'electron'
import path from 'node:path'

const win = new BrowserWindow({
  width: 1200,
  height: 800,
  webPreferences: {
    preload: path.join(__dirname, 'preload.js'),
    contextIsolation: true,
    nodeIntegration: false,
    sandbox: true,
    webSecurity: true,
  },
})

Auto-updater (electron-updater)

import { autoUpdater } from 'electron-updater'

autoUpdater.checkForUpdatesAndNotify()
autoUpdater.on('update-downloaded', () => autoUpdater.quitAndInstall())

Utility process offload

import { utilityProcess, MessageChannelMain } from 'electron'

const { port1, port2 } = new MessageChannelMain()
const child = utilityProcess.fork(path.join(__dirname, 'worker.js'))
child.postMessage({ task: 'transcode' }, [port2])
port1.on('message', (msg) => console.log('result', msg))

Code signing build (electron-builder)

{
  "build": {
    "appId": "com.example.app",
    "mac": { "hardenedRuntime": true, "gatekeeperAssess": false, "notarize": true },
    "win": { "signingHashAlgorithms": ["sha256"] },
    "asar": true
  }
}

매 결정 기준

상황 Approach
Cross-platform desktop, web team Electron
Bundle size critical (<50MB) Tauri (Rust) 고려
Native feel mandatory Native (Swift/Kotlin)
Existing web app → wrap Electron
Mobile target 도 필요 React Native / Flutter

기본값: 매 Electron 33+ + contextIsolation + electron-builder + auto-updater.

🔗 Graph

  • 부모: Chromium · Nodejs_and_Backend_Optimization
  • 변형: Tauri
  • Adjacent: Chrome DevTools(크롬 개발자 도구) · V8 엔진 힙 아키텍처

🤖 LLM 활용

언제: web stack 재사용, 빠른 cross-platform delivery, rich web-based UI 필요. 언제 X: 매 100MB+ binary 가 unacceptable, 매 deep OS integration (kernel ext, system tray 만 의 limit), battery-critical mobile.

안티패턴

  • nodeIntegration: true with remote content: 매 RCE risk. 매 contextIsolation 강제.
  • require('electron').remote: deprecated, removed v14+. @electron/remote 도 안티 — IPC handle 로 교체.
  • 불특정 origin loadURL: 매 untrusted web 을 BrowserWindow 에 load 하면 sandbox escape 위험.
  • ASAR 만 의 protection: ASAR 는 압축 일 뿐. Source 보호 의 X — 매 native module / 서버 side 로 logic 이동.

🧪 검증 / 중복

  • Verified (electronjs.org docs, Electron 33 release notes 2026).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — Electron 33 process model + secure IPC patterns

🛠️ 적용 사례 (Applied in summary)

🔎 코드베이스 근거 (자동 추출 — E:\Wiki 레포)

실제 구현/사용 위치:

  • photoai/electron.vite.config.ts:2 — import { defineConfig, externalizeDepsPlugin } from 'electron-vite'
  • photoai/src/shared/types.ts:485 — /** 드롭된 File의 로컬 절대경로 반환(Electron webUtils). 경로가 없으면 빈 문자열. */
  • photoai/src/preload/inference.ts:1 — import { contextBridge, ipcRenderer } from 'electron'
  • photoai/src/preload/index.ts:1 — import { contextBridge, ipcRenderer, webUtils } from 'electron'
  • photoai/src/main/fsExplorer.ts:4 — import { shell } from 'electron'
  • photoai/src/main/embedder.ts:1 — import { BrowserWindow } from 'electron'

관련 커밋:

  • photoai 3e73967 darktable-inspired reskin + metadata/collections, map, easy mode, select/export
  • photoai 8a8c102 Initial commit: AI Photo Organizer (Electron + face-api)

자동 생성: code_grounding.mjs · 재실행 시 갱신됨