Closed lofcz closed 1 year ago
Narrowed the problem: In the reference project, I'm already using ts with (fixed on my side)
Built-in functions module
set to es6
and apparently Electron requires at least the entry point to be commonjs
.ElectronHostHook/api
are working fine :/
So I've got it to work after like 16 hours of headache - and never had a better dopamine rush afterwards.
The thing is that main.js
generated by ElectronSharp.CLI
swallows connection errors to ElectronHostHook
silently (see try-catch above const hostHookScriptFilePath = path.join(__dirname, 'ElectronHostHook', 'index.js');
).
My tsconfig.json
in the root of the project had already ElectronHostHook
in exclude
paths but electron-sharp
generates path ./obj/Host
which ofc has it's own tsconfig.json
but the root one with module
set to es6
had priority and kept overwriting transpiled code to es6
which is incompatible with electron (commonjs
expected).
For future readers:
tsconfig.json
- "exclude": ["ElectronHostHook", "obj/Host"]
obj/Host/main.js
and debug code around ln 410 (after socket.on('console-stderr', (data) => {
), try removing try-catch or just throw
to see whether the code executes.can't import { Connector } ...
see your transpiled index.js
, connector.js
in /obj/Host
and make sure it's commonjs
es2015
, feel free to push that up at least to 2017
electron-sharp + some node-gyp
magic
Version: 22.0.0.35063
Target: Blazor (server), .NET 7
Thanks for forking ElectronNET! I guess this is a pretty early issue to file but I can't seem to get HostHook to work and as it's neither working upstream, I'm posting the problem here.
export class HookService extends Connector { // @ts-ignore constructor(socket, public app: Electron.App) { // <-- nit: stock type hint for the "socket" param causes tsc to fail super(socket, app); }
}
RunCode
runs,mainWindow
is not nill. I'm not sure whetherchangeWallpaper
is executed but I suspect it isn't. I'm not familiar withElectronSharp.API.BridgeConnector
implementation (to debugHostHook.Call/CallAsync
impl, so this is where my investigation ended.Steps to Reproduce:
HostHook
demo