Skip to content

refactor: 对齐 dsh 0.1.7-rc.2,配置改走 configForms 表单 - #6

Merged
better-er merged 3 commits into
mainfrom
feat/dsh-0.1.7-rc.2
Sep 27, 2026
Merged

better-er merged 3 commits into
mainfrom
feat/dsh-0.1.7-rc.2

Conversation

@better-er

Copy link
Copy Markdown
Owner

refactor: 对齐 dsh 0.1.7-rc.2,配置改走 configForms 表单

问题

dsh 0.1.7-rc.2 用 ctx.configForms 取代了 ctx.settingsScope,主机端的 settings.installSection() 也换成 settings.configure()。插件的 peerDependencies 上一轮已声明 ^0.1.7-rc.2,代码却还停在旧 API,装上后 extraTools 配置读不到。

更早的一层问题在依赖:devDependencies 仍是 0.1.5 时代,schemastery 3.18.2 没有 .volatile(),cordis 4.0.2 不导出 Volatile,dsh-settings 还是 0.1.5-rc.2。pnpm typecheck 与 pnpm build 都直接失败,插件在 0.1.7-rc.2 上根本构建不出来。

方案

  • 主机端:在 ctx.inject(['settings'], ...) 子级里以 effect 注册 settings.configure({ auto: false }, ctx.fiber),声明本插件自带配置页面
  • 配置字段 extraTools 加 .volatile(),使其出现在设置表单中
  • 浏览器端:ctx.settingsScope.bind() 改为 ctx.configForms.get('dsh-edit-diff'),读 getSnapshot().value
  • devDependencies 对齐 dsh 0.1.7-rc.2 自身的依赖:cordis ^4.0.4、schemastery ^3.18.4、dsh-settings 0.1.7-rc.2,新增 cosmokit ^1.8.5
  • peerDependencies 的 cordis 与 schemastery 下限同步提到能用这些 API 的版本
  • schema 注解写成 Schema<{ extraTools?: ExtraTool[] }, Config>。Schema<S, T> 的 S 是输入、T 是输出,volatile 让两者分家,只写 Schema<Config> 必然不匹配,不写注解则 dts 生成报 TS2742
  • 版本 0.4.0 → 0.4.1,description 加中文名前缀,README 里 installSection 的过时说法一并更新

行为变化

  • 插件在 dsh 0.1.7-rc.2 上可正常构建与加载
  • extraTools 出现在 dsh 设置表单里,改动即时生效
  • edit 与 write 两张 diff 卡片的行为不变

验证

  • pnpm typecheck 通过
  • pnpm build 产出 lib/index.js、lib/index.d.ts、lib/client.js 与 sourcemap
  • 加载 lib/index.js 做契约检查:extraTools 的 meta 为 {"default":[],"volatile":true},configure 收到 {auto:false} 且 owner 是插件 fiber
  • lib/client.js 内为 ctx.inject(["configForms"]) 加 scope.getSnapshot().value

其他

  • 五个文件,437 增 100 删,其中 pnpm-lock.yaml 占大部分
  • 未跑真实浏览器验证,客户端半身刷新页面即可重新拉取

- 主机端改用 settings.configure({ auto: false }, ctx.fiber),extraTools 经 .volatile() 进入设置表单
- 浏览器端改用 ctx.configForms.get('dsh-edit-diff'),替代 ctx.settingsScope
- devDependencies 对齐 dsh 0.1.7-rc.2:cordis 4.0.4、schemastery 3.18.4、dsh-settings 0.1.7-rc.2,新增 cosmokit
- peerDependencies 的 cordis 与 schemastery 下限同步
- 版本 0.4.0 → 0.4.1,description 加中文名前缀,README 更新 installSection 的过时说法
@better-er
better-er merged commit e5aeadf into main Sep 27, 2026
1 check passed
@better-er
better-er deleted the feat/dsh-0.1.7-rc.2 branch September 27, 2026 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant