Creating Sliprail Extensions: Building Your Efficiency Tools from Scratch

Sliprail is a powerful efficiency tool, and one of its key features is the ability to create custom extensions. This guide will walk you through the process of creating your own Sliprail extensions.

Getting Started

Before you begin, it's helpful to understand that Sliprail extensions have their own architecture and can leverage both Node.js interfaces and the dedicated Sliprail SDK. To explore the available interfaces, you can install the @sliprail/sdk package, which provides TypeScript type definitions for all extension APIs.

Official Templates

The Sliprail team provides two official GitHub repository templates to help you get started:

  1. Single Extension Template: sliprail-extension-template - Perfect for creating a repository with just one extension.
  2. Multiple Extension Bundle Template: sliprail-extension-bundle-template - Ideal when you want to create multiple extensions within a single repository.

Creating Public Extensions

If you want to create an extension that anyone can install and use:

  1. Create a GitHub Repository: Start by creating a public repository on GitHub.
  2. Register Your Extension: Visit https://account.fengcen.io/developer and create a new Sliprail extension. Make sure to provide your GitHub repository link during registration. After registration, you will receive an extension ID that uniquely identifies your extension.
  3. Configure manifest.json: In your extension's manifest.json file, set the id field to the extension ID you received during registration. This step is crucial for proper extension identification and functionality.
  4. Develop Your Extension: Use the official templates as reference to build your extension functionality.
  5. Publish and Deploy: Push your code to the GitHub repository, and users will be able to install your extension.

Creating Private Extensions

For extensions that only you will use:

  1. Create Private Extension: Go to https://account.fengcen.io/developer and create a new Sliprail extension. Select "Private" for visibility - no GitHub repository link is needed. You will receive an extension ID upon registration.
  2. Configure manifest.json: In your extension's manifest.json file, set the id field to the extension ID you received during registration. This ensures your extension is properly recognized by the system.
  3. Develop Your Extension: Reference the official templates to build your extension.
  4. Load Locally: Use the Sliprail extension management interface to load your local extension for immediate testing and development.

Debugging Your Extension

During development, you may need to debug your extension to identify and fix issues. Sliprail provides built-in debugging capabilities:

Debug Logging

Sliprail offers a debug logging interface that allows you to print debug messages during extension execution:

  • Use the debug logging API provided by the @sliprail/sdk package to output debug information
  • Debug messages help you track the execution flow and identify potential issues
  • You can control the verbosity of debug output based on your development needs

Accessing Debug Logs

To view debug messages from your extension:

  1. Open Settings: Navigate to the Sliprail settings panel
  2. Click Debug Log: Locate and click the "Debug Log" option to directly open the debug log file
  3. Review Output: The debug log file will open, showing all debug messages from your extensions

This feature provides direct access to debug information, making it easy to monitor your extension's behavior and troubleshoot issues during development.

Important Technical Considerations

Dependency Management

Sliprail does not automatically run npm install for extensions. If your extension uses npm packages, you must:

  • Bundle all dependencies with your code
  • Include all bundled files when pushing to your GitHub repository
  • Ensure the extension can run without additional installation steps

Available APIs

Your extensions can utilize:

  • Node.js interfaces and modules
  • APIs provided by the @sliprail/sdk package
  • TypeScript type definitions for better development experience
  • Debug logging interfaces for troubleshooting

Native Modules

Sliprail extensions do not support native modules. Extensions should be built using pure JavaScript to ensure compatibility and stability across different environments. This includes avoiding native addons compiled with node-gyp or similar tools.

Extension Discovery

Currently, the Sliprail website does not display third-party extensions. However, popular extensions may be featured on the official website in the future. Focus on creating high-quality, useful extensions that provide real value to users.

Next Steps

Now that you understand the basics of creating Sliprail extensions, you can:

  • Clone one of the official templates
  • Explore the @sliprail/sdk API
  • Start building your first extension
  • Utilize the debug logging features for smooth development
  • Join the community to share your creations

Happy coding!