Giter Club home page Giter Club logo

Comments (6)

strogonoff avatar strogonoff commented on May 26, 2024 1

I should withdraw this request, as no-VM loading of trusted code is actually straightforward to do per my previous comment. Plugin manager is still handy for installing plugins from NPM and running plugin’s Node (main thread) code within VM sandbox.

from live-plugin-manager.

strogonoff avatar strogonoff commented on May 26, 2024

Basically I’d like to use all the usual APIs like plugin installation capabilities, being able to import host modules from the plugin, etc., the only difference being that plugin code might not run in a VM but in host context (at least when it runs in window). I’d be willing to contribute support for that option, but would appreciate pointers as to where to start.

from live-plugin-manager.

davideicardi avatar davideicardi commented on May 26, 2024

I think that VM is required, because it is the only way (as I know) to run javascript code on the fly. and that allows us to load and unloads plugins at runtime. The alternative is to just use standard require but you will not able to unload plugins easily.

But a lot of users use live-plugin-manager with Electron, so for sure it is an interesting use case. The problem is that I don't have experience on this, so for me it is difficult to help.

What I really appreciate is if you create a simple/minimal example with Electron that clearly shows current problems. Having this as a unit test should be ideal, but if not possible also a simple example like https://github.com/davideicardi/live-plugin-manager/tree/master/samples can be good. In this way I can better debug and investigate these problems.

from live-plugin-manager.

strogonoff avatar strogonoff commented on May 26, 2024

from live-plugin-manager.

strogonoff avatar strogonoff commented on May 26, 2024

I think I have narrowed my issue down to “there appears to be no way of making native methods (such as window.setTimeout, element.addEventListener, etc.) callable within VM”. Accessing within VM any function that reports “native code” when printed in browser console crashes browser window instantly. The worst is that the error is so fundamental it escapes any attempt to be caught and handled. DevTools becomes disconnected before anything can be printed.

(As far as the Electron/React issue, it seems to have been unrelated and appears to have been addressed in my project by adjusting Webpack setup. Only the native function call issue remains.)

from live-plugin-manager.

strogonoff avatar strogonoff commented on May 26, 2024

I think by running VM-loaded module in browser context I was stretching what VM was intended to do, and passing native window functions to VM sandbox would not be possible any time soon. Considering plugin code is trusted, plain require() may be the way to go in browser context. Conveniently, PluginManager’s getInfo()?.location can be used to construct the path to require. Thanks for this useful package!

from live-plugin-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.