Phase 1 step 1 of VNCprodbuild: electron/main.ts boots the same Next.js "standalone" server artifact the Dockerfile already produces (next.config.ts's output: "standalone") as a child process on a random localhost port, then opens a BrowserWindow at it. electron/preload.ts is a contextBridge stub (window.vnc.isElectron) for now. scripts/assemble-standalone.mjs copies public/ and .next/static into .next/standalone, mirroring what the Dockerfile does by hand, since `next build` deliberately leaves both out of the standalone output. scripts/build-electron.mjs bundles main.ts/preload.ts to CommonJS via esbuild (already a devDependency). New npm scripts: build:standalone, build:electron, electron:dev. electron-builder.config.js is intentionally minimal - no signing, no platform targets yet, just enough to prove the concept end to end. Also fixes a pre-existing repo-wide lint gap: vnc/plugins/smime is an independent sub-package (own package.json/esbuild build, browser-only globals) that was never added to eslint's ignores alongside repos:: and examples/**, so `npm run lint` - and the husky pre-commit hook - was failing on every commit regardless of what changed. Excluded it the same way those are, and added node globals for scripts/**/*.mjs so the new build helpers above lint cleanly too. Verified manually: npm run build:standalone && npm run build:electron && electron . boots the server and opens a window with no errors.
14 lines
637 B
TypeScript
14 lines
637 B
TypeScript
// Preload script for the VNCmail+ desktop shell. Runs in an isolated
|
|
// context with access to Node APIs, and exposes a minimal, explicit surface
|
|
// to the renderer via contextBridge - the renderer never gets direct Node or
|
|
// Electron access (contextIsolation + nodeIntegration: false, see main.ts).
|
|
//
|
|
// Walking-skeleton stub for now: just `isElectron`, so renderer code can
|
|
// detect it's running inside the desktop shell. A real API surface (native
|
|
// notifications, etc.) gets added on top of this bridge in a later step.
|
|
import { contextBridge } from "electron";
|
|
|
|
contextBridge.exposeInMainWorld("vnc", {
|
|
isElectron: true,
|
|
});
|