refactor(cordis): remove obsolete ClientTimerService export

This commit is contained in:
Shigma committed 2026-10-19 13:14:59 +08:00
1 parent e821bc31d6
commit 675e5de5f8
8 files changed
+16 -12

No files matched your search

@@ -9,8 +9,8 @@
en: 8b8de9b0fc2e3fc3
zh: ffa20b7ffa7540ef
/timer-wrapper-return-types-and-disposal/change:
en: 6ecd1dc8667a321d
zh: 150f620b06934133
en: 3d607c2a17936a5a
zh: 1c90b9bce38e4186
/timer-wrapper-return-types-and-disposal/migration:
en: c07c4d66ff9fd1ff
zh: ecebc12b08a9be47
en: 569f590747c713c5
zh: f38f7af763209b94
@@ -13,9 +13,12 @@ The functions returned by `ctx.throttle()` and `ctx.debounce()` now declare a `v
Calling `.dispose()` or disposing the owning fiber cancels pending work and makes later wrapper calls inert. A disposed throttle wrapper previously could still execute a leading call; debounce wrappers already ignored calls after disposal.
The `@deepseek-ai/dsh-cordis-client-runner/client` entry no longer exports `ClientTimerService`. The runner installs the shared `TimerService` from `@deepseek-ai/cordis-plugin-timer`.
## Migration
1. Let TypeScript infer the wrapper type, or declare its call signature with a `void` return type while retaining `.dispose()` where needed.
2. Consume callback results inside the callback. Awaiting the wrapper does not wait for an asynchronous callback to finish.
3. Move required work before disposal, or create a new wrapper in an active plugin.
4. Run your extension's type check and verify that calls after disposal neither invoke the callback nor schedule work.
4. Remove imports of `ClientTimerService` from the runner. Consumer plugins declare `inject: ['timer']` and use `ctx.timer`; code that installs the service imports `TimerService` from `@deepseek-ai/cordis-plugin-timer`.
5. Run your extension's type check and verify that calls after disposal neither invoke the callback nor schedule work.
@@ -13,9 +13,12 @@ description: "Timer 包装函数的 TypeScript 返回类型为 void,释放后
调用 `.dispose()` 或释放所属 fiber 会取消待执行的工作,并使后续包装函数调用不再执行。此前已释放的 throttle 包装函数仍可能执行前沿调用;debounce 包装函数在释放后已经会忽略调用。
`@deepseek-ai/dsh-cordis-client-runner/client` 入口不再导出 `ClientTimerService`。runner 安装的是 `@deepseek-ai/cordis-plugin-timer` 中的共享 `TimerService`。
## 迁移
1. 让 TypeScript 推断包装函数的类型,或将其调用签名声明为返回 `void`,并按需保留 `.dispose()`。
2. 在回调内部使用回调结果。对包装函数使用 await 不会等待异步回调完成。
3. 将必须执行的工作移到资源释放之前,或在活动插件中创建新的包装函数。
4. 运行扩展的类型检查,并验证释放后的调用既不会执行回调,也不会安排工作。
4. 移除从 runner 导入 `ClientTimerService` 的代码。消费插件声明 `inject: ['timer']` 并使用 `ctx.timer`;负责安装服务的代码从 `@deepseek-ai/cordis-plugin-timer` 导入 `TimerService`。
5. 运行扩展的类型检查,并验证释放后的调用既不会执行回调,也不会安排工作。
@@ -33,8 +33,8 @@
en: df635b29eaef982c
zh: ddaa4bd98359bd30
/deepseek-ai-dsh-cordis-client-runner/understand-the-implementation/source-map:
en: 49412a5fd3800d54
zh: 9ba50539d19c0e86
en: 897f65050ac6c4eb
zh: c856e88f15150b9c
/deepseek-ai-dsh-cordis-client-runner/understand-the-implementation/inspecting-slot-inputs:
en: 33f14a7fff7835e6
zh: 53838ac8d4a79600
@@ -55,7 +55,7 @@ The browser half is built on one principle: a dynamic package must ride the same
### Source map
The entry installs the vendored Cordis `TimerService`, shared with the Host, in the runner's context. The browser bundle inlines Timer and uses the module table's Cordis instance. Timer calls belong to the calling plugin's fiber; disposing it cancels pending work. `ClientTimerService` is an export alias of `TimerService`.
The entry installs the vendored Cordis `TimerService`, shared with the Host, in the runner's context. The browser bundle inlines Timer and uses the module table's Cordis instance. Timer calls belong to the calling plugin's fiber; disposing it cancels pending work.
| File | Role |
|---|---|
@@ -55,7 +55,7 @@ kind: "package-reference"
### 源码地图
入口在 runner 的上下文中安装与 Host 共用的 vendored Cordis `TimerService`。浏览器包内联 Timer,并使用模块表中的 Cordis 实例。定时任务归调用插件的 fiber 所有,释放该 fiber 会取消尚未执行的任务。`ClientTimerService` 是 `TimerService` 的导出别名。
入口在 runner 的上下文中安装与 Host 共用的 vendored Cordis `TimerService`。浏览器包内联 Timer,并使用模块表中的 Cordis 实例。定时任务归调用插件的 fiber 所有,释放该 fiber 会取消尚未执行的任务。
| 文件 | 职责 |
|---|---|
@@ -49,7 +49,6 @@ export { DynamicCordisStyles, evaluateClientHalf, isDynamicCordisPlugin } from '
export type { DynamicCordisClosureEnv, DynamicCordisEvaluatedPlugin } from './evaluator.ts'
export { dynamicCordisContext } from './guard.ts'
export type { DynamicCordisGuardEnv, DynamicCordisSlotLedgerRow } from './guard.ts'
export { TimerService as ClientTimerService } from '@deepseek-ai/cordis-plugin-timer'
// Re-exported so consumers of the service face and the two events can name
// their subjects without reaching into the wire contract themselves.
export type {
@@ -201,7 +201,6 @@ describe('browser half', () => {
try {
const bench = await boot(ctx)
expect(bench.ctx.timer).toBeInstanceOf(TimerService)
expect(ClientHalf.ClientTimerService).toBe(TimerService)
const timeout = vi.fn()
const interval = vi.fn()
const delayed = vi.fn()