-
Notifications
You must be signed in to change notification settings - Fork 856
feat: add robust plugin management system to demo #2356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements a comprehensive plugin management system for the Clappr demo site, enhancing plugin selection and addressing player lifecycle issues.
Key changes:
- Added
PluginManagerclass with dropdown selection and custom URL input - Fixed player instance stacking bug by properly destroying instances before recreation
- Improved asynchronous plugin loading with better error handling and fallback behavior
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 12 comments.
| File | Description |
|---|---|
| packages/player/public/stylesheets/style.css | Updated layout for flexbox-based responsive design and added comprehensive plugin UI styling |
| packages/player/public/index.plainhtml5.html | Integrated plugin management system, improved script loading logic, and added player lifecycle management |
| packages/player/public/index.html | Identical plugin system implementation as plainhtml5 version with adjusted version link |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Hi @leaofelipe, I’ve made the requested updates and resolved the issues. Let me know if anything else is needed before approval. Thanks! |
This PR significantly improves the "Add external plugins" functionality in the Clappr demo site by implementing a comprehensive plugin management system that works across both the main version and plain HTML5 version.
Key Changes & Features
Complete Plugin Management System: Added a sophisticated
PluginManagerclass to handle plugin selection, custom URL adding, and UI display.Enhanced User Interface: Replaced the simple text input with an organized, multi-select dropdown and a visual display of all active plugins (categorized by "CDN" or "Custom").
Critical Bug Fix: Solved a long-standing bug where clicking "Run" multiple times would create new, stacked player instances instead of destroying the old one. The player lifecycle is now correctly managed.
Verified Plugin List: The dropdown is curated with a list of official and maintained plugins that are confirmed compatible with the
@latestversion of Clappr.Technical Improvements
Plugin Selection
Organized dropdown with official plugins.
Robust Asynchronous Loading
The
loadfunction was enhanced to correctly handle asynchronous script loading. It waits for all selected plugins to either load or fail before executing the player code, using a proper counter.Graceful Error Handling
Added a
try...catchblock to therunfunction. This prevents incompatible plugins or user typos in the editor from crashing the entire page. If an error occurs, an alert is shown and the default player is restored.Files Modified
index.htmlindex.plainhtml5.htmlstyle.cssTesting
✅ Official plugins (@clappr/stats) load correctly and UI appears when configured.
✅ Incompatible plugins (like old level-selector) are caught by the try...catch block and display an alert.
✅ Custom plugin URLs work, with validation for duplicates and format.
✅ onerror handler correctly catches broken/invalid plugin URLs.
✅ Bug Fix Verified: Clicking "Run" multiple times (with or without plugins) correctly destroys the old player and creates only one new instance.
✅ Player state is correctly reset (e.g., stats logs stop) when plugins are removed and "Run" is clicked.
Before & After
Before: Simple text input for plugin URLs with basic tag display
After: Comprehensive plugin management system with organized selection, visual feedback, and robust error handling
This enhancement makes the Clappr demo site much more approachable for users wanting to experiment with plugins while maintaining the flexibility for advanced customization.