fix: address review comments (protocol, config, startup)

This commit is contained in:
Aditya
2025-12-07 23:08:09 +05:30
parent b00adcbd38
commit 331c2f548c
6 changed files with 34 additions and 22 deletions

View File

@@ -0,0 +1,3 @@
node_modules
*.js
*.js.map

View File

@@ -7,12 +7,15 @@ export class Connector {
on(key: string, javaScriptCode: Function): void {
this.socket.on(key, (...args: any[]) => {
const id: string = args.pop();
const done = (result: any) => {
this.socket.emit(id, result);
};
args = [...args, done];
javaScriptCode(...args);
try {
javaScriptCode(...args, (data) => {
if (data) {
this.socket.emit(`${key}Complete${id}`, data);
}
});
} catch (error) {
this.socket.emit(`${key}Error${id}`, `Host Hook Exception`, error);
}
});
}
}

View File

@@ -0,0 +1,12 @@
{
"name": "electron-host-hook",
"version": "1.0.0",
"description": "Connector for Electron.NET projects.",
"main": "index.js",
"dependencies": {
"socket.io": "^4.8.1"
},
"devDependencies": {
"typescript": "^5.9.3"
}
}

View File

@@ -1,12 +1,9 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"noEmitOnError": true,
"removeComments": false,
"target": "ES2019",
"sourceMap": true,
"target": "es5",
"lib": ["es2015", "dom"]
"skipLibCheck": true
},
"exclude": ["node_modules", "wwwroot"]
"exclude": ["node_modules"]
}

View File

@@ -8,7 +8,11 @@ namespace ElectronNET.Samples.ElectronHostHook
{
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseElectron(args);
builder.WebHost.UseElectron(args, async () =>
{
var window = await Electron.WindowManager.CreateWindowAsync();
});
builder.Services.AddElectron();
builder.Services.AddControllersWithViews();
@@ -21,14 +25,6 @@ namespace ElectronNET.Samples.ElectronHostHook
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
if (HybridSupport.IsElectronActive)
{
Task.Run(async () =>
{
var window = await Electron.WindowManager.CreateWindowAsync();
});
}
app.Run();
}
}

View File

@@ -4,8 +4,9 @@
}
<!DOCTYPE html>
<html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width" />
<title>ElectronHostHook Sample</title>
<style>