ProtonDesigner / roadmap

This is where progress on Proton features are tracked.
0 stars 0 forks source link

Plugins #9

Closed TechStudent10 closed 1 year ago

TechStudent10 commented 1 year ago

A plugin system and NPM module that is capable of modifying Proton's themes and functionality.

A plugin class structure could look something like this:

class Plugin {
    constuctor() {}
    load() {}

    hook_into_function() {}
    hook_into_another_function() {}
}

There could be a table/object that keeps track of which plugin hooks into which function at what priority.


As an alternative, maybe instead of a class structure, it's functional:

function initialize(arg1, arg2) {
    // Initialize Plugin
}

function hook_into_function(arg) {}
function hook_into_another_function(arg) {}

export {initialize, hook_into_function, hook_into_another_function}

Last suggestion: inheritance.

Main functionality (used in app)

class EditorLogic {
    do_something_1() {}
    do_something_2() {}
}

export default EditorLogic

In a plugin...

import EditorLogic from "@proton/plugin"
class Plugin extends EditorLogic {
    do_something_2() {}
}

export default Plugin

When the plugin needs to be called...

const plugins = [...]

...

// Later in the program
main_logic.do_something_1()
plugins.forEach(plugin => {
    plugin.do_something_1()
}
TechStudent10 commented 1 year ago

https://mwax911.medium.com/building-a-plugin-architecture-with-python-7b4ab39ad4fc

This could be the main inspiration for the plugin system, which I might start calling Add-ons or something.

TechStudent10 commented 1 year ago

Haven't posted in a while, I got plugins working.

Plugin's code (using an NPM module I made called @techstudent10/plugin image

Also managed to get logging to work lol image

Plugin in action image

TechStudent10 commented 1 year ago

I think I'm gonna close this as the basic functionality is here now