@aippy/runtime 0.4.1 → 0.4.2-beta.0
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/README.md +35 -6
- package/dist/ai/errors.d.ts +1 -0
- package/dist/ai/index.d.ts +2 -0
- package/dist/ai/index.js +22 -17
- package/dist/ai/viggle/generate.d.ts +67 -0
- package/dist/ai/viggle/models.d.ts +46 -0
- package/dist/ai/viggle/recovery.d.ts +12 -0
- package/dist/{app-version-checker-Bz7FrEZz.js → app-version-checker-YVIFbytA.js} +18 -17
- package/dist/bridge-K3HqQwdj.js +311 -0
- package/dist/container-message-gRiGPin4.js +56 -0
- package/dist/core/env.d.ts +2 -0
- package/dist/core/index.js +2 -2
- package/dist/core/parent-message.d.ts +5 -0
- package/dist/core/wallet-recharge.d.ts +16 -0
- package/dist/helper-CJ3YV3nf.js +748 -0
- package/dist/{hooks-D5lkty5r.js → hooks-CMKwSLcQ.js} +1 -1
- package/dist/index/index.js +65 -55
- package/dist/index.d.ts +1 -0
- package/dist/ministore/app-authorization.d.ts +9 -0
- package/dist/ministore/authorization.d.ts +6 -0
- package/dist/ministore/consume.d.ts +3 -0
- package/dist/ministore/errors.d.ts +18 -0
- package/dist/ministore/index.d.ts +19 -0
- package/dist/ministore/index.js +99 -0
- package/dist/ministore/order.d.ts +1 -0
- package/dist/ministore/purchase.d.ts +5 -0
- package/dist/ministore/queries.d.ts +14 -0
- package/dist/ministore/recharge.d.ts +12 -0
- package/dist/ministore/transport.d.ts +14 -0
- package/dist/ministore/types.d.ts +177 -0
- package/dist/ministore/update-item.d.ts +3 -0
- package/dist/ministore/validation.d.ts +19 -0
- package/dist/ministore.d.ts +2 -0
- package/dist/recharge-o5P-y8eV.js +1036 -0
- package/dist/user/bridge.d.ts +3 -8
- package/dist/user/config.d.ts +2 -0
- package/dist/user/index.js +3 -3
- package/dist/utils/app-version-requirements.json.d.ts +4 -0
- package/dist/utils/index.js +1 -1
- package/package.json +5 -1
- package/dist/bridge-CtB9L5kL.js +0 -259
- package/dist/container-message-C3YXyTZj.js +0 -56
- package/dist/helper-WRpB-6MD.js +0 -241
package/dist/user/bridge.d.ts
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* User SDK Bridge
|
|
3
|
-
*/
|
|
4
1
|
export { isInIframe } from '../utils/platform';
|
|
5
2
|
export interface IOSUserCredentials {
|
|
6
3
|
uid: string;
|
|
@@ -17,13 +14,11 @@ export interface IOSUserInfo {
|
|
|
17
14
|
avatar?: string;
|
|
18
15
|
[key: string]: unknown;
|
|
19
16
|
}
|
|
20
|
-
/** Get auth token
|
|
17
|
+
/** Get a fresh auth token; native/iframe failures retain sign-in/upgrade UX. */
|
|
21
18
|
export declare function getAuthTokenAsync(): Promise<string>;
|
|
22
|
-
/** Get user info async, auto-detects environment */
|
|
23
19
|
export declare function getUserInfoAsync(forceRefresh?: boolean): Promise<IOSUserInfo | null>;
|
|
24
|
-
/** Get user info from parent window (iframe only, no cache) */
|
|
25
20
|
export declare function getUserInfoFromParent(timeoutMs?: number): Promise<IOSUserInfo | null>;
|
|
26
|
-
/** Called by iOS/Android: window.processUserCredentials(data) */
|
|
21
|
+
/** Called by iOS/Android: window.processUserCredentials(data). */
|
|
27
22
|
export declare function processUserCredentials(data: unknown): void;
|
|
28
|
-
/** Called by iOS/Android: window.processUserInfo(data) */
|
|
23
|
+
/** Called by iOS/Android: window.processUserInfo(data). */
|
|
29
24
|
export declare function processUserInfo(data: unknown): void;
|
package/dist/user/config.d.ts
CHANGED
|
@@ -9,4 +9,6 @@ interface UserSdkConfig {
|
|
|
9
9
|
export declare function initUserSdk(partial: Partial<UserSdkConfig>): void;
|
|
10
10
|
export declare function setAuthToken(token: string): void;
|
|
11
11
|
export declare function setCurrentUserId(userId: string | null): void;
|
|
12
|
+
/** Internal identity check; API requests still acquire fresh credentials. */
|
|
13
|
+
export declare function getCurrentUserId(): string | null;
|
|
12
14
|
export {};
|
package/dist/user/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { c as o, u as s } from "../hooks-
|
|
2
|
-
import { g as f } from "../bridge-
|
|
3
|
-
import { i as t } from "../app-version-checker-
|
|
1
|
+
import { c as o, u as s } from "../hooks-CMKwSLcQ.js";
|
|
2
|
+
import { g as f } from "../bridge-K3HqQwdj.js";
|
|
3
|
+
import { i as t } from "../app-version-checker-YVIFbytA.js";
|
|
4
4
|
export {
|
|
5
5
|
o as clearUserInfoCache,
|
|
6
6
|
f as getAuthTokenAsync,
|
package/dist/utils/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-
|
|
1
|
+
import { P as a, a as s, c as o, b as t, g as p, i, p as m, r as n, s as f } from "../app-version-checker-YVIFbytA.js";
|
|
2
2
|
import { a as c, P as l, p as P, b as F } from "../pwa-C5nXU0DN.js";
|
|
3
3
|
import { j as g } from "../url-c26cuIpu.js";
|
|
4
4
|
export {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aippy/runtime",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2-beta.0",
|
|
4
4
|
"description": "Aippy Runtime SDK - Runtime SDK for Aippy projects",
|
|
5
5
|
"private": false,
|
|
6
6
|
"type": "module",
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"import": "./dist/ai/index.js",
|
|
41
41
|
"types": "./dist/ai.d.ts"
|
|
42
42
|
},
|
|
43
|
+
"./ministore": {
|
|
44
|
+
"types": "./dist/ministore/index.d.ts",
|
|
45
|
+
"import": "./dist/ministore/index.js"
|
|
46
|
+
},
|
|
43
47
|
"./user": {
|
|
44
48
|
"import": "./dist/user/index.js",
|
|
45
49
|
"types": "./dist/user/index.d.ts"
|
package/dist/bridge-CtB9L5kL.js
DELETED
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { a as v } from "./runtime-CmoG3v2m.js";
|
|
2
|
-
import "react";
|
|
3
|
-
import { r as k, s as C, i as f } from "./app-version-checker-Bz7FrEZz.js";
|
|
4
|
-
import { c as h, a as U } from "./errors-B3bDbQbD.js";
|
|
5
|
-
const S = ".aippynow.com", R = "https://api.aippy.dev", _ = "https://api.aippy.ai";
|
|
6
|
-
let p;
|
|
7
|
-
function q() {
|
|
8
|
-
if (p) return p;
|
|
9
|
-
let n = _;
|
|
10
|
-
if (typeof window < "u" && window.location) {
|
|
11
|
-
const e = window.location.hostname;
|
|
12
|
-
(e.endsWith(S) || e === "localhost" || e === "127.0.0.1") && (n = R);
|
|
13
|
-
}
|
|
14
|
-
return p = n, n;
|
|
15
|
-
}
|
|
16
|
-
function K() {
|
|
17
|
-
p = void 0;
|
|
18
|
-
}
|
|
19
|
-
const B = {
|
|
20
|
-
apiBaseUrl: `${q()}/api`,
|
|
21
|
-
authToken: "",
|
|
22
|
-
currentUserId: null
|
|
23
|
-
};
|
|
24
|
-
function P(n) {
|
|
25
|
-
Object.assign(B, n);
|
|
26
|
-
}
|
|
27
|
-
function D(n) {
|
|
28
|
-
B.authToken = n;
|
|
29
|
-
}
|
|
30
|
-
function O(n) {
|
|
31
|
-
B.currentUserId = n;
|
|
32
|
-
}
|
|
33
|
-
const b = 3e3, T = 50, g = 500, c = { uid: "", token: "" };
|
|
34
|
-
let l = null, u = !1, a = null, t = null;
|
|
35
|
-
function I(n) {
|
|
36
|
-
if (!n || typeof n != "object") return null;
|
|
37
|
-
let e = n;
|
|
38
|
-
if (e.credentials && typeof e.credentials == "object" && (e = e.credentials), e.user && typeof e.user == "object" && e.token) {
|
|
39
|
-
const d = e.user;
|
|
40
|
-
e = { uid: d.uid || d.userId || d.id, token: e.token, apiBaseUrl: e.apiBaseUrl };
|
|
41
|
-
}
|
|
42
|
-
const r = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl;
|
|
43
|
-
if (!r || !o) return null;
|
|
44
|
-
const i = { uid: String(r), token: o, apiBaseUrl: s };
|
|
45
|
-
return O(i.uid), D(o), s && P({ apiBaseUrl: s }), i;
|
|
46
|
-
}
|
|
47
|
-
function y(n) {
|
|
48
|
-
if (console.log("🔄 [Bridge] processUserInfoData called with:", n), !n || typeof n != "object")
|
|
49
|
-
return console.warn("⚠️ [Bridge] Invalid data (null or not object):", n), null;
|
|
50
|
-
let e = n;
|
|
51
|
-
console.log("🔄 [Bridge] Initial obj keys:", Object.keys(e)), e.userInfo && typeof e.userInfo == "object" && (console.log("🔄 [Bridge] Unwrapping nested userInfo"), e = e.userInfo), e.user && typeof e.user == "object" && (console.log("🔄 [Bridge] Unwrapping nested user"), e = e.user), console.log("🔄 [Bridge] After unwrapping, obj:", e);
|
|
52
|
-
const r = e.uid || e.userId || e.id || "";
|
|
53
|
-
if (!r)
|
|
54
|
-
return console.warn("⚠️ [Bridge] No uid found in data"), null;
|
|
55
|
-
const o = { uid: String(r), ...e };
|
|
56
|
-
return console.log("✅ [Bridge] Created userInfo:", o), l = o, u = !0, console.log("✅ [Bridge] Cached userInfo, userInfoReceived = true"), o;
|
|
57
|
-
}
|
|
58
|
-
function j(n = g) {
|
|
59
|
-
return console.log("📱 [Bridge] requestCredentialsFromiOS called, timeout:", n), a ? (console.log("⏳ [Bridge] Pending credentials request exists, waiting..."), new Promise((e) => {
|
|
60
|
-
const r = a.resolve;
|
|
61
|
-
a.resolve = (o) => {
|
|
62
|
-
r(o), e(o);
|
|
63
|
-
};
|
|
64
|
-
})) : new Promise((e) => {
|
|
65
|
-
(async () => {
|
|
66
|
-
let r = window.webkit?.messageHandlers?.aippyListener;
|
|
67
|
-
if (console.log("📱 [Bridge] Checking aippyListener for credentials:", {
|
|
68
|
-
hasWebkit: !!window.webkit,
|
|
69
|
-
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
70
|
-
hasAippyListener: !!r
|
|
71
|
-
}), r || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), r = await E(1500)), !r) {
|
|
72
|
-
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning empty credentials"), e(c);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
const o = setTimeout(() => {
|
|
76
|
-
console.warn("⏰ [Bridge] Credentials request TIMEOUT after", n, "ms"), a = null, e(c);
|
|
77
|
-
}, n);
|
|
78
|
-
a = {
|
|
79
|
-
resolve: (s) => {
|
|
80
|
-
console.log("✅ [Bridge] pendingCredentialsRequest.resolve called with:", s), clearTimeout(o), a = null, e(s);
|
|
81
|
-
}
|
|
82
|
-
}, console.log("📱 [Bridge] pendingCredentialsRequest set"), v.receiveChannel.once("user.credentials", (s) => {
|
|
83
|
-
console.log("📩 [Bridge] Received user.credentials via receiveChannel:", s), clearTimeout(o);
|
|
84
|
-
const i = I(s) || c;
|
|
85
|
-
a && a.resolve(i);
|
|
86
|
-
});
|
|
87
|
-
try {
|
|
88
|
-
const s = {
|
|
89
|
-
command: "user.getCredentials",
|
|
90
|
-
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.credentials" })
|
|
91
|
-
};
|
|
92
|
-
console.log("📤 [Bridge] Sending credentials request:", s), r.postMessage(s), console.log("📤 [Bridge] Credentials postMessage sent successfully");
|
|
93
|
-
} catch (s) {
|
|
94
|
-
console.error("❌ [Bridge] Failed to send credentials postMessage:", s), clearTimeout(o), a = null, e(c);
|
|
95
|
-
}
|
|
96
|
-
})();
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
function M(n = g) {
|
|
100
|
-
return new Promise((e) => {
|
|
101
|
-
if (!f()) {
|
|
102
|
-
e(c);
|
|
103
|
-
return;
|
|
104
|
-
}
|
|
105
|
-
const r = setTimeout(() => {
|
|
106
|
-
window.removeEventListener("message", o), e(c);
|
|
107
|
-
}, n), o = (s) => {
|
|
108
|
-
s.data?.type === "user-credentials-response" && (clearTimeout(r), window.removeEventListener("message", o), e(I(s.data) || c));
|
|
109
|
-
};
|
|
110
|
-
window.addEventListener("message", o);
|
|
111
|
-
try {
|
|
112
|
-
window.parent.postMessage({ type: "user-credentials-request", timestamp: Date.now() }, "*");
|
|
113
|
-
} catch {
|
|
114
|
-
clearTimeout(r), window.removeEventListener("message", o), e(c);
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
const F = () => /Aippy\/[\d.]+\/\d+\/Android/i.test(navigator.userAgent);
|
|
119
|
-
async function E(n = 1500) {
|
|
120
|
-
if (!F())
|
|
121
|
-
return console.log("📱 [Bridge] Not Android, skipping waitForAippyListener"), window.webkit?.messageHandlers?.aippyListener || null;
|
|
122
|
-
const e = Date.now(), r = 50;
|
|
123
|
-
for (console.log("🤖 [Bridge] Android: Waiting for aippyListener (max", n, "ms)..."); Date.now() - e < n; ) {
|
|
124
|
-
const o = window.webkit?.messageHandlers?.aippyListener;
|
|
125
|
-
if (o)
|
|
126
|
-
return console.log("✅ [Bridge] aippyListener became available after", Date.now() - e, "ms"), o;
|
|
127
|
-
await new Promise((s) => setTimeout(s, r));
|
|
128
|
-
}
|
|
129
|
-
return console.warn("⏰ [Bridge] aippyListener not available after", n, "ms"), null;
|
|
130
|
-
}
|
|
131
|
-
function N(n = !1, e = g) {
|
|
132
|
-
return console.log("📱 [Bridge] requestUserInfoFromiOS called:", { forceRefresh: n, timeoutMs: e }), console.log("📱 [Bridge] Cache state:", { userInfoReceived: u, cachedUserInfo: l ? "(cached)" : null }), u && l && !n ? (console.log("✅ [Bridge] Returning cached userInfo from requestUserInfoFromiOS"), Promise.resolve(l)) : t ? (console.log("⏳ [Bridge] Pending userInfo request exists, waiting..."), new Promise((r) => {
|
|
133
|
-
const o = t.resolve;
|
|
134
|
-
t.resolve = (s) => {
|
|
135
|
-
console.log("⏳ [Bridge] Pending request resolved:", s), o(s), r(s);
|
|
136
|
-
};
|
|
137
|
-
})) : new Promise((r) => {
|
|
138
|
-
(async () => {
|
|
139
|
-
let o = window.webkit?.messageHandlers?.aippyListener;
|
|
140
|
-
if (console.log("📱 [Bridge] Checking aippyListener:", {
|
|
141
|
-
hasWebkit: !!window.webkit,
|
|
142
|
-
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
143
|
-
hasAippyListener: !!o
|
|
144
|
-
}), o || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), o = await E(1500)), !o) {
|
|
145
|
-
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning null"), r(null);
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
console.log("📱 [Bridge] Setting up timeout:", e, "ms");
|
|
149
|
-
const s = setTimeout(() => {
|
|
150
|
-
console.warn("⏰ [Bridge] UserInfo request TIMEOUT after", e, "ms"), t = null, r(null);
|
|
151
|
-
}, e);
|
|
152
|
-
t = { resolve: (i) => {
|
|
153
|
-
console.log("✅ [Bridge] pendingUserInfoRequest.resolve called with:", i), clearTimeout(s), t = null, r(i);
|
|
154
|
-
} }, console.log("📱 [Bridge] pendingUserInfoRequest set"), v.receiveChannel.once("user.info", (i) => {
|
|
155
|
-
console.log("📩 [Bridge] Received user.info via receiveChannel:", i), clearTimeout(s);
|
|
156
|
-
const d = y(i);
|
|
157
|
-
console.log("📩 [Bridge] Processed userInfo:", d), t ? t.resolve(d) : console.warn("⚠️ [Bridge] No pendingUserInfoRequest when receiveChannel fired");
|
|
158
|
-
}), console.log("📱 [Bridge] receiveChannel.once registered for user.info");
|
|
159
|
-
try {
|
|
160
|
-
const i = {
|
|
161
|
-
command: "user.getUserInfo",
|
|
162
|
-
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.info" })
|
|
163
|
-
};
|
|
164
|
-
console.log("📤 [Bridge] Sending to aippyListener:", i), o.postMessage(i), console.log("📤 [Bridge] postMessage sent successfully");
|
|
165
|
-
} catch (i) {
|
|
166
|
-
console.error("❌ [Bridge] Failed to send postMessage:", i), clearTimeout(s), t = null, r(null);
|
|
167
|
-
}
|
|
168
|
-
})();
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
|
-
function A(n = g) {
|
|
172
|
-
return new Promise((e) => {
|
|
173
|
-
if (!f()) {
|
|
174
|
-
e(null);
|
|
175
|
-
return;
|
|
176
|
-
}
|
|
177
|
-
const r = setTimeout(() => {
|
|
178
|
-
window.removeEventListener("message", o), e(null);
|
|
179
|
-
}, n), o = (s) => {
|
|
180
|
-
s.data?.type === "user-info-response" && (clearTimeout(r), window.removeEventListener("message", o), e(y(s.data)));
|
|
181
|
-
};
|
|
182
|
-
window.addEventListener("message", o);
|
|
183
|
-
try {
|
|
184
|
-
window.parent.postMessage({ type: "user-info-request", timestamp: Date.now() }, "*");
|
|
185
|
-
} catch {
|
|
186
|
-
clearTimeout(r), window.removeEventListener("message", o), e(null);
|
|
187
|
-
}
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
async function L() {
|
|
191
|
-
const { envCheck: n } = k("userCredentials");
|
|
192
|
-
switch (n.type) {
|
|
193
|
-
case "new_app": {
|
|
194
|
-
const e = await j(b);
|
|
195
|
-
if (!e?.token) throw h("Token unavailable in app", U.PERMISSION_DENIED);
|
|
196
|
-
return e.token;
|
|
197
|
-
}
|
|
198
|
-
case "iframe": {
|
|
199
|
-
const e = await M(T);
|
|
200
|
-
if (e?.token) return e.token;
|
|
201
|
-
throw C("Sign in to continue.Open this project in the app.", "signin"), h("Token unavailable: User needs to login", U.PERMISSION_DENIED);
|
|
202
|
-
}
|
|
203
|
-
default:
|
|
204
|
-
return "";
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
async function H(n = !1) {
|
|
208
|
-
if (console.log("🔍 [Bridge] getUserInfoAsync called, forceRefresh:", n), console.log("🔍 [Bridge] Current cache state:", { userInfoReceived: u, cachedUserInfo: l }), u && l && !n)
|
|
209
|
-
return console.log("✅ [Bridge] Returning cached userInfo"), l;
|
|
210
|
-
const { envCheck: e } = k("userInfo");
|
|
211
|
-
switch (console.log("🔍 [Bridge] Environment check result:", e), e.type) {
|
|
212
|
-
case "new_app":
|
|
213
|
-
return console.log("📱 [Bridge] Detected new_app environment"), await N(n, b);
|
|
214
|
-
case "iframe":
|
|
215
|
-
return console.log("🖼️ [Bridge] Detected iframe environment"), await A(T);
|
|
216
|
-
default:
|
|
217
|
-
return console.log("🌐 [Bridge] Detected web environment, returning cached:", l), l;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
async function x(n = g) {
|
|
221
|
-
return f() ? await A(n) : null;
|
|
222
|
-
}
|
|
223
|
-
function w(n) {
|
|
224
|
-
const e = I(n);
|
|
225
|
-
e && a && (a.resolve(e), a = null);
|
|
226
|
-
}
|
|
227
|
-
function m(n) {
|
|
228
|
-
console.log("📩 [Bridge] window.processUserInfo called with:", n), console.log("📩 [Bridge] pendingUserInfoRequest exists:", !!t);
|
|
229
|
-
const e = y(n);
|
|
230
|
-
t ? (console.log("✅ [Bridge] Resolving pendingUserInfoRequest with:", e), t.resolve(e), t = null) : (console.warn("⚠️ [Bridge] No pendingUserInfoRequest when processUserInfo called!"), console.warn("⚠️ [Bridge] UserInfo was processed but no one is waiting for it"));
|
|
231
|
-
}
|
|
232
|
-
function z() {
|
|
233
|
-
if (typeof window > "u") {
|
|
234
|
-
console.log("🔧 [Bridge] initUserBridge: window is undefined, skipping");
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
console.log("🔧 [Bridge] initUserBridge: Initializing..."), console.log("🔧 [Bridge] UserAgent:", navigator.userAgent), window.processUserCredentials = w, window.processUserInfo = m, console.log("🔧 [Bridge] Exposed window.processUserCredentials and window.processUserInfo"), window.addEventListener("message", (n) => {
|
|
238
|
-
n.data?.type === "user-credentials" && (console.log("📩 [Bridge] Received postMessage user-credentials:", n.data), w(n.data)), n.data?.type === "user-info" && (console.log("📩 [Bridge] Received postMessage user-info:", n.data), m(n.data));
|
|
239
|
-
}), console.log("🔧 [Bridge] Added message event listener"), console.log("✅ [Bridge] initUserBridge complete");
|
|
240
|
-
}
|
|
241
|
-
z();
|
|
242
|
-
L().catch((n) => {
|
|
243
|
-
console.warn("[UserSDK] Auth check on load:", n.message);
|
|
244
|
-
});
|
|
245
|
-
const X = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
246
|
-
__proto__: null,
|
|
247
|
-
getAuthTokenAsync: L,
|
|
248
|
-
getUserInfoAsync: H,
|
|
249
|
-
getUserInfoFromParent: x,
|
|
250
|
-
isInIframe: f,
|
|
251
|
-
processUserCredentials: w,
|
|
252
|
-
processUserInfo: m
|
|
253
|
-
}, Symbol.toStringTag, { value: "Module" }));
|
|
254
|
-
export {
|
|
255
|
-
K as _,
|
|
256
|
-
X as b,
|
|
257
|
-
L as g,
|
|
258
|
-
q as r
|
|
259
|
-
};
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import "react";
|
|
2
|
-
import { g as a } from "./bridge-CtB9L5kL.js";
|
|
3
|
-
const r = "0.4.1", i = {
|
|
4
|
-
version: r
|
|
5
|
-
}, o = i.version, c = "@aippy/runtime";
|
|
6
|
-
function w() {
|
|
7
|
-
return {
|
|
8
|
-
name: c,
|
|
9
|
-
version: o,
|
|
10
|
-
buildTime: (/* @__PURE__ */ new Date()).toISOString()
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function p(n) {
|
|
14
|
-
const { token: s, existingHeaders: e } = n, t = new Headers(e);
|
|
15
|
-
return t.set("Aippy-Runtime-Authorization", `Bearer ${s}`), t.set("Aippy-Runtime-SDK-Version", o), typeof navigator < "u" && navigator.userAgent && t.set("Aippy-Runtime-UA", navigator.userAgent), t;
|
|
16
|
-
}
|
|
17
|
-
async function m(n) {
|
|
18
|
-
const s = await a();
|
|
19
|
-
return p({ token: s, existingHeaders: n });
|
|
20
|
-
}
|
|
21
|
-
function u(n) {
|
|
22
|
-
if (!(typeof window > "u"))
|
|
23
|
-
try {
|
|
24
|
-
const s = window.webkit?.messageHandlers?.aippyListener;
|
|
25
|
-
if (s)
|
|
26
|
-
try {
|
|
27
|
-
const e = {
|
|
28
|
-
command: "container.message",
|
|
29
|
-
parameters: n
|
|
30
|
-
};
|
|
31
|
-
s.postMessage(e), console.log("📤 [Container Message] Sent message to iOS app container:", n);
|
|
32
|
-
} catch (e) {
|
|
33
|
-
console.warn("❌ [Container Message] Failed to send message to iOS app:", e);
|
|
34
|
-
}
|
|
35
|
-
if (window.parent && window.parent !== window)
|
|
36
|
-
try {
|
|
37
|
-
const e = {
|
|
38
|
-
type: "container.message",
|
|
39
|
-
data: n
|
|
40
|
-
};
|
|
41
|
-
window.parent.postMessage(e, "*"), console.log("📤 [Container Message] Sent message to parent window:", n);
|
|
42
|
-
} catch (e) {
|
|
43
|
-
console.warn("❌ [Container Message] Failed to send message to parent window:", e);
|
|
44
|
-
}
|
|
45
|
-
} catch (s) {
|
|
46
|
-
console.warn("⚠️ [Container Message] Failed to send message:", s);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
export {
|
|
50
|
-
c as S,
|
|
51
|
-
o as V,
|
|
52
|
-
m as a,
|
|
53
|
-
p as c,
|
|
54
|
-
w as g,
|
|
55
|
-
u as s
|
|
56
|
-
};
|
package/dist/helper-WRpB-6MD.js
DELETED
|
@@ -1,241 +0,0 @@
|
|
|
1
|
-
import { createOpenAICompatible as d } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import { r as f } from "./bridge-CtB9L5kL.js";
|
|
3
|
-
import { s as m, a as b } from "./container-message-C3YXyTZj.js";
|
|
4
|
-
import { AISDKError as c, DefaultChatTransport as h } from "ai";
|
|
5
|
-
import { E as g, b as p, a as u } from "./errors-B3bDbQbD.js";
|
|
6
|
-
import { j as A } from "./url-c26cuIpu.js";
|
|
7
|
-
const j = `${f()}/aisdk/v1/`, x = `${f()}/aisdk/v1/ui/`, I = "gpt-5-nano", v = "";
|
|
8
|
-
function w(o = {}) {
|
|
9
|
-
return {
|
|
10
|
-
baseUrl: o.baseUrl ?? `${f()}/aisdk/v1/`
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function C(o = {}) {
|
|
14
|
-
return {
|
|
15
|
-
baseUrl: o.baseUrl ?? `${f()}/aisdk/v1/ui/`
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
|
-
function O(o, e) {
|
|
19
|
-
const r = o.status;
|
|
20
|
-
if (e && typeof e == "object" && "error" in e) {
|
|
21
|
-
const t = e, n = t.error.code, s = n != null ? `AippyAIError_${n}` : `AippyAIError_${r}`, a = e;
|
|
22
|
-
return "appMessage" in a && a.appMessage !== void 0 && m(a.appMessage), new c({
|
|
23
|
-
name: s,
|
|
24
|
-
message: `${g.RUNTIME} ${t.error.message}`,
|
|
25
|
-
cause: {
|
|
26
|
-
type: t.error.type ?? void 0,
|
|
27
|
-
param: t.error.param ?? void 0,
|
|
28
|
-
status: r
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
if (e && typeof e == "object" && e !== null) {
|
|
33
|
-
const t = e;
|
|
34
|
-
"appMessage" in t && t.appMessage !== void 0 && m(t.appMessage);
|
|
35
|
-
}
|
|
36
|
-
return new c({
|
|
37
|
-
name: `AippyAIError_${r}`,
|
|
38
|
-
message: `${g.RUNTIME} Request failed with status ${r}`,
|
|
39
|
-
cause: { status: r }
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
function l() {
|
|
43
|
-
return async (o, e) => {
|
|
44
|
-
const r = await b(e?.headers), t = await globalThis.fetch(o, { ...e, headers: r });
|
|
45
|
-
if (!t.ok) {
|
|
46
|
-
const n = await t.text().catch(() => null);
|
|
47
|
-
let s = null;
|
|
48
|
-
if (n)
|
|
49
|
-
try {
|
|
50
|
-
s = JSON.parse(n);
|
|
51
|
-
} catch {
|
|
52
|
-
s = { message: n };
|
|
53
|
-
}
|
|
54
|
-
throw O(t, s);
|
|
55
|
-
}
|
|
56
|
-
return t;
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
const E = [
|
|
60
|
-
"gpt-image-1",
|
|
61
|
-
"gpt-image-1-mini",
|
|
62
|
-
"gpt-image-1.5"
|
|
63
|
-
];
|
|
64
|
-
function _(o) {
|
|
65
|
-
try {
|
|
66
|
-
const e = JSON.parse(o);
|
|
67
|
-
if (e.model && E.some((r) => e.model.startsWith(r))) {
|
|
68
|
-
const { response_format: r, ...t } = e;
|
|
69
|
-
return JSON.stringify(t);
|
|
70
|
-
}
|
|
71
|
-
} catch {
|
|
72
|
-
}
|
|
73
|
-
return o;
|
|
74
|
-
}
|
|
75
|
-
function J(o = {}) {
|
|
76
|
-
const { baseUrl: e } = w(o), r = l();
|
|
77
|
-
return d({
|
|
78
|
-
name: "aippy",
|
|
79
|
-
baseURL: e,
|
|
80
|
-
fetch: async (n, s) => n.toString().includes("/images/generations") && s?.method?.toUpperCase() === "POST" && s?.body ? r(n, {
|
|
81
|
-
...s,
|
|
82
|
-
body: _(s.body)
|
|
83
|
-
}) : r(n, s),
|
|
84
|
-
// Enable structured outputs support (json_schema response format)
|
|
85
|
-
// This is required for Output.object() and Output.array() to work properly
|
|
86
|
-
supportsStructuredOutputs: !0
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
const S = "/chat";
|
|
90
|
-
function B(o = {}) {
|
|
91
|
-
const { baseUrl: e } = C(o), r = o.model ?? I, t = o.system ?? v, n = o.api ?? A(e, S), s = { model: r, system: t }, a = l();
|
|
92
|
-
return {
|
|
93
|
-
transport: new h({
|
|
94
|
-
api: n,
|
|
95
|
-
body: s,
|
|
96
|
-
// Ensure token is fetched fresh for every request
|
|
97
|
-
fetch: a
|
|
98
|
-
})
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
function y(o) {
|
|
102
|
-
const e = [];
|
|
103
|
-
if (!o || typeof o != "object")
|
|
104
|
-
throw p("AIConfig must be an object", u.INVALID_CONFIG);
|
|
105
|
-
const r = o;
|
|
106
|
-
for (const [t, n] of Object.entries(r)) {
|
|
107
|
-
if (!n || typeof n != "object") {
|
|
108
|
-
e.push({ key: t, message: "Item must be an object" });
|
|
109
|
-
continue;
|
|
110
|
-
}
|
|
111
|
-
const s = n;
|
|
112
|
-
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" });
|
|
113
|
-
const a = s.type;
|
|
114
|
-
if (!["number", "boolean", "text", "enum"].includes(a)) {
|
|
115
|
-
e.push({
|
|
116
|
-
key: t,
|
|
117
|
-
message: `type must be one of: number, boolean, text, enum (got: ${a})`
|
|
118
|
-
});
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
if (a === "number")
|
|
122
|
-
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" });
|
|
123
|
-
else if (a === "boolean")
|
|
124
|
-
typeof s.value != "boolean" && e.push({ key: t, message: 'value must be a boolean for type "boolean"' });
|
|
125
|
-
else if (a === "text")
|
|
126
|
-
typeof s.value != "string" && e.push({ key: t, message: 'value must be a string for type "text"' });
|
|
127
|
-
else if (a === "enum") {
|
|
128
|
-
if (!Array.isArray(s.options))
|
|
129
|
-
e.push({ key: t, message: 'options must be an array for type "enum"' });
|
|
130
|
-
else if (s.options.length === 0)
|
|
131
|
-
e.push({ key: t, message: 'options array cannot be empty for type "enum"' });
|
|
132
|
-
else
|
|
133
|
-
for (let i = 0; i < s.options.length; i++)
|
|
134
|
-
typeof s.options[i] != "string" && e.push({
|
|
135
|
-
key: t,
|
|
136
|
-
message: `options[${i}] must be a string`
|
|
137
|
-
});
|
|
138
|
-
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({
|
|
139
|
-
key: t,
|
|
140
|
-
message: `value "${s.value}" is not in options: [${s.options.join(", ")}]`
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
s.group !== void 0 && typeof s.group != "string" && e.push({ key: t, message: "group must be a string" });
|
|
144
|
-
}
|
|
145
|
-
if (e.length > 0)
|
|
146
|
-
throw p(
|
|
147
|
-
`AIConfig validation failed with ${e.length} error(s)`,
|
|
148
|
-
u.INVALID_CONFIG,
|
|
149
|
-
{ errors: e }
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
function H(o) {
|
|
153
|
-
let e;
|
|
154
|
-
try {
|
|
155
|
-
e = JSON.parse(o);
|
|
156
|
-
} catch (r) {
|
|
157
|
-
throw p(
|
|
158
|
-
`Invalid JSON: ${r instanceof Error ? r.message : String(r)}`,
|
|
159
|
-
u.INVALID_CONFIG
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
|
-
return y(e), e;
|
|
163
|
-
}
|
|
164
|
-
function U(o) {
|
|
165
|
-
return y(o), o;
|
|
166
|
-
}
|
|
167
|
-
function N(o, e) {
|
|
168
|
-
const r = o[e];
|
|
169
|
-
if (!r)
|
|
170
|
-
throw p(
|
|
171
|
-
`AIConfig key "${e}" not found`,
|
|
172
|
-
u.INVALID_CONFIG,
|
|
173
|
-
{ key: e }
|
|
174
|
-
);
|
|
175
|
-
return r.value;
|
|
176
|
-
}
|
|
177
|
-
function T(o) {
|
|
178
|
-
if (!(typeof window > "u"))
|
|
179
|
-
try {
|
|
180
|
-
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
181
|
-
if (e)
|
|
182
|
-
try {
|
|
183
|
-
const r = {
|
|
184
|
-
command: "ai.initialize",
|
|
185
|
-
parameters: JSON.stringify(o)
|
|
186
|
-
};
|
|
187
|
-
e.postMessage(r);
|
|
188
|
-
} catch (r) {
|
|
189
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", r);
|
|
190
|
-
}
|
|
191
|
-
if (window.parent && window.parent !== window)
|
|
192
|
-
try {
|
|
193
|
-
const r = {
|
|
194
|
-
type: "ai.initialize",
|
|
195
|
-
config: JSON.stringify(o)
|
|
196
|
-
};
|
|
197
|
-
window.parent.postMessage(r, "*");
|
|
198
|
-
} catch (r) {
|
|
199
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", r);
|
|
200
|
-
}
|
|
201
|
-
} catch (e) {
|
|
202
|
-
console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
function P(o) {
|
|
206
|
-
const e = U(o);
|
|
207
|
-
return T(e), new Proxy({}, {
|
|
208
|
-
get(r, t) {
|
|
209
|
-
if (typeof t == "string")
|
|
210
|
-
try {
|
|
211
|
-
return N(e, t);
|
|
212
|
-
} catch {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
has(r, t) {
|
|
217
|
-
return typeof t != "string" ? !1 : t in e;
|
|
218
|
-
},
|
|
219
|
-
ownKeys(r) {
|
|
220
|
-
return Object.keys(e);
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
export {
|
|
225
|
-
j as D,
|
|
226
|
-
S as U,
|
|
227
|
-
J as a,
|
|
228
|
-
B as b,
|
|
229
|
-
x as c,
|
|
230
|
-
I as d,
|
|
231
|
-
v as e,
|
|
232
|
-
C as f,
|
|
233
|
-
N as g,
|
|
234
|
-
P as h,
|
|
235
|
-
U as l,
|
|
236
|
-
O as n,
|
|
237
|
-
H as p,
|
|
238
|
-
w as r,
|
|
239
|
-
T as s,
|
|
240
|
-
y as v
|
|
241
|
-
};
|