@cordis-tavern/ct-client-found
v0.1.0-rc.1
Published
cordis-tavern 的前端插件发现与加载内核
Readme
@cordis-tavern/ct-client-found
cordis-tavern 的前端插件发现与加载内核:装配插件表 → 发现各包的 ct.client 声明 → 拓扑排序 → 构建 __CT_BOOT__ 启动图 → 经 index-inject 事件线发布(CT_SEED / 模块表 / boot-runtime)→ 向 host 注册页面与模块路由。
行为
| 步骤 | 说明 |
| --- | --- |
| 装配 | 表来源按序:注入 table → 宿主 assembleTable → 本地读 profile/<env>/package.json 的 ct.profile 兜底;ctHome 来源:注入 → process.env.CT_HOME → cwd/.env(判据镜像 CLI) |
| 发现 | 扫描已装配包的 ct.client(platform: 'web' / immediately / inject),模块入口为 exports["./client"] |
| 启动图 | topo 按 inject 依赖排序 → __CT_BOOT__ / __CT_MODULES__ / __CT_SEED__(CT_SEED 为依赖真库工厂,非占位) |
| 事件线 | index-inject 统一交由 ct-index-renderer 插入 index(本包不 provide distIndex) |
| 路由 | exact 主页(SPA 壳,注入后的完整 HTML)+ prefix 模块 bundle(注册路径去尾斜杠以适配 host 的段边界匹配) |
无 indexRenderer 注入时(单测 / 未装载场景)本地组装 homepage HTML 并 warn,不静默丢注入。
配置
| 键 | 默认 | 说明 |
| --- | --- | --- |
| homepage | '/' | 主页路由(exact) |
| bundlePrefix | '/bundles/' | 前端模块 bundle 前缀 |
未知键与非法值一律 TypeError 并指名键名。
装载
ct plugin add -g @cordis-tavern/ct-client-found # 系统级($CT_HOME)
ct plugin add -p <环境名> @cordis-tavern/ct-client-found # 环境级(profile/<环境名>)- 安装前有契约预检(
$CT_HOME/tmp内 npm pack 验包),不合格黄警中止、不落安装。 - 两级目录皆可装载:解析锚在环境目录、按 Node 向上检索(环境级优先、系统级兜底)。
inject: ['webServer', 'indexRenderer']—— 分别由@cordis-tavern/ct-host-web与@cordis-tavern/ct-index-renderer提供。- peer
@cordis-tavern/cordis-tavern:*(宽松跟最新;宿主导出缺席时由本地ct.profile兜底接管)。
开发
pnpm build # 根仓库:esbuild → ct-client-found/dist/
pnpm typecheck
pnpm test # 对 dist/ 产物状态
0.0.4-alpha.3(2026-09-27):apply 双兜底(.env / ct.profile)、bundle 路由段边界适配已修,实机冒烟通过。
