feat: electron playground - #38
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds an Electron-based “playground” to improve LNReader plugin development/debugging by providing a desktop environment with IPC-backed fetch/cookies/storage, plus a built-in WebView-like browser tab for solving challenges (e.g., Cloudflare) and reusing the same cookie jar.
Changes:
- Add a new
electron/subproject (Vite + Electron) with preload + main process IPC handlers for fetch/cookies/storage/settings. - Update the React UI to detect Electron and route settings persistence through
window.electronAPI, and switch chapter preview rendering to an isolated iframe-based preview. - Update tooling/config/docs: exclude/ignore Electron from root TS/ESLint, add
.gitignoreentries, and document the new Electron workflow (VI docs).
Reviewed changes
Copilot reviewed 22 out of 27 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tsconfig.json | Excludes electron/ from the root TS project. |
| eslint.config.js | Ignores the electron/ folder in root linting. |
| src/types/electron.d.ts | Adds global typings for window.electronAPI in the web UI codebase. |
| src/main.tsx | Skips the localhost fetch-rewrite when running under Electron. |
| src/components/settings.tsx | Uses Electron IPC for loading/saving settings when available. |
| src/components/parse-chapter.tsx | Reworks chapter preview to render in an iframe and loads plugin custom assets inside it. |
| electron/vite.config.ts | Adds an Electron-specific Vite config that merges the root config and overrides library aliases for IPC. |
| electron/tsconfig.json | Adds a dedicated TS config for the Electron subproject. |
| electron/preload/preload.ts | Implements a contextBridge preload exposing a whitelisted IPC invoke API. |
| electron/preload/preload.cjs | Provides a CommonJS preload variant for direct loading. |
| electron/package.json | Defines Electron subproject scripts and dev dependencies. |
| electron/package-lock.json | Locks Electron subproject dependencies. |
| electron/main/main.ts | Creates the main BrowserWindow, shared persistent session, menu, and a “Spawn New Tab” BrowserWindow. |
| electron/main/ipc/index.ts | Registers IPC handlers via side-effect imports. |
| electron/main/ipc/fetch-handler.ts | Adds IPC-based fetch via net.request, including cookie merge + Set-Cookie persistence. |
| electron/main/ipc/cookie-handler.ts | Adds IPC endpoints for cookie CRUD/flush/clear. |
| electron/main/ipc/storage-handler.ts | Adds a simple JSON-file backed plugin storage service over IPC. |
| electron/main/ipc/settings-handler.ts | Adds in-memory settings + effective User-Agent lookup for IPC fetch. |
| electron/lib/fetch.ts | Renderer-side fetch wrapper that calls IPC and rebuilds a Response. |
| electron/lib/cookie.ts | Renderer-side cookie helpers backed by IPC. |
| electron/lib/storage.ts | Renderer-side storage implementation backed by IPC. |
| electron/lib/utils.ts | Electron renderer override for shared utils (UA caching + Node crypto/Buffer exports). |
| electron/lib/env.d.ts | Electron-side global typing for window.electronAPI. |
| electron/eslint.config.js | Adds a minimal ESLint config for the Electron subproject. |
| electron/browser/index.html | Adds a simple Browser tab UI around a <webview> to interactively solve challenges. |
| docs/docs_vi.md | Documents the new Electron Playground workflow. |
| .gitignore | Ignores Electron build output and .agent/ artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| "include": [ | ||
| "main/**/*.ts", | ||
| "preload/**/*.ts", | ||
| "lib/**/*.ts" |
Comment on lines
+21
to
+26
| sandbox: true, | ||
| session: customSession, | ||
| preload: process.env.VITE_DEV_SERVER_URL | ||
| ? path.resolve(__dirname, '../../preload/preload.cjs') | ||
| : path.join(__dirname, '../preload/preload.cjs'), | ||
| }, |
Comment on lines
+173
to
+181
| const parts = raw.split(';').map(s => s.trim()); | ||
| const [nameVal, ...attrs] = parts; | ||
| const eqIdx = nameVal.indexOf('='); | ||
|
|
||
| const details: Electron.CookiesSetDetails = { | ||
| url: requestUrl, | ||
| name: nameVal.substring(0, eqIdx), | ||
| value: nameVal.substring(eqIdx + 1), | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Enhance the plugin development experience.