@aippy/runtime 0.2.7-dev.1 → 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/index.js +2 -2
- package/dist/{bridge-D2d8hnO_.js → bridge-N9ELFpfV.js} +201 -166
- package/dist/core/index.js +1 -1
- package/dist/{helper-CRGxnlsu.js → helper-CsFko67T.js} +11 -8
- package/dist/index/index.js +86 -84
- package/dist/pwa-CilSlaik.js +249 -0
- package/dist/ui-D6IZ1jrR.js +119 -0
- package/dist/user/bridge.d.ts +1 -3
- package/dist/user/index.js +2 -2
- package/dist/{userSessionInfo-SbuNZ7JR.js → userSessionInfo-DFvsuELU.js} +2 -2
- 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 +1 -1
- package/dist/pwa-8DGmPqLV.js +0 -341
package/dist/ai/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { A as i, D as A, d as n, e, c as E, U as C, f as p, a as g, a as t, b as I, j as T, i as _, l as f, m as U, g as d, n as D, h as L, p as l, s as m, v as F } from "../helper-
|
|
1
|
+
import { A as i, D as A, d as n, e, c as E, U as C, f as p, a as g, a as t, b as I, j as T, i as _, l as f, m as U, g as d, n as D, h as L, p as l, s as m, v as F } from "../helper-CsFko67T.js";
|
|
2
2
|
import "react";
|
|
3
|
-
import "../bridge-
|
|
3
|
+
import "../bridge-N9ELFpfV.js";
|
|
4
4
|
export {
|
|
5
5
|
i as AIConfigValidationError,
|
|
6
6
|
A as DEFAULT_BASE_URL,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { hasNativeBridge as
|
|
3
|
-
|
|
1
|
+
import { a as I } from "./runtime-CmoG3v2m.js";
|
|
2
|
+
import { hasNativeBridge as k } from "./native-bridge-BnvipFJc.js";
|
|
3
|
+
import { p as M, s as w } from "./ui-D6IZ1jrR.js";
|
|
4
|
+
const C = {
|
|
4
5
|
apiBaseUrl: "https://api.aippy.dev/api",
|
|
5
6
|
authToken: "",
|
|
6
7
|
// 默认为空,由 iOS 桥接填充
|
|
@@ -9,124 +10,124 @@ const v = {
|
|
|
9
10
|
cacheTime: 300 * 1e3
|
|
10
11
|
// 5 minutes
|
|
11
12
|
};
|
|
12
|
-
let p = { ...
|
|
13
|
-
function
|
|
13
|
+
let p = { ...C };
|
|
14
|
+
function j(r) {
|
|
14
15
|
p = {
|
|
15
|
-
...
|
|
16
|
+
...C,
|
|
16
17
|
...r
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
|
-
function
|
|
20
|
+
function Z() {
|
|
20
21
|
return p;
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
+
function b(r) {
|
|
23
24
|
p.authToken = r;
|
|
24
25
|
}
|
|
25
|
-
function
|
|
26
|
+
function q(r) {
|
|
26
27
|
p.currentUserId = r;
|
|
27
28
|
}
|
|
28
|
-
function
|
|
29
|
+
function ee() {
|
|
29
30
|
return p.authToken;
|
|
30
31
|
}
|
|
31
32
|
const c = {
|
|
32
33
|
uid: "",
|
|
33
34
|
token: "",
|
|
34
35
|
apiBaseUrl: void 0
|
|
35
|
-
}, m =
|
|
36
|
-
let
|
|
37
|
-
function
|
|
36
|
+
}, m = 500;
|
|
37
|
+
let f = !1, y = !1, d = null, u = null, U = !1, a = null, l = null;
|
|
38
|
+
function g() {
|
|
38
39
|
try {
|
|
39
40
|
return typeof window < "u" && window.parent !== window;
|
|
40
41
|
} catch {
|
|
41
42
|
return !0;
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function T(r = m) {
|
|
45
46
|
return new Promise((e) => {
|
|
46
|
-
if (!
|
|
47
|
+
if (!g()) {
|
|
47
48
|
console.log("ℹ️ [UserSDK Bridge] Not in iframe, skipping parent request"), e(c);
|
|
48
49
|
return;
|
|
49
50
|
}
|
|
50
51
|
console.log("📤 [UserSDK Bridge] Requesting credentials from parent window");
|
|
51
|
-
const
|
|
52
|
-
console.warn(`⚠️ [UserSDK Bridge] Parent request timeout (${r}ms)`), window.removeEventListener("message",
|
|
53
|
-
}, r),
|
|
54
|
-
if (
|
|
55
|
-
console.log("📩 [UserSDK Bridge] Received credentials from parent:",
|
|
56
|
-
const t =
|
|
52
|
+
const n = setTimeout(() => {
|
|
53
|
+
console.warn(`⚠️ [UserSDK Bridge] Parent request timeout (${r}ms)`), window.removeEventListener("message", o), e(c);
|
|
54
|
+
}, r), o = (s) => {
|
|
55
|
+
if (s.data && s.data.type === "user-credentials-response") {
|
|
56
|
+
console.log("📩 [UserSDK Bridge] Received credentials from parent:", s.data), clearTimeout(n), window.removeEventListener("message", o);
|
|
57
|
+
const t = K(s.data);
|
|
57
58
|
e(t || c);
|
|
58
59
|
}
|
|
59
60
|
};
|
|
60
|
-
window.addEventListener("message",
|
|
61
|
+
window.addEventListener("message", o);
|
|
61
62
|
try {
|
|
62
63
|
window.parent.postMessage({
|
|
63
64
|
type: "user-credentials-request",
|
|
64
65
|
timestamp: Date.now()
|
|
65
66
|
}, "*");
|
|
66
|
-
} catch (
|
|
67
|
-
console.error("❌ [UserSDK Bridge] Failed to send request to parent:",
|
|
67
|
+
} catch (s) {
|
|
68
|
+
console.error("❌ [UserSDK Bridge] Failed to send request to parent:", s), clearTimeout(n), window.removeEventListener("message", o), e(c);
|
|
68
69
|
}
|
|
69
70
|
});
|
|
70
71
|
}
|
|
71
|
-
function
|
|
72
|
+
function P(r = m) {
|
|
72
73
|
return new Promise((e) => {
|
|
73
|
-
if (!
|
|
74
|
+
if (!g()) {
|
|
74
75
|
console.log("ℹ️ [UserSDK Bridge] Not in iframe, skipping parent user info request"), e(null);
|
|
75
76
|
return;
|
|
76
77
|
}
|
|
77
78
|
console.log("📤 [UserSDK Bridge] Requesting user info from parent window");
|
|
78
|
-
const
|
|
79
|
-
console.warn(`⚠️ [UserSDK Bridge] Parent user info request timeout (${r}ms)`), window.removeEventListener("message",
|
|
80
|
-
}, r),
|
|
81
|
-
if (
|
|
82
|
-
console.log("📩 [UserSDK Bridge] Received user info from parent:",
|
|
83
|
-
const t =
|
|
79
|
+
const n = setTimeout(() => {
|
|
80
|
+
console.warn(`⚠️ [UserSDK Bridge] Parent user info request timeout (${r}ms)`), window.removeEventListener("message", o), e(null);
|
|
81
|
+
}, r), o = (s) => {
|
|
82
|
+
if (s.data && s.data.type === "user-info-response") {
|
|
83
|
+
console.log("📩 [UserSDK Bridge] Received user info from parent:", s.data), clearTimeout(n), window.removeEventListener("message", o);
|
|
84
|
+
const t = h(s.data);
|
|
84
85
|
e(t);
|
|
85
86
|
}
|
|
86
87
|
};
|
|
87
|
-
window.addEventListener("message",
|
|
88
|
+
window.addEventListener("message", o);
|
|
88
89
|
try {
|
|
89
90
|
window.parent.postMessage({
|
|
90
91
|
type: "user-info-request",
|
|
91
92
|
timestamp: Date.now()
|
|
92
93
|
}, "*");
|
|
93
|
-
} catch (
|
|
94
|
-
console.error("❌ [UserSDK Bridge] Failed to send user info request to parent:",
|
|
94
|
+
} catch (s) {
|
|
95
|
+
console.error("❌ [UserSDK Bridge] Failed to send user info request to parent:", s), clearTimeout(n), window.removeEventListener("message", o), e(null);
|
|
95
96
|
}
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
|
-
function
|
|
99
|
-
if (!
|
|
99
|
+
function A() {
|
|
100
|
+
if (!g())
|
|
100
101
|
return null;
|
|
101
102
|
try {
|
|
102
103
|
const r = window.parent.localStorage.getItem("token"), e = window.parent.localStorage.getItem("user");
|
|
103
104
|
if (!r || !e)
|
|
104
105
|
return console.log("ℹ️ [UserSDK Bridge] Parent localStorage credentials not found"), null;
|
|
105
|
-
const
|
|
106
|
-
if (!
|
|
106
|
+
const n = JSON.parse(e), o = n.uid || n.userId || n.id || "";
|
|
107
|
+
if (!o)
|
|
107
108
|
return console.warn("⚠️ [UserSDK Bridge] Parent user data missing uid"), null;
|
|
108
|
-
const
|
|
109
|
-
uid: String(
|
|
109
|
+
const s = {
|
|
110
|
+
uid: String(o),
|
|
110
111
|
token: r,
|
|
111
112
|
apiBaseUrl: void 0
|
|
112
113
|
};
|
|
113
|
-
return
|
|
114
|
+
return q(s.uid), b(s.token), console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage:", s.uid), d = s, f = !0, s;
|
|
114
115
|
} catch {
|
|
115
116
|
return console.log("ℹ️ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
|
-
function
|
|
119
|
-
if (!
|
|
119
|
+
function N() {
|
|
120
|
+
if (!g())
|
|
120
121
|
return null;
|
|
121
122
|
try {
|
|
122
123
|
const r = window.parent.localStorage.getItem("user");
|
|
123
124
|
if (!r)
|
|
124
125
|
return console.log("ℹ️ [UserSDK Bridge] Parent localStorage user not found"), null;
|
|
125
|
-
const e = JSON.parse(r),
|
|
126
|
-
if (!
|
|
126
|
+
const e = JSON.parse(r), n = e.uid || e.userId || e.id || "";
|
|
127
|
+
if (!n)
|
|
127
128
|
return console.warn("⚠️ [UserSDK Bridge] Parent user data missing uid"), null;
|
|
128
|
-
const
|
|
129
|
-
uid: String(
|
|
129
|
+
const o = {
|
|
130
|
+
uid: String(n),
|
|
130
131
|
avatar: e.avatar || e.photoUrl || e.avatarUrl || "",
|
|
131
132
|
nickName: e.nickName || e.nickname || e.displayName || "",
|
|
132
133
|
username: e.username || e.userName || "",
|
|
@@ -136,32 +137,32 @@ function P() {
|
|
|
136
137
|
bio: e.bio || "",
|
|
137
138
|
online: e.online || e.isOnline || !1
|
|
138
139
|
};
|
|
139
|
-
return console.log("✅ [UserSDK Bridge] Got user info from parent localStorage (fresh):",
|
|
140
|
+
return console.log("✅ [UserSDK Bridge] Got user info from parent localStorage (fresh):", o.uid), o;
|
|
140
141
|
} catch {
|
|
141
142
|
return console.log("ℹ️ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
|
|
142
143
|
}
|
|
143
144
|
}
|
|
144
145
|
function R(r = m) {
|
|
145
|
-
return
|
|
146
|
-
const
|
|
147
|
-
a.resolve = (
|
|
148
|
-
|
|
146
|
+
return f && d ? (console.log("✅ [UserSDK Bridge] Returning cached credentials"), Promise.resolve(d)) : y && !f ? (console.log("ℹ️ [UserSDK Bridge] Previous request failed, returning empty credentials"), Promise.resolve(c)) : a ? (console.log("⏳ [UserSDK Bridge] Request already pending, waiting..."), new Promise((e) => {
|
|
147
|
+
const n = a.resolve;
|
|
148
|
+
a.resolve = (o) => {
|
|
149
|
+
n(o), e(o);
|
|
149
150
|
};
|
|
150
151
|
})) : new Promise((e) => {
|
|
151
152
|
y = !0;
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
153
|
+
const n = window.webkit?.messageHandlers?.aippyListener;
|
|
154
|
+
if (!n) {
|
|
154
155
|
console.warn("⚠️ [UserSDK Bridge] Native bridge not available, returning empty credentials"), e(c);
|
|
155
156
|
return;
|
|
156
157
|
}
|
|
157
|
-
const
|
|
158
|
+
const o = setTimeout(() => {
|
|
158
159
|
console.warn(`⚠️ [UserSDK Bridge] Request timeout (${r}ms), returning empty credentials`), a = null, e(c);
|
|
159
160
|
}, r);
|
|
160
161
|
a = { resolve: e, reject: () => {
|
|
161
162
|
} };
|
|
162
|
-
const
|
|
163
|
-
console.log("📩 [UserSDK Bridge] Received credentials via receiveChannel:", t), clearTimeout(
|
|
164
|
-
const i =
|
|
163
|
+
const s = I.receiveChannel.once("user.credentials", (t) => {
|
|
164
|
+
console.log("📩 [UserSDK Bridge] Received credentials via receiveChannel:", t), clearTimeout(o);
|
|
165
|
+
const i = K(t);
|
|
165
166
|
i ? a?.resolve(i) : a?.resolve(c), a = null;
|
|
166
167
|
});
|
|
167
168
|
try {
|
|
@@ -173,13 +174,13 @@ function R(r = m) {
|
|
|
173
174
|
// Tell iOS which endpoint to respond to
|
|
174
175
|
})
|
|
175
176
|
};
|
|
176
|
-
console.log("📤 [UserSDK Bridge] Requesting credentials from iOS:", t),
|
|
177
|
+
console.log("📤 [UserSDK Bridge] Requesting credentials from iOS:", t), n.postMessage(t);
|
|
177
178
|
} catch (t) {
|
|
178
|
-
console.error("❌ [UserSDK Bridge] Failed to send request to iOS:", t), clearTimeout(
|
|
179
|
+
console.error("❌ [UserSDK Bridge] Failed to send request to iOS:", t), clearTimeout(o), s.cancel(), a = null, e(c);
|
|
179
180
|
}
|
|
180
181
|
});
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
+
function K(r) {
|
|
183
184
|
if (!r || typeof r != "object")
|
|
184
185
|
return console.warn("⚠️ [UserSDK Bridge] Invalid credentials data:", r), null;
|
|
185
186
|
let e = r;
|
|
@@ -192,27 +193,27 @@ function B(r) {
|
|
|
192
193
|
apiBaseUrl: e.apiBaseUrl
|
|
193
194
|
};
|
|
194
195
|
}
|
|
195
|
-
const
|
|
196
|
-
if (!
|
|
196
|
+
const n = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl || e.baseUrl;
|
|
197
|
+
if (!n || !o)
|
|
197
198
|
return console.warn("⚠️ [UserSDK Bridge] Missing uid or token in credentials:", r), null;
|
|
198
|
-
const t = { uid: String(
|
|
199
|
-
return
|
|
199
|
+
const t = { uid: String(n), token: o, apiBaseUrl: s };
|
|
200
|
+
return q(t.uid), b(o), s && j({ apiBaseUrl: s }), console.log("✅ [UserSDK Bridge] Config updated with credentials:", t.uid), d = t, f = !0, t;
|
|
200
201
|
}
|
|
201
|
-
function
|
|
202
|
+
function D(r) {
|
|
202
203
|
console.log("📩 [UserSDK Bridge] processUserCredentials called with:", r);
|
|
203
|
-
const e =
|
|
204
|
+
const e = K(r);
|
|
204
205
|
e && a && (a.resolve(e), a = null);
|
|
205
206
|
}
|
|
206
|
-
function
|
|
207
|
+
function h(r) {
|
|
207
208
|
if (!r || typeof r != "object")
|
|
208
209
|
return console.warn("⚠️ [UserSDK Bridge] Invalid user info data:", r), null;
|
|
209
210
|
let e = r;
|
|
210
211
|
e.userInfo && typeof e.userInfo == "object" && (console.log("📦 [UserSDK Bridge] Detected nested userInfo format"), e = e.userInfo), e.user && typeof e.user == "object" && (console.log("📦 [UserSDK Bridge] Detected nested user format"), e = e.user);
|
|
211
|
-
const
|
|
212
|
-
if (!
|
|
212
|
+
const n = e.uid || e.userId || e.id || "";
|
|
213
|
+
if (!n)
|
|
213
214
|
return console.warn("⚠️ [UserSDK Bridge] Missing uid in user info:", r), null;
|
|
214
|
-
const
|
|
215
|
-
uid: String(
|
|
215
|
+
const o = {
|
|
216
|
+
uid: String(n),
|
|
216
217
|
displayName: e.displayName,
|
|
217
218
|
nickname: e.nickname,
|
|
218
219
|
username: e.username,
|
|
@@ -224,34 +225,34 @@ function K(r) {
|
|
|
224
225
|
online: e.online,
|
|
225
226
|
...e
|
|
226
227
|
};
|
|
227
|
-
return console.log("✅ [UserSDK Bridge] Processed user info:",
|
|
228
|
+
return console.log("✅ [UserSDK Bridge] Processed user info:", o.uid), u = o, U = !0, o;
|
|
228
229
|
}
|
|
229
|
-
function
|
|
230
|
+
function B(r) {
|
|
230
231
|
console.log("📩 [UserSDK Bridge] processUserInfo called with:", r);
|
|
231
|
-
const e =
|
|
232
|
+
const e = h(r);
|
|
232
233
|
e && l && (l.resolve(e), l = null);
|
|
233
234
|
}
|
|
234
|
-
function
|
|
235
|
-
return U && u && !r ? (console.log("✅ [UserSDK Bridge] Returning cached user info"), Promise.resolve(u)) : l ? (console.log("⏳ [UserSDK Bridge] User info request already pending, waiting..."), new Promise((
|
|
236
|
-
const
|
|
237
|
-
l.resolve = (
|
|
238
|
-
|
|
235
|
+
function O(r = !1, e = m) {
|
|
236
|
+
return U && u && !r ? (console.log("✅ [UserSDK Bridge] Returning cached user info"), Promise.resolve(u)) : l ? (console.log("⏳ [UserSDK Bridge] User info request already pending, waiting..."), new Promise((n) => {
|
|
237
|
+
const o = l.resolve;
|
|
238
|
+
l.resolve = (s) => {
|
|
239
|
+
o(s), n(s);
|
|
239
240
|
};
|
|
240
|
-
})) : new Promise((
|
|
241
|
-
const
|
|
242
|
-
if (!
|
|
243
|
-
console.warn("⚠️ [UserSDK Bridge] Native bridge not available, cannot get user info"),
|
|
241
|
+
})) : new Promise((n) => {
|
|
242
|
+
const o = window.webkit?.messageHandlers?.aippyListener;
|
|
243
|
+
if (!o) {
|
|
244
|
+
console.warn("⚠️ [UserSDK Bridge] Native bridge not available, cannot get user info"), n(null);
|
|
244
245
|
return;
|
|
245
246
|
}
|
|
246
|
-
const
|
|
247
|
-
console.warn(`⚠️ [UserSDK Bridge] User info request timeout (${e}ms)`), l = null,
|
|
247
|
+
const s = setTimeout(() => {
|
|
248
|
+
console.warn(`⚠️ [UserSDK Bridge] User info request timeout (${e}ms)`), l = null, n(null);
|
|
248
249
|
}, e);
|
|
249
|
-
l = { resolve:
|
|
250
|
+
l = { resolve: n, reject: () => {
|
|
250
251
|
} };
|
|
251
|
-
const t =
|
|
252
|
-
console.log("📩 [UserSDK Bridge] Received user info via receiveChannel:", i), clearTimeout(
|
|
253
|
-
const
|
|
254
|
-
l?.resolve(
|
|
252
|
+
const t = I.receiveChannel.once("user.info", (i) => {
|
|
253
|
+
console.log("📩 [UserSDK Bridge] Received user info via receiveChannel:", i), clearTimeout(s);
|
|
254
|
+
const S = h(i);
|
|
255
|
+
l?.resolve(S), l = null;
|
|
255
256
|
});
|
|
256
257
|
try {
|
|
257
258
|
const i = {
|
|
@@ -262,49 +263,49 @@ function N(r = !1, e = m) {
|
|
|
262
263
|
// Tell iOS which endpoint to respond to
|
|
263
264
|
})
|
|
264
265
|
};
|
|
265
|
-
console.log("📤 [UserSDK Bridge] Requesting user info from iOS:", i),
|
|
266
|
+
console.log("📤 [UserSDK Bridge] Requesting user info from iOS:", i), o.postMessage(i);
|
|
266
267
|
} catch (i) {
|
|
267
|
-
console.error("❌ [UserSDK Bridge] Failed to send user info request to iOS:", i), clearTimeout(
|
|
268
|
+
console.error("❌ [UserSDK Bridge] Failed to send user info request to iOS:", i), clearTimeout(s), t.cancel(), l = null, n(null);
|
|
268
269
|
}
|
|
269
270
|
});
|
|
270
271
|
}
|
|
271
|
-
async function
|
|
272
|
-
return U && u && !r ? u :
|
|
272
|
+
async function F(r = !1) {
|
|
273
|
+
return U && u && !r ? u : k() ? await O(r) : u;
|
|
273
274
|
}
|
|
274
|
-
async function
|
|
275
|
-
if (!
|
|
275
|
+
async function G(r = m) {
|
|
276
|
+
if (!g())
|
|
276
277
|
return console.log("ℹ️ [UserSDK Bridge] Not in iframe, cannot get user info from parent"), null;
|
|
277
278
|
console.log("🔍 [UserSDK Bridge] Getting fresh user info from parent (no cache)");
|
|
278
|
-
const e =
|
|
279
|
+
const e = N();
|
|
279
280
|
if (e)
|
|
280
281
|
return console.log("✅ [UserSDK Bridge] Got fresh user info from parent localStorage"), e;
|
|
281
282
|
console.log("🔍 [UserSDK Bridge] Trying postMessage to parent for user info");
|
|
282
|
-
const
|
|
283
|
-
return
|
|
283
|
+
const n = await P(r);
|
|
284
|
+
return n ? (console.log("✅ [UserSDK Bridge] Got fresh user info from parent postMessage"), n) : (console.log("⚠️ [UserSDK Bridge] Could not get user info from parent"), null);
|
|
284
285
|
}
|
|
285
|
-
function
|
|
286
|
+
function _() {
|
|
286
287
|
return u;
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
+
function $() {
|
|
289
290
|
return U;
|
|
290
291
|
}
|
|
291
|
-
function
|
|
292
|
+
function V() {
|
|
292
293
|
u = null, U = !1, console.log("🧹 [UserSDK Bridge] Cleared cached user info");
|
|
293
294
|
}
|
|
294
|
-
function
|
|
295
|
-
typeof window > "u" || (window.processUserCredentials =
|
|
296
|
-
r.data && r.data.type === "user-credentials" && (console.log("📩 [UserSDK Bridge] Received credentials via postMessage:", r.data),
|
|
295
|
+
function E() {
|
|
296
|
+
typeof window > "u" || (window.processUserCredentials = D, window.processUserInfo = B, window.addEventListener("message", (r) => {
|
|
297
|
+
r.data && r.data.type === "user-credentials" && (console.log("📩 [UserSDK Bridge] Received credentials via postMessage:", r.data), D(r.data)), r.data && r.data.type === "user-info" && (console.log("📩 [UserSDK Bridge] Received user info via postMessage:", r.data), B(r.data)), r.data && r.data.type === "user-info-response" && console.log("📩 [UserSDK Bridge] Received user info response from parent");
|
|
297
298
|
}), console.log("✅ [UserSDK Bridge] Bridge initialized"));
|
|
298
299
|
}
|
|
299
|
-
async function
|
|
300
|
-
if (
|
|
300
|
+
async function v() {
|
|
301
|
+
if (f && d) {
|
|
301
302
|
console.log("✅ [UserSDK Bridge] Already have cached credentials");
|
|
302
303
|
return;
|
|
303
304
|
}
|
|
304
|
-
if (
|
|
305
|
+
if (k()) {
|
|
305
306
|
console.log("🔍 [UserSDK Bridge] Detected iOS environment, requesting from native");
|
|
306
307
|
try {
|
|
307
|
-
if (await R(),
|
|
308
|
+
if (await R(), f) {
|
|
308
309
|
console.log("✅ [UserSDK Bridge] Got credentials from iOS");
|
|
309
310
|
return;
|
|
310
311
|
}
|
|
@@ -312,14 +313,14 @@ async function S() {
|
|
|
312
313
|
console.warn("⚠️ [UserSDK Bridge] iOS request failed:", r);
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
|
-
if (
|
|
316
|
-
if (console.log("🔍 [UserSDK Bridge] Detected iframe environment"),
|
|
316
|
+
if (g()) {
|
|
317
|
+
if (console.log("🔍 [UserSDK Bridge] Detected iframe environment"), A()) {
|
|
317
318
|
console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage");
|
|
318
319
|
return;
|
|
319
320
|
}
|
|
320
321
|
console.log("🔍 [UserSDK Bridge] Trying postMessage to parent");
|
|
321
322
|
try {
|
|
322
|
-
const e = await
|
|
323
|
+
const e = await T();
|
|
323
324
|
if (e.uid && e.token) {
|
|
324
325
|
console.log("✅ [UserSDK Bridge] Got credentials from parent postMessage");
|
|
325
326
|
return;
|
|
@@ -330,66 +331,100 @@ async function S() {
|
|
|
330
331
|
}
|
|
331
332
|
console.log("ℹ️ [UserSDK Bridge] No credentials source available");
|
|
332
333
|
}
|
|
333
|
-
|
|
334
|
-
|
|
334
|
+
function x(r, e) {
|
|
335
|
+
const n = r.split(".").map(Number), o = e.split(".").map(Number), s = Math.max(n.length, o.length);
|
|
336
|
+
for (let t = 0; t < s; t++) {
|
|
337
|
+
const i = n[t] || 0, S = o[t] || 0;
|
|
338
|
+
if (i < S) return -1;
|
|
339
|
+
if (i > S) return 1;
|
|
340
|
+
}
|
|
341
|
+
return 0;
|
|
342
|
+
}
|
|
343
|
+
function H(r) {
|
|
344
|
+
if (!r)
|
|
345
|
+
return !1;
|
|
346
|
+
const n = {
|
|
347
|
+
iOS: "1.6.6",
|
|
348
|
+
Android: "1.1.8"
|
|
349
|
+
}[r.platform];
|
|
350
|
+
return n ? x(r.version, n) >= 0 : (console.warn("⚠️ [UserSDK Bridge] Unknown platform:", r.platform), !1);
|
|
335
351
|
}
|
|
336
|
-
async function
|
|
337
|
-
|
|
352
|
+
async function L() {
|
|
353
|
+
console.log("📱 [UserSDK Bridge] Navigator UserAgent:", navigator.userAgent);
|
|
354
|
+
const r = M.parseAippyInfo();
|
|
355
|
+
if (r) {
|
|
356
|
+
if (console.log(`📱 [UserSDK Bridge] Aippy App - Platform: ${r.platform}, Version: ${r.version}`), w("Your app version is outdated. Please upgrade to the latest version."), !H(r)) {
|
|
357
|
+
const n = { iOS: "1.6.6", Android: "1.1.8" };
|
|
358
|
+
throw console.error(`❌ [UserSDK Bridge] App version ${r.version} < ${n[r.platform]}`), w("Your app version is outdated. Please upgrade to the latest version."), new Error("App version too old");
|
|
359
|
+
}
|
|
360
|
+
console.log("✅ [UserSDK Bridge] App version OK");
|
|
361
|
+
} else if (!g())
|
|
362
|
+
throw console.error("❌ [UserSDK Bridge] Native bridge exists but no Aippy info (old version)"), w("Your app version is outdated. Please upgrade to the latest version."), new Error("App version too old");
|
|
363
|
+
await v();
|
|
364
|
+
const e = d?.token || "";
|
|
365
|
+
if (!e)
|
|
366
|
+
throw w("Please log in to use this feature."), new Error("Token unavailable: User needs to login");
|
|
367
|
+
return e;
|
|
338
368
|
}
|
|
339
|
-
function J() {
|
|
340
|
-
return
|
|
369
|
+
async function J() {
|
|
370
|
+
return await v(), d?.uid || "";
|
|
341
371
|
}
|
|
342
|
-
function
|
|
372
|
+
function Y() {
|
|
373
|
+
return f;
|
|
374
|
+
}
|
|
375
|
+
function z() {
|
|
343
376
|
return d;
|
|
344
377
|
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
378
|
+
E();
|
|
379
|
+
L().catch((r) => {
|
|
380
|
+
console.warn("[UserSDK] Auth check on load:", r.message);
|
|
381
|
+
});
|
|
382
|
+
const re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
348
383
|
__proto__: null,
|
|
349
|
-
autoRequestCredentials:
|
|
350
|
-
clearCachedUserInfo:
|
|
351
|
-
getAuthTokenAsync:
|
|
352
|
-
getCachedCredentials:
|
|
353
|
-
getCachedUserInfo:
|
|
354
|
-
getCurrentUserIdAsync:
|
|
355
|
-
getUserInfoAsync:
|
|
356
|
-
getUserInfoFromParent:
|
|
357
|
-
hasCredentials:
|
|
358
|
-
hasUserInfo:
|
|
359
|
-
initUserBridge:
|
|
360
|
-
isInIframe:
|
|
361
|
-
processUserCredentials:
|
|
362
|
-
processUserInfo:
|
|
363
|
-
requestCredentialsFromParent:
|
|
384
|
+
autoRequestCredentials: v,
|
|
385
|
+
clearCachedUserInfo: V,
|
|
386
|
+
getAuthTokenAsync: L,
|
|
387
|
+
getCachedCredentials: z,
|
|
388
|
+
getCachedUserInfo: _,
|
|
389
|
+
getCurrentUserIdAsync: J,
|
|
390
|
+
getUserInfoAsync: F,
|
|
391
|
+
getUserInfoFromParent: G,
|
|
392
|
+
hasCredentials: Y,
|
|
393
|
+
hasUserInfo: $,
|
|
394
|
+
initUserBridge: E,
|
|
395
|
+
isInIframe: g,
|
|
396
|
+
processUserCredentials: D,
|
|
397
|
+
processUserInfo: B,
|
|
398
|
+
requestCredentialsFromParent: T,
|
|
364
399
|
requestCredentialsFromiOS: R,
|
|
365
|
-
requestUserInfoFromParent:
|
|
366
|
-
requestUserInfoFromiOS:
|
|
367
|
-
tryGetCredentialsFromParentStorage:
|
|
368
|
-
tryGetUserInfoFromParentStorage:
|
|
400
|
+
requestUserInfoFromParent: P,
|
|
401
|
+
requestUserInfoFromiOS: O,
|
|
402
|
+
tryGetCredentialsFromParentStorage: A,
|
|
403
|
+
tryGetUserInfoFromParentStorage: N
|
|
369
404
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
370
405
|
export {
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
406
|
+
q as a,
|
|
407
|
+
ee as b,
|
|
408
|
+
g as c,
|
|
409
|
+
T as d,
|
|
410
|
+
E as e,
|
|
411
|
+
v as f,
|
|
412
|
+
Z as g,
|
|
413
|
+
L as h,
|
|
414
|
+
j as i,
|
|
415
|
+
J as j,
|
|
416
|
+
Y as k,
|
|
417
|
+
z as l,
|
|
418
|
+
O as m,
|
|
419
|
+
F as n,
|
|
420
|
+
_ as o,
|
|
421
|
+
$ as p,
|
|
422
|
+
V as q,
|
|
388
423
|
R as r,
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
424
|
+
b as s,
|
|
425
|
+
A as t,
|
|
426
|
+
P as u,
|
|
427
|
+
N as v,
|
|
428
|
+
G as w,
|
|
429
|
+
re as x
|
|
395
430
|
};
|
package/dist/core/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createOpenAICompatible as l } from "@ai-sdk/openai-compatible";
|
|
2
2
|
import "react";
|
|
3
|
-
import { h as d } from "./bridge-
|
|
3
|
+
import { h as d } from "./bridge-N9ELFpfV.js";
|
|
4
4
|
import { DefaultChatTransport as y, AISDKError as i } from "ai";
|
|
5
5
|
import { s as u } from "./container-message-DGrno17o.js";
|
|
6
|
-
const m = "https://api.aippy.dev", h = `${m}/
|
|
6
|
+
const m = "https://api.aippy.dev", h = `${m}/aisdk/v1/`, A = `${m}/aisdk/v1/ui/`, b = "gpt-5-nano", E = "";
|
|
7
7
|
function w(r = {}) {
|
|
8
8
|
return {
|
|
9
9
|
baseUrl: r.baseUrl ?? h
|
|
@@ -29,7 +29,7 @@ const _ = [
|
|
|
29
29
|
"gpt-image-1-mini",
|
|
30
30
|
"gpt-image-1.5"
|
|
31
31
|
];
|
|
32
|
-
function
|
|
32
|
+
function S(r) {
|
|
33
33
|
try {
|
|
34
34
|
const e = JSON.parse(r);
|
|
35
35
|
if (e.model && _.some((n) => e.model.startsWith(n))) {
|
|
@@ -47,13 +47,16 @@ function j(r = {}) {
|
|
|
47
47
|
baseURL: e,
|
|
48
48
|
fetch: async (a, s) => a.toString().includes("/images/generations") && s?.method?.toUpperCase() === "POST" && s?.body ? n(a, {
|
|
49
49
|
...s,
|
|
50
|
-
body:
|
|
51
|
-
}) : n(a, s)
|
|
50
|
+
body: S(s.body)
|
|
51
|
+
}) : n(a, s),
|
|
52
|
+
// Enable structured outputs support (json_schema response format)
|
|
53
|
+
// This is required for Output.object() and Output.array() to work properly
|
|
54
|
+
supportsStructuredOutputs: !0
|
|
52
55
|
});
|
|
53
56
|
}
|
|
54
|
-
const
|
|
57
|
+
const C = "/chat";
|
|
55
58
|
function F(r = {}) {
|
|
56
|
-
const { baseUrl: e } = I(r), n = r.model ?? b, t = r.system ?? E, a = r.api ?? v(e,
|
|
59
|
+
const { baseUrl: e } = I(r), n = r.model ?? b, t = r.system ?? E, a = r.api ?? v(e, C), s = { model: n, system: t }, o = c();
|
|
57
60
|
return {
|
|
58
61
|
transport: new y({
|
|
59
62
|
api: a,
|
|
@@ -241,7 +244,7 @@ function z(r) {
|
|
|
241
244
|
export {
|
|
242
245
|
f as A,
|
|
243
246
|
h as D,
|
|
244
|
-
|
|
247
|
+
C as U,
|
|
245
248
|
j as a,
|
|
246
249
|
F as b,
|
|
247
250
|
A as c,
|