01

打包与分发

MikuTV 按 GitHub topic mikutv-plugin 发现仓库,只安装正式 Release 里的 plugin.zip。未知字段在解码阶段直接报错。

规则要求
topicmikutv-plugin(主题加 mikutv-theme,语言包加 mikutv-locale)
assetRelease 资产精确命名为 plugin.zip,不超过 8 MiB
tag必须匹配 v<version>,与 plugin.json 的 version 一致
rootplugin.json 放在 zip 根目录,不包外层目录,无符号链接
sha256安装时记录摘要并绑定 ID 归属,更新不可变更 kind
02

内容源

内容源插件声明 kind: "source",入口为运行在 moejs 中的 ES 模块。所有出站域名必须写入 permissions.network;连接自建服务器时,可声明 credentials 与 serverURL: "required",登录时仅放行用户输入的单个地址。

{
  "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.browsebrowse—
catalog.itemgetItem—
catalog.searchsearch—
catalog.searchSuggestsearchSuggestcatalog.search
catalog.seriesreadSeries—
catalog.livereadLive—
catalog.creatorreadCreator—
catalog.videoCommentsvideoComments—
catalog.followingreadFollowingaccount.signIn
catalog.libraryreadAccountaccount.signIn
playback.resolveresolvePlayback—
playback.progressreportPlaybackaccount.signIn
playback.danmakureadDanmaku—
playback.subtitlesreadSubtitles—
live.chatconnectLiveChat—
live.chatWritesendLiveChatlive.chat + account.signIn
account.signInrestoreAccount, signOut, beginSignIn/pollSignIn or signInWithCredentialsauthentication.methods
account.videoInteractioneditVideoaccount.signIn
account.videoFavoritesvideoFavoriteFolders, editVideoFavoriteFoldersaccount.signIn
account.danmakupostDanmakuaccount.signIn
account.danmakuRulesreadDanmakuRules, addDanmakuRule, removeDanmakuRuleaccount.signIn
account.followCreatorfollowCreatoraccount.signIn
account.trackSeriestrackSeries—
account.history / watchLater / favorites / tracking / courses / notificationsreadAccountaccount.signIn
account.editFavoriteFolderseditFavoriteFolderaccount.favorites
account.editHistory / editWatchLater / editTrackingremoveAccountItemsmatching read capability
account.privateMessagesreadPrivateConversations, readPrivateMessagesaccount.signIn
account.writePrivateMessagessendPrivateMessage, markPrivateMessagesReadaccount.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。

{
  "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
MikuTV plugin discovery screen on Apple TV 4K
发布正式 RELEASE 并添加 TOPIC:MIKUTV-PLUGIN 后,插件会自动出现在电视端发现列表中。