jeudi 19 mars 2015

Plugins with code that runs only once


I don't know exactly how to ask or define this question so it may be a duplicate but I haven't found anything yet.


I'm working on a project in Javascript (browser extension) that requires plugins, but it's too risky to allow them to be written in Javascript directly since users may download a plugin from somewhere and it would have access to a lot of power through the application. Thus, I decided that the plugins should be written in an entirely different language to which I would export an API object, limiting plugin capabilities to exactly the scope I want.


So at the moment, the plan is to use lua.vm.js so they can be written in Lua, with an object exported that gives access to the API. However, since I intend to implement a large part of the high-level functionality included in the release through this same system, I can't really have 10-20-50 instances of the VM running in web workers, so I decided that there is only one instance of the VM running at any one time and the scripts in Lua just build Javascript objects that describe functionality and since that functionality would then become part of the main process, the scripts would only need to run once.


At this point however I'm lost - I have no idea on how to design a practical API that would allow both initialization-only plugins and be useful enough to allow for enough scriptability to serve extension purposes.


Are there any known examples of such a plugin architecture or design patterns? Is this even possible or should I ditch the idea, bite the bullet and just hope users aren't malicious or careless enough?





Aucun commentaire:

Enregistrer un commentaire