@aippy/runtime 0.2.7-dev.0 → 0.2.7-dev.1
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-D2d8hnO_.js +395 -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-CRGxnlsu.js +261 -0
- package/dist/index/index.js +105 -90
- package/dist/{native-bridge-JAmH-zTN.js → native-bridge-BnvipFJc.js} +1 -1
- package/dist/user/bridge.d.ts +82 -0
- 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-SbuNZ7JR.js +229 -0
- package/package.json +4 -2
- package/dist/bridge-DdAH4txB.js +0 -222
- package/dist/errors-DWRVLkVz.js +0 -152
- package/dist/userSessionInfo-CBk9ywXi.js +0 -186
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
import { createOpenAICompatible as l } from "@ai-sdk/openai-compatible";
|
|
2
|
+
import "react";
|
|
3
|
+
import { h as d } from "./bridge-D2d8hnO_.js";
|
|
4
|
+
import { DefaultChatTransport as y, AISDKError as i } from "ai";
|
|
5
|
+
import { s as u } from "./container-message-DGrno17o.js";
|
|
6
|
+
const m = "https://api.aippy.dev", h = `${m}/api/aisdk/v1/`, A = `${m}/api/aisdk/v1/ui/`, b = "gpt-5-nano", E = "";
|
|
7
|
+
function w(r = {}) {
|
|
8
|
+
return {
|
|
9
|
+
baseUrl: r.baseUrl ?? h
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function I(r = {}) {
|
|
13
|
+
return {
|
|
14
|
+
baseUrl: r.baseUrl ?? A
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
function v(r, e) {
|
|
18
|
+
const n = r.endsWith("/") ? r : `${r}/`, t = e.startsWith("/") ? e.slice(1) : e;
|
|
19
|
+
return new URL(t, n).href;
|
|
20
|
+
}
|
|
21
|
+
function c() {
|
|
22
|
+
return async (r, e) => {
|
|
23
|
+
const n = await d(), t = new Headers(e?.headers);
|
|
24
|
+
return t.set("Authorization", `Bearer ${n}`), globalThis.fetch(r, { ...e, headers: t });
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
const _ = [
|
|
28
|
+
"gpt-image-1",
|
|
29
|
+
"gpt-image-1-mini",
|
|
30
|
+
"gpt-image-1.5"
|
|
31
|
+
];
|
|
32
|
+
function C(r) {
|
|
33
|
+
try {
|
|
34
|
+
const e = JSON.parse(r);
|
|
35
|
+
if (e.model && _.some((n) => e.model.startsWith(n))) {
|
|
36
|
+
const { response_format: n, ...t } = e;
|
|
37
|
+
return JSON.stringify(t);
|
|
38
|
+
}
|
|
39
|
+
} catch {
|
|
40
|
+
}
|
|
41
|
+
return r;
|
|
42
|
+
}
|
|
43
|
+
function j(r = {}) {
|
|
44
|
+
const { baseUrl: e } = w(r), n = c();
|
|
45
|
+
return l({
|
|
46
|
+
name: "aippy",
|
|
47
|
+
baseURL: e,
|
|
48
|
+
fetch: async (a, s) => a.toString().includes("/images/generations") && s?.method?.toUpperCase() === "POST" && s?.body ? n(a, {
|
|
49
|
+
...s,
|
|
50
|
+
body: C(s.body)
|
|
51
|
+
}) : n(a, s)
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const S = "/chat";
|
|
55
|
+
function F(r = {}) {
|
|
56
|
+
const { baseUrl: e } = I(r), n = r.model ?? b, t = r.system ?? E, a = r.api ?? v(e, S), s = { model: n, system: t }, o = c();
|
|
57
|
+
return {
|
|
58
|
+
transport: new y({
|
|
59
|
+
api: a,
|
|
60
|
+
body: s,
|
|
61
|
+
// Ensure token is fetched fresh for every request
|
|
62
|
+
fetch: o
|
|
63
|
+
})
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function L(r, e) {
|
|
67
|
+
const n = r.status;
|
|
68
|
+
if (e && typeof e == "object" && "error" in e) {
|
|
69
|
+
const t = e, a = t.error.code, s = a != null ? `AippyAIError_${a}` : `AippyAIError_${n}`, o = e;
|
|
70
|
+
return "appMessage" in o && o.appMessage !== void 0 ? u(o.appMessage) : "containerErrorData" in o && o.containerErrorData !== void 0 && u(o.containerErrorData), new i({
|
|
71
|
+
name: s,
|
|
72
|
+
message: t.error.message,
|
|
73
|
+
cause: {
|
|
74
|
+
type: t.error.type ?? void 0,
|
|
75
|
+
param: t.error.param ?? void 0,
|
|
76
|
+
status: n
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (e && typeof e == "object" && e !== null) {
|
|
81
|
+
const t = e;
|
|
82
|
+
"appMessage" in t && t.appMessage !== void 0 ? u(t.appMessage) : "containerErrorData" in t && t.containerErrorData !== void 0 && u(t.containerErrorData);
|
|
83
|
+
}
|
|
84
|
+
return new i({
|
|
85
|
+
name: `AippyAIError_${n}`,
|
|
86
|
+
message: `Request failed with status ${n}`,
|
|
87
|
+
cause: { status: n }
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function x() {
|
|
91
|
+
return new i({
|
|
92
|
+
name: "AippyAIError_MISSING_TOKEN",
|
|
93
|
+
message: "User token is required. Ensure user credentials are available via initUserBridge()."
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
function k() {
|
|
97
|
+
return new i({
|
|
98
|
+
name: "AippyAIError_REQUEST_ABORTED",
|
|
99
|
+
message: "Request was aborted"
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
function B(r) {
|
|
103
|
+
const e = r instanceof Error ? r.message : "Network request failed";
|
|
104
|
+
return new i({
|
|
105
|
+
name: "AippyAIError_NETWORK_ERROR",
|
|
106
|
+
message: e,
|
|
107
|
+
cause: r instanceof Error ? r : String(r)
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function P(r) {
|
|
111
|
+
return new i({
|
|
112
|
+
name: "AippyAIError_PARSE_ERROR",
|
|
113
|
+
message: `Failed to parse response: ${r}`
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
class f extends Error {
|
|
117
|
+
constructor(e, n) {
|
|
118
|
+
super(e), this.errors = n, this.name = "AIConfigValidationError";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function g(r) {
|
|
122
|
+
const e = [];
|
|
123
|
+
if (!r || typeof r != "object")
|
|
124
|
+
throw new f("AIConfig must be an object", []);
|
|
125
|
+
const n = r;
|
|
126
|
+
for (const [t, a] of Object.entries(n)) {
|
|
127
|
+
if (!a || typeof a != "object") {
|
|
128
|
+
e.push({ key: t, message: "Item must be an object" });
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const s = a;
|
|
132
|
+
typeof s.index != "number" && e.push({ key: t, message: "index must be a number" }), typeof s.name != "string" && e.push({ key: t, message: "name must be a string" }), typeof s.description != "string" && e.push({ key: t, message: "description must be a string" });
|
|
133
|
+
const o = s.type;
|
|
134
|
+
if (!["number", "boolean", "text", "enum"].includes(o)) {
|
|
135
|
+
e.push({
|
|
136
|
+
key: t,
|
|
137
|
+
message: `type must be one of: number, boolean, text, enum (got: ${o})`
|
|
138
|
+
});
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
if (o === "number")
|
|
142
|
+
typeof s.value != "number" && e.push({ key: t, message: 'value must be a number for type "number"' }), s.min !== void 0 && typeof s.min != "number" && e.push({ key: t, message: "min must be a number" }), s.max !== void 0 && typeof s.max != "number" && e.push({ key: t, message: "max must be a number" }), s.step !== void 0 && typeof s.step != "number" && e.push({ key: t, message: "step must be a number" });
|
|
143
|
+
else if (o === "boolean")
|
|
144
|
+
typeof s.value != "boolean" && e.push({ key: t, message: 'value must be a boolean for type "boolean"' });
|
|
145
|
+
else if (o === "text")
|
|
146
|
+
typeof s.value != "string" && e.push({ key: t, message: 'value must be a string for type "text"' });
|
|
147
|
+
else if (o === "enum") {
|
|
148
|
+
if (!Array.isArray(s.options))
|
|
149
|
+
e.push({ key: t, message: 'options must be an array for type "enum"' });
|
|
150
|
+
else if (s.options.length === 0)
|
|
151
|
+
e.push({ key: t, message: 'options array cannot be empty for type "enum"' });
|
|
152
|
+
else
|
|
153
|
+
for (let p = 0; p < s.options.length; p++)
|
|
154
|
+
typeof s.options[p] != "string" && e.push({
|
|
155
|
+
key: t,
|
|
156
|
+
message: `options[${p}] must be a string`
|
|
157
|
+
});
|
|
158
|
+
typeof s.value != "string" ? e.push({ key: t, message: 'value must be a string for type "enum"' }) : Array.isArray(s.options) && !s.options.includes(s.value) && e.push({
|
|
159
|
+
key: t,
|
|
160
|
+
message: `value "${s.value}" is not in options: [${s.options.join(", ")}]`
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
s.group !== void 0 && typeof s.group != "string" && e.push({ key: t, message: "group must be a string" });
|
|
164
|
+
}
|
|
165
|
+
if (e.length > 0)
|
|
166
|
+
throw new f(
|
|
167
|
+
`AIConfig validation failed with ${e.length} error(s)`,
|
|
168
|
+
e
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
function J(r) {
|
|
172
|
+
let e;
|
|
173
|
+
try {
|
|
174
|
+
e = JSON.parse(r);
|
|
175
|
+
} catch (n) {
|
|
176
|
+
throw new f("Invalid JSON", [
|
|
177
|
+
{
|
|
178
|
+
key: "",
|
|
179
|
+
message: `JSON parse error: ${n instanceof Error ? n.message : String(n)}`
|
|
180
|
+
}
|
|
181
|
+
]);
|
|
182
|
+
}
|
|
183
|
+
return g(e), e;
|
|
184
|
+
}
|
|
185
|
+
function O(r) {
|
|
186
|
+
return g(r), r;
|
|
187
|
+
}
|
|
188
|
+
function T(r, e) {
|
|
189
|
+
const n = r[e];
|
|
190
|
+
if (!n)
|
|
191
|
+
throw new Error(`AIConfig key "${e}" not found`);
|
|
192
|
+
return n.value;
|
|
193
|
+
}
|
|
194
|
+
function U(r) {
|
|
195
|
+
if (!(typeof window > "u"))
|
|
196
|
+
try {
|
|
197
|
+
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
198
|
+
if (e)
|
|
199
|
+
try {
|
|
200
|
+
const n = {
|
|
201
|
+
command: "ai.initialize",
|
|
202
|
+
parameters: JSON.stringify(r)
|
|
203
|
+
};
|
|
204
|
+
e.postMessage(n);
|
|
205
|
+
} catch (n) {
|
|
206
|
+
console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", n);
|
|
207
|
+
}
|
|
208
|
+
if (window.parent && window.parent !== window)
|
|
209
|
+
try {
|
|
210
|
+
const n = {
|
|
211
|
+
type: "ai.initialize",
|
|
212
|
+
config: JSON.stringify(r)
|
|
213
|
+
};
|
|
214
|
+
window.parent.postMessage(n, "*");
|
|
215
|
+
} catch (n) {
|
|
216
|
+
console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", n);
|
|
217
|
+
}
|
|
218
|
+
} catch (e) {
|
|
219
|
+
console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function z(r) {
|
|
223
|
+
const e = O(r);
|
|
224
|
+
return U(e), new Proxy({}, {
|
|
225
|
+
get(n, t) {
|
|
226
|
+
if (typeof t == "string")
|
|
227
|
+
try {
|
|
228
|
+
return T(e, t);
|
|
229
|
+
} catch {
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
has(n, t) {
|
|
234
|
+
return typeof t != "string" ? !1 : t in e;
|
|
235
|
+
},
|
|
236
|
+
ownKeys(n) {
|
|
237
|
+
return Object.keys(e);
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
export {
|
|
242
|
+
f as A,
|
|
243
|
+
h as D,
|
|
244
|
+
S as U,
|
|
245
|
+
j as a,
|
|
246
|
+
F as b,
|
|
247
|
+
A as c,
|
|
248
|
+
b as d,
|
|
249
|
+
E as e,
|
|
250
|
+
k as f,
|
|
251
|
+
B as g,
|
|
252
|
+
J as h,
|
|
253
|
+
T as i,
|
|
254
|
+
z as j,
|
|
255
|
+
O as l,
|
|
256
|
+
x as m,
|
|
257
|
+
L as n,
|
|
258
|
+
P as p,
|
|
259
|
+
U as s,
|
|
260
|
+
g as v
|
|
261
|
+
};
|
package/dist/index/index.js
CHANGED
|
@@ -1,101 +1,116 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as
|
|
2
|
-
import { A as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { a as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import { h as
|
|
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 c, C as I, R as g, a as l, 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 { c as L, a as q, P as w, b as G, p as N, d as B } from "../pwa-8DGmPqLV.js";
|
|
7
|
+
import { a as V, b as j } from "../useTweaks-QxMRmg7i.js";
|
|
8
|
+
import { c as z, a as J, b as K, i as W, p as Y, u as X } from "../useAudioContext-CNQQSTab.js";
|
|
9
|
+
import { reportScore as $, sendEvent as ee, updateScore as re } from "../leaderboard/index.js";
|
|
10
|
+
import { A as se, D as oe, d as te, e as ne, c as ie, U as fe, f as pe, a as de, a as me, b as ue, j as Ce, i as Ae, l as ce, m as Ie, g as ge, n as le, h as Ue, p as Ee, s as Se, v as he } from "../helper-CRGxnlsu.js";
|
|
11
|
+
import { f as ye, q as Te, b as xe, h as Fe, l as _e, o as De, j as Re, n as Me, w as ke, g as Oe, k as ve, p as be, e as Le, i as qe, c as we, d as Ge, r as Ne, u as Be, m as He, s as Ve, a as je, t as Qe, v as ze } from "../bridge-D2d8hnO_.js";
|
|
12
|
+
import { i as Ke, f as We, h as Ye, g as Xe, a as Ze, u as $e, b as er, d as rr, c as ar, e as sr, j as or } from "../userSessionInfo-SbuNZ7JR.js";
|
|
13
|
+
import { hasNativeBridge as nr } from "../native-bridge-BnvipFJc.js";
|
|
13
14
|
export {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
se as AIConfigValidationError,
|
|
16
|
+
c as AippyRuntime,
|
|
17
|
+
p as AippyRuntimeError,
|
|
18
|
+
S as CameraAPI,
|
|
19
|
+
I as Cancellable,
|
|
20
|
+
oe as DEFAULT_BASE_URL,
|
|
21
|
+
te as DEFAULT_CHAT_MODEL,
|
|
22
|
+
ne as DEFAULT_CHAT_SYSTEM,
|
|
23
|
+
a as DEFAULT_CONFIG,
|
|
24
|
+
ie as DEFAULT_UI_BASE_URL,
|
|
23
25
|
d as ERROR_CODES,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
h as FileSystemAPI,
|
|
27
|
+
P as GeolocationAPI,
|
|
28
|
+
L as PWAUtils,
|
|
29
|
+
q as PerformanceMonitor,
|
|
30
|
+
w as PlatformDetector,
|
|
31
|
+
g as ReceiveChannel,
|
|
30
32
|
s as SDK_NAME,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
ie as UI_COMPLETION_ENDPOINT,
|
|
34
|
-
ne as UI_OBJECT_ENDPOINT,
|
|
33
|
+
y as SensorsAPI,
|
|
34
|
+
fe as UI_CHAT_ENDPOINT,
|
|
35
35
|
o as VERSION,
|
|
36
36
|
pe as abortedError,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ue as
|
|
40
|
-
fe as aippyObjectBaseConfig,
|
|
41
|
-
Ce as aippyObjectConfig,
|
|
37
|
+
de as aippy,
|
|
38
|
+
me as aippyAIProvider,
|
|
39
|
+
ue as aippyChatConfig,
|
|
42
40
|
l as aippyRuntime,
|
|
43
|
-
|
|
41
|
+
V as aippyTweaks,
|
|
44
42
|
j as aippyTweaksRuntime,
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
43
|
+
ye as autoRequestCredentials,
|
|
44
|
+
T as camera,
|
|
45
|
+
Te as clearCachedUserInfo,
|
|
46
|
+
Ke as clearProfileCache,
|
|
47
|
+
We as clearUserInfoCache,
|
|
48
|
+
Ce as createAIConfig,
|
|
49
|
+
m as createError,
|
|
50
|
+
z as createHiddenMediaElement,
|
|
51
|
+
J as createHiddenVideoElement,
|
|
52
|
+
Ye as fetchUserProfile,
|
|
53
|
+
x as fileSystem,
|
|
54
|
+
F as geolocation,
|
|
55
|
+
Ae as getAIConfigValue,
|
|
56
|
+
xe as getAuthToken,
|
|
57
|
+
Fe as getAuthTokenAsync,
|
|
58
|
+
_e as getCachedCredentials,
|
|
59
|
+
De as getCachedUserInfo,
|
|
57
60
|
t as getConfigFromEnv,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
61
|
+
Xe as getCurrentUserId,
|
|
62
|
+
Re as getCurrentUserIdAsync,
|
|
63
|
+
Me as getUserInfoAsync,
|
|
64
|
+
ke as getUserInfoFromParent,
|
|
65
|
+
Oe as getUserSdkConfig,
|
|
66
|
+
n as getVersionInfo,
|
|
67
|
+
ve as hasCredentials,
|
|
68
|
+
nr as hasNativeBridge,
|
|
69
|
+
be as hasUserInfo,
|
|
70
|
+
Le as initUserBridge,
|
|
71
|
+
qe as initUserSdk,
|
|
72
|
+
K as isIOSDevice,
|
|
73
|
+
we as isInIframe,
|
|
74
|
+
W as isMediaStreamAudioSupported,
|
|
69
75
|
_ as isMotionSupported,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
76
|
+
D as isOrientationSupported,
|
|
77
|
+
ce as loadAIConfig,
|
|
78
|
+
i as mergeConfig,
|
|
79
|
+
Ie as missingTokenError,
|
|
80
|
+
ge as networkError,
|
|
74
81
|
le as normalizeError,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
82
|
+
Ue as parseAIConfig,
|
|
83
|
+
Ee as parseError,
|
|
84
|
+
Y as patchAudioContext,
|
|
85
|
+
G as performanceMonitor,
|
|
86
|
+
N as platform,
|
|
87
|
+
U as processMotionData,
|
|
88
|
+
B as pwa,
|
|
89
|
+
$ as reportScore,
|
|
90
|
+
Ge as requestCredentialsFromParent,
|
|
91
|
+
Ne as requestCredentialsFromiOS,
|
|
92
|
+
R as requestMotionPermission,
|
|
93
|
+
Be as requestUserInfoFromParent,
|
|
94
|
+
He as requestUserInfoFromiOS,
|
|
95
|
+
Se as sendAIConfigToContainer,
|
|
96
|
+
ee as sendEvent,
|
|
97
|
+
C as sendMessageToContainer,
|
|
98
|
+
M as sensors,
|
|
99
|
+
Ve as setAuthToken,
|
|
100
|
+
je as setCurrentUserId,
|
|
101
|
+
Qe as tryGetCredentialsFromParentStorage,
|
|
102
|
+
ze as tryGetUserInfoFromParentStorage,
|
|
103
|
+
re as updateScore,
|
|
104
|
+
X as useAudioContext,
|
|
105
|
+
Ze as useAuthToken,
|
|
106
|
+
$e as useCurrentUserId,
|
|
107
|
+
er as useGetCurrentUserProfileQuery,
|
|
108
|
+
rr as useGetJoinedUserProfilesQuery,
|
|
109
|
+
ar as useGetUserProfileByIdQuery,
|
|
110
|
+
sr as useUserInfo,
|
|
111
|
+
or as userSessionInfo,
|
|
112
|
+
he as validateAIConfig,
|
|
113
|
+
k as vibrate,
|
|
114
|
+
O as watchMotion,
|
|
115
|
+
v as watchOrientation
|
|
101
116
|
};
|
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
|
*/
|
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';
|