@aippy/runtime 0.2.7-dev.3 → 0.2.7-dev.4

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.
@@ -1,118 +1,89 @@
1
- import { DEFAULT_CONFIG as a, SDK_NAME as s, VERSION as o, getConfigFromEnv as t, getVersionInfo as n, mergeConfig as i } from "../core/index.js";
2
- import { A as p, E as d, c as m } from "../errors-CDEBaBxB.js";
3
- import { s as C } from "../container-message-DGrno17o.js";
4
- import { A as I, C as c, R as l, a as g, p as U } from "../runtime-CmoG3v2m.js";
5
- import { CameraAPI as S, FileSystemAPI as h, GeolocationAPI as P, SensorsAPI as y, camera as T, fileSystem as x, geolocation as F, isMotionSupported as _, isOrientationSupported as D, requestMotionPermission as R, sensors as M, vibrate as k, watchMotion as O, watchOrientation as v } from "../device/index.js";
6
- import { P as w, p as L, s as q } from "../ui-D6IZ1jrR.js";
7
- import { a as N, P as B, p as H, b as V } from "../pwa-CilSlaik.js";
8
- import { a as Q, b as z } from "../useTweaks-QxMRmg7i.js";
9
- import { c as K, a as W, b as Y, i as X, p as Z, u as $ } from "../useAudioContext-CNQQSTab.js";
10
- import { reportScore as re, sendEvent as ae, updateScore as se } from "../leaderboard/index.js";
11
- import { A as te, D as ne, d as ie, e as fe, c as pe, U as de, f as me, a as ue, a as Ce, b as Ae, j as Ie, i as ce, l as le, m as ge, g as Ue, n as Ee, h as Se, p as he, s as Pe, v as ye } from "../helper-CKiqfKle.js";
12
- import { f as xe, q as Fe, b as _e, h as De, l as Re, o as Me, j as ke, n as Oe, w as ve, g as be, k as we, p as Le, e as qe, i as Ge, c as Ne, d as Be, r as He, u as Ve, m as je, s as Qe, a as ze, t as Je, v as Ke } from "../bridge-N9ELFpfV.js";
13
- import { i as Ye, f as Xe, h as Ze, g as $e, a as er, u as rr, b as ar, d as sr, c as or, e as tr, j as nr } from "../userSessionInfo-DFvsuELU.js";
14
- import { hasNativeBridge as fr } from "../native-bridge-BnvipFJc.js";
1
+ import { DEFAULT_CONFIG as o, SDK_NAME as r, VERSION as s, getConfigFromEnv as t, getVersionInfo as i, mergeConfig as n } from "../core/index.js";
2
+ import { A as m, E as A, c as f } from "../errors-CDEBaBxB.js";
3
+ import { s as E } from "../container-message-DGrno17o.js";
4
+ import { A as d, C as I, R as l, a as g, p as u } from "../runtime-CmoG3v2m.js";
5
+ import { CameraAPI as x, FileSystemAPI as T, GeolocationAPI as _, SensorsAPI as D, camera as U, fileSystem as M, geolocation as P, isMotionSupported as R, isOrientationSupported as y, requestMotionPermission as h, sensors as v, vibrate as O, watchMotion as F, watchOrientation as L } from "../device/index.js";
6
+ import { P as w, c as N, i as V, p as k, s as H } from "../ui-y5N62DqC.js";
7
+ import { a as G, P as j, p as q, b as z } from "../pwa-CilSlaik.js";
8
+ import { a as W, b as Y } from "../useTweaks-QxMRmg7i.js";
9
+ import { c as Q, a as X, b as Z, i as $, p as ee, u as ae } from "../useAudioContext-CNQQSTab.js";
10
+ import { reportScore as re, sendEvent as se, updateScore as te } from "../leaderboard/index.js";
11
+ import { A as ne, D as pe, d as me, e as Ae, c as fe, U as ce, f as Ee, a as Ce, a as de, b as Ie, j as le, i as ge, l as ue, m as Se, g as xe, n as Te, h as _e, p as De, s as Ue, v as Me } from "../helper-CIt1_T-j.js";
12
+ import { c as Re, u as ye } from "../hooks-CE9cjXHP.js";
13
+ import { getAuthTokenAsync as ve } from "../bridge-Ca3H2iN1.js";
14
+ import { hasNativeBridge as Fe } from "../native-bridge-BnvipFJc.js";
15
15
  export {
16
- te as AIConfigValidationError,
17
- I as AippyRuntime,
18
- p as AippyRuntimeError,
19
- S as CameraAPI,
20
- c as Cancellable,
21
- ne as DEFAULT_BASE_URL,
22
- ie as DEFAULT_CHAT_MODEL,
23
- fe as DEFAULT_CHAT_SYSTEM,
24
- a as DEFAULT_CONFIG,
25
- pe as DEFAULT_UI_BASE_URL,
26
- d as ERROR_CODES,
27
- h as FileSystemAPI,
28
- P as GeolocationAPI,
29
- N as PWAUtils,
30
- B as PerformanceMonitor,
16
+ ne as AIConfigValidationError,
17
+ d as AippyRuntime,
18
+ m as AippyRuntimeError,
19
+ x as CameraAPI,
20
+ I as Cancellable,
21
+ pe as DEFAULT_BASE_URL,
22
+ me as DEFAULT_CHAT_MODEL,
23
+ Ae as DEFAULT_CHAT_SYSTEM,
24
+ o as DEFAULT_CONFIG,
25
+ fe as DEFAULT_UI_BASE_URL,
26
+ A as ERROR_CODES,
27
+ T as FileSystemAPI,
28
+ _ as GeolocationAPI,
29
+ G as PWAUtils,
30
+ j as PerformanceMonitor,
31
31
  w as PlatformDetector,
32
32
  l as ReceiveChannel,
33
- s as SDK_NAME,
34
- y as SensorsAPI,
35
- de as UI_CHAT_ENDPOINT,
36
- o as VERSION,
37
- me as abortedError,
38
- ue as aippy,
39
- Ce as aippyAIProvider,
40
- Ae as aippyChatConfig,
33
+ r as SDK_NAME,
34
+ D as SensorsAPI,
35
+ ce as UI_CHAT_ENDPOINT,
36
+ s as VERSION,
37
+ Ee as abortedError,
38
+ Ce as aippy,
39
+ de as aippyAIProvider,
40
+ Ie as aippyChatConfig,
41
41
  g as aippyRuntime,
42
- Q as aippyTweaks,
43
- z as aippyTweaksRuntime,
44
- xe as autoRequestCredentials,
45
- T as camera,
46
- Fe as clearCachedUserInfo,
47
- Ye as clearProfileCache,
48
- Xe as clearUserInfoCache,
49
- Ie as createAIConfig,
50
- m as createError,
51
- K as createHiddenMediaElement,
52
- W as createHiddenVideoElement,
53
- Ze as fetchUserProfile,
54
- x as fileSystem,
55
- F as geolocation,
56
- ce as getAIConfigValue,
57
- _e as getAuthToken,
58
- De as getAuthTokenAsync,
59
- Re as getCachedCredentials,
60
- Me as getCachedUserInfo,
42
+ W as aippyTweaks,
43
+ Y as aippyTweaksRuntime,
44
+ U as camera,
45
+ Re as clearUserInfoCache,
46
+ N as compareVersions,
47
+ le as createAIConfig,
48
+ f as createError,
49
+ Q as createHiddenMediaElement,
50
+ X as createHiddenVideoElement,
51
+ M as fileSystem,
52
+ P as geolocation,
53
+ ge as getAIConfigValue,
54
+ ve as getAuthTokenAsync,
61
55
  t as getConfigFromEnv,
62
- $e as getCurrentUserId,
63
- ke as getCurrentUserIdAsync,
64
- Oe as getUserInfoAsync,
65
- ve as getUserInfoFromParent,
66
- be as getUserSdkConfig,
67
- n as getVersionInfo,
68
- we as hasCredentials,
69
- fr as hasNativeBridge,
70
- Le as hasUserInfo,
71
- qe as initUserBridge,
72
- Ge as initUserSdk,
73
- Y as isIOSDevice,
74
- Ne as isInIframe,
75
- X as isMediaStreamAudioSupported,
76
- _ as isMotionSupported,
77
- D as isOrientationSupported,
78
- le as loadAIConfig,
79
- i as mergeConfig,
80
- ge as missingTokenError,
81
- Ue as networkError,
82
- Ee as normalizeError,
83
- Se as parseAIConfig,
84
- he as parseError,
85
- Z as patchAudioContext,
86
- H as performanceMonitor,
87
- L as platform,
88
- U as processMotionData,
89
- V as pwa,
56
+ i as getVersionInfo,
57
+ Fe as hasNativeBridge,
58
+ Z as isIOSDevice,
59
+ V as isInIframe,
60
+ $ as isMediaStreamAudioSupported,
61
+ R as isMotionSupported,
62
+ y as isOrientationSupported,
63
+ ue as loadAIConfig,
64
+ n as mergeConfig,
65
+ Se as missingTokenError,
66
+ xe as networkError,
67
+ Te as normalizeError,
68
+ _e as parseAIConfig,
69
+ De as parseError,
70
+ ee as patchAudioContext,
71
+ q as performanceMonitor,
72
+ k as platform,
73
+ u as processMotionData,
74
+ z as pwa,
90
75
  re as reportScore,
91
- Be as requestCredentialsFromParent,
92
- He as requestCredentialsFromiOS,
93
- R as requestMotionPermission,
94
- Ve as requestUserInfoFromParent,
95
- je as requestUserInfoFromiOS,
96
- Pe as sendAIConfigToContainer,
97
- ae as sendEvent,
98
- C as sendMessageToContainer,
99
- M as sensors,
100
- Qe as setAuthToken,
101
- ze as setCurrentUserId,
102
- q as showAlert,
103
- Je as tryGetCredentialsFromParentStorage,
104
- Ke as tryGetUserInfoFromParentStorage,
105
- se as updateScore,
106
- $ as useAudioContext,
107
- er as useAuthToken,
108
- rr as useCurrentUserId,
109
- ar as useGetCurrentUserProfileQuery,
110
- sr as useGetJoinedUserProfilesQuery,
111
- or as useGetUserProfileByIdQuery,
112
- tr as useUserInfo,
113
- nr as userSessionInfo,
114
- ye as validateAIConfig,
115
- k as vibrate,
116
- O as watchMotion,
117
- v as watchOrientation
76
+ h as requestMotionPermission,
77
+ Ue as sendAIConfigToContainer,
78
+ se as sendEvent,
79
+ E as sendMessageToContainer,
80
+ v as sensors,
81
+ H as showAlert,
82
+ te as updateScore,
83
+ ae as useAudioContext,
84
+ ye as useUserInfo,
85
+ Me as validateAIConfig,
86
+ O as vibrate,
87
+ F as watchMotion,
88
+ L as watchOrientation
118
89
  };
