@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 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-CRGxnlsu.js";
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-D2d8hnO_.js";
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 h } from "./runtime-CmoG3v2m.js";
2
- import { hasNativeBridge as I } from "./native-bridge-BnvipFJc.js";
3
- const v = {
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 = { ...v };
13
- function M(r) {
13
+ let p = { ...C };
14
+ function j(r) {
14
15
  p = {
15
- ...v,
16
+ ...C,
16
17
  ...r
17
18
  };
18
19
  }
19
- function Y() {
20
+ function Z() {
20
21
  return p;
21
22
  }
22
- function k(r) {
23
+ function b(r) {
23
24
  p.authToken = r;
24
25
  }
25
- function C(r) {
26
+ function q(r) {
26
27
  p.currentUserId = r;
27
28
  }
28
- function Q() {
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 = 5e3;
36
- let g = !1, y = !1, d = null, u = null, U = !1, a = null, l = null;
37
- function f() {
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 q(r = m) {
45
+ function T(r = m) {
45
46
  return new Promise((e) => {
46
- if (!f()) {
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 s = setTimeout(() => {
52
- console.warn(`⚠️ [UserSDK Bridge] Parent request timeout (${r}ms)`), window.removeEventListener("message", n), e(c);
53
- }, r), n = (o) => {
54
- if (o.data && o.data.type === "user-credentials-response") {
55
- console.log("📩 [UserSDK Bridge] Received credentials from parent:", o.data), clearTimeout(s), window.removeEventListener("message", n);
56
- const t = B(o.data);
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", n);
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 (o) {
67
- console.error("❌ [UserSDK Bridge] Failed to send request to parent:", o), clearTimeout(s), window.removeEventListener("message", n), e(c);
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 T(r = m) {
72
+ function P(r = m) {
72
73
  return new Promise((e) => {
73
- if (!f()) {
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 s = setTimeout(() => {
79
- console.warn(`⚠️ [UserSDK Bridge] Parent user info request timeout (${r}ms)`), window.removeEventListener("message", n), e(null);
80
- }, r), n = (o) => {
81
- if (o.data && o.data.type === "user-info-response") {
82
- console.log("📩 [UserSDK Bridge] Received user info from parent:", o.data), clearTimeout(s), window.removeEventListener("message", n);
83
- const t = K(o.data);
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", n);
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 (o) {
94
- console.error("❌ [UserSDK Bridge] Failed to send user info request to parent:", o), clearTimeout(s), window.removeEventListener("message", n), e(null);
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 b() {
99
- if (!f())
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 s = JSON.parse(e), n = s.uid || s.userId || s.id || "";
106
- if (!n)
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 o = {
109
- uid: String(n),
109
+ const s = {
110
+ uid: String(o),
110
111
  token: r,
111
112
  apiBaseUrl: void 0
112
113
  };
113
- return C(o.uid), k(o.token), console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage:", o.uid), d = o, g = !0, o;
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 P() {
119
- if (!f())
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), s = e.uid || e.userId || e.id || "";
126
- if (!s)
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 n = {
129
- uid: String(s),
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):", n.uid), n;
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 g && d ? (console.log("✅ [UserSDK Bridge] Returning cached credentials"), Promise.resolve(d)) : y && !g ? (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) => {
146
- const s = a.resolve;
147
- a.resolve = (n) => {
148
- s(n), e(n);
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 s = window.webkit?.messageHandlers?.aippyListener;
153
- if (!s) {
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 n = setTimeout(() => {
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 o = h.receiveChannel.once("user.credentials", (t) => {
163
- console.log("📩 [UserSDK Bridge] Received credentials via receiveChannel:", t), clearTimeout(n);
164
- const i = B(t);
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), s.postMessage(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(n), o.cancel(), a = null, e(c);
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 B(r) {
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 s = e.uid || e.userId || e.id || "", n = e.token || e.authToken || "", o = e.apiBaseUrl || e.baseUrl;
196
- if (!s || !n)
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(s), token: n, apiBaseUrl: o };
199
- return C(t.uid), k(n), o && M({ apiBaseUrl: o }), console.log("✅ [UserSDK Bridge] Config updated with credentials:", t.uid), d = t, g = !0, t;
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 w(r) {
202
+ function D(r) {
202
203
  console.log("📩 [UserSDK Bridge] processUserCredentials called with:", r);
203
- const e = B(r);
204
+ const e = K(r);
204
205
  e && a && (a.resolve(e), a = null);
205
206
  }
206
- function K(r) {
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 s = e.uid || e.userId || e.id || "";
212
- if (!s)
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 n = {
215
- uid: String(s),
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:", n.uid), u = n, U = !0, n;
228
+ return console.log("✅ [UserSDK Bridge] Processed user info:", o.uid), u = o, U = !0, o;
228
229
  }
229
- function D(r) {
230
+ function B(r) {
230
231
  console.log("📩 [UserSDK Bridge] processUserInfo called with:", r);
231
- const e = K(r);
232
+ const e = h(r);
232
233
  e && l && (l.resolve(e), l = null);
233
234
  }
234
- function N(r = !1, e = m) {
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((s) => {
236
- const n = l.resolve;
237
- l.resolve = (o) => {
238
- n(o), s(o);
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((s) => {
241
- const n = window.webkit?.messageHandlers?.aippyListener;
242
- if (!n) {
243
- console.warn("⚠️ [UserSDK Bridge] Native bridge not available, cannot get user info"), s(null);
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 o = setTimeout(() => {
247
- console.warn(`⚠️ [UserSDK Bridge] User info request timeout (${e}ms)`), l = null, s(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: s, reject: () => {
250
+ l = { resolve: n, reject: () => {
250
251
  } };
251
- const t = h.receiveChannel.once("user.info", (i) => {
252
- console.log("📩 [UserSDK Bridge] Received user info via receiveChannel:", i), clearTimeout(o);
253
- const L = K(i);
254
- l?.resolve(L), l = null;
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), n.postMessage(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(o), t.cancel(), l = null, s(null);
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 E(r = !1) {
272
- return U && u && !r ? u : I() ? await N(r) : u;
272
+ async function F(r = !1) {
273
+ return U && u && !r ? u : k() ? await O(r) : u;
273
274
  }
274
- async function j(r = m) {
275
- if (!f())
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 = P();
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 s = await T(r);
283
- return s ? (console.log("✅ [UserSDK Bridge] Got fresh user info from parent postMessage"), s) : (console.log("⚠️ [UserSDK Bridge] Could not get user info from parent"), null);
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 F() {
286
+ function _() {
286
287
  return u;
287
288
  }
288
- function A() {
289
+ function $() {
289
290
  return U;
290
291
  }
291
- function G() {
292
+ function V() {
292
293
  u = null, U = !1, console.log("🧹 [UserSDK Bridge] Cleared cached user info");
293
294
  }
294
- function O() {
295
- typeof window > "u" || (window.processUserCredentials = w, window.processUserInfo = D, window.addEventListener("message", (r) => {
296
- r.data && r.data.type === "user-credentials" && (console.log("📩 [UserSDK Bridge] Received credentials via postMessage:", r.data), w(r.data)), r.data && r.data.type === "user-info" && (console.log("📩 [UserSDK Bridge] Received user info via postMessage:", r.data), D(r.data)), r.data && r.data.type === "user-info-response" && console.log("📩 [UserSDK Bridge] Received user info response from parent");
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 S() {
300
- if (g && d) {
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 (I()) {
305
+ if (k()) {
305
306
  console.log("🔍 [UserSDK Bridge] Detected iOS environment, requesting from native");
306
307
  try {
307
- if (await R(), g) {
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 (f()) {
316
- if (console.log("🔍 [UserSDK Bridge] Detected iframe environment"), b()) {
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 q();
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
- async function _() {
334
- return await S(), d?.token || "";
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 H() {
337
- return await S(), d?.uid || "";
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 g;
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
- O();
346
- S();
347
- const V = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
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: S,
350
- clearCachedUserInfo: G,
351
- getAuthTokenAsync: _,
352
- getCachedCredentials: $,
353
- getCachedUserInfo: F,
354
- getCurrentUserIdAsync: H,
355
- getUserInfoAsync: E,
356
- getUserInfoFromParent: j,
357
- hasCredentials: J,
358
- hasUserInfo: A,
359
- initUserBridge: O,
360
- isInIframe: f,
361
- processUserCredentials: w,
362
- processUserInfo: D,
363
- requestCredentialsFromParent: q,
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: T,
366
- requestUserInfoFromiOS: N,
367
- tryGetCredentialsFromParentStorage: b,
368
- tryGetUserInfoFromParentStorage: P
400
+ requestUserInfoFromParent: P,
401
+ requestUserInfoFromiOS: O,
402
+ tryGetCredentialsFromParentStorage: A,
403
+ tryGetUserInfoFromParentStorage: N
369
404
  }, Symbol.toStringTag, { value: "Module" }));
370
405
  export {
371
- C as a,
372
- Q as b,
373
- f as c,
374
- q as d,
375
- O as e,
376
- S as f,
377
- Y as g,
378
- _ as h,
379
- M as i,
380
- H as j,
381
- J as k,
382
- $ as l,
383
- N as m,
384
- E as n,
385
- F as o,
386
- A as p,
387
- G as q,
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
- k as s,
390
- b as t,
391
- T as u,
392
- P as v,
393
- j as w,
394
- V as x
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
  };
@@ -24,7 +24,7 @@ function p(e) {
24
24
  }
25
25
  };
26
26
  }
27
- const r = "0.2.7-dev.1", a = {
27
+ const r = "0.2.7-dev.2", a = {
28
28
  version: r
29
29
  }, t = a.version, i = "@aippy/runtime";
30
30
  function c() {
@@ -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-D2d8hnO_.js";
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}/api/aisdk/v1/`, A = `${m}/api/aisdk/v1/ui/`, b = "gpt-5-nano", E = "";
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 C(r) {
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: C(s.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 S = "/chat";
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, S), s = { model: n, system: t }, o = c();
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
- S as U,
247
+ C as U,
245
248
  j as a,
246
249
  F as b,
247
250
  A as c,