Skip to content

插件中心规范

字数
175 字
阅读时间
1 分钟

本文档定义了 InPageEdit 插件中心(Plugin Store)的数据规范,供插件开发者和插件中心平台参考使用。

插件包结构

Schema
json
{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "InPageEdit Plugin Central Schema",
  "type": "object",
  "additionalProperties": false,
  "required": [
    "name",
    "registry",
    "packages"
  ],
  "properties": {
    "name": {
      "type": "string",
      "description": "Registry/package set display name"
    },
    "registry": {
      "type": "string",
      "format": "uri",
      "description": "Base URL of the plugin registry"
    },
    "homepage": {
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "description": "Optional homepage URL"
    },
    "maintainers": {
      "type": "array",
      "description": "List of maintainers",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "email"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "email": {
            "type": "string",
            "format": "email"
          }
        }
      }
    },
    "repository": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "type",
        "url"
      ],
      "properties": {
        "type": {
          "type": "string",
          "description": "Repository type, e.g. git"
        },
        "url": {
          "type": "string",
          "format": "uri",
          "description": "Repository URL"
        }
      }
    },
    "packages": {
      "type": "array",
      "description": "Array of plugin package descriptors",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "version",
          "loader"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string",
            "pattern": "^\\d+\\.\\d+\\.\\d+(?:[-+].*)?$",
            "description": "Simple semver-like pattern (major.minor.patch)"
          },
          "description": {
            "type": [
              "string",
              "null"
            ]
          },
          "author": {
            "type": [
              "string",
              "null"
            ]
          },
          "license": {
            "type": [
              "string",
              "null"
            ]
          },
          "loader": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "kind",
              "base"
            ],
            "properties": {
              "kind": {
                "type": "string",
                "enum": [
                  "autoload",
                  "module",
                  "umd",
                  "styles"
                ],
                "description": "Loader kind; allowed values: autoload | module | umd | styles"
              },
              "base": {
                "type": "string",
                "description": "Base folder for assets relative to registry URL, or full URL, if external"
              },
              "entry": {
                "description": "Entry script path relative to base, or null for style-only packages",
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "styles": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "Array of stylesheet paths relative to base"
              },
              "main_export": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "null"
                  }
                ],
                "description": "Name of the exported symbol for module/UMD loaders or null"
              }
            }
          }
        }
      }
    }
  }
}

插件中心注册商示例

以下是一个插件中心注册商(Plugin Store Registry)的示例,展示了如何使用上述规范来定义一个插件中心。

文件结构

root/
├── index.json                    # 插件中心索引数据
└── plugins/
    ├── plugin-a/
    │   ├── src/                  # 插件 A 的源代码
    │   ├── dist/                 # 插件 A 的构建产物
    │   └── ...
    ├── plugin-b/
    │   ├── src/                  # 插件 B 的源代码
    │   ├── dist/                 # 插件 B 的构建产物
    │   └── ...
    └── ...
index.json 示例
json
{
  "$schema": "plugin-store.schema.json",
  "name": "InPageEdit Official Plugin Central",
  "registry": "https://ipe-plugins.js.org/plugins/",
  "homepage": "https://ipe-plugins.js.org/",
  "maintainers": [
    {
      "name": "dragon-fish",
      "email": "[email protected]"
    }
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/inpageedit/official-plugins.git"
  },
  "packages": [
    {
      "name": "Autoload Plugin",
      "version": "1.0.0",
      "description": "A sample plugin for InPageEdit",
      "author": "dragon-fish",
      "license": "MIT",
      "loader": {
        "kind": "autoload",
        "base": "autoload-sample/",
        "entry": "dist/index.js",
        "styles": [
          "dist/index.css"
        ],
        "main_export": null
      }
    },
    {
      "name": "Module Plugin",
      "version": "1.0.0",
      "description": "A sample plugin for InPageEdit",
      "author": "dragon-fish",
      "license": "MIT",
      "loader": {
        "kind": "module",
        "base": "module-sample/",
        "entry": "dist/index.mjs",
        "styles": [
          "dist/index.css"
        ],
        "main_export": "PluginSample"
      }
    },
    {
      "name": "Global UMD Plugin",
      "version": "1.0.0",
      "description": "A sample plugin for InPageEdit",
      "author": "dragon-fish",
      "license": "MIT",
      "loader": {
        "kind": "umd",
        "base": "sample/",
        "entry": "dist/index.umd.js",
        "styles": [
          "dist/index.css"
        ],
        "main_export": "InPageEditPluginSample"
      }
    },
    {
      "name": "Style Only Plugin",
      "version": "1.0.0",
      "description": "A sample plugin for InPageEdit",
      "author": "dragon-fish",
      "license": "MIT",
      "loader": {
        "kind": "styles",
        "base": "sample/",
        "entry": null,
        "styles": [
          "dist/index.css"
        ],
        "main_export": "InPageEditPluginSample"
      }
    }
  ]
}

贡献者

The avatar of contributor named as dragon-fish dragon-fish

✏️ InPageEdit NEXT