Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two-way deno bindings #12

Closed
2 tasks
eliassjogreen opened this issue May 15, 2020 · 6 comments
Closed
2 tasks

Two-way deno bindings #12

eliassjogreen opened this issue May 15, 2020 · 6 comments
Labels
enhancement New feature or request

Comments

@eliassjogreen
Copy link
Member

eliassjogreen commented May 15, 2020

  • Calling functions in the webview from deno
  • Calling deno from webview

To call deno externals from the webview an invoke handler function will be needed. I tried to implement it in src/lib.rs:111 but to no avail. We will also need to implement a way of calling deno callbacks from rust. To do this we will most likely use a polling solution like signal or fs events.

Help from some rust wizard would be pretty nice :)

@eliassjogreen eliassjogreen added the help wanted Extra attention is needed label May 15, 2020
@treeandgrass
Copy link

how about deno and webview share v8 isolate.

electron impleaments:

https://github.com/electron/electron/blob/06bf0d08dc3c941ccce0dfb0f9e0e146d9232605/shell/common/node_bindings.cc

@eliassjogreen
Copy link
Member Author

Probably isn't possible as the isolate isn't shared with plugins (docs.rs).

@jcc10
Copy link
Contributor

jcc10 commented Sep 20, 2020

Could I ask what is the situation where web-sockets would not be sufficient? Since the web-view front-end (IMO) should be on a different thread then the deno back-end.

@eliassjogreen
Copy link
Member Author

Ideally we want to use the webview_bind function but due to threading issues blocking the deno thread (because the op_webview_run is blocking) we cannot communicate between rust and deno and therefor not have the callbacks needed for implementing binding deno functions to a webview. Web-sockets would not work unless you run the webview in a separate web-worker, and running the webview in a separate web-worker blocks the web-worker deno message polling which means you cannot interact with the webview methods like webview.exit. For further reading on the threading issue.

@eliassjogreen
Copy link
Member Author

I solved it in release 0.5.3, it's far from perfect with a pretty bad js/ts interface but that can always be improved upon. There is an example in examples/external.

@eliassjogreen
Copy link
Member Author

And with the release of 0.5.4 the js/ts interface is pretty good:

for await (const event of webview.iter()) {
  console.log(event)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

3 participants