@@ -1,26 +1,49 @@
1
- var a = Object.defineProperty;
2
- var c = (o, e, n) => e in o ? a(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
- var s = (o, e, n) => c(o, typeof e != "symbol" ? e + "" : e, n);
4
- import { UAParser as d } from "ua-parser-js";
5
- class l {
1
+ var d = Object.defineProperty;
2
+ var l = (o, e, n) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
3
+ var c = (o, e, n) => l(o, typeof e != "symbol" ? e + "" : e, n);
4
+ import { UAParser as u } from "ua-parser-js";
5
+ import { hasNativeBridge as p } from "./native-bridge-BnvipFJc.js";
6
+ function m() {
7
+ try {
8
+ return typeof window < "u" && window.parent !== window;
9
+ } catch {
10
+ return !0;
11
+ }
12
+ }
13
+ function f(o, e) {
14
+ const n = o.split(".").map(Number), r = e.split(".").map(Number), t = Math.max(n.length, r.length);
15
+ for (let i = 0; i < t; i++) {
16
+ const s = n[i] || 0, a = r[i] || 0;
17
+ if (s < a) return -1;
18
+ if (s > a) return 1;
19
+ }
20
+ return 0;
21
+ }
22
+ class w {
6
23
  constructor() {
7
- s(this, "parser");
8
- this.parser = new d();
24
+ c(this, "parser");
25
+ this.parser = new u();
9
26
  }
10
27
  /**
11
28
  * Get platform information
12
29
  */
13
30
  getPlatformInfo() {
14
- const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), t = this.normalizeBrowserName(e.browser.name), r = this.isMobileDevice(), i = !r;
31
+ const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name), t = this.isMobileDevice(), i = !t;
15
32
  return {
16
33
  name: n,
17
34
  version: e.os.version,
18
- browser: t,
35
+ browser: r,
19
36
  browserVersion: e.browser.version,
20
- isMobile: r,
37
+ isMobile: t,
21
38
  isDesktop: i
22
39
  };
23
40
  }
41
+ /**
42
+ * Get raw UA parser result
43
+ */
44
+ getRawParserResult() {
45
+ return this.parser.getResult();
46
+ }
24
47
  /**
25
48
  * Get platform capabilities
26
49
  */
@@ -69,15 +92,46 @@ class l {
69
92
  return e.name === "android" && e.browser === "chrome";
70
93
  }
71
94
  /**
72
- * 解析 User-Agent 中的 Aippy App 信息
95
+ * Check if running in Android WebView (old app version)
96
+ * Detects by checking if browser name contains "webview"
97
+ */
98
+ isAndroidWebView() {
99
+ return (this.parser.getResult().browser.name || "").toLowerCase().includes("webview");
100
+ }
101
+ /**
102
+ * Check app environment and validate version
103
+ */
104
+ checkAppEnvironment(e) {
105
+ const n = this.parseAippyInfo();
106
+ if (n) {
107
+ const r = e[n.platform], t = f(n.version, r) >= 0;
108
+ return {
109
+ type: "new_app",
110
+ isValid: t,
111
+ aippyInfo: n,
112
+ message: t ? void 0 : `App version ${n.version} < ${r}`
113
+ };
114
+ }
115
+ return p() ? {
116
+ type: "old_ios_app",
117
+ isValid: !1,
118
+ message: "Native bridge exists but no Aippy info (old iOS version)"
119
+ } : this.isAndroidWebView() ? {
120
+ type: "old_android_app",
121
+ isValid: !1,
122
+ message: "Android WebView detected but no Aippy info (old Android version)"
123
+ } : m() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
124
+ }
125
+ /**
126
+ * Parse Aippy App info from User-Agent
73
127
  */
74
128
  parseAippyInfo() {
75
- const e = navigator.userAgent, n = /Aippy\/([^\/]+)\/[^\/]+\/(iOS|Android)/i, t = e.match(n);
76
- if (t) {
77
- const r = t[1];
129
+ const e = navigator.userAgent, n = /Aippy\/([^/]+)\/[^/]+\/(iOS|Android)/i, r = e.match(n);
130
+ if (r) {
131
+ const t = r[1];
78
132
  return {
79
- platform: t[2],
80
- version: r
133
+ platform: r[2],
134
+ version: t
81
135
  };
82
136
  }
83
137
  return null;
@@ -101,19 +155,21 @@ class l {
101
155
  }
102
156
  }
103
157
  }
104
- const f = new l();
105
- function p(o) {
158
+ const x = new w();
159
+ function v(o) {
106
160
  const e = document.createElement("div");
107
161
  e.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:999999";
108
162
  const n = document.createElement("div");
109
163
  n.style.cssText = "background:#fff;border-radius:12px;padding:24px 32px;max-width:80%;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,0.15)";
110
- const t = document.createElement("p");
111
- t.style.cssText = "margin:0 0 20px;font-size:16px;color:#333;line-height:1.5", t.textContent = o;
112
- const r = document.createElement("button");
113
- r.style.cssText = "background:#007AFF;color:#fff;border:none;border-radius:8px;padding:10px 32px;font-size:15px;cursor:pointer", r.textContent = "OK", r.onclick = () => e.remove(), n.appendChild(t), n.appendChild(r), e.appendChild(n), document.body.appendChild(e);
164
+ const r = document.createElement("p");
165
+ r.style.cssText = "margin:0 0 20px;font-size:16px;color:#333;line-height:1.5", r.textContent = o;
166
+ const t = document.createElement("button");
167
+ t.style.cssText = "background:#007AFF;color:#fff;border:none;border-radius:8px;padding:10px 32px;font-size:15px;cursor:pointer", t.textContent = "OK", t.onclick = () => e.remove(), n.appendChild(r), n.appendChild(t), e.appendChild(n), document.body.appendChild(e);
114
168
  }
115
169
  export {
116
- l as P,
117
- f as p,
118
- p as s
170
+ w as P,
171
+ f as c,
172
+ m as i,
173
+ x as p,
174
+ v as s
119
175
  };
@@ -1,160 +1,29 @@
1
1
  /**
2
2
  * User SDK Bridge
3
- * Handles communication with:
4
- * - iOS native layer via window.webkit.aippyListener
5
- * - Parent window via postMessage (iframe scenario)
6
- */
7
- /**
8
- * User credentials
9
3
  */
4
+ export { isInIframe } from '../utils/platform';
10
5
  export interface IOSUserCredentials {
11
6
  uid: string;
12
7
  token: string;
13
8
  apiBaseUrl?: string;
14
9
  }
15
- /**
16
- * User information (extended profile data)
17
- */
18
10
  export interface IOSUserInfo {
19
11
  uid: string;
20
12
  displayName?: string;
21
13
  nickname?: string;
14
+ nickName?: string;
22
15
  username?: string;
23
16
  photoUrl?: string;
24
17
  avatar?: string;
25
- email?: string;
26
- phone?: string;
27
- bio?: string;
28
- online?: boolean;
29
18
  [key: string]: unknown;
30
19
  }
31
- /**
32
- * Check if running inside an iframe
33
- */
34
- export declare function isInIframe(): boolean;
35
- /**
36
- * Request user credentials from parent window (iframe scenario)
37
- * Parent window should respond with postMessage containing credentials
38
- *
39
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
40
- * @returns Promise resolving to user credentials
41
- */
42
- export declare function requestCredentialsFromParent(timeoutMs?: number): Promise<IOSUserCredentials>;
43
- /**
44
- * Request user info from parent window (iframe scenario)
45
- * Parent window should respond with postMessage containing user info
46
- * IMPORTANT: This method does NOT cache - it always requests fresh data
47
- *
48
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
49
- * @returns Promise resolving to user info (null if unavailable)
50
- */
51
- export declare function requestUserInfoFromParent(timeoutMs?: number): Promise<IOSUserInfo | null>;
52
- /**
53
- * Try to get credentials from parent localStorage directly
54
- * This works when same-origin, otherwise falls back to postMessage
55
- *
56
- * localStorage format:
57
- * - token: JWT string
58
- * - user: JSON string with { uid, nickName, ... }
59
- */
60
- export declare function tryGetCredentialsFromParentStorage(): IOSUserCredentials | null;
61
- /**
62
- * Try to get user info from parent localStorage directly
63
- * This works when same-origin, otherwise falls back to postMessage
64
- * IMPORTANT: This method does NOT cache - it always reads fresh data from parent
65
- *
66
- * localStorage format:
67
- * - user: JSON string with { uid, nickName, username, avatar, ... }
68
- *
69
- * @returns User info or null if unavailable
70
- */
71
- export declare function tryGetUserInfoFromParentStorage(): IOSUserInfo | null;
72
- /**
73
- * Request user credentials from iOS native layer
74
- * Uses aippyRuntime's message passing mechanism
75
- *
76
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
77
- * @returns Promise resolving to user credentials (empty if unavailable)
78
- */
79
- export declare function requestCredentialsFromiOS(timeoutMs?: number): Promise<IOSUserCredentials>;
80
- /**
81
- * Receive credentials directly from iOS or parent window
82
- * Called via: window.processUserCredentials(data)
83
- */
84
- export declare function processUserCredentials(data: unknown): void;
85
- /**
86
- * Receive user info directly from iOS or parent window
87
- * Called via: window.processUserInfo(data)
88
- */
89
- export declare function processUserInfo(data: unknown): void;
90
- /**
91
- * Request user info from iOS native layer
92
- * This method caches the result and won't request again unless forced
93
- *
94
- * @param forceRefresh - Force refresh even if cached (default: false)
95
- * @param timeoutMs - Timeout in milliseconds (default: 5000)
96
- * @returns Promise resolving to user info (null if unavailable)
97
- */
98
- export declare function requestUserInfoFromiOS(forceRefresh?: boolean, timeoutMs?: number): Promise<IOSUserInfo | null>;
99
- /**
100
- * Get user info asynchronously
101
- * Returns cached user info if available, otherwise requests from iOS
102
- *
103
- * @param forceRefresh - Force refresh even if cached (default: false)
104
- * @returns Promise resolving to user info, or null if unavailable
105
- */
20
+ /** Get auth token async, auto-detects environment */
21
+ export declare function getAuthTokenAsync(): Promise<string>;
22
+ /** Get user info async, auto-detects environment */
106
23
  export declare function getUserInfoAsync(forceRefresh?: boolean): Promise<IOSUserInfo | null>;
107
- /**
108
- * Get user info from parent window (iframe scenario)
109
- * IMPORTANT: This method ALWAYS fetches fresh data, NO caching
110
- *
111
- * Strategy:
112
- * 1. Try to get from parent localStorage (same-origin, faster)
113
- * 2. If cross-origin, use postMessage (slower but works cross-origin)
114
- *
115
- * @param timeoutMs - Timeout for postMessage request (default: 5000)
116
- * @returns Promise resolving to fresh user info, or null if unavailable
117
- */
24
+ /** Get user info from parent window (iframe only, no cache) */
118
25
  export declare function getUserInfoFromParent(timeoutMs?: number): Promise<IOSUserInfo | null>;
119
- /**
120
- * Get cached user info (synchronous, may be null if not yet received)
121
- */
122
- export declare function getCachedUserInfo(): IOSUserInfo | null;
123
- /**
124
- * Check if user info has been received
125
- */
126
- export declare function hasUserInfo(): boolean;
127
- /**
128
- * Clear cached user info (useful for logout)
129
- */
130
- export declare function clearCachedUserInfo(): void;
131
- /**
132
- * Initialize bridge and expose to window
133
- */
134
- export declare function initUserBridge(): void;
135
- /**
136
- * Auto-request credentials on SDK load
137
- * Tries multiple sources in order:
138
- * 1. iOS native bridge (if available)
139
- * 2. Parent localStorage (if in iframe, same-origin)
140
- * 3. Parent postMessage (if in iframe, cross-origin)
141
- */
142
- export declare function autoRequestCredentials(): Promise<void>;
143
- /**
144
- * 异步获取 Auth Token
145
- */
146
- export declare function getAuthTokenAsync(): Promise<string>;
147
- /**
148
- * Get current user ID asynchronously
149
- * Waits for credentials if not already available
150
- * @returns Promise resolving to user ID string, or "" if unavailable
151
- */
152
- export declare function getCurrentUserIdAsync(): Promise<string>;
153
- /**
154
- * Check if credentials have been received
155
- */
156
- export declare function hasCredentials(): boolean;
157
- /**
158
- * Get cached credentials (synchronous, may be null if not yet received)
159
- */
160
- export declare function getCachedCredentials(): IOSUserCredentials | null;
26
+ /** Called by iOS/Android: window.processUserCredentials(data) */
27
+ export declare function processUserCredentials(data: unknown): void;
28
+ /** Called by iOS/Android: window.processUserInfo(data) */
29
+ export declare function processUserInfo(data: unknown): void;
@@ -1,21 +1,12 @@
1
- import { UserSdkConfig } from './types';
2
1
  /**
3
- * Initialize user SDK configuration
4
- */
5
- export declare function initUserSdk(config: Partial<UserSdkConfig>): void;
6
- /**
7
- * Get current user SDK configuration
8
- */
9
- export declare function getUserSdkConfig(): UserSdkConfig;
10
- /**
11
- * Update auth token
2
+ * User SDK Config (internal)
12
3
  */
4
+ interface UserSdkConfig {
5
+ apiBaseUrl: string;
6
+ authToken: string;
7
+ currentUserId: string | null;
8
+ }
9
+ export declare function initUserSdk(partial: Partial<UserSdkConfig>): void;
13
10
  export declare function setAuthToken(token: string): void;
14
- /**
15
- * Update current user ID
16
- */
17
11
  export declare function setCurrentUserId(userId: string | null): void;
18
- /**
19
- * Get current auth token synchronously
20
- */
21
- export declare function getAuthToken(): string;
12
+ export {};
@@ -1,74 +1,12 @@
1
- import { UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions } from './types';
2
- import { getAuthToken } from './config';
3
1
  /**
4
- * Hook to get current user ID
5
- * @returns Current user ID or null
6
- */
7
- export declare function useCurrentUserId(): string | null;
8
- /**
9
- * Hook to get current auth token
10
- * @returns Current auth token string
11
- */
12
- export declare function useAuthToken(): string;
13
- /**
14
- * Hook to get current user's profile
15
- * @returns Query result with current user profile data
16
- */
17
- export declare function useGetCurrentUserProfileQuery(): UserProfileQueryResult;
18
- /**
19
- * Hook to get user profile by ID
20
- * @param options - Options containing user ID to fetch
21
- * @returns Query result with user profile data
22
- */
23
- export declare function useGetUserProfileByIdQuery(options: GetUserProfileByIdOptions): UserProfileQueryResult;
24
- /**
25
- * Hook to get all joined user profiles
26
- * @param options - Options for filtering users
27
- * @returns Query result with user profiles array
28
- *
29
- * Note: This is a simplified implementation that only fetches the current user.
30
- * In production, this would fetch all users from a users list API.
31
- */
32
- export declare function useGetJoinedUserProfilesQuery(options?: GetJoinedUserProfilesOptions): UserProfilesQueryResult;
33
- /**
34
- * Synchronous function to get current user ID
35
- * Use this in non-React contexts
36
- */
37
- export declare function getCurrentUserId(): string | null;
38
- export { getAuthToken };
39
- /**
40
- * Hook to get user info from iOS or parent window (no backend API)
41
- * Automatically detects environment (iOS App or iframe) and uses appropriate method
42
- *
43
- * Uses module-level cache to avoid duplicate requests when used in multiple components
44
- *
45
- * @returns User info with avatar, nickName, username, uid
46
- *
47
- * @example
48
- * ```typescript
49
- * const { avatar, nickName, username, uid } = useUserInfo();
50
- *
51
- * <Avatar>
52
- * <AvatarImage src={avatar} />
53
- * <AvatarFallback>{nickName[0]}</AvatarFallback>
54
- * </Avatar>
55
- * <span>{nickName}</span>
56
- * ```
2
+ * User SDK Hooks
57
3
  */
4
+ /** Hook to get user info (avatar, nickName, username, uid) */
58
5
  export declare function useUserInfo(): {
59
6
  avatar: string;
60
7
  nickName: string;
61
8
  username: string;
62
9
  uid: string;
63
10
  };
64
- /**
65
- * Clear the cached user info
66
- * Useful when user logs out or switches account
67
- *
68
- * @example
69
- * ```typescript
70
- * // When user logs out
71
- * clearUserInfoCache();
72
- * ```
73
- */
11
+ /** Clear cached user info */
74
12
  export declare function clearUserInfoCache(): void;
@@ -1,12 +1,6 @@
1
1
  /**
2
- * User SDK module
3
- * Provides user profile fetching and session management
2
+ * User SDK
4
3
  */
5
- export type { UserProfile, UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions, FormatDateOptions, UserSessionInfoInterface, UserSdkConfig, } from './types';
6
- export { initUserSdk, getUserSdkConfig, setAuthToken, setCurrentUserId, } from './config';
7
- export { useCurrentUserId, useAuthToken, useGetCurrentUserProfileQuery, useGetUserProfileByIdQuery, useGetJoinedUserProfilesQuery, getCurrentUserId, getAuthToken, useUserInfo, // Simple hook for iOS/iframe user info
8
- clearUserInfoCache, } from './hooks';
9
- export { fetchUserProfile, clearProfileCache } from './api';
10
- export { userSessionInfo } from './userSessionInfo';
11
- export { isInIframe, requestCredentialsFromiOS, requestCredentialsFromParent, tryGetCredentialsFromParentStorage, initUserBridge, autoRequestCredentials, getAuthTokenAsync, getCurrentUserIdAsync, hasCredentials, getCachedCredentials, requestUserInfoFromiOS, getUserInfoAsync, getCachedUserInfo, hasUserInfo, clearCachedUserInfo, requestUserInfoFromParent, tryGetUserInfoFromParentStorage, getUserInfoFromParent, } from './bridge';
4
+ export { useUserInfo, clearUserInfoCache } from './hooks';
5
+ export { getAuthTokenAsync, isInIframe } from './bridge';
12
6
  export type { IOSUserCredentials, IOSUserInfo } from './bridge';