Getting Started
Miru Alpha’s extension system supports both JavaScript and Go as runtime languages:
- JavaScript runtime: powered by goja (a pure-Go ECMAScript engine); extension files use the
.jssuffix. - Go runtime: powered by Scriggo (a Go templating/scripting engine); extension files use the
.gosuffix.
Both kinds of extensions share the same metadata format and data-return structures; they differ mainly in syntax and the engine that runs them. Below we cover the shared metadata first, then give complete JavaScript and Go examples.
To develop extensions you need a working knowledge of JavaScript or Go, plus regular expressions. If you are new to regular expressions, start with “Regular Expressions and String Methods” and “Regular Expressions in 30 Minutes”.
This documentation assumes you have already set up the development environment as described in the Environment Setup section.
Extension Metadata
Section titled “Extension Metadata”For both JS and Go extensions, the file must start with a metadata block wrapped in // ==MiruExtension== … // ==/MiruExtension== comments.
// ==MiruExtension==// @name My Extension// @version v0.0.1// @author YourName// @license MIT// @lang zh-cn// @icon https://example.com/icon.png// @package my.extension// @type bangumi// @webSite https://example.com/// @apiVersion 2// ==/MiruExtension==Choose a Runtime
Section titled “Choose a Runtime”Once the metadata is in place, pick the guide for your language. Each contains the full entry points, request/cache APIs, and a runnable example:
- JavaScript: JavaScript Extensions V2 (goja) (recommended); for the old style see JavaScript Extensions V1 (legacy).
- Go: Go Extensions (Scriggo)
The return structures (list items, detail, and per-type playback shapes) are defined in Data Formats.