Plugin Dev Environment (OpenVideoAPI-Dev)
OpenVideoAPI-Dev is the official plugin development environment: clone it and start writing modular plugins immediately — no manual server setup, no npm publishing, and files hot-reload automatically.
Quick Start
bash
git clone https://github.com/yangyang8002/OpenVideoAPI-Dev.git
cd OpenVideoAPI-Dev
npm run setup # ① clone server code to server/ + install deps + isolated .data/
npm run dev # ② start dev server → http://localhost:1920/admin/ (admin / admin123)
npm run new hello # ③ scaffold plugins/openvideo-plugin-hello/Layout
OpenVideoAPI-Dev/
├── server/ # server code (cloned by setup, git pull anytime)
├── plugins/ # ★ your plugins live here (local packages, no npm publish needed)
│ ├── openvideo-plugin-demo/ # full example (1.1.0, complete v2 demo)
│ └── openvideo-plugin-hello/ # generated by npm run new
├── tools/
│ ├── setup.js # init
│ ├── dev.js # dev server launcher
│ └── new-plugin.js # scaffolding
├── registry.json # local plugin market (file:// source demo)
└── .data/ # isolated data (never touches production)Workflow
- Scaffold:
npm run new hello→ complete skeleton with backend + lifecycle hooks + admin tab + player hook + README - Run:
npm run dev(port 1920 by default, isolated from production 1919;node tools/dev.js 3000to change) - Enable: Admin "Plugins" → enable
openvideo-plugin-hello(new plugin dirs are auto-discovered) - Develop: edit any
.js/.jsonunderplugins/<pkg>/lib/→ hot reload (400ms debounce) - Verify:
/api/plugin/hello(routes), admin sidebar tab, player hooks
Dev Features
| Feature | Notes |
|---|---|
| Configurable plugin dir | OPENVIDEO_PLUGIN_DIR → plugins/ |
| Isolated data dir | OPENVIDEO_DATA_DIR → .data/ |
| Hot reload | --dev watches local plugin changes (recursive fs.watch, polling fallback on Linux) |
| Auto-discovery | package dirs with openvideoPlugin under plugins/ register automatically |
| Local registry | OPENVIDEO_PLUGIN_REGISTRY=file://...registry.json (file:// supported) |
| Crash auto-restart | dev server respawns 3s after abnormal exit |
| Local uninstall | only deregisters, keeps sources; delete the dir to fully remove |
Scaffolded Plugin
bash
npm run new helloGenerates plugins/openvideo-plugin-hello/:
openvideo-plugin-hello/
├── package.json # openvideoPlugin manifest (inject/schema/client + optional v2 deps/hooks)
├── README.md # dev guide (contract entry / demo sample / hot-reload notes)
└── lib/
├── index.js # apply(ctx, config) + v2 lifecycle hooks: routes / dynamic tables / events / timer
└── client/
├── admin/panel.js # OpenVideoAdmin.registerTab admin tab
└── player/hook.js # OpenVideoPlayer.onReady player hookThe complete contract (v1 + v2) lives in PLUGIN-CONTRACT.md at the root of the OpenVideoAPI main repo; see Plugin Contract v2 for the v2 capability overview, and plugins/openvideo-plugin-demo (1.1.0) in the Dev repo for a full v2 sample.
From Dev to Release
- Develop & verify in the Dev environment
- Publish to npm (name it
openvideo-plugin-*) - Open a PR to OpenVideoAPI adding an entry to
plugin-registry.json— listed on the official marketplace