feat: 插件检验器 plugin:check + L6/L7 教程 + 模板接入组件库——性能与样式标准成为机器关卡

This commit is contained in:
Rick Ye
2026-09-11 10:11:55 +08:00
parent f77942ee2b
commit 835b910d42
12 changed files with 471 additions and 30 deletions
+14 -1
View File
@@ -120,7 +120,20 @@ export const { jsx, jsxs, Fragment } = J
```
- 装载时机与热重载:插件列表变化(扫描/启停/`plugins:reload`)即按 `?t=` cache-bust 重装;被禁用/移除的插件注册随之清除
- 门控:仅开发版装载(`import.meta.env.DEV` + 主进程 `EXTERNAL_PLUGINS_ENABLED`);错误隔离到单插件(装载失败仅 console.error,渲染崩溃由 PluginErrorBoundary 兜底)
- 门控:仅开发版装载(`import.meta.env.DEV` + 主进程 `EXTERNAL_PLUGINS_ENABLED`)
- 性能护栏:读源与 import 各限时 8s,超时/失败由宿主槽位呈现统一等待/失败态(ErrorState + 重试,见 `plugins/renderer-host`);渲染期崩溃由 PluginErrorBoundary 兜底
## 公共 UI 组件库与异步工具(`@aso/plugin-sdk/ui` · `withTimeout`/`withRetry`)
- **`./ui` 子入口**:宿主视觉规范的代码化——`Button`/`Input`/`Select`/`Switch`/`Card`/`SettingRow`/`Badge`
+ 三态组件 `LoadingState`/`ErrorState`/`EmptyState`/`Spinner`。仅 renderer 组件槽位可用
(渲染在宿主 DOM,复用宿主样式表);组件目录与三态铁律见 [docs/plugins/07-ui-components.md](./plugins/07-ui-components.md)
- **异步工具(主入口导出)**:`withTimeout(promise, ms, label?)`、`withRetry(fn, { retries, delayMs, timeoutMs, onRetry })`、
`TimeoutError`——插件内一切可能挂起的异步(网络/子进程/文件轮询)必须自带超时与重试
- **宿主兜底**:插件激活限时 10s(异步工厂超时/reject 即标记插件失败,不拖垮 runtime 重建);
renderer 装载限时 8s
- **机器关卡**:`pnpm plugin:check <插件目录>` 校验契约完整性、同步 IO、console.*、
React 单实例、hex 色值、三态使用等(error 级不通过即 exit 1),规则见 [docs/plugins/08-performance.md](./plugins/08-performance.md)
## 插件设置(声明式 schema,`api.ui.registerSettings`)