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.jsSetting 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:
- Open your terminal (or Command Prompt on Windows).
- Navigate to the folder where you want to create the BeeGraphy Sandbox directory.
- Run the following command to install the BeeGraphy Sandbox and set the BeeGraphy registry as the npm registry for your project:
- This command will set the npm registry to BeeGraphy’s and start installing the BeeGraphy Sandbox package.
- When prompted to install the
@beegraphy/sandbox
package, type “y” and press Enter. - 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. - The installer will automatically download and install any dependencies required for your project.
- 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:
This error occurs due to an issue with npm’s handling of optional dependencies. To fix this issue, follow these steps:
- Delete the
node_modules
folder and package-lock.json
file from your BeeGraphy Sandbox project directory. - In your terminal, run the following command to reinstall all dependencies:
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:
- 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.
- cd your-sandbox-project-directory
- Replace your-sandbox-project-directory with your actual project's directory path.
- 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.
- Run Your BeeGraphy Editor Locally: To start developing and testing your plugin, run the following command within your project directory:
- npm start
- 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.
- Login using your BeeGraphy account
- 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.
- 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.
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.
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:
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
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.
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.
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.
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.
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.
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.
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.
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.