-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Open
Description
https://github.com/formula1/match-lock/tree/Bug-NW.js/typescript/prep-app
https://github.com/formula1/match-lock/blob/Bug-NW.js/typescript/prep-app/src/App.tsx
package.json
{
"name": "@matchlock/prep-app",
"main": "main.js",
"nodejs": true,
"window": {
"title": "MatchLock Prep App",
"width": 1024,
"height": 768
}
}
main.js
const { join: pathJoin } = require('path');
const { readFileSync } = require('fs');
// Read NW.js config from the local package.json
const config = JSON.parse(readFileSync(pathJoin(__dirname, 'package.json'), 'utf-8'));
const isDev = process.env.NODE_ENV !== 'production';
const url = isDev ? 'http://localhost:5173' : 'index.html';
console.log("About to start NW.js");
nw.Window.open(url, config.window, (win) => {
console.log("NW.js started");
win.show(); // Ensures it becomes visible
win.focus(); // Brings to foreground
// Enable devTools with error handling
win.on("loaded", () => {
setTimeout(() => {
try {
console.log("Opening DevTools...");
win.showDevTools();
console.log("DevTools opened successfully");
} catch (error) {
console.error("Failed to open DevTools:", error);
}
}, 2000);
});
// Add error handling for devtools events
win.on('devtools-opened', (url) => {
console.log('DevTools opened at:', url);
});
win.on('devtools-closed', () => {
console.log('DevTools closed');
});
});
Metadata
Metadata
Assignees
Labels
No labels