@aippy/runtime 0.2.7-dev.3 → 0.2.7-dev.5

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.
@@ -1,430 +0,0 @@
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 = {
5
- apiBaseUrl: "https://api.aippy.dev/api",
6
- authToken: "",
7
- // 默认为空,由 iOS 桥接填充
8
- currentUserId: null,
9
- // 默认为空,由 iOS 桥接填充
10
- cacheTime: 300 * 1e3
11
- // 5 minutes
12
- };
13
- let p = { ...C };
14
- function j(r) {
15
- p = {
16
- ...C,
17
- ...r
18
- };
19
- }
20
- function Z() {
21
- return p;
22
- }
23
- function b(r) {
24
- p.authToken = r;
25
- }
26
- function q(r) {
27
- p.currentUserId = r;
28
- }
29
- function ee() {
30
- return p.authToken;
31
- }
32
- const c = {
33
- uid: "",
34
- token: "",
35
- apiBaseUrl: void 0
36
- }, m = 500;
37
- let f = !1, y = !1, d = null, u = null, U = !1, a = null, l = null;
38
- function g() {
39
- try {
40
- return typeof window < "u" && window.parent !== window;
41
- } catch {
42
- return !0;
43
- }
44
- }
45
- function T(r = m) {
46
- return new Promise((e) => {
47
- if (!g()) {
48
- console.log("ℹ️ [UserSDK Bridge] Not in iframe, skipping parent request"), e(c);
49
- return;
50
- }
51
- console.log("📤 [UserSDK Bridge] Requesting credentials from parent window");
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);
58
- e(t || c);
59
- }
60
- };
61
- window.addEventListener("message", o);
62
- try {
63
- window.parent.postMessage({
64
- type: "user-credentials-request",
65
- timestamp: Date.now()
66
- }, "*");
67
- } catch (s) {
68
- console.error("❌ [UserSDK Bridge] Failed to send request to parent:", s), clearTimeout(n), window.removeEventListener("message", o), e(c);
69
- }
70
- });
71
- }
72
- function P(r = m) {
73
- return new Promise((e) => {
74
- if (!g()) {
75
- console.log("ℹ️ [UserSDK Bridge] Not in iframe, skipping parent user info request"), e(null);
76
- return;
77
- }
78
- console.log("📤 [UserSDK Bridge] Requesting user info from parent window");
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);
85
- e(t);
86
- }
87
- };
88
- window.addEventListener("message", o);
89
- try {
90
- window.parent.postMessage({
91
- type: "user-info-request",
92
- timestamp: Date.now()
93
- }, "*");
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);
96
- }
97
- });
98
- }
99
- function A() {
100
- if (!g())
101
- return null;
102
- try {
103
- const r = window.parent.localStorage.getItem("token"), e = window.parent.localStorage.getItem("user");
104
- if (!r || !e)
105
- return console.log("ℹ️ [UserSDK Bridge] Parent localStorage credentials not found"), null;
106
- const n = JSON.parse(e), o = n.uid || n.userId || n.id || "";
107
- if (!o)
108
- return console.warn("⚠️ [UserSDK Bridge] Parent user data missing uid"), null;
109
- const s = {
110
- uid: String(o),
111
- token: r,
112
- apiBaseUrl: void 0
113
- };
114
- return q(s.uid), b(s.token), console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage:", s.uid), d = s, f = !0, s;
115
- } catch {
116
- return console.log("ℹ️ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
117
- }
118
- }
119
- function N() {
120
- if (!g())
121
- return null;
122
- try {
123
- const r = window.parent.localStorage.getItem("user");
124
- if (!r)
125
- return console.log("ℹ️ [UserSDK Bridge] Parent localStorage user not found"), null;
126
- const e = JSON.parse(r), n = e.uid || e.userId || e.id || "";
127
- if (!n)
128
- return console.warn("⚠️ [UserSDK Bridge] Parent user data missing uid"), null;
129
- const o = {
130
- uid: String(n),
131
- avatar: e.avatar || e.photoUrl || e.avatarUrl || "",
132
- nickName: e.nickName || e.nickname || e.displayName || "",
133
- username: e.username || e.userName || "",
134
- displayName: e.displayName || e.nickName || "",
135
- email: e.email || "",
136
- phone: e.phone || "",
137
- bio: e.bio || "",
138
- online: e.online || e.isOnline || !1
139
- };
140
- return console.log("✅ [UserSDK Bridge] Got user info from parent localStorage (fresh):", o.uid), o;
141
- } catch {
142
- return console.log("ℹ️ [UserSDK Bridge] Cannot access parent localStorage (cross-origin), will use postMessage"), null;
143
- }
144
- }
145
- function R(r = m) {
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);
150
- };
151
- })) : new Promise((e) => {
152
- y = !0;
153
- const n = window.webkit?.messageHandlers?.aippyListener;
154
- if (!n) {
155
- console.warn("⚠️ [UserSDK Bridge] Native bridge not available, returning empty credentials"), e(c);
156
- return;
157
- }
158
- const o = setTimeout(() => {
159
- console.warn(`⚠️ [UserSDK Bridge] Request timeout (${r}ms), returning empty credentials`), a = null, e(c);
160
- }, r);
161
- a = { resolve: e, reject: () => {
162
- } };
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);
166
- i ? a?.resolve(i) : a?.resolve(c), a = null;
167
- });
168
- try {
169
- const t = {
170
- command: "user.getCredentials",
171
- parameters: JSON.stringify({
172
- timestamp: Date.now(),
173
- endpoint: "user.credentials"
174
- // Tell iOS which endpoint to respond to
175
- })
176
- };
177
- console.log("📤 [UserSDK Bridge] Requesting credentials from iOS:", t), n.postMessage(t);
178
- } catch (t) {
179
- console.error("❌ [UserSDK Bridge] Failed to send request to iOS:", t), clearTimeout(o), s.cancel(), a = null, e(c);
180
- }
181
- });
182
- }
183
- function K(r) {
184
- if (!r || typeof r != "object")
185
- return console.warn("⚠️ [UserSDK Bridge] Invalid credentials data:", r), null;
186
- let e = r;
187
- if (e.credentials && typeof e.credentials == "object" && (console.log("📦 [UserSDK Bridge] Detected nested credentials format"), e = e.credentials), e.user && typeof e.user == "object" && e.token) {
188
- console.log("📦 [UserSDK Bridge] Detected parent window format");
189
- const i = e.user;
190
- e = {
191
- uid: i.uid || i.userId || i.id,
192
- token: e.token,
193
- apiBaseUrl: e.apiBaseUrl
194
- };
195
- }
196
- const n = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl || e.baseUrl;
197
- if (!n || !o)
198
- return console.warn("⚠️ [UserSDK Bridge] Missing uid or token in credentials:", r), null;
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;
201
- }
202
- function D(r) {
203
- console.log("📩 [UserSDK Bridge] processUserCredentials called with:", r);
204
- const e = K(r);
205
- e && a && (a.resolve(e), a = null);
206
- }
207
- function h(r) {
208
- if (!r || typeof r != "object")
209
- return console.warn("⚠️ [UserSDK Bridge] Invalid user info data:", r), null;
210
- let e = r;
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);
212
- const n = e.uid || e.userId || e.id || "";
213
- if (!n)
214
- return console.warn("⚠️ [UserSDK Bridge] Missing uid in user info:", r), null;
215
- const o = {
216
- uid: String(n),
217
- displayName: e.displayName,
218
- nickname: e.nickname,
219
- username: e.username,
220
- photoUrl: e.photoUrl,
221
- avatar: e.avatar,
222
- email: e.email,
223
- phone: e.phone,
224
- bio: e.bio,
225
- online: e.online,
226
- ...e
227
- };
228
- return console.log("✅ [UserSDK Bridge] Processed user info:", o.uid), u = o, U = !0, o;
229
- }
230
- function B(r) {
231
- console.log("📩 [UserSDK Bridge] processUserInfo called with:", r);
232
- const e = h(r);
233
- e && l && (l.resolve(e), l = null);
234
- }
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);
240
- };
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);
245
- return;
246
- }
247
- const s = setTimeout(() => {
248
- console.warn(`⚠️ [UserSDK Bridge] User info request timeout (${e}ms)`), l = null, n(null);
249
- }, e);
250
- l = { resolve: n, reject: () => {
251
- } };
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;
256
- });
257
- try {
258
- const i = {
259
- command: "user.getUserInfo",
260
- parameters: JSON.stringify({
261
- timestamp: Date.now(),
262
- endpoint: "user.info"
263
- // Tell iOS which endpoint to respond to
264
- })
265
- };
266
- console.log("📤 [UserSDK Bridge] Requesting user info from iOS:", i), o.postMessage(i);
267
- } catch (i) {
268
- console.error("❌ [UserSDK Bridge] Failed to send user info request to iOS:", i), clearTimeout(s), t.cancel(), l = null, n(null);
269
- }
270
- });
271
- }
272
- async function F(r = !1) {
273
- return U && u && !r ? u : k() ? await O(r) : u;
274
- }
275
- async function G(r = m) {
276
- if (!g())
277
- return console.log("ℹ️ [UserSDK Bridge] Not in iframe, cannot get user info from parent"), null;
278
- console.log("🔍 [UserSDK Bridge] Getting fresh user info from parent (no cache)");
279
- const e = N();
280
- if (e)
281
- return console.log("✅ [UserSDK Bridge] Got fresh user info from parent localStorage"), e;
282
- console.log("🔍 [UserSDK Bridge] Trying postMessage to parent for user info");
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);
285
- }
286
- function _() {
287
- return u;
288
- }
289
- function $() {
290
- return U;
291
- }
292
- function V() {
293
- u = null, U = !1, console.log("🧹 [UserSDK Bridge] Cleared cached user info");
294
- }
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");
298
- }), console.log("✅ [UserSDK Bridge] Bridge initialized"));
299
- }
300
- async function v() {
301
- if (f && d) {
302
- console.log("✅ [UserSDK Bridge] Already have cached credentials");
303
- return;
304
- }
305
- if (k()) {
306
- console.log("🔍 [UserSDK Bridge] Detected iOS environment, requesting from native");
307
- try {
308
- if (await R(), f) {
309
- console.log("✅ [UserSDK Bridge] Got credentials from iOS");
310
- return;
311
- }
312
- } catch (r) {
313
- console.warn("⚠️ [UserSDK Bridge] iOS request failed:", r);
314
- }
315
- }
316
- if (g()) {
317
- if (console.log("🔍 [UserSDK Bridge] Detected iframe environment"), A()) {
318
- console.log("✅ [UserSDK Bridge] Got credentials from parent localStorage");
319
- return;
320
- }
321
- console.log("🔍 [UserSDK Bridge] Trying postMessage to parent");
322
- try {
323
- const e = await T();
324
- if (e.uid && e.token) {
325
- console.log("✅ [UserSDK Bridge] Got credentials from parent postMessage");
326
- return;
327
- }
328
- } catch (e) {
329
- console.warn("⚠️ [UserSDK Bridge] Parent postMessage request failed:", e);
330
- }
331
- }
332
- console.log("ℹ️ [UserSDK Bridge] No credentials source available");
333
- }
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);
351
- }
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;
368
- }
369
- async function J() {
370
- return await v(), d?.uid || "";
371
- }
372
- function Y() {
373
- return f;
374
- }
375
- function z() {
376
- return d;
377
- }
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({
383
- __proto__: null,
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,
399
- requestCredentialsFromiOS: R,
400
- requestUserInfoFromParent: P,
401
- requestUserInfoFromiOS: O,
402
- tryGetCredentialsFromParentStorage: A,
403
- tryGetUserInfoFromParentStorage: N
404
- }, Symbol.toStringTag, { value: "Module" }));
405
- export {
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,
423
- R as r,
424
- b as s,
425
- A as t,
426
- P as u,
427
- N as v,
428
- G as w,
429
- re as x
430
- };
@@ -1,264 +0,0 @@
1
- import { createOpenAICompatible as l } from "@ai-sdk/openai-compatible";
2
- import "react";
3
- import { h as d } from "./bridge-N9ELFpfV.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}/aisdk/v1/`, A = `${m}/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("Aippy-Runtime-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 S(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: 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
55
- });
56
- }
57
- const C = "/chat";
58
- function F(r = {}) {
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();
60
- return {
61
- transport: new y({
62
- api: a,
63
- body: s,
64
- // Ensure token is fetched fresh for every request
65
- fetch: o
66
- })
67
- };
68
- }
69
- function L(r, e) {
70
- const n = r.status;
71
- if (e && typeof e == "object" && "error" in e) {
72
- const t = e, a = t.error.code, s = a != null ? `AippyAIError_${a}` : `AippyAIError_${n}`, o = e;
73
- return "appMessage" in o && o.appMessage !== void 0 ? u(o.appMessage) : "containerErrorData" in o && o.containerErrorData !== void 0 && u(o.containerErrorData), new i({
74
- name: s,
75
- message: t.error.message,
76
- cause: {
77
- type: t.error.type ?? void 0,
78
- param: t.error.param ?? void 0,
79
- status: n
80
- }
81
- });
82
- }
83
- if (e && typeof e == "object" && e !== null) {
84
- const t = e;
85
- "appMessage" in t && t.appMessage !== void 0 ? u(t.appMessage) : "containerErrorData" in t && t.containerErrorData !== void 0 && u(t.containerErrorData);
86
- }
87
- return new i({
88
- name: `AippyAIError_${n}`,
89
- message: `Request failed with status ${n}`,
90
- cause: { status: n }
91
- });
92
- }
93
- function x() {
94
- return new i({
95
- name: "AippyAIError_MISSING_TOKEN",
96
- message: "User token is required. Ensure user credentials are available via initUserBridge()."
97
- });
98
- }
99
- function k() {
100
- return new i({
101
- name: "AippyAIError_REQUEST_ABORTED",
102
- message: "Request was aborted"
103
- });
104
- }
105
- function B(r) {
106
- const e = r instanceof Error ? r.message : "Network request failed";
107
- return new i({
108
- name: "AippyAIError_NETWORK_ERROR",
109
- message: e,
110
- cause: r instanceof Error ? r : String(r)
111
- });
112
- }
113
- function P(r) {
114
- return new i({
115
- name: "AippyAIError_PARSE_ERROR",
116
- message: `Failed to parse response: ${r}`
117
- });
118
- }
119
- class f extends Error {
120
- constructor(e, n) {
121
- super(e), this.errors = n, this.name = "AIConfigValidationError";
122
- }
123
- }
124
- function g(r) {
125
- const e = [];
126
- if (!r || typeof r != "object")
127
- throw new f("AIConfig must be an object", []);
128
- const n = r;
129
- for (const [t, a] of Object.entries(n)) {
130
- if (!a || typeof a != "object") {
131
- e.push({ key: t, message: "Item must be an object" });
132
- continue;
133
- }
134
- const s = a;
135
- 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" });
136
- const o = s.type;
137
- if (!["number", "boolean", "text", "enum"].includes(o)) {
138
- e.push({
139
- key: t,
140
- message: `type must be one of: number, boolean, text, enum (got: ${o})`
141
- });
142
- continue;
143
- }
144
- if (o === "number")
145
- 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" });
146
- else if (o === "boolean")
147
- typeof s.value != "boolean" && e.push({ key: t, message: 'value must be a boolean for type "boolean"' });
148
- else if (o === "text")
149
- typeof s.value != "string" && e.push({ key: t, message: 'value must be a string for type "text"' });
150
- else if (o === "enum") {
151
- if (!Array.isArray(s.options))
152
- e.push({ key: t, message: 'options must be an array for type "enum"' });
153
- else if (s.options.length === 0)
154
- e.push({ key: t, message: 'options array cannot be empty for type "enum"' });
155
- else
156
- for (let p = 0; p < s.options.length; p++)
157
- typeof s.options[p] != "string" && e.push({
158
- key: t,
159
- message: `options[${p}] must be a string`
160
- });
161
- 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({
162
- key: t,
163
- message: `value "${s.value}" is not in options: [${s.options.join(", ")}]`
164
- });
165
- }
166
- s.group !== void 0 && typeof s.group != "string" && e.push({ key: t, message: "group must be a string" });
167
- }
168
- if (e.length > 0)
169
- throw new f(
170
- `AIConfig validation failed with ${e.length} error(s)`,
171
- e
172
- );
173
- }
174
- function J(r) {
175
- let e;
176
- try {
177
- e = JSON.parse(r);
178
- } catch (n) {
179
- throw new f("Invalid JSON", [
180
- {
181
- key: "",
182
- message: `JSON parse error: ${n instanceof Error ? n.message : String(n)}`
183
- }
184
- ]);
185
- }
186
- return g(e), e;
187
- }
188
- function O(r) {
189
- return g(r), r;
190
- }
191
- function T(r, e) {
192
- const n = r[e];
193
- if (!n)
194
- throw new Error(`AIConfig key "${e}" not found`);
195
- return n.value;
196
- }
197
- function U(r) {
198
- if (!(typeof window > "u"))
199
- try {
200
- const e = window.webkit?.messageHandlers?.aippyListener;
201
- if (e)
202
- try {
203
- const n = {
204
- command: "ai.initialize",
205
- parameters: JSON.stringify(r)
206
- };
207
- e.postMessage(n);
208
- } catch (n) {
209
- console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", n);
210
- }
211
- if (window.parent && window.parent !== window)
212
- try {
213
- const n = {
214
- type: "ai.initialize",
215
- config: JSON.stringify(r)
216
- };
217
- window.parent.postMessage(n, "*");
218
- } catch (n) {
219
- console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", n);
220
- }
221
- } catch (e) {
222
- console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
223
- }
224
- }
225
- function z(r) {
226
- const e = O(r);
227
- return U(e), new Proxy({}, {
228
- get(n, t) {
229
- if (typeof t == "string")
230
- try {
231
- return T(e, t);
232
- } catch {
233
- return;
234
- }
235
- },
236
- has(n, t) {
237
- return typeof t != "string" ? !1 : t in e;
238
- },
239
- ownKeys(n) {
240
- return Object.keys(e);
241
- }
242
- });
243
- }
244
- export {
245
- f as A,
246
- h as D,
247
- C as U,
248
- j as a,
249
- F as b,
250
- A as c,
251
- b as d,
252
- E as e,
253
- k as f,
254
- B as g,
255
- J as h,
256
- T as i,
257
- z as j,
258
- O as l,
259
- x as m,
260
- L as n,
261
- P as p,
262
- U as s,
263
- g as v
264
- };
@@ -1,9 +0,0 @@
1
- import { UserProfile } from './types';
2
- /**
3
- * Fetch user profile by ID from API
4
- */
5
- export declare function fetchUserProfile(userId: string): Promise<UserProfile | null>;
6
- /**
7
- * Clear profile cache
8
- */
9
- export declare function clearProfileCache(userId?: string): void;