littledivy / autopilot-deno

:rocket: Cross-platform desktop automation module for Deno.
https://autopilot.mod.land
MIT License
492 stars 15 forks source link

Writing Deno Plugins #3

Closed danbulant closed 4 years ago

danbulant commented 4 years ago

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!

littledivy commented 4 years ago

@danbulant Let me tell you how Deno plugins work.

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

tionis commented 4 years ago

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.

littledivy commented 4 years ago

@tionis I have fixed it. Please try again.

tionis commented 4 years ago

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
littledivy commented 4 years ago

@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

littledivy commented 4 years ago

@tionis Added a reference issue, see #5

littledivy commented 4 years ago

@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 :)

nhrones commented 4 years ago

If only this had a few methods to manipulate the screens bitmap, you'd be well underway to an Electron replacement!

littledivy commented 4 years ago

@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)

nhrones commented 4 years ago

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 .

littledivy commented 4 years ago

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.

littledivy commented 4 years ago

Closing this, Thanks you all.