From 675e5de5f888a45bec11ced26548fdac66d5bb22 Mon Sep 17 00:00:00 2001 From: Shigma Date: Mon, 19 Oct 2026 13:14:59 +0800 Subject: [PATCH] refactor(cordis): remove obsolete ClientTimerService export --- .../v0.2.1-alpha.2/cordis-timer-wrappers/guide.i18n.yaml | 8 ++++---- .../v0.2.1-alpha.2/cordis-timer-wrappers/guide.md | 5 ++++- .../v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md | 5 ++++- packages/extensions/cordis-client-runner/README.i18n.yaml | 4 ++-- packages/extensions/cordis-client-runner/README.md | 2 +- packages/extensions/cordis-client-runner/README.zh.md | 2 +- .../extensions/cordis-client-runner/src/client/index.ts | 1 - .../cordis-client-runner/tests/plugin.client.spec.ts | 1 - 8 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.i18n.yaml b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.i18n.yaml index 7b44caf7b1..a1e83a9a65 100644 --- a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.i18n.yaml +++ b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.i18n.yaml @@ -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 diff --git a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md index fbed59a398..2534f04dda 100644 --- a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md +++ b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.md @@ -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. diff --git a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md index 2245e95119..0587f65d24 100644 --- a/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md +++ b/docs/upgrade-guide/v0.2.1-alpha.2/cordis-timer-wrappers/guide.zh.md @@ -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. 运行扩展的类型检查,并验证释放后的调用既不会执行回调,也不会安排工作。 diff --git a/packages/extensions/cordis-client-runner/README.i18n.yaml b/packages/extensions/cordis-client-runner/README.i18n.yaml index d98d6aa7cd..7b22f847df 100644 --- a/packages/extensions/cordis-client-runner/README.i18n.yaml +++ b/packages/extensions/cordis-client-runner/README.i18n.yaml @@ -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 diff --git a/packages/extensions/cordis-client-runner/README.md b/packages/extensions/cordis-client-runner/README.md index af33e2fd41..dd39d8e2c4 100644 --- a/packages/extensions/cordis-client-runner/README.md +++ b/packages/extensions/cordis-client-runner/README.md @@ -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 | |---|---| diff --git a/packages/extensions/cordis-client-runner/README.zh.md b/packages/extensions/cordis-client-runner/README.zh.md index 3c31c1a838..ce1cd3e78d 100644 --- a/packages/extensions/cordis-client-runner/README.zh.md +++ b/packages/extensions/cordis-client-runner/README.zh.md @@ -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 会取消尚未执行的任务。 | 文件 | 职责 | |---|---| diff --git a/packages/extensions/cordis-client-runner/src/client/index.ts b/packages/extensions/cordis-client-runner/src/client/index.ts index 623dde7d49..68858edfee 100644 --- a/packages/extensions/cordis-client-runner/src/client/index.ts +++ b/packages/extensions/cordis-client-runner/src/client/index.ts @@ -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 { diff --git a/packages/extensions/cordis-client-runner/tests/plugin.client.spec.ts b/packages/extensions/cordis-client-runner/tests/plugin.client.spec.ts index eca7bcc6c2..50ef6169b2 100644 --- a/packages/extensions/cordis-client-runner/tests/plugin.client.spec.ts +++ b/packages/extensions/cordis-client-runner/tests/plugin.client.spec.ts @@ -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()