@aippy/runtime 0.2.7-dev.0 → 0.2.7-dev.2
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/config/bridge.d.ts +23 -0
- package/dist/ai/config/helper.d.ts +43 -0
- package/dist/ai/config/index.d.ts +11 -0
- package/dist/ai/config/parser.d.ts +60 -0
- package/dist/ai/config/types.d.ts +80 -0
- package/dist/ai/errors.d.ts +4 -0
- package/dist/ai/index.d.ts +8 -7
- package/dist/ai/index.js +22 -19
- package/dist/ai/openai/index.d.ts +2 -2
- package/dist/ai/openai/provider.d.ts +3 -3
- package/dist/ai/ui/config.d.ts +2 -58
- package/dist/ai/ui/endpoints.d.ts +0 -4
- package/dist/ai/ui/index.d.ts +3 -5
- package/dist/ai/ui/types.d.ts +0 -25
- package/dist/bridge-N9ELFpfV.js +430 -0
- package/dist/container-message-DGrno17o.js +31 -0
- package/dist/core/container-message.d.ts +81 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +18 -16
- package/dist/device/index.js +1 -1
- package/dist/helper-CsFko67T.js +264 -0
- package/dist/index/index.js +110 -93
- package/dist/{native-bridge-JAmH-zTN.js → native-bridge-BnvipFJc.js} +1 -1
- package/dist/pwa-CilSlaik.js +249 -0
- package/dist/ui-D6IZ1jrR.js +119 -0
- package/dist/user/bridge.d.ts +83 -3
- package/dist/user/hooks.d.ts +36 -0
- package/dist/user/index.d.ts +4 -3
- package/dist/user/index.js +35 -25
- package/dist/user/types.d.ts +2 -0
- package/dist/userSessionInfo-DFvsuELU.js +229 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +9 -7
- package/dist/utils/platform.d.ts +7 -0
- package/dist/utils/ui.d.ts +11 -0
- package/package.json +4 -2
- package/dist/bridge-DdAH4txB.js +0 -222
- package/dist/errors-DWRVLkVz.js +0 -152
- package/dist/pwa-8DGmPqLV.js +0 -341
- package/dist/userSessionInfo-CBk9ywXi.js +0 -186
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
class f {
|
|
2
|
+
/**
|
|
3
|
+
* Get Core Web Vitals metrics
|
|
4
|
+
*/
|
|
5
|
+
async getCoreWebVitals() {
|
|
6
|
+
const r = {};
|
|
7
|
+
try {
|
|
8
|
+
const e = performance.getEntriesByName("first-contentful-paint")[0];
|
|
9
|
+
e && (r.fcp = e.startTime);
|
|
10
|
+
const t = performance.getEntriesByType("largest-contentful-paint");
|
|
11
|
+
if (t.length > 0) {
|
|
12
|
+
const n = t[t.length - 1];
|
|
13
|
+
r.lcp = n.startTime;
|
|
14
|
+
}
|
|
15
|
+
const i = performance.getEntriesByType("first-input");
|
|
16
|
+
if (i.length > 0) {
|
|
17
|
+
const n = i[0];
|
|
18
|
+
r.fid = n.processingStart - n.startTime;
|
|
19
|
+
}
|
|
20
|
+
const o = performance.getEntriesByType("layout-shift");
|
|
21
|
+
if (o.length > 0) {
|
|
22
|
+
let n = 0;
|
|
23
|
+
for (const l of o) {
|
|
24
|
+
const s = l;
|
|
25
|
+
s.hadRecentInput || (n += s.value);
|
|
26
|
+
}
|
|
27
|
+
r.cls = n;
|
|
28
|
+
}
|
|
29
|
+
const a = this.calculateTTI();
|
|
30
|
+
a && (r.tti = a);
|
|
31
|
+
} catch (e) {
|
|
32
|
+
console.warn("Failed to get Core Web Vitals:", e);
|
|
33
|
+
}
|
|
34
|
+
return r;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Get navigation timing metrics
|
|
38
|
+
*/
|
|
39
|
+
getNavigationTiming() {
|
|
40
|
+
const r = performance.getEntriesByType("navigation")[0];
|
|
41
|
+
return r ? {
|
|
42
|
+
// DNS lookup time
|
|
43
|
+
dns: r.domainLookupEnd - r.domainLookupStart,
|
|
44
|
+
// TCP connection time
|
|
45
|
+
tcp: r.connectEnd - r.connectStart,
|
|
46
|
+
// Request time
|
|
47
|
+
request: r.responseStart - r.requestStart,
|
|
48
|
+
// Response time
|
|
49
|
+
response: r.responseEnd - r.responseStart,
|
|
50
|
+
// DOM processing time
|
|
51
|
+
domProcessing: r.domComplete - r.domInteractive,
|
|
52
|
+
// Total page load time
|
|
53
|
+
total: r.loadEventEnd - r.fetchStart
|
|
54
|
+
} : null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get resource timing metrics
|
|
58
|
+
*/
|
|
59
|
+
getResourceTiming() {
|
|
60
|
+
return performance.getEntriesByType("resource").map((e) => ({
|
|
61
|
+
name: e.name,
|
|
62
|
+
duration: e.duration,
|
|
63
|
+
size: e.transferSize,
|
|
64
|
+
type: this.getResourceType(e.name)
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Measure function execution time
|
|
69
|
+
*/
|
|
70
|
+
measureFunction(r, e) {
|
|
71
|
+
const t = r();
|
|
72
|
+
return e && (performance.mark(`${e}-start`), performance.mark(`${e}-end`), performance.measure(e, `${e}-start`, `${e}-end`)), t;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Measure async function execution time
|
|
76
|
+
*/
|
|
77
|
+
async measureAsyncFunction(r, e) {
|
|
78
|
+
const t = await r();
|
|
79
|
+
return e && (performance.mark(`${e}-start`), performance.mark(`${e}-end`), performance.measure(e, `${e}-start`, `${e}-end`)), t;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Get memory usage (if available)
|
|
83
|
+
*/
|
|
84
|
+
getMemoryUsage() {
|
|
85
|
+
if ("memory" in performance) {
|
|
86
|
+
const r = performance.memory;
|
|
87
|
+
return {
|
|
88
|
+
used: r.usedJSHeapSize,
|
|
89
|
+
total: r.totalJSHeapSize,
|
|
90
|
+
limit: r.jsHeapSizeLimit
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
calculateTTI() {
|
|
96
|
+
const r = performance.getEntriesByType("navigation")[0];
|
|
97
|
+
return r ? r.domContentLoadedEventEnd - r.fetchStart : null;
|
|
98
|
+
}
|
|
99
|
+
getResourceType(r) {
|
|
100
|
+
return r.includes(".js") ? "script" : r.includes(".css") ? "stylesheet" : r.includes(".png") || r.includes(".jpg") || r.includes(".gif") ? "image" : r.includes(".woff") || r.includes(".ttf") ? "font" : "other";
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
const p = new f();
|
|
104
|
+
class d {
|
|
105
|
+
/**
|
|
106
|
+
* Get PWA information
|
|
107
|
+
*/
|
|
108
|
+
getPWAInfo() {
|
|
109
|
+
return {
|
|
110
|
+
isInstalled: this.isInstalled(),
|
|
111
|
+
isInstallable: this.isInstallable(),
|
|
112
|
+
canInstall: this.canInstall(),
|
|
113
|
+
isStandalone: this.isStandalone()
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Check if PWA is installed
|
|
118
|
+
*/
|
|
119
|
+
isInstalled() {
|
|
120
|
+
return this.isStandalone() || this.isInApp();
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Check if PWA is installable
|
|
124
|
+
*/
|
|
125
|
+
isInstallable() {
|
|
126
|
+
return "serviceWorker" in navigator && "PushManager" in window;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Check if install prompt is available
|
|
130
|
+
*/
|
|
131
|
+
canInstall() {
|
|
132
|
+
return this.isInstallable() && !this.isInstalled();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Check if running in standalone mode
|
|
136
|
+
*/
|
|
137
|
+
isStandalone() {
|
|
138
|
+
return window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === !0;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Check if running in app (iOS)
|
|
142
|
+
*/
|
|
143
|
+
isInApp() {
|
|
144
|
+
return window.navigator.standalone === !0;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Register service worker
|
|
148
|
+
*/
|
|
149
|
+
async registerServiceWorker(r) {
|
|
150
|
+
if (!("serviceWorker" in navigator))
|
|
151
|
+
return console.warn("Service Worker not supported"), null;
|
|
152
|
+
try {
|
|
153
|
+
return await navigator.serviceWorker.register(r);
|
|
154
|
+
} catch (e) {
|
|
155
|
+
return console.error("Service Worker registration failed:", e), null;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Unregister service worker
|
|
160
|
+
*/
|
|
161
|
+
async unregisterServiceWorker() {
|
|
162
|
+
if (!("serviceWorker" in navigator))
|
|
163
|
+
return !1;
|
|
164
|
+
try {
|
|
165
|
+
const r = await navigator.serviceWorker.getRegistrations();
|
|
166
|
+
for (const e of r)
|
|
167
|
+
await e.unregister();
|
|
168
|
+
return !0;
|
|
169
|
+
} catch (r) {
|
|
170
|
+
return console.error("Service Worker unregistration failed:", r), !1;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Request notification permission
|
|
175
|
+
*/
|
|
176
|
+
async requestNotificationPermission() {
|
|
177
|
+
if (!("Notification" in window))
|
|
178
|
+
throw new Error("Notifications not supported");
|
|
179
|
+
return Notification.permission === "granted" ? "granted" : Notification.permission === "denied" ? "denied" : await Notification.requestPermission();
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Send notification
|
|
183
|
+
*/
|
|
184
|
+
async sendNotification(r, e) {
|
|
185
|
+
if (!("Notification" in window))
|
|
186
|
+
throw new Error("Notifications not supported");
|
|
187
|
+
if (Notification.permission !== "granted")
|
|
188
|
+
throw new Error("Notification permission not granted");
|
|
189
|
+
const t = new Notification(r, e);
|
|
190
|
+
setTimeout(() => {
|
|
191
|
+
t.close();
|
|
192
|
+
}, 5e3);
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Share content using Web Share API
|
|
196
|
+
*/
|
|
197
|
+
async share(r) {
|
|
198
|
+
if (!("share" in navigator))
|
|
199
|
+
throw new Error("Web Share API not supported");
|
|
200
|
+
try {
|
|
201
|
+
await navigator.share(r);
|
|
202
|
+
} catch (e) {
|
|
203
|
+
if (e instanceof Error && e.name !== "AbortError")
|
|
204
|
+
throw new Error(`Share failed: ${e.message}`);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Copy text to clipboard
|
|
209
|
+
*/
|
|
210
|
+
async copyToClipboard(r) {
|
|
211
|
+
if (!("clipboard" in navigator))
|
|
212
|
+
throw new Error("Clipboard API not supported");
|
|
213
|
+
try {
|
|
214
|
+
await navigator.clipboard.writeText(r);
|
|
215
|
+
} catch (e) {
|
|
216
|
+
throw new Error(`Copy to clipboard failed: ${e instanceof Error ? e.message : "Unknown error"}`);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Read text from clipboard
|
|
221
|
+
*/
|
|
222
|
+
async readFromClipboard() {
|
|
223
|
+
if (!("clipboard" in navigator))
|
|
224
|
+
throw new Error("Clipboard API not supported");
|
|
225
|
+
try {
|
|
226
|
+
return await navigator.clipboard.readText();
|
|
227
|
+
} catch (r) {
|
|
228
|
+
throw new Error(`Read from clipboard failed: ${r instanceof Error ? r.message : "Unknown error"}`);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Get install prompt event
|
|
233
|
+
*/
|
|
234
|
+
getInstallPromptEvent() {
|
|
235
|
+
return new Promise((r) => {
|
|
236
|
+
const e = (t) => {
|
|
237
|
+
t.preventDefault(), r(t), window.removeEventListener("beforeinstallprompt", e);
|
|
238
|
+
};
|
|
239
|
+
window.addEventListener("beforeinstallprompt", e);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
const u = new d();
|
|
244
|
+
export {
|
|
245
|
+
f as P,
|
|
246
|
+
d as a,
|
|
247
|
+
u as b,
|
|
248
|
+
p
|
|
249
|
+
};
|
|
@@ -0,0 +1,119 @@
|
|
|
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 {
|
|
6
|
+
constructor() {
|
|
7
|
+
s(this, "parser");
|
|
8
|
+
this.parser = new d();
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Get platform information
|
|
12
|
+
*/
|
|
13
|
+
getPlatformInfo() {
|
|
14
|
+
const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), t = this.normalizeBrowserName(e.browser.name), r = this.isMobileDevice(), i = !r;
|
|
15
|
+
return {
|
|
16
|
+
name: n,
|
|
17
|
+
version: e.os.version,
|
|
18
|
+
browser: t,
|
|
19
|
+
browserVersion: e.browser.version,
|
|
20
|
+
isMobile: r,
|
|
21
|
+
isDesktop: i
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Get platform capabilities
|
|
26
|
+
*/
|
|
27
|
+
getCapabilities() {
|
|
28
|
+
return {
|
|
29
|
+
serviceWorker: "serviceWorker" in navigator,
|
|
30
|
+
pushNotifications: "PushManager" in window,
|
|
31
|
+
webShare: "share" in navigator,
|
|
32
|
+
clipboard: "clipboard" in navigator,
|
|
33
|
+
webRTC: !!(window.RTCPeerConnection || window.webkitRTCPeerConnection),
|
|
34
|
+
webGL: !!this.getWebGLContext(),
|
|
35
|
+
webAssembly: "WebAssembly" in window
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if device is mobile
|
|
40
|
+
*/
|
|
41
|
+
isMobileDevice() {
|
|
42
|
+
const e = navigator.userAgent;
|
|
43
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e) || this.isTouchDevice();
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if device supports touch
|
|
47
|
+
*/
|
|
48
|
+
isTouchDevice() {
|
|
49
|
+
return "ontouchstart" in window || navigator.maxTouchPoints > 0;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if running in standalone mode (PWA)
|
|
53
|
+
*/
|
|
54
|
+
isStandalone() {
|
|
55
|
+
return window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === !0;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Check if running in iOS Safari
|
|
59
|
+
*/
|
|
60
|
+
isIOSSafari() {
|
|
61
|
+
const e = this.getPlatformInfo();
|
|
62
|
+
return e.name === "ios" && e.browser === "safari";
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Check if running in Android Chrome
|
|
66
|
+
*/
|
|
67
|
+
isAndroidChrome() {
|
|
68
|
+
const e = this.getPlatformInfo();
|
|
69
|
+
return e.name === "android" && e.browser === "chrome";
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* 解析 User-Agent 中的 Aippy App 信息
|
|
73
|
+
*/
|
|
74
|
+
parseAippyInfo() {
|
|
75
|
+
const e = navigator.userAgent, n = /Aippy\/([^\/]+)\/[^\/]+\/(iOS|Android)/i, t = e.match(n);
|
|
76
|
+
if (t) {
|
|
77
|
+
const r = t[1];
|
|
78
|
+
return {
|
|
79
|
+
platform: t[2],
|
|
80
|
+
version: r
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
normalizePlatformName(e) {
|
|
86
|
+
if (!e) return "unknown";
|
|
87
|
+
const n = e.toLowerCase();
|
|
88
|
+
return n.includes("ios") ? "ios" : n.includes("android") ? "android" : n.includes("windows") ? "windows" : n.includes("mac") ? "macos" : n.includes("linux") ? "linux" : "unknown";
|
|
89
|
+
}
|
|
90
|
+
normalizeBrowserName(e) {
|
|
91
|
+
if (!e) return "unknown";
|
|
92
|
+
const n = e.toLowerCase();
|
|
93
|
+
return n.includes("chrome") ? "chrome" : n.includes("firefox") ? "firefox" : n.includes("safari") ? "safari" : n.includes("edge") ? "edge" : "unknown";
|
|
94
|
+
}
|
|
95
|
+
getWebGLContext() {
|
|
96
|
+
try {
|
|
97
|
+
const e = document.createElement("canvas");
|
|
98
|
+
return e.getContext("webgl") || e.getContext("experimental-webgl");
|
|
99
|
+
} catch {
|
|
100
|
+
return null;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const f = new l();
|
|
105
|
+
function p(o) {
|
|
106
|
+
const e = document.createElement("div");
|
|
107
|
+
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
|
+
const n = document.createElement("div");
|
|
109
|
+
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);
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
l as P,
|
|
117
|
+
f as p,
|
|
118
|
+
p as s
|
|
119
|
+
};
|
package/dist/user/bridge.d.ts
CHANGED
|
@@ -12,6 +12,22 @@ export interface IOSUserCredentials {
|
|
|
12
12
|
token: string;
|
|
13
13
|
apiBaseUrl?: string;
|
|
14
14
|
}
|
|
15
|
+
/**
|
|
16
|
+
* User information (extended profile data)
|
|
17
|
+
*/
|
|
18
|
+
export interface IOSUserInfo {
|
|
19
|
+
uid: string;
|
|
20
|
+
displayName?: string;
|
|
21
|
+
nickname?: string;
|
|
22
|
+
username?: string;
|
|
23
|
+
photoUrl?: string;
|
|
24
|
+
avatar?: string;
|
|
25
|
+
email?: string;
|
|
26
|
+
phone?: string;
|
|
27
|
+
bio?: string;
|
|
28
|
+
online?: boolean;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
15
31
|
/**
|
|
16
32
|
* Check if running inside an iframe
|
|
17
33
|
*/
|
|
@@ -24,6 +40,15 @@ export declare function isInIframe(): boolean;
|
|
|
24
40
|
* @returns Promise resolving to user credentials
|
|
25
41
|
*/
|
|
26
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>;
|
|
27
52
|
/**
|
|
28
53
|
* Try to get credentials from parent localStorage directly
|
|
29
54
|
* This works when same-origin, otherwise falls back to postMessage
|
|
@@ -33,6 +58,17 @@ export declare function requestCredentialsFromParent(timeoutMs?: number): Promis
|
|
|
33
58
|
* - user: JSON string with { uid, nickName, ... }
|
|
34
59
|
*/
|
|
35
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;
|
|
36
72
|
/**
|
|
37
73
|
* Request user credentials from iOS native layer
|
|
38
74
|
* Uses aippyRuntime's message passing mechanism
|
|
@@ -46,6 +82,52 @@ export declare function requestCredentialsFromiOS(timeoutMs?: number): Promise<I
|
|
|
46
82
|
* Called via: window.processUserCredentials(data)
|
|
47
83
|
*/
|
|
48
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
|
+
*/
|
|
106
|
+
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
|
+
*/
|
|
118
|
+
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;
|
|
49
131
|
/**
|
|
50
132
|
* Initialize bridge and expose to window
|
|
51
133
|
*/
|
|
@@ -59,9 +141,7 @@ export declare function initUserBridge(): void;
|
|
|
59
141
|
*/
|
|
60
142
|
export declare function autoRequestCredentials(): Promise<void>;
|
|
61
143
|
/**
|
|
62
|
-
*
|
|
63
|
-
* Waits for credentials if not already available
|
|
64
|
-
* @returns Promise resolving to token string, or "" if unavailable
|
|
144
|
+
* 异步获取 Auth Token
|
|
65
145
|
*/
|
|
66
146
|
export declare function getAuthTokenAsync(): Promise<string>;
|
|
67
147
|
/**
|
package/dist/user/hooks.d.ts
CHANGED
|
@@ -36,3 +36,39 @@ export declare function useGetJoinedUserProfilesQuery(options?: GetJoinedUserPro
|
|
|
36
36
|
*/
|
|
37
37
|
export declare function getCurrentUserId(): string | null;
|
|
38
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
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
export declare function useUserInfo(): {
|
|
59
|
+
avatar: string;
|
|
60
|
+
nickName: string;
|
|
61
|
+
username: string;
|
|
62
|
+
uid: string;
|
|
63
|
+
};
|
|
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
|
+
*/
|
|
74
|
+
export declare function clearUserInfoCache(): void;
|
package/dist/user/index.d.ts
CHANGED
|
@@ -4,8 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export type { UserProfile, UserProfileQueryResult, UserProfilesQueryResult, GetUserProfileByIdOptions, GetJoinedUserProfilesOptions, FormatDateOptions, UserSessionInfoInterface, UserSdkConfig, } from './types';
|
|
6
6
|
export { initUserSdk, getUserSdkConfig, setAuthToken, setCurrentUserId, } from './config';
|
|
7
|
-
export { useCurrentUserId, useAuthToken, useGetCurrentUserProfileQuery, useGetUserProfileByIdQuery, useGetJoinedUserProfilesQuery, getCurrentUserId, getAuthToken,
|
|
7
|
+
export { useCurrentUserId, useAuthToken, useGetCurrentUserProfileQuery, useGetUserProfileByIdQuery, useGetJoinedUserProfilesQuery, getCurrentUserId, getAuthToken, useUserInfo, // Simple hook for iOS/iframe user info
|
|
8
|
+
clearUserInfoCache, } from './hooks';
|
|
8
9
|
export { fetchUserProfile, clearProfileCache } from './api';
|
|
9
10
|
export { userSessionInfo } from './userSessionInfo';
|
|
10
|
-
export { isInIframe, requestCredentialsFromiOS, requestCredentialsFromParent, tryGetCredentialsFromParentStorage, initUserBridge, autoRequestCredentials, getAuthTokenAsync, getCurrentUserIdAsync, hasCredentials, getCachedCredentials, } from './bridge';
|
|
11
|
-
export type { IOSUserCredentials } from './bridge';
|
|
11
|
+
export { isInIframe, requestCredentialsFromiOS, requestCredentialsFromParent, tryGetCredentialsFromParentStorage, initUserBridge, autoRequestCredentials, getAuthTokenAsync, getCurrentUserIdAsync, hasCredentials, getCachedCredentials, requestUserInfoFromiOS, getUserInfoAsync, getCachedUserInfo, hasUserInfo, clearCachedUserInfo, requestUserInfoFromParent, tryGetUserInfoFromParentStorage, getUserInfoFromParent, } from './bridge';
|
|
12
|
+
export type { IOSUserCredentials, IOSUserInfo } from './bridge';
|
package/dist/user/index.js
CHANGED
|
@@ -1,28 +1,38 @@
|
|
|
1
|
-
import { f as r,
|
|
2
|
-
import {
|
|
1
|
+
import { f as r, q as a, b as t, h as n, l as o, o as u, j as i, n as f, w as U, g as d, k as I, p as C, e as g, i as l, c, d as h, r as m, u as P, m as y, s as k, a as A, t as F, v as S } from "../bridge-N9ELFpfV.js";
|
|
2
|
+
import { i as G, f as T, h as p, g as Q, a as b, u as j, b as x, d as B, c as O, e as v, j as w } from "../userSessionInfo-DFvsuELU.js";
|
|
3
3
|
export {
|
|
4
4
|
r as autoRequestCredentials,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
5
|
+
a as clearCachedUserInfo,
|
|
6
|
+
G as clearProfileCache,
|
|
7
|
+
T as clearUserInfoCache,
|
|
8
|
+
p as fetchUserProfile,
|
|
9
|
+
t as getAuthToken,
|
|
10
|
+
n as getAuthTokenAsync,
|
|
11
|
+
o as getCachedCredentials,
|
|
12
|
+
u as getCachedUserInfo,
|
|
13
|
+
Q as getCurrentUserId,
|
|
14
|
+
i as getCurrentUserIdAsync,
|
|
15
|
+
f as getUserInfoAsync,
|
|
16
|
+
U as getUserInfoFromParent,
|
|
17
|
+
d as getUserSdkConfig,
|
|
18
|
+
I as hasCredentials,
|
|
19
|
+
C as hasUserInfo,
|
|
20
|
+
g as initUserBridge,
|
|
21
|
+
l as initUserSdk,
|
|
22
|
+
c as isInIframe,
|
|
23
|
+
h as requestCredentialsFromParent,
|
|
24
|
+
m as requestCredentialsFromiOS,
|
|
25
|
+
P as requestUserInfoFromParent,
|
|
26
|
+
y as requestUserInfoFromiOS,
|
|
27
|
+
k as setAuthToken,
|
|
28
|
+
A as setCurrentUserId,
|
|
29
|
+
F as tryGetCredentialsFromParentStorage,
|
|
30
|
+
S as tryGetUserInfoFromParentStorage,
|
|
31
|
+
b as useAuthToken,
|
|
32
|
+
j as useCurrentUserId,
|
|
33
|
+
x as useGetCurrentUserProfileQuery,
|
|
34
|
+
B as useGetJoinedUserProfilesQuery,
|
|
35
|
+
O as useGetUserProfileByIdQuery,
|
|
36
|
+
v as useUserInfo,
|
|
37
|
+
w as userSessionInfo
|
|
28
38
|
};
|
package/dist/user/types.d.ts
CHANGED