@qilin-agent/client-ui-session 0.0.0-stage → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.i18n.yaml +28 -0
- package/README.md +44 -2
- package/README.zh.md +45 -0
- package/lib/client.js +1134 -0
- package/lib/index.js +6 -0
- package/lib/types/client/index.d.ts +192 -0
- package/lib/types/client/session-provider.d.ts +11 -0
- package/lib/types/index.d.ts +4 -0
- package/package.json +63 -3
package/lib/index.js
ADDED
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/** Session Controller adapter for React selector hooks and Slot scope data. */
|
|
2
|
+
import { Service, type Context } from '@qilin-agent/kylin';
|
|
3
|
+
import type { ISessions, SessionBinding, SessionListState, SessionReference, SessionRetainInfo, SessionSnapshot, UseProjection } from '@qilin-agent/api-session-controller/client';
|
|
4
|
+
import type { SessionId } from '@qilin-agent/session/types';
|
|
5
|
+
import type { HostObservable, KeyedStandardSource, MaybeSnapshotSelectorHook, SlotScopeAdapter, SnapshotSelectorHook, StandardSourceBinding } from '@qilin-agent/client-ui-slots';
|
|
6
|
+
/** Selector hook over the Session Controller list and current selection. */
|
|
7
|
+
export type UseSessions = SnapshotSelectorHook<SessionListState>;
|
|
8
|
+
/** Selector hook over one Session's lifecycle and control state. */
|
|
9
|
+
export type SessionSnapshotSelector = SnapshotSelectorHook<SessionSnapshot>;
|
|
10
|
+
/** Public name for the Session lifecycle selector hook. */
|
|
11
|
+
export type UseSession = SessionSnapshotSelector;
|
|
12
|
+
/** Common identity carried by every Session-scoped pending interaction. */
|
|
13
|
+
export interface SessionPendingInteractionBase {
|
|
14
|
+
/** Opaque request identity; a replacement request must use a new key. */
|
|
15
|
+
readonly key: string;
|
|
16
|
+
/** Domain-owned presentation discriminator. */
|
|
17
|
+
readonly kind: string;
|
|
18
|
+
/** Session whose UI can answer this interaction. */
|
|
19
|
+
readonly sessionId: SessionId;
|
|
20
|
+
}
|
|
21
|
+
/** Declaration-merged map of domain keys to their pending-interaction values. */
|
|
22
|
+
export interface SessionPendingInteractionMap {
|
|
23
|
+
}
|
|
24
|
+
/** Union of every pending-interaction value contributed by the assembled Client. */
|
|
25
|
+
export type SessionPendingInteraction = [
|
|
26
|
+
keyof SessionPendingInteractionMap
|
|
27
|
+
] extends [never] ? SessionPendingInteractionBase : SessionPendingInteractionMap[keyof SessionPendingInteractionMap];
|
|
28
|
+
/** Independent UI status facts for one Session identity. */
|
|
29
|
+
export interface SessionStatus {
|
|
30
|
+
/** Latest known running state; absent until a baseline or event establishes it. */
|
|
31
|
+
readonly running: boolean | undefined;
|
|
32
|
+
/** Highest-precedence domain request currently awaiting user interaction. */
|
|
33
|
+
readonly pendingInteraction: SessionPendingInteraction | undefined;
|
|
34
|
+
/** Whether an observed stop outside the main view still needs acknowledgement. */
|
|
35
|
+
readonly completionUnread: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** Current UI status indexed by Session identity. */
|
|
38
|
+
export type SessionStatusSnapshot = ReadonlyMap<SessionId, SessionStatus>;
|
|
39
|
+
/** Selector hook over the unified Session UI status snapshot. */
|
|
40
|
+
export type UseSessionStatus = SnapshotSelectorHook<SessionStatusSnapshot>;
|
|
41
|
+
/** Selector hook for explicit or surrounding-Provider Session reference counts. */
|
|
42
|
+
export interface UseSessionRetainInfo {
|
|
43
|
+
/**
|
|
44
|
+
* Read the complete retain information for an explicit Session identity.
|
|
45
|
+
* @param sessionId - Session identity to inspect without retaining it.
|
|
46
|
+
* @returns current local reference counts, or absence while the source is unavailable.
|
|
47
|
+
*/
|
|
48
|
+
(sessionId: SessionId): SessionRetainInfo | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* Select from the retain information for an explicit Session identity.
|
|
51
|
+
* @param sessionId - Session identity to inspect without retaining it.
|
|
52
|
+
* @param selector - projection over the current value.
|
|
53
|
+
* @param equal - optional selected-value equality.
|
|
54
|
+
* @returns selected value.
|
|
55
|
+
*/
|
|
56
|
+
<Selected>(sessionId: SessionId, selector: (value: SessionRetainInfo | undefined) => Selected, equal?: (left: Selected, right: Selected) => boolean): Selected;
|
|
57
|
+
/**
|
|
58
|
+
* Select from the surrounding Provider's Session retain information.
|
|
59
|
+
* @param selector - projection receiving absence outside a Session binding.
|
|
60
|
+
* @param equal - optional selected-value equality.
|
|
61
|
+
* @returns selected value.
|
|
62
|
+
*/
|
|
63
|
+
<Selected>(selector: (value: SessionRetainInfo | undefined) => Selected, equal?: (left: Selected, right: Selected) => boolean): Selected;
|
|
64
|
+
}
|
|
65
|
+
/** Publish one pending interaction and define how plugin teardown delegates it. */
|
|
66
|
+
export type PendingInteractionPublisher<T extends SessionPendingInteractionBase> = (interaction: T, delegate: () => Promise<void>) => () => void;
|
|
67
|
+
declare module '@qilin-agent/client-ui-slots' {
|
|
68
|
+
interface SlotScopeTargetMap {
|
|
69
|
+
session: SessionReference;
|
|
70
|
+
}
|
|
71
|
+
interface GlobalStandardProps {
|
|
72
|
+
/** Session list and current selection. */
|
|
73
|
+
useSessions: UseSessions;
|
|
74
|
+
useSessionStatus: UseSessionStatus;
|
|
75
|
+
useSessionRetainInfo: UseSessionRetainInfo;
|
|
76
|
+
}
|
|
77
|
+
interface SessionStandardProps {
|
|
78
|
+
/** Current Session lifecycle and control state. */
|
|
79
|
+
useSession: SessionSnapshotSelector;
|
|
80
|
+
/** Current Session identity. */
|
|
81
|
+
sessionId: SessionId;
|
|
82
|
+
/** Host-computed projection values addressed by projection key. */
|
|
83
|
+
useProjection: UseProjection;
|
|
84
|
+
}
|
|
85
|
+
interface SessionMaybeStandardProps {
|
|
86
|
+
/** Current Session state, absent while no Session is selected. */
|
|
87
|
+
useSession: MaybeSnapshotSelectorHook<SessionSnapshot>;
|
|
88
|
+
/** Current Session identity, absent while no Session is selected. */
|
|
89
|
+
sessionId: SessionId | undefined;
|
|
90
|
+
/** Host-computed projection values; every key is absent without a Session. */
|
|
91
|
+
useProjection: UseProjection;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
declare module '@qilin-agent/api-session-controller/client' {
|
|
95
|
+
interface SessionReferenceSourceMap {
|
|
96
|
+
mainView: unknown;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
declare module '@qilin-agent/kylin' {
|
|
100
|
+
interface Context {
|
|
101
|
+
/** Session Controller adapter and session-scoped source registry. */
|
|
102
|
+
uiSession: UiSession;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
type SessionSourceRoster = readonly string[] | undefined;
|
|
106
|
+
type SessionSourceRecord<Roster extends SessionSourceRoster, Value> = Roster extends readonly string[] ? Readonly<Record<Roster[number], Value>> : never;
|
|
107
|
+
/** Bare values produced by one Session-scoped source contribution. */
|
|
108
|
+
export interface SessionSourceContribution<Hooks extends SessionSourceRoster = SessionSourceRoster, KeyedHooks extends SessionSourceRoster = SessionSourceRoster, Props extends SessionSourceRoster = SessionSourceRoster> {
|
|
109
|
+
readonly hooks?: SessionSourceRecord<Hooks, HostObservable<unknown>>;
|
|
110
|
+
readonly keyedHooks?: SessionSourceRecord<KeyedHooks, KeyedStandardSource>;
|
|
111
|
+
readonly props?: SessionSourceRecord<Props, unknown>;
|
|
112
|
+
}
|
|
113
|
+
/** Static roster and per-Session resolver for one standard-props contribution. */
|
|
114
|
+
export interface SessionSourceDescriptor<Hooks extends SessionSourceRoster = SessionSourceRoster, KeyedHooks extends SessionSourceRoster = SessionSourceRoster, Props extends SessionSourceRoster = SessionSourceRoster> {
|
|
115
|
+
readonly hooks?: Hooks;
|
|
116
|
+
readonly keyedHooks?: KeyedHooks;
|
|
117
|
+
readonly props?: Props;
|
|
118
|
+
/**
|
|
119
|
+
* Resolve every declared member for one Session binding.
|
|
120
|
+
* @param binding - Controller-owned Session binding.
|
|
121
|
+
* @returns all declared bare sources and stable props.
|
|
122
|
+
*/
|
|
123
|
+
resolve(binding: SessionBinding): SessionSourceContribution<NoInfer<Hooks>, NoInfer<KeyedHooks>, NoInfer<Props>>;
|
|
124
|
+
}
|
|
125
|
+
/** Session-scoped source roster and renderer adapter. */
|
|
126
|
+
export declare class UiSession extends Service {
|
|
127
|
+
private readonly sessions;
|
|
128
|
+
private readonly descriptors;
|
|
129
|
+
private readonly bindings;
|
|
130
|
+
private readonly absent;
|
|
131
|
+
private readonly current;
|
|
132
|
+
private readonly pendingDomains;
|
|
133
|
+
private pendingSnapshot;
|
|
134
|
+
private readonly running;
|
|
135
|
+
private readonly completionUnread;
|
|
136
|
+
private statusSnapshot;
|
|
137
|
+
private readonly statusListeners;
|
|
138
|
+
private mainRetainId;
|
|
139
|
+
private disposeMainRetain;
|
|
140
|
+
private active;
|
|
141
|
+
/** Root source combining running, pending-interaction, and completion-reminder facts. */
|
|
142
|
+
readonly sessionStatus: HostObservable<SessionStatusSnapshot>;
|
|
143
|
+
/** Renderer-facing adapter for `session` and `session-maybe` scopes. */
|
|
144
|
+
readonly adapter: SlotScopeAdapter;
|
|
145
|
+
/**
|
|
146
|
+
* @param ctx - Client root context.
|
|
147
|
+
* @param sessions - Controller-owned Session object layer.
|
|
148
|
+
*/
|
|
149
|
+
constructor(ctx: Context, sessions: ISessions);
|
|
150
|
+
/**
|
|
151
|
+
* Resolve a stable renderer source for an owned Session reference or explicit absence.
|
|
152
|
+
* @param reference - active reference supplied by the Provider owner, or absence.
|
|
153
|
+
* @returns the binding source, which falls back to the absent projection when its generation ends.
|
|
154
|
+
* @throws when the reference does not belong to the active Controller generation.
|
|
155
|
+
*/
|
|
156
|
+
bindingSource(reference: SessionReference | undefined): HostObservable<StandardSourceBinding>;
|
|
157
|
+
/**
|
|
158
|
+
* Register one Session-scoped standard-source contribution.
|
|
159
|
+
* @param descriptor - static member roster and per-binding resolver.
|
|
160
|
+
* @returns disposer owned by the caller's Cordis fiber.
|
|
161
|
+
*/
|
|
162
|
+
provide<const Hooks extends SessionSourceRoster = undefined, const KeyedHooks extends SessionSourceRoster = undefined, const Props extends SessionSourceRoster = undefined>(descriptor: SessionSourceDescriptor<Hooks, KeyedHooks, Props>): () => void;
|
|
163
|
+
/**
|
|
164
|
+
* Register one pending-interaction domain and return its publication function.
|
|
165
|
+
* Domain teardown first removes its visible values, then delegates and awaits
|
|
166
|
+
* every still-active owner request.
|
|
167
|
+
* @param precedence - deterministic cross-domain precedence; larger values win.
|
|
168
|
+
* @returns a function that publishes one interaction and its teardown delegation.
|
|
169
|
+
*/
|
|
170
|
+
registerPendingInteraction<T extends SessionPendingInteractionBase>(precedence: (interaction: T) => number): PendingInteractionPublisher<T>;
|
|
171
|
+
private rebuildBindings;
|
|
172
|
+
private sourceFor;
|
|
173
|
+
private publishMain;
|
|
174
|
+
private watchMainRetention;
|
|
175
|
+
private publishPendingInteractions;
|
|
176
|
+
private observeRunning;
|
|
177
|
+
private reconcileStatus;
|
|
178
|
+
private isMain;
|
|
179
|
+
private publishStatus;
|
|
180
|
+
private createMaterializedBinding;
|
|
181
|
+
private materialize;
|
|
182
|
+
private materializeAbsent;
|
|
183
|
+
}
|
|
184
|
+
/** Required Controller and renderer services. */
|
|
185
|
+
export declare const inject: string[];
|
|
186
|
+
/**
|
|
187
|
+
* Install the Session root source and scoped adapter.
|
|
188
|
+
* @param ctx - Client Cordis context.
|
|
189
|
+
*/
|
|
190
|
+
export declare function apply(ctx: Context): void;
|
|
191
|
+
export {};
|
|
192
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Session-owned rendering semantics for the standard SessionProvider seat. */
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { SessionAreaProps, StandardSourceBinding } from '@qilin-agent/client-ui-slots';
|
|
4
|
+
/**
|
|
5
|
+
* Render the selected Session body or its empty branch.
|
|
6
|
+
* @param binding - current Session scope binding.
|
|
7
|
+
* @param props - standard Session area render props.
|
|
8
|
+
* @returns the selected Session subtree.
|
|
9
|
+
*/
|
|
10
|
+
export declare function renderSessionArea(binding: StandardSourceBinding, { empty, children }: SessionAreaProps): ReactNode;
|
|
11
|
+
//# sourceMappingURL=session-provider.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qilin-agent/client-ui-session",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"description": "Session Controller adapter for React and session-scoped slots",
|
|
4
|
+
"version": "3.1.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/kkutysllb/QiLin.git",
|
|
11
|
+
"directory": "packages/client/ui-session"
|
|
12
|
+
},
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": "^22.19.0 || >=24.0.0"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "lib/index.js",
|
|
18
|
+
"types": "lib/types/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./lib/types/index.d.ts",
|
|
22
|
+
"default": "./lib/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./client": {
|
|
25
|
+
"types": "./lib/types/client/index.d.ts",
|
|
26
|
+
"default": "./lib/client.js"
|
|
27
|
+
},
|
|
28
|
+
"./src/*": "./src/*",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"qilin": {
|
|
32
|
+
"client": {
|
|
33
|
+
"inject": [
|
|
34
|
+
"@qilin-agent/api-remotes",
|
|
35
|
+
"@qilin-agent/api-session-controller",
|
|
36
|
+
"@qilin-agent/client-ui-renderer"
|
|
37
|
+
],
|
|
38
|
+
"platform": "web"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT",
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@qilin-agent/kylin": "~4.0.3"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@types/react": "~18.3.1",
|
|
47
|
+
"react": "^18.2.0",
|
|
48
|
+
"@qilin-agent/kylin": "~4.0.3",
|
|
49
|
+
"@qilin-agent/api-remotes": "3.1.3",
|
|
50
|
+
"@qilin-agent/api-session-controller": "3.1.3",
|
|
51
|
+
"@qilin-agent/client-store": "3.1.3",
|
|
52
|
+
"@qilin-agent/client-ui-renderer": "3.1.3",
|
|
53
|
+
"@qilin-agent/client-ui-slots": "3.1.3",
|
|
54
|
+
"@qilin-agent/session": "3.1.3",
|
|
55
|
+
"@qilin-agent/util-values": "3.1.3"
|
|
56
|
+
},
|
|
57
|
+
"files": [
|
|
58
|
+
"lib/index.js",
|
|
59
|
+
"lib/client.js",
|
|
60
|
+
"lib/types/**/*.d.ts"
|
|
61
|
+
],
|
|
62
|
+
"scripts": {
|
|
63
|
+
"bundle": "tsdown",
|
|
64
|
+
"watch": "tsdown --watch"
|
|
65
|
+
}
|
|
6
66
|
}
|