Create Plugins

A step by step guide to create plugins using BeeGraphy sandbox

Creating a Plugin for BeeGraphy Editor

Prerequisites

Before you can create a plugin for BeeGraphy Editor, you need to ensure that you have the latest version of Node.js installed on your system. You can download Node.js from the official website: Node.js

Setting up the BeeGraphy Sandbox

To create a plugin for BeeGraphy Editor, you'll need to set up the BeeGraphy Sandbox. Follow these steps to configure the sandbox:
  1. Open your terminal (or Command Prompt on Windows).
  2. Navigate to the folder where you want to create the BeeGraphy Sandbox directory.
  3. Run the following command to install the BeeGraphy Sandbox and set the BeeGraphy registry as the npm registry for your project:
  4. npx --registry=https://npm.beegraphy.com @beegraphy/sandbox
  5. This command will set the npm registry to BeeGraphy’s and start installing the BeeGraphy Sandbox package.
  6. When prompted to install the @beegraphy/sandbox package, type “y” and press Enter.
  7. The BeeGraphy Sandbox will prompt you to provide a name for your sandbox project. By default, it is named beegraphy-sandbox. You can choose to use the default name or enter a custom name for your project.
  8. The installer will automatically download and install any dependencies required for your project.
  9. Additionally, the installer will create an example plugin named node-editor-package-example in your sandbox project.
Once the BeeGraphy Sandbox setup is complete, you can start developing your custom plugin for BeeGraphy Editor within the sandbox environment.

Fixing Rollup Dependency Errors in BeeGraphy Sandbox

After setting up the BeeGraphy Sandbox, you might encounter an error similar to:
Error: Cannot find module '@rollup/rollup-darwin-arm64'
This error occurs due to an issue with npm’s handling of optional dependencies. To fix this issue, follow these steps:
  1. Delete the node_modules folder and package-lock.json file from your BeeGraphy Sandbox project directory.
  2. In your terminal, run the following command to reinstall all dependencies:
  3. npm install
This should resolve the Rollup dependency issue and allow your BeeGraphy Sandbox to install successfully.

Getting Started with Your BeeGraphy Plugin

Prerequisites

Once you have set up the BeeGraphy Sandbox and explored the project structure, it's time to dive into developing your custom BeeGraphy plugin. Here's how to get started:
  1. Navigate to Your Sandbox Project Directory: If you provided a custom name for your sandbox project, navigate to the directory where it was created. If you used the default name ("beegraphy-sandbox"), you can find it in the current directory.
  2. cd your-sandbox-project-directory
  3. Replace your-sandbox-project-directory with your actual project's directory path.
  4. Explore the Project Structure: Take some time to understand the project structure, including the "node-editor-package-example" plugin. This will give you insights into how BeeGraphy plugins are organized and how you can structure your own.
  5. Run Your BeeGraphy Editor Locally: To start developing and testing your plugin, run the following command within your project directory:
  6. npm start
  7. This command will launch a local BeeGraphy Node Editor instance on localhost:2023. You can access the BeeGraphy Node Editor in your web browser by navigating to http://localhost:2023.
  8. Login using your BeeGraphy account
  9. Develop Your Plugin:Now that you have the development environment set up and your plugin configured, you can start developing your custom BeeGraphy plugin. Refer to the BeeGraphy documentation for guidance on plugin development.
  10. Testing Your Plugin:As you make changes to your plugin, you can test them within the locally running BeeGraphy Node Editor. Simply access http://localhost:2023 in your web browser to see how your plugin integrates with BeeGraphy Editor.
Integration and Sharing:Once your plugin is complete and thoroughly tested, you can consider integrating it into your BeeGraphy Editor workflow or sharing it with the BeeGraphy community.
That's it! You're now ready to embark on your BeeGraphy plugin development journey. Enjoy building amazing extensions for BeeGraphy Editor!

Creating Your First Node for BeeGraphy Node Editor

In BeeGraphy Node Editor, nodes are essential building blocks for creating visual workflows. To create your first node, you will need to define a NodePackage that includes your node and its associated properties. Let's go through the process step by step:

1. Define a NodePackage

First, create a NodePackage with the desired name, in this case, 'Example', and include the node types within it. Additionally, you can use the init function to preload any necessary resources like a wasm file.

import { NodeTypePackage, NodeType } from 'beegraphy';
      
export const NodeEditorExamplePackage = (): NodeTypePackage => ({
  async init() {
    // Perform any preloading here if needed
  },
  name: 'Example',
  nodeTypes: [...ExampleGroupNodes], // Include your node types here
});

2. Organize Nodes into Groups

For better organization, you can group your nodes. In the above code, we include an array of ExampleGroupNodes. You can create and customize your node groups as needed.

import { NodeType } from 'beegraphy';
            
export const ExampleGroupNodes: NodeType[] = [ExampleNode]; // Include your nodes here

3. Define Your Example Node

Now, let's explore the structure of an example node. Below is an example node named 'Example Node' with input (inPorts) and output (outPorts) ports:

