Import src/client/directory-flow.ts

This commit is contained in:
QQ 2026-11-11 22:31:37 +08:00
parent 2e238c6cea
commit a6e39d5a1a
1 changed files with 16 additions and 0 deletions

View File

@ -0,0 +1,16 @@
import type { StoredEntry } from '@deepseek-ai/dsh-client-ui-slots'
import type { GroupsBrowserInjected } from './contract.ts'
/** Adapt the elected self-contained picker, without stealing its original slot. */
export function directoryFlowFromEntry(entry: StoredEntry | undefined): ReturnType<GroupsBrowserInjected['getDirectoryFlow']> {
if (!entry) return null
// Stateful/translated/nested seats need the full original renderer context.
// Never silently drop them or fall back to a local picker for a remote request.
if (entry.store || entry.locale || entry.children || typeof entry.component !== 'function') {
throw new Error('This directory picker requires an unsupported renderer context.')
}
return {
component: entry.component as NonNullable<ReturnType<GroupsBrowserInjected['getDirectoryFlow']>>['component'],
injected: entry.inject?.() ?? {},
}
}