refactor(client): rename the host provide source to provideInfo

This commit is contained in:
imccyu
2026-07-28 11:03:56 +08:00
parent bce9910b47
commit 71529aa7d2
8 changed files with 10 additions and 10 deletions

View File

@@ -256,7 +256,7 @@ export class SlotsService extends Service {
entry.store === undefined ? undefined : this.resolveStore(entry.store as unknown as EngineStoreHandle, scopeKey), entry.store === undefined ? undefined : this.resolveStore(entry.store as unknown as EngineStoreHandle, scopeKey),
sessions: { sessions: {
list: sessions.list, list: sessions.list,
provide: sessions.currentProvide, provideInfo: sessions.currentProvide,
}, },
workspaces: { list: workspaces.list }, workspaces: { list: workspaces.list },
} }

View File

@@ -231,7 +231,7 @@ describe('host face', () => {
const bench = await boot() const bench = await boot()
const host = captureHost(bench) const host = captureHost(bench)
expect(host.sessions.list.getSnapshot()).toMatchObject({ ids: [] }) expect(host.sessions.list.getSnapshot()).toMatchObject({ ids: [] })
expect(host.sessions.provide.getSnapshot()).toMatchObject({ sessionId: undefined }) expect(host.sessions.provideInfo.getSnapshot()).toMatchObject({ sessionId: undefined })
}) })
it('exposes the independent Workspace list source', async () => { it('exposes the independent Workspace list source', async () => {

View File

@@ -112,7 +112,7 @@ export interface SlotRendererHost {
* obsolete hook/prop schema. Carries the static roster with sessionId * obsolete hook/prop schema. Carries the static roster with sessionId
* undefined while no current session resolves. * undefined while no current session resolves.
*/ */
provide: HostObservable<SessionMaybeProvideInfo> provideInfo: HostObservable<SessionMaybeProvideInfo>
} }
/** Workspace-side standard-kit sources. */ /** Workspace-side standard-kit sources. */
workspaces: { workspaces: {

View File

@@ -90,7 +90,7 @@ function useAbsentSnapshot<S>(_selector: (snapshot: never) => S, _equal?: (a: S,
*/ */
export function SessionMaybeProvider({ children }: { children: ReactNode }) { export function SessionMaybeProvider({ children }: { children: ReactNode }) {
const host = useHost() const host = useHost()
const info = observableHook(host.sessions.provide)(s => s) const info = observableHook(host.sessions.provideInfo)(s => s)
return ( return (
<BindingContext.Provider value={info}> <BindingContext.Provider value={info}>
{children} {children}
@@ -115,7 +115,7 @@ export interface SessionProviderProps {
*/ */
export function SessionProvider({ empty, children }: SessionProviderProps) { export function SessionProvider({ empty, children }: SessionProviderProps) {
const host = useHost() const host = useHost()
const info = observableHook(host.sessions.provide)(s => s) const info = observableHook(host.sessions.provideInfo)(s => s)
const id = info.sessionId const id = info.sessionId
if (id === undefined) return <>{empty?.() ?? null}</> if (id === undefined) return <>{empty?.() ?? null}</>
return ( return (

View File

@@ -36,7 +36,7 @@ function hostOver(core: SlotCore): SlotRendererHost {
storeOf: () => undefined, storeOf: () => undefined,
sessions: { sessions: {
list: { getSnapshot: () => ({}), subscribe: () => () => {} }, list: { getSnapshot: () => ({}), subscribe: () => () => {} },
provide: { getSnapshot: () => absentInfo, subscribe: () => () => {} }, provideInfo: { getSnapshot: () => absentInfo, subscribe: () => () => {} },
}, },
workspaces: { workspaces: {
list: { getSnapshot: () => ({}), subscribe: () => () => {} }, list: { getSnapshot: () => ({}), subscribe: () => () => {} },

View File

@@ -126,7 +126,7 @@ function makeHost() {
}, },
sessions: { sessions: {
list, list,
provide, provideInfo: provide,
}, },
workspaces: { list: workspaces }, workspaces: { list: workspaces },
} }

View File

@@ -26,7 +26,7 @@ function observable<T>(initial: T) {
} }
/** /**
* Minimal host: SessionProvider only reads sessions.provide, but it must * Minimal host: SessionProvider only reads sessions.provideInfo, but it must
* render inside the renderer tree (HostContext), so the harness mounts a real * render inside the renderer tree (HostContext), so the harness mounts a real
* root entry whose body is the test's render-prop provider. * root entry whose body is the test's render-prop provider.
*/ */
@@ -51,7 +51,7 @@ function makeHost(bodies: { root: (rp: (key: string, owner: object) => React.Rea
storeOf: () => undefined, storeOf: () => undefined,
sessions: { sessions: {
list: observable<unknown>({ ids: [] }), list: observable<unknown>({ ids: [] }),
provide, provideInfo: provide,
}, },
workspaces: { list: observable<unknown>({ items: [] }) }, workspaces: { list: observable<unknown>({ items: [] }) },
} }

View File

@@ -40,7 +40,7 @@ function makeHost() {
storeOf: () => undefined, storeOf: () => undefined,
sessions: { sessions: {
list: { getSnapshot: () => ({}), subscribe: () => () => {} }, list: { getSnapshot: () => ({}), subscribe: () => () => {} },
provide: { getSnapshot: () => absentInfo, subscribe: () => () => {} }, provideInfo: { getSnapshot: () => absentInfo, subscribe: () => () => {} },
}, },
workspaces: { workspaces: {
list: { getSnapshot: () => ({}), subscribe: () => () => {} }, list: { getSnapshot: () => ({}), subscribe: () => () => {} },