@aippy/runtime 0.2.7-dev.5 → 0.2.7-dev.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ai/config/index.d.ts +1 -1
- package/dist/ai/config/parser.d.ts +5 -12
- package/dist/ai/errors.d.ts +1 -0
- package/dist/ai/index.d.ts +1 -1
- package/dist/ai/index.js +15 -16
- package/dist/ai/shared/fetch.d.ts +0 -4
- package/dist/ai/shared/index.d.ts +1 -1
- package/dist/app-version-checker-B1UXEcy9.js +240 -0
- package/dist/bridge-BQQ3PfSO.js +237 -0
- package/dist/config-B0A7gHQM.js +28 -0
- package/dist/container-message-YB3cWpWj.js +56 -0
- package/dist/core/errors.d.ts +22 -3
- package/dist/core/headers.d.ts +31 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +22 -50
- package/dist/device/index.js +194 -194
- package/dist/errors-B3bDbQbD.js +40 -0
- package/dist/helper-BjRhidue.js +238 -0
- package/dist/hooks-C7VP176R.js +98 -0
- package/dist/index/index.js +89 -80
- package/dist/pwa-C5nXU0DN.js +250 -0
- package/dist/tweaks/index.js +1 -1
- package/dist/url-c26cuIpu.js +7 -0
- package/dist/{useTweaks-QxMRmg7i.js → useTweaks-B7Muzo78.js} +10 -9
- package/dist/user/hooks.d.ts +6 -2
- package/dist/user/index.d.ts +1 -0
- package/dist/user/index.js +3 -3
- package/dist/utils/app-version-checker.d.ts +62 -0
- package/dist/utils/app-version-requirements.json.d.ts +13 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +17 -11
- package/dist/utils/ui.d.ts +3 -1
- package/dist/utils/url.d.ts +7 -0
- package/package.json +1 -1
- package/dist/bridge-Ca3H2iN1.js +0 -197
- package/dist/container-message-DGrno17o.js +0 -31
- package/dist/errors-CDEBaBxB.js +0 -26
- package/dist/helper-BENVYOU-.js +0 -247
- package/dist/hooks-CE9cjXHP.js +0 -46
- package/dist/pwa-CilSlaik.js +0 -249
- package/dist/ui-y5N62DqC.js +0 -175
package/dist/bridge-Ca3H2iN1.js
DELETED
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import { a as y } from "./runtime-CmoG3v2m.js";
|
|
2
|
-
import { p as T, s as v, i as f } from "./ui-y5N62DqC.js";
|
|
3
|
-
const m = {
|
|
4
|
-
apiBaseUrl: "https://api.aippy.dev/api",
|
|
5
|
-
authToken: "",
|
|
6
|
-
currentUserId: null
|
|
7
|
-
};
|
|
8
|
-
function b(n) {
|
|
9
|
-
Object.assign(m, n);
|
|
10
|
-
}
|
|
11
|
-
function P(n) {
|
|
12
|
-
m.authToken = n;
|
|
13
|
-
}
|
|
14
|
-
function O(n) {
|
|
15
|
-
m.currentUserId = n;
|
|
16
|
-
}
|
|
17
|
-
const k = { iOS: "1.6.6", Android: "1.1.8" }, E = 3e3, S = 50, l = 500, a = { uid: "", token: "" };
|
|
18
|
-
let d = null, _ = !1, u = null, w = !1, o = null;
|
|
19
|
-
function g(n) {
|
|
20
|
-
if (!n || typeof n != "object") return null;
|
|
21
|
-
let e = n;
|
|
22
|
-
if (e.credentials && typeof e.credentials == "object" && (e = e.credentials), e.user && typeof e.user == "object" && e.token) {
|
|
23
|
-
const c = e.user;
|
|
24
|
-
e = { uid: c.uid || c.userId || c.id, token: e.token, apiBaseUrl: e.apiBaseUrl };
|
|
25
|
-
}
|
|
26
|
-
const s = e.uid || e.userId || e.id || "", t = e.token || e.authToken || "", r = e.apiBaseUrl;
|
|
27
|
-
if (!s || !t) return null;
|
|
28
|
-
const i = { uid: String(s), token: t, apiBaseUrl: r };
|
|
29
|
-
return O(i.uid), P(t), r && b({ apiBaseUrl: r }), d = i, _ = !0, i;
|
|
30
|
-
}
|
|
31
|
-
function h(n) {
|
|
32
|
-
if (!n || typeof n != "object") return null;
|
|
33
|
-
let e = n;
|
|
34
|
-
e.userInfo && typeof e.userInfo == "object" && (e = e.userInfo), e.user && typeof e.user == "object" && (e = e.user);
|
|
35
|
-
const s = e.uid || e.userId || e.id || "";
|
|
36
|
-
if (!s) return null;
|
|
37
|
-
const t = { uid: String(s), ...e };
|
|
38
|
-
return u = t, w = !0, t;
|
|
39
|
-
}
|
|
40
|
-
function p(n) {
|
|
41
|
-
throw console.warn(`[UserSDK] ${n}`), v("Your app version is outdated. Please upgrade to the latest version."), new Error("App version too old");
|
|
42
|
-
}
|
|
43
|
-
function L(n = l) {
|
|
44
|
-
return _ && d ? Promise.resolve(d) : new Promise((e) => {
|
|
45
|
-
const s = window.webkit?.messageHandlers?.aippyListener;
|
|
46
|
-
if (!s) {
|
|
47
|
-
e(a);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
const t = setTimeout(() => e(a), n);
|
|
51
|
-
y.receiveChannel.once("user.credentials", (r) => {
|
|
52
|
-
clearTimeout(t), e(g(r) || a);
|
|
53
|
-
});
|
|
54
|
-
try {
|
|
55
|
-
s.postMessage({
|
|
56
|
-
command: "user.getCredentials",
|
|
57
|
-
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.credentials" })
|
|
58
|
-
});
|
|
59
|
-
} catch {
|
|
60
|
-
clearTimeout(t), e(a);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
function C(n = l) {
|
|
65
|
-
return new Promise((e) => {
|
|
66
|
-
if (!f()) {
|
|
67
|
-
e(a);
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
const s = setTimeout(() => {
|
|
71
|
-
window.removeEventListener("message", t), e(a);
|
|
72
|
-
}, n), t = (r) => {
|
|
73
|
-
r.data?.type === "user-credentials-response" && (clearTimeout(s), window.removeEventListener("message", t), e(g(r.data) || a));
|
|
74
|
-
};
|
|
75
|
-
window.addEventListener("message", t);
|
|
76
|
-
try {
|
|
77
|
-
window.parent.postMessage({ type: "user-credentials-request", timestamp: Date.now() }, "*");
|
|
78
|
-
} catch {
|
|
79
|
-
clearTimeout(s), window.removeEventListener("message", t), e(a);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
function D(n = !1, e = l) {
|
|
84
|
-
return w && u && !n ? Promise.resolve(u) : o ? new Promise((s) => {
|
|
85
|
-
const t = o.resolve;
|
|
86
|
-
o.resolve = (r) => {
|
|
87
|
-
t(r), s(r);
|
|
88
|
-
};
|
|
89
|
-
}) : new Promise((s) => {
|
|
90
|
-
const t = window.webkit?.messageHandlers?.aippyListener;
|
|
91
|
-
if (!t) {
|
|
92
|
-
s(null);
|
|
93
|
-
return;
|
|
94
|
-
}
|
|
95
|
-
const r = setTimeout(() => {
|
|
96
|
-
o = null, s(null);
|
|
97
|
-
}, e);
|
|
98
|
-
o = { resolve: (i) => {
|
|
99
|
-
clearTimeout(r), o = null, s(i);
|
|
100
|
-
} }, y.receiveChannel.once("user.info", (i) => {
|
|
101
|
-
console.log("[UserSDK] Received user.info via receiveChannel:", i), clearTimeout(r);
|
|
102
|
-
const c = h(i);
|
|
103
|
-
o && o.resolve(c);
|
|
104
|
-
});
|
|
105
|
-
try {
|
|
106
|
-
console.log("[UserSDK] Requesting user info from iOS"), t.postMessage({
|
|
107
|
-
command: "user.getUserInfo",
|
|
108
|
-
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.info" })
|
|
109
|
-
});
|
|
110
|
-
} catch {
|
|
111
|
-
clearTimeout(r), o = null, s(null);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
function A(n = l) {
|
|
116
|
-
return new Promise((e) => {
|
|
117
|
-
if (!f()) {
|
|
118
|
-
e(null);
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
const s = setTimeout(() => {
|
|
122
|
-
window.removeEventListener("message", t), e(null);
|
|
123
|
-
}, n), t = (r) => {
|
|
124
|
-
r.data?.type === "user-info-response" && (clearTimeout(s), window.removeEventListener("message", t), e(h(r.data)));
|
|
125
|
-
};
|
|
126
|
-
window.addEventListener("message", t);
|
|
127
|
-
try {
|
|
128
|
-
window.parent.postMessage({ type: "user-info-request", timestamp: Date.now() }, "*");
|
|
129
|
-
} catch {
|
|
130
|
-
clearTimeout(s), window.removeEventListener("message", t), e(null);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
async function M() {
|
|
135
|
-
const n = T.checkAppEnvironment(k);
|
|
136
|
-
switch (n.type) {
|
|
137
|
-
case "new_app": {
|
|
138
|
-
n.isValid || p(n.message || "App version too old"), await L(E);
|
|
139
|
-
const e = d?.token || "";
|
|
140
|
-
if (!e) throw new Error("Token unavailable in app");
|
|
141
|
-
return e;
|
|
142
|
-
}
|
|
143
|
-
case "old_ios_app":
|
|
144
|
-
case "old_android_app":
|
|
145
|
-
throw p(n.message || "Old app version"), new Error("Token unavailable: Old app version not supported");
|
|
146
|
-
case "iframe": {
|
|
147
|
-
const e = await C(S);
|
|
148
|
-
if (e?.token) return e.token;
|
|
149
|
-
throw v("Please log in to use this feature."), new Error("Token unavailable: User needs to login");
|
|
150
|
-
}
|
|
151
|
-
default:
|
|
152
|
-
return "";
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
async function F(n = !1) {
|
|
156
|
-
if (w && u && !n) return u;
|
|
157
|
-
const e = T.checkAppEnvironment(k);
|
|
158
|
-
switch (e.type) {
|
|
159
|
-
case "new_app":
|
|
160
|
-
return e.isValid || p(e.message || "App version too old"), await D(n, E);
|
|
161
|
-
case "old_ios_app":
|
|
162
|
-
case "old_android_app":
|
|
163
|
-
return p(e.message || "Old app version"), u;
|
|
164
|
-
case "iframe":
|
|
165
|
-
return await A(S);
|
|
166
|
-
default:
|
|
167
|
-
return u;
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
async function B(n = l) {
|
|
171
|
-
return f() ? await A(n) : null;
|
|
172
|
-
}
|
|
173
|
-
function I(n) {
|
|
174
|
-
g(n);
|
|
175
|
-
}
|
|
176
|
-
function U(n) {
|
|
177
|
-
console.log("[UserSDK] processUserInfo called with:", n);
|
|
178
|
-
const e = h(n);
|
|
179
|
-
o && (o.resolve(e), o = null);
|
|
180
|
-
}
|
|
181
|
-
function j() {
|
|
182
|
-
typeof window > "u" || (window.processUserCredentials = I, window.processUserInfo = U, window.addEventListener("message", (n) => {
|
|
183
|
-
n.data?.type === "user-credentials" && I(n.data), n.data?.type === "user-info" && U(n.data);
|
|
184
|
-
}));
|
|
185
|
-
}
|
|
186
|
-
j();
|
|
187
|
-
M().catch((n) => {
|
|
188
|
-
console.warn("[UserSDK] Auth check on load:", n.message);
|
|
189
|
-
});
|
|
190
|
-
export {
|
|
191
|
-
M as getAuthTokenAsync,
|
|
192
|
-
F as getUserInfoAsync,
|
|
193
|
-
B as getUserInfoFromParent,
|
|
194
|
-
f as isInIframe,
|
|
195
|
-
I as processUserCredentials,
|
|
196
|
-
U as processUserInfo
|
|
197
|
-
};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
function o(n) {
|
|
2
|
-
if (!(typeof window > "u"))
|
|
3
|
-
try {
|
|
4
|
-
const s = window.webkit?.messageHandlers?.aippyListener;
|
|
5
|
-
if (s)
|
|
6
|
-
try {
|
|
7
|
-
const e = {
|
|
8
|
-
command: "container.message",
|
|
9
|
-
parameters: n
|
|
10
|
-
};
|
|
11
|
-
s.postMessage(e), console.log("📤 [Container Message] Sent message to iOS app container:", n);
|
|
12
|
-
} catch (e) {
|
|
13
|
-
console.warn("❌ [Container Message] Failed to send message to iOS app:", e);
|
|
14
|
-
}
|
|
15
|
-
if (window.parent && window.parent !== window)
|
|
16
|
-
try {
|
|
17
|
-
const e = {
|
|
18
|
-
type: "container.message",
|
|
19
|
-
data: n
|
|
20
|
-
};
|
|
21
|
-
window.parent.postMessage(e, "*"), console.log("📤 [Container Message] Sent message to parent window:", n);
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.warn("❌ [Container Message] Failed to send message to parent window:", e);
|
|
24
|
-
}
|
|
25
|
-
} catch (s) {
|
|
26
|
-
console.warn("⚠️ [Container Message] Failed to send message:", s);
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
export {
|
|
30
|
-
o as s
|
|
31
|
-
};
|
package/dist/errors-CDEBaBxB.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
var e = Object.defineProperty;
|
|
2
|
-
var o = (E, R, N) => R in E ? e(E, R, { enumerable: !0, configurable: !0, writable: !0, value: N }) : E[R] = N;
|
|
3
|
-
var O = (E, R, N) => o(E, typeof R != "symbol" ? R + "" : R, N);
|
|
4
|
-
class I extends Error {
|
|
5
|
-
constructor(N, r = "AIPPY_ERROR", t) {
|
|
6
|
-
super(N);
|
|
7
|
-
O(this, "code");
|
|
8
|
-
O(this, "context");
|
|
9
|
-
this.name = "AippyRuntimeError", this.code = r, this.context = t;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const _ = {
|
|
13
|
-
NOT_SUPPORTED: "NOT_SUPPORTED",
|
|
14
|
-
PERMISSION_DENIED: "PERMISSION_DENIED",
|
|
15
|
-
INVALID_CONFIG: "INVALID_CONFIG",
|
|
16
|
-
NETWORK_ERROR: "NETWORK_ERROR",
|
|
17
|
-
UNKNOWN_ERROR: "UNKNOWN_ERROR"
|
|
18
|
-
};
|
|
19
|
-
function s(E, R = "UNKNOWN_ERROR", N) {
|
|
20
|
-
return new I(E, _[R], N);
|
|
21
|
-
}
|
|
22
|
-
export {
|
|
23
|
-
I as A,
|
|
24
|
-
_ as E,
|
|
25
|
-
s as c
|
|
26
|
-
};
|
package/dist/helper-BENVYOU-.js
DELETED
|
@@ -1,247 +0,0 @@
|
|
|
1
|
-
import { createOpenAICompatible as l } from "@ai-sdk/openai-compatible";
|
|
2
|
-
import "react";
|
|
3
|
-
import { getAuthTokenAsync as y } from "./bridge-Ca3H2iN1.js";
|
|
4
|
-
import { AISDKError as u, DefaultChatTransport as d } from "ai";
|
|
5
|
-
import { s as f } from "./container-message-DGrno17o.js";
|
|
6
|
-
const c = "https://api.aippy.dev", h = `${c}/aisdk/v1/`, b = `${c}/aisdk/v1/ui/`, A = "gpt-5-nano", w = "";
|
|
7
|
-
function v(n = {}) {
|
|
8
|
-
return {
|
|
9
|
-
baseUrl: n.baseUrl ?? h
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
function I(n = {}) {
|
|
13
|
-
return {
|
|
14
|
-
baseUrl: n.baseUrl ?? b
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
function C(n, e) {
|
|
18
|
-
const s = n.status;
|
|
19
|
-
if (e && typeof e == "object" && "error" in e) {
|
|
20
|
-
const t = e, o = t.error.code, r = o != null ? `AippyAIError_${o}` : `AippyAIError_${s}`, a = e;
|
|
21
|
-
return "appMessage" in a && a.appMessage !== void 0 && f(a.appMessage), new u({
|
|
22
|
-
name: r,
|
|
23
|
-
message: t.error.message,
|
|
24
|
-
cause: {
|
|
25
|
-
type: t.error.type ?? void 0,
|
|
26
|
-
param: t.error.param ?? void 0,
|
|
27
|
-
status: s
|
|
28
|
-
}
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
if (e && typeof e == "object" && e !== null) {
|
|
32
|
-
const t = e;
|
|
33
|
-
"appMessage" in t && t.appMessage !== void 0 && f(t.appMessage);
|
|
34
|
-
}
|
|
35
|
-
return new u({
|
|
36
|
-
name: `AippyAIError_${s}`,
|
|
37
|
-
message: `Request failed with status ${s}`,
|
|
38
|
-
cause: { status: s }
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
function E(n, e) {
|
|
42
|
-
const s = n.endsWith("/") ? n : `${n}/`, t = e.startsWith("/") ? e.slice(1) : e;
|
|
43
|
-
return new URL(t, s).href;
|
|
44
|
-
}
|
|
45
|
-
function m() {
|
|
46
|
-
return async (n, e) => {
|
|
47
|
-
const s = await y(), t = new Headers(e?.headers);
|
|
48
|
-
t.set("Aippy-Runtime-Authorization", `Bearer ${s}`);
|
|
49
|
-
const o = await globalThis.fetch(n, { ...e, headers: t });
|
|
50
|
-
if (!o.ok) {
|
|
51
|
-
const r = await o.text().catch(() => null);
|
|
52
|
-
let a = null;
|
|
53
|
-
if (r)
|
|
54
|
-
try {
|
|
55
|
-
a = JSON.parse(r);
|
|
56
|
-
} catch {
|
|
57
|
-
a = { message: r };
|
|
58
|
-
}
|
|
59
|
-
throw C(o, a);
|
|
60
|
-
}
|
|
61
|
-
return o;
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
const S = [
|
|
65
|
-
"gpt-image-1",
|
|
66
|
-
"gpt-image-1-mini",
|
|
67
|
-
"gpt-image-1.5"
|
|
68
|
-
];
|
|
69
|
-
function O(n) {
|
|
70
|
-
try {
|
|
71
|
-
const e = JSON.parse(n);
|
|
72
|
-
if (e.model && S.some((s) => e.model.startsWith(s))) {
|
|
73
|
-
const { response_format: s, ...t } = e;
|
|
74
|
-
return JSON.stringify(t);
|
|
75
|
-
}
|
|
76
|
-
} catch {
|
|
77
|
-
}
|
|
78
|
-
return n;
|
|
79
|
-
}
|
|
80
|
-
function N(n = {}) {
|
|
81
|
-
const { baseUrl: e } = v(n), s = m();
|
|
82
|
-
return l({
|
|
83
|
-
name: "aippy",
|
|
84
|
-
baseURL: e,
|
|
85
|
-
fetch: async (o, r) => o.toString().includes("/images/generations") && r?.method?.toUpperCase() === "POST" && r?.body ? s(o, {
|
|
86
|
-
...r,
|
|
87
|
-
body: O(r.body)
|
|
88
|
-
}) : s(o, r),
|
|
89
|
-
// Enable structured outputs support (json_schema response format)
|
|
90
|
-
// This is required for Output.object() and Output.array() to work properly
|
|
91
|
-
supportsStructuredOutputs: !0
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
const _ = "/chat";
|
|
95
|
-
function D(n = {}) {
|
|
96
|
-
const { baseUrl: e } = I(n), s = n.model ?? A, t = n.system ?? w, o = n.api ?? E(e, _), r = { model: s, system: t }, a = m();
|
|
97
|
-
return {
|
|
98
|
-
transport: new d({
|
|
99
|
-
api: o,
|
|
100
|
-
body: r,
|
|
101
|
-
// Ensure token is fetched fresh for every request
|
|
102
|
-
fetch: a
|
|
103
|
-
})
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
class p extends Error {
|
|
107
|
-
constructor(e, s) {
|
|
108
|
-
super(e), this.errors = s, this.name = "AIConfigValidationError";
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
function g(n) {
|
|
112
|
-
const e = [];
|
|
113
|
-
if (!n || typeof n != "object")
|
|
114
|
-
throw new p("AIConfig must be an object", []);
|
|
115
|
-
const s = n;
|
|
116
|
-
for (const [t, o] of Object.entries(s)) {
|
|
117
|
-
if (!o || typeof o != "object") {
|
|
118
|
-
e.push({ key: t, message: "Item must be an object" });
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const r = o;
|
|
122
|
-
typeof r.index != "number" && e.push({ key: t, message: "index must be a number" }), typeof r.name != "string" && e.push({ key: t, message: "name must be a string" }), typeof r.description != "string" && e.push({ key: t, message: "description must be a string" });
|
|
123
|
-
const a = r.type;
|
|
124
|
-
if (!["number", "boolean", "text", "enum"].includes(a)) {
|
|
125
|
-
e.push({
|
|
126
|
-
key: t,
|
|
127
|
-
message: `type must be one of: number, boolean, text, enum (got: ${a})`
|
|
128
|
-
});
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (a === "number")
|
|
132
|
-
typeof r.value != "number" && e.push({ key: t, message: 'value must be a number for type "number"' }), r.min !== void 0 && typeof r.min != "number" && e.push({ key: t, message: "min must be a number" }), r.max !== void 0 && typeof r.max != "number" && e.push({ key: t, message: "max must be a number" }), r.step !== void 0 && typeof r.step != "number" && e.push({ key: t, message: "step must be a number" });
|
|
133
|
-
else if (a === "boolean")
|
|
134
|
-
typeof r.value != "boolean" && e.push({ key: t, message: 'value must be a boolean for type "boolean"' });
|
|
135
|
-
else if (a === "text")
|
|
136
|
-
typeof r.value != "string" && e.push({ key: t, message: 'value must be a string for type "text"' });
|
|
137
|
-
else if (a === "enum") {
|
|
138
|
-
if (!Array.isArray(r.options))
|
|
139
|
-
e.push({ key: t, message: 'options must be an array for type "enum"' });
|
|
140
|
-
else if (r.options.length === 0)
|
|
141
|
-
e.push({ key: t, message: 'options array cannot be empty for type "enum"' });
|
|
142
|
-
else
|
|
143
|
-
for (let i = 0; i < r.options.length; i++)
|
|
144
|
-
typeof r.options[i] != "string" && e.push({
|
|
145
|
-
key: t,
|
|
146
|
-
message: `options[${i}] must be a string`
|
|
147
|
-
});
|
|
148
|
-
typeof r.value != "string" ? e.push({ key: t, message: 'value must be a string for type "enum"' }) : Array.isArray(r.options) && !r.options.includes(r.value) && e.push({
|
|
149
|
-
key: t,
|
|
150
|
-
message: `value "${r.value}" is not in options: [${r.options.join(", ")}]`
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
r.group !== void 0 && typeof r.group != "string" && e.push({ key: t, message: "group must be a string" });
|
|
154
|
-
}
|
|
155
|
-
if (e.length > 0)
|
|
156
|
-
throw new p(
|
|
157
|
-
`AIConfig validation failed with ${e.length} error(s)`,
|
|
158
|
-
e
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
function R(n) {
|
|
162
|
-
let e;
|
|
163
|
-
try {
|
|
164
|
-
e = JSON.parse(n);
|
|
165
|
-
} catch (s) {
|
|
166
|
-
throw new p("Invalid JSON", [
|
|
167
|
-
{
|
|
168
|
-
key: "",
|
|
169
|
-
message: `JSON parse error: ${s instanceof Error ? s.message : String(s)}`
|
|
170
|
-
}
|
|
171
|
-
]);
|
|
172
|
-
}
|
|
173
|
-
return g(e), e;
|
|
174
|
-
}
|
|
175
|
-
function U(n) {
|
|
176
|
-
return g(n), n;
|
|
177
|
-
}
|
|
178
|
-
function T(n, e) {
|
|
179
|
-
const s = n[e];
|
|
180
|
-
if (!s)
|
|
181
|
-
throw new Error(`AIConfig key "${e}" not found`);
|
|
182
|
-
return s.value;
|
|
183
|
-
}
|
|
184
|
-
function $(n) {
|
|
185
|
-
if (!(typeof window > "u"))
|
|
186
|
-
try {
|
|
187
|
-
const e = window.webkit?.messageHandlers?.aippyListener;
|
|
188
|
-
if (e)
|
|
189
|
-
try {
|
|
190
|
-
const s = {
|
|
191
|
-
command: "ai.initialize",
|
|
192
|
-
parameters: JSON.stringify(n)
|
|
193
|
-
};
|
|
194
|
-
e.postMessage(s);
|
|
195
|
-
} catch (s) {
|
|
196
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to iOS app:", s);
|
|
197
|
-
}
|
|
198
|
-
if (window.parent && window.parent !== window)
|
|
199
|
-
try {
|
|
200
|
-
const s = {
|
|
201
|
-
type: "ai.initialize",
|
|
202
|
-
config: JSON.stringify(n)
|
|
203
|
-
};
|
|
204
|
-
window.parent.postMessage(s, "*");
|
|
205
|
-
} catch (s) {
|
|
206
|
-
console.warn("❌ [Aippy AI Config] Failed to send config to parent window:", s);
|
|
207
|
-
}
|
|
208
|
-
} catch (e) {
|
|
209
|
-
console.warn("⚠️ [Aippy AI Config] Failed to send config:", e);
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
function B(n) {
|
|
213
|
-
const e = U(n);
|
|
214
|
-
return $(e), new Proxy({}, {
|
|
215
|
-
get(s, t) {
|
|
216
|
-
if (typeof t == "string")
|
|
217
|
-
try {
|
|
218
|
-
return T(e, t);
|
|
219
|
-
} catch {
|
|
220
|
-
return;
|
|
221
|
-
}
|
|
222
|
-
},
|
|
223
|
-
has(s, t) {
|
|
224
|
-
return typeof t != "string" ? !1 : t in e;
|
|
225
|
-
},
|
|
226
|
-
ownKeys(s) {
|
|
227
|
-
return Object.keys(e);
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
export {
|
|
232
|
-
p as A,
|
|
233
|
-
h as D,
|
|
234
|
-
_ as U,
|
|
235
|
-
N as a,
|
|
236
|
-
D as b,
|
|
237
|
-
b as c,
|
|
238
|
-
A as d,
|
|
239
|
-
w as e,
|
|
240
|
-
B as f,
|
|
241
|
-
T as g,
|
|
242
|
-
U as l,
|
|
243
|
-
C as n,
|
|
244
|
-
R as p,
|
|
245
|
-
$ as s,
|
|
246
|
-
g as v
|
|
247
|
-
};
|
package/dist/hooks-CE9cjXHP.js
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { useState as l, useEffect as c } from "react";
|
|
2
|
-
let n = null, r = null;
|
|
3
|
-
function U() {
|
|
4
|
-
const [s, i] = l(n || {
|
|
5
|
-
avatar: "",
|
|
6
|
-
nickName: "用户",
|
|
7
|
-
username: "",
|
|
8
|
-
uid: ""
|
|
9
|
-
});
|
|
10
|
-
return c(() => {
|
|
11
|
-
let t = !0;
|
|
12
|
-
return (async () => {
|
|
13
|
-
try {
|
|
14
|
-
if (n) {
|
|
15
|
-
t && i(n);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (r) {
|
|
19
|
-
await r, t && n && i(n);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
r = (async () => {
|
|
23
|
-
const { getUserInfoAsync: a, getUserInfoFromParent: o, isInIframe: f } = await import("./bridge-Ca3H2iN1.js"), { hasNativeBridge: u } = await import("./native-bridge-BnvipFJc.js");
|
|
24
|
-
let e = null;
|
|
25
|
-
u() ? e = await a() : f() ? e = await o() : e = await a(), e && (n = {
|
|
26
|
-
avatar: String(e.avatar || e.photoUrl || ""),
|
|
27
|
-
nickName: String(e.nickName || e.displayName || "用户"),
|
|
28
|
-
username: String(e.username || ""),
|
|
29
|
-
uid: String(e.uid || "")
|
|
30
|
-
});
|
|
31
|
-
})(), await r, r = null, t && n && i(n);
|
|
32
|
-
} catch (a) {
|
|
33
|
-
console.error("[useUserInfo] Failed:", a), r = null;
|
|
34
|
-
}
|
|
35
|
-
})(), () => {
|
|
36
|
-
t = !1;
|
|
37
|
-
};
|
|
38
|
-
}, []), s;
|
|
39
|
-
}
|
|
40
|
-
function d() {
|
|
41
|
-
n = null, r = null;
|
|
42
|
-
}
|
|
43
|
-
export {
|
|
44
|
-
d as c,
|
|
45
|
-
U as u
|
|
46
|
-
};
|