refactor(ui-goal): keep activation slot types private

This commit is contained in:
mektpoy committed 2026-09-07 13:50:11 +08:00
1 parent 03ce9c2ab3
commit 21db102cea
3 files changed
+9 -9

No files matched your search

+1 -2
View File
@@ -34,8 +34,7 @@ import { en, zh, type GoalKey } from './locales.ts'
export { GoalBar, GoalDock } from './GoalBar.tsx'
export type {
GoalActionResult, GoalActivationInjected, GoalActivationSnapshot, GoalBarActions,
GoalBarInjected, UseGoalActivation,
GoalActionResult, GoalBarActions,
} from './slots.ts'
export type { GoalKey } from './locales.ts'
+1 -4
View File
@@ -8,7 +8,7 @@
*/
import type { RemoteResult } from '@deepseek-ai/dsh-api-remotes/client'
import type { HostObservable, SnapshotSelectorHook } from '@deepseek-ai/dsh-client-ui-slots'
import type { HostObservable } from '@deepseek-ai/dsh-client-ui-slots'
import type { GoalActivation, GoalId } from '@deepseek-ai/dsh-goal/client'
/**
@@ -44,9 +44,6 @@ export interface GoalActivationInjected {
}
}
/** Selector hook synthesized from the activation source. */
export type UseGoalActivation = SnapshotSelectorHook<GoalActivationSnapshot>
/** Injected business face of the GoalBar dock entry: the mutation verbs (function properties: the strip destructures them freely). */
export interface GoalBarActions {
/**
@@ -21,7 +21,7 @@ import { LocaleRuntime } from '@deepseek-ai/dsh-client-locale/client'
import { makeTranslate, RemoteError } from '@deepseek-ai/dsh-client-test-runtime'
import type { RemoteFailure } from '@deepseek-ai/dsh-api-remotes/client'
import { zh as commonZh } from '@deepseek-ai/dsh-client-locale/src/locales/zh.ts'
import type { GoalBarActions, GoalBarInjected, UseGoalActivation } from '../src/client/slots.ts'
import type { GoalActivationSnapshot, GoalBarActions, GoalBarInjected } from '../src/client/slots.ts'
import { apply, inject } from '../src/client/index.ts'
import { GoalDock } from '../src/client/GoalBar.tsx'
import { zh } from '../src/client/locales.ts'
@@ -278,7 +278,9 @@ describe('GoalDock adapter', () => {
it('renders the projected goal snapshot and nothing for absent/null', () => {
const projection = makeProjection()
const useProjection = vi.fn(() => projection)
const useGoalActivation: UseGoalActivation = selector => selector({ id: GOAL_ID, revision: 3, activation: 'armed' })
const useGoalActivation = (
selector: (snapshot: GoalActivationSnapshot) => unknown,
) => selector({ id: GOAL_ID, revision: 3, activation: 'armed' })
const actions: GoalBarActions = {
onEdit: () => Promise.resolve({ ok: true, value: undefined }),
onPause: () => Promise.resolve({ ok: true, value: undefined }),
@@ -303,7 +305,9 @@ describe('GoalDock adapter', () => {
it('matches activation by goal id and revision from the injected hook', () => {
const projection = makeProjection()
const useProjection = vi.fn(() => projection)
const useGoalActivation: UseGoalActivation = selector => selector({ id: GOAL_ID, revision: 3, activation: 'disarmed' })
const useGoalActivation = (
selector: (snapshot: GoalActivationSnapshot) => unknown,
) => selector({ id: GOAL_ID, revision: 3, activation: 'disarmed' })
const actions: GoalBarActions = {
onEdit: () => Promise.resolve({ ok: true, value: undefined }),
onPause: () => Promise.resolve({ ok: true, value: undefined }),