import { NodeType, Type, PortParams } from 'beegraphy';
      
export const ExampleNode: NodeType = {
        name: 'Example Node',
        description: 'This is an example node, feel free to customize or remove it.',
        groupName: 'Example Group', // Assign it to the desired group
        keywords: ['example', 'ex'], // Keywords for searching
        icon: exampleNodeIcon, // Define the icon for your node
        inPorts: [
          {
            name: 'a',
            label: 'A',
            type: Type.Number, // Port type
            description: 'A In Port Description',
          },
          {
            name: 'b',
            label: 'B',
            type: Type.Number,
            description: 'B In Port Description',
            defaultValue: 2, // Default value for the port
          },
        ],
        outPorts: [
          {
            name: 'c',
            label: 'C',
            type: Type.Number,
            description: 'C Out Port Description',
          },
        ],
        exec({ a, b }: PortParams): PortParams {
          // Your node's execution logic goes here
          // You can access input values a and b, perform operations, and return the result
          const c: PortParams = {
            type: Type.Number,
            value: a.value * b.value, // Your computation logic here
          };
          return { c };
        },
      };
This example node includes several important properties:
  • name: The name of your node.
  • description: A description of your node (optional).
  • groupName: The name of the group to which your node belongs.
  • keywords: Keywords that can be used to search for your node.
  • icon: An icon for your node.
  • inPorts: Input ports with names, labels, types, and descriptions.
  • outPorts: Output ports with names, labels, types, and descriptions.
  • exec: The execution function for your node, where you define the logic based on input ports and return output ports.

4. Port Types

Nodes in BeeGraphy can have various port types. In the example above, we used Type.Number. You can choose from a range of predefined types such as strings, vectors, curves, colors, and more to suit your specific use case.

That's it! You've created your first node for BeeGraphy Node Editor. You can now include this node package in your BeeGraphy project and start using it within the editor's visual workflows. Remember to customize the node properties and logic to fit your specific needs.

Publishing your first plugin package

To use your plugin, you need to publish it to the BeeGraphy Package Manager (BGPM).


Step 1: Navigate to the Workspace - Plugins Page

Workspace Plugin

You currently don't have any plugins.

Here you will see your plugins once you create them.


Step 2: Create a New Plugin

Click the "New Plugin" button: In the upper right corner, to start creating a new plugin.

New Plugin

Step 3: Fill out the Plugin Creation Form

A form will open with the following fields:

  • Title: Enter the name of the plugin.
  • Name (PluginID): Specify a unique identifier for the plugin.
    Note: Ensure the name field in the package.json file exactly matches this PluginID. This is essential for a successful publishing process, as any mismatch could lead to errors or conflicts in the plugin registry.
  • Slug: Enter a unique URL identifier for the plugin (must not be repeated).
  • Plugin Type: Choose between Library or Node Editor Package.
  • Boolean Button: Specify the status of the plugin (Public or Private).
  • Upload Image: Upload images for dark and light interfaces.
  • Description: Add a description of the plugin.

Once all fields are filled, click the "Create" button to complete the plugin creation.

Plugin Fields

Step 4: View Your Plugin

After creating the plugin, it will be visible in the designated section on the Plugins page. You can view and manage your newly created plugin from there.

Plugin View

Step 5: Open the Plugin After Creation

After creating the plugin, it will open on a page displaying information about the default version. Here, you can view details about the current version of the plugin.

View Plugin Information: The page will show version details, status, and other plugin-specific information.


Plugin Info

Step 6: Choose the Version Type and Add a New Version

When adding a new version, three types of versions are available:

  • Major: Major changes that introduce new features or significant changes.
  • Minor: Minor changes that add functionality in a backward-compatible manner.
  • Patch: Bug fixes that address issues without affecting functionality.

Choose the necessary version type and click the "Add" button to proceed.


New Version

Step 7: Upload the Zip File

For the new version of the plugin, you need to upload a zip file that includes the following required files:

  • README.md: Description of the plugin.
  • package.json: Configuration file for the plugin package.
  • icon.png: Icon of the plugin.
  • tsconfig.json: TypeScript configuration file.

This folder was created in the "beegraphy-sandbox". You need to compress it into a zip file and upload it.


Step 8: Upload Process

After uploading the zip file, the following steps will occur:

  • Unzip: Unzipping the uploaded zip file.
  • Install Dependencies (npm i): Installing dependencies using npm.
  • Build: Building the plugin.
  • Grab: Capturing the necessary data for the plugin.
  • Deploy: Deploying the plugin.
Upload Plugin

Step 8: Publishing the Plugin

After successfully completing the upload process, the Publish button will be activated.

By clicking the Alpha Publish button, the new version of the plugin becomes available for internal testing but is not yet accessible to other users on the BGPM page of the site.

Publish Plugin

Step 9: Publishing the Plugin

By clicking the Publish button, the new version of the plugin becomes available to other users on the BGPM page of the site.

Note: The plugin can be unpublished within 24 hours after publication if needed.

Publish