@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.
- package/dist/ai/errors.d.ts +37 -0
- package/dist/ai/index.js +2 -2
- package/dist/ai/shared/fetch.d.ts +6 -0
- package/dist/bridge-Ca3H2iN1.js +197 -0
- package/dist/core/index.js +1 -1
- package/dist/helper-CIt1_T-j.js +275 -0
- package/dist/hooks-CE9cjXHP.js +46 -0
- package/dist/index/index.js +82 -111
- package/dist/{ui-D6IZ1jrR.js → ui-y5N62DqC.js} +81 -25
- package/dist/user/bridge.d.ts +10 -141
- package/dist/user/config.d.ts +8 -17
- package/dist/user/hooks.d.ts +3 -65
- package/dist/user/index.d.ts +3 -9
- package/dist/user/index.js +7 -36
- package/dist/user/types.d.ts +2 -105
- package/dist/utils/index.js +11 -9
- package/dist/utils/platform.d.ts +42 -1
- package/package.json +1 -1
- package/dist/bridge-N9ELFpfV.js +0 -430
- package/dist/helper-CKiqfKle.js +0 -264
- package/dist/user/api.d.ts +0 -9
- package/dist/user/userSessionInfo.d.ts +0 -6
- package/dist/userSessionInfo-DFvsuELU.js +0 -229
package/dist/index/index.js
CHANGED
|
@@ -1,118 +1,89 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as
|
|
2
|
-
import { A as
|
|
3
|
-
import { s as
|
|
4
|
-
import { A as
|
|
5
|
-
import { CameraAPI as
|
|
6
|
-
import { P as w, p as
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as
|
|
9
|
-
import { c as
|
|
10
|
-
import { reportScore as re, sendEvent as
|
|
11
|
-
import { A as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { hasNativeBridge as
|
|
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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UAParser as
|
|
5
|
-
|
|
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
|
-
|
|
8
|
-
this.parser = new
|
|
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),
|
|
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:
|
|
35
|
+
browser: r,
|
|
19
36
|
browserVersion: e.browser.version,
|
|
20
|
-
isMobile:
|
|
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
|
-
*
|
|
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\/([
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
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:
|
|
80
|
-
version:
|
|
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
|
|
105
|
-
function
|
|
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
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
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
|
-
|
|
117
|
-
f as
|
|
118
|
-
|
|
170
|
+
w as P,
|
|
171
|
+
f as c,
|
|
172
|
+
m as i,
|
|
173
|
+
x as p,
|
|
174
|
+
v as s
|
|
119
175
|
};
|
package/dist/user/bridge.d.ts
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
121
|
-
*/
|
|
122
|
-
export declare function
|
|
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;
|
package/dist/user/config.d.ts
CHANGED
|
@@ -1,21 +1,12 @@
|
|
|
1
|
-
import { UserSdkConfig } from './types';
|
|
2
1
|
/**
|
|
3
|
-
*
|
|
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 {};
|
package/dist/user/hooks.d.ts
CHANGED
|
@@ -1,74 +1,12 @@
|
|
|
1
|
-
import { UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions } from './types';
|
|
2
|
-
import { getAuthToken } from './config';
|
|
3
1
|
/**
|
|
4
|
-
*
|
|
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;
|
package/dist/user/index.d.ts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* User SDK
|
|
3
|
-
* Provides user profile fetching and session management
|
|
2
|
+
* User SDK
|
|
4
3
|
*/
|
|
5
|
-
export
|
|
6
|
-
export {
|
|
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';
|