@pooflabs/core 0.0.21 → 0.0.23

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.
@@ -55,3 +55,4 @@ export declare function setFile(path: string, file: File | null): Promise<boolea
55
55
  export declare function signMessage(message: string): Promise<string>;
56
56
  export declare function signTransaction(transaction: Transaction | VersionedTransaction): Promise<Transaction | VersionedTransaction>;
57
57
  export declare function signAndSubmitTransaction(transaction: Transaction | VersionedTransaction, feePayer?: PublicKey): Promise<string>;
58
+ export declare function syncItems(paths: string[]): Promise<any>;
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WebSocket v2 Subscription Manager
3
+ *
4
+ * This module implements multiplexed subscriptions over a single WebSocket connection.
5
+ * It maintains the same external API as v1 but uses the new v2 protocol internally.
6
+ */
7
+ import { SubscriptionOptions } from '../types';
8
+ /**
9
+ * Subscribe to data at a path using WebSocket v2.
10
+ * Returns an unsubscribe function.
11
+ */
12
+ export declare function subscribeV2(path: string, subscriptionOptions: SubscriptionOptions): Promise<() => Promise<void>>;
13
+ /**
14
+ * Close all v2 subscriptions.
15
+ */
16
+ export declare function closeAllSubscriptionsV2(): Promise<void>;
17
+ /**
18
+ * Clear the v2 cache.
19
+ */
20
+ export declare function clearCacheV2(path?: string): void;
21
+ /**
22
+ * Get cached data for a path (v2).
23
+ */
24
+ export declare function getCachedDataV2(path: string, prompt?: string): any | null;
25
+ /**
26
+ * Reconnect all v2 WebSocket connections with fresh authentication.
27
+ * Call this when the user's auth state changes (login/logout).
28
+ *
29
+ * This will:
30
+ * 1. Close existing connections
31
+ * 2. Re-establish with new auth token
32
+ * 3. Re-subscribe to all active paths
33
+ *
34
+ * Note: Existing subscriptions will receive new initial data after reconnection.
35
+ */
36
+ export declare function reconnectWithNewAuthV2(): Promise<void>;
37
+ /**
38
+ * Force close and reconnect all connections.
39
+ * This is more aggressive than reconnectWithNewAuthV2() and ensures
40
+ * a complete teardown and rebuild of connections.
41
+ */
42
+ export declare function forceReconnectV2(): Promise<void>;
43
+ declare global {
44
+ interface Window {
45
+ CUSTOM_TAROBASE_APP_ID_HEADER?: string;
46
+ }
47
+ }
@@ -1,8 +1,62 @@
1
+ /**
2
+ * WebSocket Subscription Module
3
+ *
4
+ * This module provides real-time data subscriptions using WebSocket v2 protocol
5
+ * with multiplexed connections (one connection per client, multiple subscriptions).
6
+ *
7
+ * The external API remains unchanged - just use subscribe(path, options) as before.
8
+ */
1
9
  import { SubscriptionOptions } from '../types';
10
+ /**
11
+ * Subscribe to real-time updates for a path.
12
+ *
13
+ * @param path - The path to subscribe to (e.g., 'users/123' or 'posts')
14
+ * @param subscriptionOptions - Options including onData and onError callbacks
15
+ * @returns A function to unsubscribe
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const unsubscribe = await subscribe('users/123', {
20
+ * onData: (data) => console.log('User updated:', data),
21
+ * onError: (error) => console.error('Subscription error:', error),
22
+ * });
23
+ *
24
+ * // Later, to unsubscribe:
25
+ * await unsubscribe();
26
+ * ```
27
+ */
2
28
  export declare function subscribe(path: string, subscriptionOptions: SubscriptionOptions): Promise<() => Promise<void>>;
29
+ /**
30
+ * Close all active subscriptions.
31
+ * Call this when cleaning up (e.g., on logout or component unmount).
32
+ */
3
33
  export declare function closeAllSubscriptions(): Promise<void>;
34
+ /**
35
+ * Clear the subscription cache.
36
+ *
37
+ * @param path - Optional path to clear. If not provided, clears all cached data.
38
+ */
4
39
  export declare function clearCache(path?: string): void;
40
+ /**
41
+ * Get cached data for a path without making a network request.
42
+ *
43
+ * @param path - The path to get cached data for
44
+ * @param prompt - Optional prompt that was used for the subscription
45
+ * @returns The cached data, or null if not cached or expired
46
+ */
5
47
  export declare function getCachedData(path: string, prompt?: string): any | null;
48
+ /**
49
+ * Reconnect all WebSocket connections with fresh authentication.
50
+ * Call this when the user's auth state changes (login/logout).
51
+ *
52
+ * This will:
53
+ * 1. Close existing connections
54
+ * 2. Re-establish with new auth token
55
+ * 3. Re-subscribe to all active paths
56
+ *
57
+ * Existing subscriptions will receive new initial data after reconnection.
58
+ */
59
+ export declare function reconnectWithNewAuth(): Promise<void>;
6
60
  declare global {
7
61
  interface Window {
8
62
  CUSTOM_TAROBASE_APP_ID_HEADER?: string;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  export { init } from './client/config';
2
2
  export { getConfig, ClientConfig } from './client/config';
3
3
  export { get, set, setMany, setFile, getFiles, runQuery, runQueryMany, runExpression, runExpressionMany, signMessage, signTransaction, signAndSubmitTransaction, SetOptions, RunExpressionOptions, RunExpressionResult } from './client/operations';
4
- export { subscribe } from './client/subscription';
4
+ export { subscribe, closeAllSubscriptions, clearCache, getCachedData, reconnectWithNewAuth } from './client/subscription';
5
5
  export * from './types';
6
6
  export { getIdToken } from './utils/utils';
7
7
  export { WebSessionManager } from './utils/web-session-manager';