You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
dsh-pause 兼容 dsh 0.1.5-rc.2
背景
connection.rpc.handle登记路由时会在 connection 服务自身上下文解析webServer,而该上下文的 inject 只有 credentials,于是抛cannot get property "webServer" without inject,插件树因此加载失败。对照 0.1.2-rc.1 与 0.1.5-rc.2,get rpc与register逐字相同、owner.webServer行为一致,所以这不是 0.1.5 引入的回归,该 API 自 0.1.2 起即不可用。官方/api走ctx.inject(['webServer'], ...),从不经过rpc.handle。自注册并非唯一出路:私有
register(owner, channel, handler)显式接收 owner,不解析this.ctx,在注入了 webServer 的作用域里可用,能完整复用官方 transport;代价是它是 private 成员,需要类型断言且上游可能改名或移除。本 PR 选择自行实现同样的信封语义。改动
src/rpc-channel.ts:mountRpcChannel直接向 webServer 注册一条 prefix 路由,复用connection.requestRejection做 Host 校验与浏览器鉴权,自行实现 client-request/server-response 信封。仅接受 POST,校验 content-type 与 endpoint 段字符集,请求体限长 8 MiB 且超限回 413 带connection: close,客户端断开即 abort,非 web profile 下不挂载。文件头列明与官方 transport 的有意差异。src/index.ts:不再调用ctx.connection.rpc.handle,改经mountRpcChannel注册/dsh-pause通道;删除两行死导入。tests/rpc-channel.spec.ts:新增 14 项通道单测,覆盖信封回写、401/403 透传、非 POST 404、路径与端点非法字符 404、415、bad-request、413 限长、服务缺席不挂载。tests/real-cordis.spec.ts:新增真实 cordis 4.0.2 与真实 client-connection 服务接线冒烟,断言/api与/dsh-pause同时挂载,以及 connection 缺席时不挂载。tests/index.spec.ts:沿用真实 HTTP 通道测试,覆盖暂停放行、release 带文字并入 user 消息、status 与 setEnabled 收口、空端点 404。package.json与pnpm-lock.yaml:@deepseek-ai/dsh-client-connection升到 0.1.5-rc.2,typecheck 与单测落在目标版本上。README.md:补「关键词」一节与主机侧自注册通道说明。本 PR 还带上上一提交 27d9598:暂停图标与预览截图更新。
验证
pnpm typecheck、36 项pnpm test、pnpm build全绿。