Closed danbulant closed 4 years ago
@danbulant Let me tell you how Deno plugins work.
Plugins are nothing but Rust binaries that are built using cargo
(Rust's Package Manager)
Deno provides a rust crate called deno_core
that binds your rust binary with your Deno code.
Now, once we have built the binaries, we open them using Deno.openPlugin()
We can now access our Rust exported OPs with it.
You can see src/lib.rs
for how to export OPs and plugin/index.js
for how to open up a plugin.
Another point that the prepare_plugin
module not at all related to writing native plugins. It is a helper to import plugins from GitHub releases (so that the user does not have to build the while plugin from source).
This is basically for providing pre built binaries for the users OS.
Also, rust binaries are different for every OS. I recommend setting ng up GitHub actions for automating that.
See .github/workflows/main.yml
TL;DR Deno provides a really easy way to write native plugins which for me is better than Node's N-API
Feel free to ask questions here. I'll keep this issue open for discussion.
PS: my english sucks
I'm gonna hijack this thread as it seems relevant: When trying to run my script I get following Error in Runtime:
error: Uncaught ReferenceError: prepare is not defined
const pluginId = await prepare({
^
at https://raw.githubusercontent.com/tionis/autopilot-deno/master/plugin/index.js:30:20
I just used import AutoPilot from 'https://raw.githubusercontent.com/tionis/autopilot-deno/master/mod.ts';
to import the library.
@tionis I have fixed it. Please try again.
I reloaded it and am now getting a different error:
error: TS2339 [ERROR]: Property 'openPlugin' does not exist on type 'typeof Deno'.
return Deno.openPlugin(localPath);
~~~~~~~~~~
at https://raw.githubusercontent.com/manyuanrong/deno-plugin-prepare/master/mod.ts:64:15
@tionis You need to give Deno some flags.
deno run --unstable --allow-net --allow-plugin --allow-env --allow-read --allow-write file.ts
I'll add this in the README
@tionis Added a reference issue, see #5
@danbulant I hope you understood deno plugins. You can create more issues if you face a problem. I'll close this issue in case everything's ok :)
If only this had a few methods to manipulate the screens bitmap, you'd be well underway to an Electron replacement!
@nhrones I'd say https://github.com/eliassjogreen/deno_webview is some sort of a electron replacement. Could you elaborate on how this can lead to something like electron? (Electron is sort of chrome webview with node)
Unfortunately, deno-webview is a very limited tech. It basically allows you to launch a WebView and show static web content. There is no bi-directional interaction with deno.. It allows you to launch a webview with either a static web page or a URL As I see it, your autopilot has access to the native screen and I/O. If from deno you could then manipulate the screen bitmap, then you could produce a native app completely in deno. I have a framework that produces a complete DOM experience on a single full screen canvas element. It is very lightweight and performant. If we could manipulate native screen bitmap from deno, then we could have a DOM-Like native app from Deno. No HTML, CSS, just pure Typescript objects. I currently read one or more http/css files and use these to just-in-time 'hydrate' virtual DOM like objects to the canvas, These objects have full I/O eventing (click,hover...) They update 60 frames per second based on object state-change. Anyway, Autopilot seems to capture native I/O and bitmap, how much more work would be involved to output to native bitmap? Just musing about a very light weight 'Electron-Like' environment based on deno.
On Wed, May 27, 2020 at 11:39 PM Divy Srivastava notifications@github.com wrote:
@nhrones https://github.com/nhrones I'd say https://github.com/eliassjogreen/deno_webview is some sort of a electron replacement. Could you elaborate on how this can lead to something like electron? (Electron is sort of chrome webview with node)
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/divy-work/autopilot-deno/issues/3#issuecomment-635077594, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAZAPQ4S23XVMGYVXENVU5LRTXMFXANCNFSM4NJQGFZQ .
I'm afraid autopilot doesn't hijack the screen and does the I/O. It uses low level "official" C libraries binded with Rust to do it.
We could probably create GUI using rustlibs and bind to Deno. I'm really interested in your "typescript object GUI" idea and I think this can be a different project altogether. @nhrones Could you ping me on discord(username at Readme) or email. Thanks.
Closing this, Thanks you all.
Hey there! I'm new to deno, but I'm really interested in it. I couldn't find any help about importing deno plugins, and the only lib I found (https://deno.land/x/plugin_prepare/mod.ts) doesn't work since there's no
Deno.openPlugin
.Can you tell me how to import the plugin to use this lib? Thanks!