Plugin API #114
Replies: 6 comments 2 replies
-
Thanks for the super thorough writeup and roadmap. A few follow up thoughts and questions:
Let's discuss more next time we meet! |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Another good use-case for plugins could be error tracking services, like rollbar or sentry. Log errors on unsuccessful fetches, broken assets, etc. |
Beta Was this translation helpful? Give feedback.
-
A few more questions and thoughts for our discussion this week: Questions
Requirements
|
Beta Was this translation helpful? Give feedback.
-
Work Session Aug 10, 2023
Key Takeaways
Key Open Questions
Next Steps
|
Beta Was this translation helpful? Give feedback.
-
Plugin API for content and monitor is included in 2.0 release! |
Beta Was this translation helpful? Give feedback.
-
Dumping some ideas I've been mulling over while using launchpad lately.
I'm wondering if it might be worth taking #65/#70 a step further and abandoning JSON configs altogether, rearchitecting the config (and launchpad core) to use a plugin API inspired by some common js build tools and frameworks like vite, rollup, webpack, etc.
Edit 05/10: The original proposal was vague on the role of
content
andmonitor
as plugins vs higher-level config options. After some thought, it seems like the latter makes more sense. I've updated the proposal to reflect that.API Proposal
Basic Plugins
A simple plugin would look something like this:
Both options show basically the same thing:
Complex Plugins
In addition to this, a plugin could also be a function that returns or resolves an object with the same shape, allowing for more complex plugins that need to do some async work before returning the plugin object, or that need to be configured with some options:
Usage in Launchpad
I think it's worth thinking about launchpad as having two different lifecycles: one for
content
and one formonitor
, each with their own set of events. Plugins would be focused on one or the other, not both.The config for
content
andmonitor
would look largely the same, though each could have their own set of plugins.Plugin Specific Events (maybe?)
In addition to the lifecycle hooks from launchpad core, we could potentially also add a way for plugins to emit events that other plugins could listen for.
Why?
Project-specific needs
As launchpad is used in more and more projects, it seems like we're occasionally adding features, flags, and options to the config that are pretty project specific, and because of launchpad's API they need to be implemented at the library level. Making this change would open up the internals of launchpad, so that those project specific changes could instead be written as plugins in the project repo.
Isolated code
The event/hooks system also means more isolated, feature-focused code. Imagine a simple plugin that, after the content is done downloading, copies it to an additional directory – a feature that could be useful for mirroring the content directory in the project folder and build folder for unity projects (sounds super simple, but imagine we want to only perform this copy if that target directory exists, and also backup the existing data incase something goes wrong). With the current API, if we wanted to include this as a
launchpad content
feature, we would have to add at least one option to the content config, and add that logic somewhere in thecontent
class. With the plugin API, this logic could live isolated in acopyContent()
plugin.In-place testing and modification
Additionally, this would allow for quick and easy testing of changes/additions to launchpad logic without having to setup a linked local clone of the launchpad repo. You could add (or copy) a plugin to your project repo, make updates and test locally before copying it to the launchpad repo.
Expose APIs for modifying json
For the
content
lifecycle, we can expose opportunities to alter json before it's written to disk. Currently the only way to modify json would be adding a custompost-content
hook that would read in the data, modify it, and write it to disk again. Plus, a secondary script like that would either have to recreate the backup behavior, or sacrifice that security.Env overrides, shareable configs, jsdoc hints
This approach also offers all of the benefits mentioned in #65.
To me this doesn't feel like a super big jump, considering launchpad already has defined lifecycle hooks, plus
pre
/post
hooks. This would however likely involve a pretty big effort to refactor the existing launchpad tools and documentation to match this plugin API.Potential Roadmap for Refactor
monitor
andcontent
lifecycles, and thecontext
for eachcore
,content
, andmonitor
to implement event emitter APISome Open Questions
Beta Was this translation helpful? Give feedback.
All reactions