Inter Plugin Communication

UXP allows communication between plugins that are installed in the same application.

This is particularly handy when you know a certain task is already automated by another plugin and you would like to invoke it instead of duplicating the effort. But make sure the user is not caught by surprise. Your plugin should call out such dependencies to ensure flawless functioning of your plugin.

The Plugin Manager module provides APIs that will help establish the connection. But before we take a look at an example, be sure to be well-versed in these topics

Additionally, you will need

System requirements

Please make sure your local environment uses the following application versions before proceeding.

Example

Caller Plugin

data-slots=heading, code
data-repeat=2
data-languages=JSON, JavaScript

manifest

{
    "requiredPermissions": {
        "ipc": {
            "enablePluginCommunication": true
        }
    }
}

JavaScript

const { pluginManager } = require("uxp");
function communicateWithAnotherPlugin() {
    try {
        const allPlugins = pluginManager.plugins;
        const plugin = Array.from(allPlugins).find(plugin => plugin.id === "com.adobe.example.coolPlugin");
        if (plugin && plugin.enabled) {
            console.log('All commands:', plugin.manifest.commands);
            console.log('All panels:', plugin.manifest.panels);

            /* Show the plugin panel; Note that panels can only be made visible -- you can't ask to hide the panel */
            plugin.showPanel("simplePanel");

            plugin.invokeCommand("simpleCommand");

            /* Send an argument to the command  */
            const name = {
                firstName: "John",
                lastName: "Doe"
            };
            plugin.invokeCommand("commandWithInput", name);
        } else {
            // prompt the user to install or enable the plugin before trying again
        }
    } catch (e) {
        console.error(e);
    }
}

Callee Plugin

data-slots=heading, code
data-repeat=2
data-languages=JSON, JavaScript

manifest

{
    "id": "com.adobe.example.coolPlugin",
    "name": "The cool plugin",
    "main": "index.html",
    "entrypoints": [
        {
            "type": "command",
            "id": "simpleCommand",
            "label": "Do your thing"
        },
        {
            "type": "command",
            "id": "commandWithInput",
            "label": "Do you thing with inputs"
        },
        {
            "type": "panel",
            "id": "simplePanel",
            "label": {"default": "Do your thing with UI"},
            // ...
        }
    ],
}

JavaScript

const { entrypoints } = require("uxp");
entrypoints.setup({
  commands: {
    simpleCommand: () => doThing(),
    commandWithInput: (args) => doThing(args)
  },
  panels: {
    simplePanel: {
      show({node} = {}) { /* ... */}
    }
  }
});

function doThing(args) {
  console.log('Executed a command to do something cool', args && args.data[0]);
}

Additional notes

Reference docs