WIP: Fix Electron build issues and migrate to @nostr/tools

- Fix TypeScript compilation errors in platform services
- Add missing rotateCamera method and isNativeApp property
- Fix index.html path resolution for packaged Electron apps
- Create separate Vite config for Electron renderer process
- Migrate from nostr-tools to @nostr/tools via JSR for ESM compatibility
- Update all Vite configs to handle mixed npm/JSR package management
- Add comprehensive documentation in BUILDING.md
- Fix preload script path resolution in packaged builds

Resolves build failures with deep imports and missing UI in AppImage.
This commit is contained in:
Matthew Raymer
2025-06-25 08:53:21 +00:00
parent 94ac7d648d
commit fe55d0b431
18 changed files with 305 additions and 167 deletions

View File

@@ -21,7 +21,9 @@ const isDev = process.argv.includes("--inspect");
function createWindow(): void {
// Add before createWindow function
const preloadPath = path.join(__dirname, "preload.js");
const preloadPath = app.isPackaged
? path.join(app.getAppPath(), "dist-electron", "preload.js")
: path.join(__dirname, "preload.js");
logger.log("Checking preload path:", preloadPath);
logger.log("Preload exists:", fs.existsSync(preloadPath));
@@ -53,7 +55,7 @@ function createWindow(): void {
contextIsolation: true,
webSecurity: true,
allowRunningInsecureContent: false,
preload: path.join(__dirname, "preload.js"),
preload: preloadPath,
},
});
@@ -107,15 +109,27 @@ function createWindow(): void {
logger.log("process.cwd():", process.cwd());
}
let indexPath = path.resolve(__dirname, "dist-electron", "www", "index.html");
if (!fs.existsSync(indexPath)) {
// Fallback for dev mode
let indexPath: string;
if (app.isPackaged) {
indexPath = path.join(
app.getAppPath(),
"dist-electron",
"www",
"index.html",
);
logger.log("[main.ts] Using packaged indexPath:", indexPath);
} else {
indexPath = path.resolve(
process.cwd(),
"dist-electron",
"www",
"index.html",
);
logger.log("[main.ts] Using dev indexPath:", indexPath);
if (!fs.existsSync(indexPath)) {
logger.error("[main.ts] Dev index.html not found:", indexPath);
throw new Error("Index file not found");
}
}
if (isDev) {
@@ -124,11 +138,6 @@ function createWindow(): void {
logger.log("www assets path:", path.join(__dirname, "www", "assets"));
}
if (!fs.existsSync(indexPath)) {
logger.error(`Index file not found at: ${indexPath}`);
throw new Error("Index file not found");
}
// Add CSP headers to allow API connections
mainWindow.webContents.session.webRequest.onHeadersReceived(
(details, callback) => {