Skip to content

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 ​

  1. Scaffold: npm run new hello → complete skeleton with backend + lifecycle hooks + admin tab + player hook + README
  2. Run: npm run dev (port 1920 by default, isolated from production 1919; node tools/dev.js 3000 to change)
  3. Enable: Admin "Plugins" → enable openvideo-plugin-hello (new plugin dirs are auto-discovered)
  4. Develop: edit any .js/.json under plugins/<pkg>/lib/ → hot reload (400ms debounce)
  5. Verify: /api/plugin/hello (routes), admin sidebar tab, player hooks

Dev Features ​

FeatureNotes
Configurable plugin dirOPENVIDEO_PLUGIN_DIR → plugins/
Isolated data dirOPENVIDEO_DATA_DIR → .data/
Hot reload--dev watches local plugin changes (recursive fs.watch, polling fallback on Linux)
Auto-discoverypackage dirs with openvideoPlugin under plugins/ register automatically
Local registryOPENVIDEO_PLUGIN_REGISTRY=file://...registry.json (file:// supported)
Crash auto-restartdev server respawns 3s after abnormal exit
Local uninstallonly deregisters, keeps sources; delete the dir to fully remove

Scaffolded Plugin ​

bash
npm run new hello

Generates 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 hook

The 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 ​

  1. Develop & verify in the Dev environment
  2. Publish to npm (name it openvideo-plugin-*)
  3. Open a PR to OpenVideoAPI adding an entry to plugin-registry.json — listed on the official marketplace

MIT License · Made with ♥ by yangyang8002