Getting started

This is a brief walk through for developing Drovp plugins.

Environment setup

Go to Settings section, scroll to the bottom, and enable Developer mode.

This will enable more settings, New subsection in main Registry section, as well as some other development related features around the app.

The app will now also have comfy buttons and context menus to open local plugins in your preferred code editor, so lets configure that.

Right below the now enabled Developer mode checkbox is the Edit command setting, where you can configure how to open projects in your preferred editor of choice. By default it's configured to use VSCode.

Creating a plugin

After enabling Developer mode, head over to the Registry section, where you can access the newly visible New subsection for creating new plugin boilerplates.

To find out more about where plugins are stored, how they are structured, and how they work, visit the Plugin structure documentation.

Plugin example

Here's a simple plugin that renames jpeg files to jpg.

Remember, a boilerplate with way more features can be generated in app's Registry > New section. This is just to give you an idea how a Drovp plugin looks like before you hop in.

package.json

{
    "name": "drovp-stop-jpeg",
    "description": "Renames jpeg extensions to jpg, as THEY SHOULD BE!",
    "version": "1.0.0",
    "main": "index.js",
    "keywords": ["drovpplugin"]
}

index.js

module.exports = (plugin) => {
    plugin.registerProcessor('stop-jpeg', {
        main: 'processor.js',
        accepts: {
            files: ['jpeg'],
        },
        // Simple & ugly options map with default values.
        // Please use a proper options schema for public plugins.
        options: {
            forceLowerCase: false,
        },
        threadType: 'io',
    });
};

processor.js

const FSP = require('fs').promises;

module.exports = async (payload, utils) => {
    const {input, options} = payload;
    const parts = input.path.split('.');
    const originalExtension = parts.pop();
    let jpgExtension = originalExtension.replace(/e/gi, '');

    if (options.forceLowerCase) jpgExtension = jpgExtension.toLowerCase();

    parts.push(jpgExtension);

    const newPath = parts.join('.');

    await FSP.rename(input.path, newPath);

    // Emits an output input the user can click on directly in the UI
    utils.output.file(newPath);
};

Publishing

To make the plugin available to all Drovp users, it needs to be published to npm. The documentation on how to do that can be found here: Contributing packages to the registry.

Please note that it might take several hours before the package pops up in search results, as npm might be slow on indexing new packages. You can check dropplugin keyword search to see if it popped up yet. For example, most of the official plugins took around an hour, but @drovp/rename took 5 days due to some indexing issue that was going on at the time. Plugins can still be installed since the moment they're published by manually entering their npm identifier into the external plugin installation input (section to the right of registry).

Versioning

When bumping the version of your package, please adhere to the semantic versioning standard of major.minor.patch, where patch means fixes, minor means new features, and major means any breaking changes.

In Drovp plugin context, breaking changes mean anything that in any way changes, or removes functionality of profiles created for any processor that comes with the concerned plugin. So stuff like changing or removing processors, processor options schema, dependencies other plugins might depend on, etc.

This way Drovp can warn users about a breaking change, and direct them to changelogs before they update their plugins.

Development mode caveats

Parts of the app or plugins might work differently in development mode.

Deprecation warnings

If Drovp detects plugin is local (not installed from registry), and development mode setting is enabled, it won't disable deprecation warnings when spawning its node subprocess. This means that if you, or something your plugin depends on, is using deprecated features, the operation will resolve normally, but there will be an extra deprecation error created by node in its outputs, flipping the operation into an error state.

Reloading plugins

When you work on plugins, Drovp seamlessly reloads them as it detects changes. This doesn't happen on Linux tough, as Node fs.watch's recursive file watching doesn't work there. Instead, you have to either press F5 anywhere in the app, or click the Reload button in the Plugins > Installed section.