-
Notifications
You must be signed in to change notification settings - Fork 30
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
basil.js Plugin System #337
Comments
ping |
Sounds neat. Some ideas:
|
If (big IF) somewhere in the future Adobe makes an update to the scripting engine, I guess it will be oriented towards the current JS workflows. Then using |
I wouldn't overcomplicate things for now. First we should finish implementing the thing itself. And then I think it would make most sense to have a new repo here that holds some official plugins and some example plugins, just as simple folders. We can always get more sophisticated later.
I would love to get it to work there, but I currently know of no way to retrieve the currently running (user) script file if it is started from VSCode. If you know of a way, let me know, I'll include it right away. Otherwise we'll have to live with this limitation for now. Apart from that I have to say the ExtendScript Debugger feels like a broken mess currently. Super slow, very buggy and very un-intuitive to set up. I hope Adobe gets their s**t together, but it seems like they take forever. So with my classes I will stay with Sublime Text until these problems are resolved. |
True.
Also true.
Yes. I took a look into the prerelease channels this morning. Looks still messy |
This is 🍌's! Great idea and way of implementing! The fact if the folder is there and properly named – it will just become available is huge. I can see this being a great way to ease the development for others to get into basil.js with just a couple useful functions or to simply have their own custom overwrites if they think we're doing something wrong. Also a playground for exploring GUI options which are often brought up as requests. For the structure of the plugins, would it help (especially when writing one) if it had the same name as the folder containing it rather than I'm also only using the Sublime route in my courses and workshops – luckily the Run In InDesign package has worked really smoothly. But should give VSCode a try... Is it necessary for you to overwrite the
No idea how this would work in the namespace... if it's possible to give priority when one calls |
I thougth about this as well, but then decided against it. I think it is just more flexible, to always use the same entry point. This way, users can rename folders themselves. This could be useful, if two plugins have the same name as well as when they want to control the order of execution of the plugins (we could make it a rule that plugins are called from top to bottom). So I think
Yes, a way to just extend existing functions would be a good idea. I don't know if your suggestion does work or cause some issues with namespace. I could do some testing later this week (hopefully). |
Also, since we now seem to agree on having a plugin system, I would like to create a dedicated repo for these plugins. However, I have still no admin privileges in the basil group. Could someone make me an owner, so I could also create a repo? I promise I won't break anything. 🤞 Thanks! |
Pinky Swear? |
@trych done |
Thanks! |
Quick question, are the folders necessary? In Processing sure, since it contains docs/library/examples/src/etc – but in js land... also borrowing from p5js– isn't it enough to just have the single plugin file, ie |
I would keep it at folders. That way potential plugin developers can add a README, some media, several js files etc. The question is rather if we should additionally allow toplevel |
|
I actually (now) dislike the |
I don't think the react thing should be an issue. I think the chance that a However, since we should also include |
My concern is not about a React file ending up there. It's about the syntax.highlighters that identify these as React files. It will start to pull in React specific snippets and what not. Also there should just be one file called |
Also we should ignore |
Hm, okay, but this is more the developer's concern then. But either way, I don't really care, so let's just decide the system checks for one
I kind of agree with the sentiment, but I still think if somebody wants to provide some functionality without exposing their code, they should still be able to do so. However, it does not really matter at all, if they really want to obfuscate their code, they can just include some So, all in all, I would say lets have this one entry point |
🚀 |
@trych – Just thought about it again due to #362 and was curious how you imagined including plugins for a given script (not sure I saw it mentioned above).
Seems like a trade off between easily loaded.. potential loading time before script run? issue of hot-swapping that folder if running into any conflicts between plugin names.. etc. |
Generally I think it should always load all install plugins, but I guess there should be some exclude/include functionality which you can put in the beginning of a given script in case you need to disable a certain plugin for a script. Edit: No, hang on, now I remember the actual plan: There are globally installed plugins next to you basil.js file, then there can be locally installed plugins next to your script file. That still requires some exclude functionality, though. Another edit: Actually, now that I think about it, this system is even cooler than I imagined it, because it means you could set up different "basil.js environments". Just put different basil.js files in different locations, each with a different set of plugins and then in your script you can target one specific "basil environment". |
One problem I see with implicitly loading all plugins is the following case: User A writes something. Installs plugin You get the gist. This will be a common error beginners will make. When using a explicit "Array/import/@include/something on the top of the main script" you directly see if something is missing |
IMHO this is the easiest way |
I'm for the I think we can suggest users put their plugins in a central place like |
If we use There will always be the possibility to load additional code with They way I implemented this in the branch so far is that plugins are auto-detected and automatically loaded and having used this setup on my system for a bit, I have to say this is really awesome and convenient. You can customize your basil setup and you don't need to re-link certain plugins that you always need for each little script that you write. Say you have a plugin that formats your console output in a certain way, because that's the way you prefer, then it would be really annoying to always put this on top of each script. I agree that there should be an easy way to disable all plugins, maybe some command Also note in the examples I give above that the plugin system reports in the command line how many global and local plugins were loaded, so it should not be difficult to detect that a plugin might be causing an issue. Lastly, you could always have a "clean" basil.js install somewhere on your system, as in this "environments" idea i mentioned above, so you could put a basil.js file at |
We have been talking about this in the past, I have been toying around with the idea for a while and been trying out some things.
I think we should include a simple plugin system in basil.js.
I just implemented the basics for such a system in the plugins branch that I just uploaded and even in this basic implementation the system is already quite powerful.
The current implementation works like this: The user can place a
plugins
folder next to thebasil.js
file. Within this plugins folder there can be subfolders, each of them is considered a plugin. If basil.js finds aindex.jsx
file in such a plugin folder, the code within will be executed. All this happens before the main script flow of the user script is started. This allows to inject new functions into the global basil namespace (so, basically to add new custom basil functions) or to overwrite existing basil functions. (Later we could also add the possibility of "hooks" that trigger at specific events like document creation or after the main script flow finishes etc.)To allow for easy disabling of plugins, a folder can be renamed to start with an underscore (
_examplePlugin
), in this case the plugin will be ignored.Additionally there is the possibility to install "local" plugins on a per script basis, by placing a
plugins
folder next to the script file of the user. These plugins will be registered the same way, but they only refer to the script file they are placed next to (also this localplugins
folder could further come with a list of global plugins that should be ignored to be able to further fine tune the plugin structure of each single script. This is not implemented yet in the branch at its current state). Due to the nature of ExtendScript, the local plugin folder currently works only when the script is run via Sublime Text or the InDesign Scripting panel (as I have found no way to retrieve the user script file when run from ESTK or Visual Studio Code).Just to give you a quick and very simple example what is possible and how a plugin code could look like: Let's write a script that creates a new function
bananaAlert()
that alerts a 🍌-emoji. Let's further alter basil'sprintln()
function in a way that it also adds some bananas to its output. A plugin like this would simply be aindex.jsx
file that is placed into a folderbanana
next to thebasil.js
file. Theindex.js
file would contain code like this:And then a user script like this
would output something like this:
(and alert 🍌).
Hope this all makes sense and that you agree that such a plugin architecture adds huge value to basil.js. I think it will also help us devs if we could not (right away) agree on the best implementation of a feature, so that we could just write a plugin that solves our specific problem and that could then be used in class for example.
Would love to hear your opinions and feedback, so check out the
plugins
branch and give it a try! 😎The text was updated successfully, but these errors were encountered: