01
打包与分发
MikuTV 按 GitHub topic mikutv-plugin 发现仓库,只安装正式 Release 里的 plugin.zip。未知字段在解码阶段直接报错。
| 规则 | 要求 |
|---|---|
topic | mikutv-plugin(主题加 mikutv-theme,语言包加 mikutv-locale) |
asset | Release 资产精确命名为 plugin.zip,不超过 8 MiB |
tag | 必须匹配 v<version>,与 plugin.json 的 version 一致 |
root | plugin.json 放在 zip 根目录,不包外层目录,无符号链接 |
sha256 | 安装时记录摘要并绑定 ID 归属,更新不可变更 kind |
02
内容源
内容源插件声明 kind: "source",入口为运行在 moejs 中的 ES 模块。所有出站域名必须写入 permissions.network;连接自建服务器时,可声明 credentials 与 serverURL: "required",登录时仅放行用户输入的单个地址。
plugin.jsonJELLYFIN EXAMPLE ↗
{
"id": "example-source",
"name": "Example Source",
"kind": "source",
"version": "1.0.0",
"apiVersion": 1,
"minAppVersion": "0.1.0",
"license": "Apache-2.0",
"main": "index.js",
"permissions": { "network": ["api.example.com"] },
"capabilities": ["catalog.browse", "catalog.item", "playback.resolve"]
}03
沙盒宿主接口
沙盒内可用标准 ES 语法、受白名单限制的 fetch,以及 globalThis.host:
host.storage.get / set / delete | 每插件独立持久化 KV,总配额 8 KiB |
host.locale.current() | 当前生效的 BCP-47 语言标签(如 zh-Hans、en、ja) |
host.crypto.sha256 / encryptRSAOAEP | 十六进制 SHA-256 与 RSA-OAEP-SHA256 加密 |
host.compress.inflateZlib(bytes) | Zlib 解压(上限 4 MiB 输出) |
04
能力导出表
每声明一项能力,main 就必须导出对应命名函数。缺少导出会在打开包时失败。
| Capability | 导出函数 | 依赖 |
|---|---|---|
catalog.browse | browse | — |
catalog.item | getItem | — |
catalog.search | search | — |
catalog.searchSuggest | searchSuggest | catalog.search |
catalog.series | readSeries | — |
catalog.live | readLive | — |
catalog.creator | readCreator | — |
catalog.videoComments | videoComments | — |
catalog.following | readFollowing | account.signIn |
catalog.library | readAccount | account.signIn |
playback.resolve | resolvePlayback | — |
playback.progress | reportPlayback | account.signIn |
playback.danmaku | readDanmaku | — |
playback.subtitles | readSubtitles | — |
live.chat | connectLiveChat | — |
live.chatWrite | sendLiveChat | live.chat + account.signIn |
account.signIn | restoreAccount, signOut, beginSignIn/pollSignIn or signInWithCredentials | authentication.methods |
account.videoInteraction | editVideo | account.signIn |
account.videoFavorites | videoFavoriteFolders, editVideoFavoriteFolders | account.signIn |
account.danmaku | postDanmaku | account.signIn |
account.danmakuRules | readDanmakuRules, addDanmakuRule, removeDanmakuRule | account.signIn |
account.followCreator | followCreator | account.signIn |
account.trackSeries | trackSeries | — |
account.history / watchLater / favorites / tracking / courses / notifications | readAccount | account.signIn |
account.editFavoriteFolders | editFavoriteFolder | account.favorites |
account.editHistory / editWatchLater / editTracking | removeAccountItems | matching read capability |
account.privateMessages | readPrivateConversations, readPrivateMessages | account.signIn |
account.writePrivateMessages | sendPrivateMessage, markPrivateMessagesRead | account.privateMessages |
05
主题
主题不启动 JS 运行时,仅由 plugin.json 与 theme.json(≤ 64 KiB)组成,稀疏覆盖 46 项色彩令牌。打开包时自动校验正文与焦点环对比度(4.5:1 / 3.0:1)。
theme.json
{
"schemaVersion": 1,
"base": "mikutv-dark",
"appearance": "dark",
"colors": {
"surface": {
"canvas": "#16161E",
"sidebar": "#13131A",
"panel": "#1A1B26"
},
"accent": {
"primary": "#7AA2F7",
"soft": "#89B4FA"
}
}
}06
语言包
语言包同样纯 JSON(locale.json ≤ 256 KiB),镜像 internal/ui/assets/labels.en.json,缺省键自动回落英文。参考 yuchanns/mikutv-locale-ja。
plugin.jsonMIKUTV-LOCALE-JA ↗
{
"id": "mikutv-locale-ja",
"name": "Japanese (日本語)",
"kind": "locale",
"version": "1.0.0",
"apiVersion": 1,
"minAppVersion": "0.1.0",
"license": "Apache-2.0",
"language": "ja",
"nativeName": "日本語",
"locale": "locale.json"
}07
校验与发布
PACKAGE & VERIFY
zip -r -X plugin.zip plugin.json LICENSE index.js
# Validate via internal/plugin:
# InspectPackage / Open / OpenTheme / OpenLocale
# Tag v1.0.0 -> GitHub Release -> attach plugin.zip
# Add repository topic: mikutv-plugin