Deno Desktop - How to combine win.binding with framework autodetection? #36392
|
When reading the docs, I see 2 separate options:
Option 1 allows to add bindings to supply deno functions to access the filesystem, etc. Now for a real application I want to combine that, but from the documentation it's not clear for me how to do that. So my question is how can I add a some startup wrapper code that executes in deno's context (having access to the Deno.BrowserWindow() etc) so that I can bind functions that will be later available for the autodected application before handing it over to the framework auto-detection for the handler? Thank you! Take care, |
Replies: 3 comments
|
The exact combination is not currently exposed by the CLI.
If you need bindings, the supported approach is an explicit entry: const win = new Deno.BrowserWindow();
win.bind("myBinding", () => {
// ...
});
// Import and start the framework server here.You then own the framework server startup and build output. Framework HMR will only work if the server you start provides it. So there is currently no hook for registering bindings before handing control back to the auto-generated framework entry. |
|
There isn't currently a general startup-wrapper hook that can be composed with framework auto-detection. Framework detection only runs when the source is
Therefore, during detected-framework HMR, there is no user-owned Deno startup module in which to register For now, use an explicit entrypoint and start the framework server or handler yourself: const win = new Deno.BrowserWindow();
win.bind("readFile", async (path: string) => {
return await Deno.readTextFile(path);
});
// This module must start the framework/server integration.
await import("./server.ts");deno desktop --hmr desktop.tsThe first There is one framework-specific exception in production: for example, Vite SSR detection imports an existing A bootstrap/preload option imported by both the generated production entrypoint and the framework-HMR runtime would be needed to support this generically. |
|
Thank you guys for the quick answer! I feared that I needed to do the manual route. Take care, |
There isn't currently a general startup-wrapper hook that can be composed with framework auto-detection.
Framework detection only runs when the source is
.. Supplyingdesktop.tsswitches to explicit-entrypoint mode:source_file == "."Therefore, during detected-framework HMR, there is no user-owned Deno startup module in which to register
win.bind().For now, use an explicit entrypoint and start the framework server or handler yourself: