import type { ChannelType, SubscribeOptions, Subscription, NotificationChannel } from './types'; interface DiscoveredService { baseEndpoint: string; supportedChannels: ChannelType[]; } export interface NotificationsClientConfig { /** 通道偏好顺序,默认 ['streaming-http', 'websocket'] */ preferredChannels?: ChannelType[]; } /** * Solid Notifications 客户端 * * 支持两种通道: * - streaming-http (SSE): CSS 直接连接模式,无需订阅 * - websocket: 标准订阅模式,POST 获取 receiveFrom * * 特性: * - 自动重连:当连接断开时(如 xpod node_id 切换),自动重新订阅 * - 指数退避:重连延迟采用指数退避策略,避免服务器过载 */ export declare class NotificationsClient { private readonly fetch; private readonly subscriptions; private readonly preferredChannels; constructor(authenticatedFetch: typeof globalThis.fetch, config?: NotificationsClientConfig); /** * 订阅资源变化 */ subscribe(topic: string, options: SubscribeOptions): Promise; /** * 重新订阅(内部方法,用于自动重连) * @internal */ resubscribe(topic: string, channelType: ChannelType, discovery: DiscoveredService, options: SubscribeOptions): Promise; /** * 连接到指定通道 */ private connectChannel; /** * 构建 SSE 直接连接 URL (CSS 模式) * 格式: /.notifications/StreamingHTTPChannel2023/{encodeURIComponent(topic)} */ private buildSSEDirectUrl; /** * 取消所有订阅 */ unsubscribeAll(): void; /** * 发现资源的 notifications 服务 * * 发现顺序: * 1. 从 HEAD 请求的 Link header 直接获取通知端点 * 2. 从 storage description (.well-known/solid) 获取 * 3. 回退到默认的 /.notifications/ 路径 */ private discoverNotificationService; /** * 从 HEAD 请求的 Link header 发现通知端点 * * CSS 在 Link header 中提供: * - solid:updatesViaStreamingHttp2023 - SSE 端点 * - (WebSocket 通常也可用,但不在 Link header 中公开) */ private discoverFromLinkHeader; /** * 查找资源的存储根 URL */ private findStorageRoot; /** * 获取 storage description 并提取 notifications 端点 */ private fetchStorageDescription; /** * 创建 WebSocket 订阅(POST 请求) */ private createSubscription; /** * 创建通道实例 */ private createChannel; /** * 创建带自动重连支持的通道实例 */ private createChannelWithReconnect; } export {}; //# sourceMappingURL=notifications-client.d.ts.map