@aippy/runtime 0.2.7-dev.6 → 0.2.7-dev.8
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/{app-version-checker-GLONqMxq.js → app-version-checker-Bz7FrEZz.js} +70 -52
- package/dist/{bridge-BKcAlLAd.js → bridge-CqV1iP30.js} +51 -51
- package/dist/{container-message-WJolNXso.js → container-message-C14NWxTG.js} +2 -2
- package/dist/core/errors.d.ts +22 -3
- package/dist/core/index.js +14 -12
- package/dist/device/index.js +194 -194
- package/dist/errors-B3bDbQbD.js +40 -0
- package/dist/{helper-yKJ_6uB-.js → helper-CCP_kta2.js} +63 -65
- package/dist/{hooks-DgadJdiM.js → hooks-Dmr_Dcnz.js} +1 -1
- package/dist/index/index.js +82 -81
- package/dist/pwa-C5nXU0DN.js +250 -0
- package/dist/tweaks/index.js +1 -1
- package/dist/{useTweaks-QxMRmg7i.js → useTweaks-B7Muzo78.js} +10 -9
- package/dist/user/index.js +3 -3
- package/dist/utils/index.js +2 -2
- package/dist/utils/ui.d.ts +3 -1
- package/package.json +1 -1
- package/dist/errors-CDEBaBxB.js +0 -26
- package/dist/pwa-CilSlaik.js +0 -249
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export type { AIConfig, AIConfigValue, AIConfigItem, NumberAIConfigItem, BooleanAIConfigItem, TextAIConfigItem, EnumAIConfigItem, AIConfigError, } from './types';
|
|
8
8
|
export type { AIConfigValues } from './helper';
|
|
9
|
-
export {
|
|
9
|
+
export { validateAIConfig, parseAIConfig, loadAIConfig, getAIConfigValue, } from './parser';
|
|
10
10
|
export { sendAIConfigToContainer } from './bridge';
|
|
11
11
|
export { createAIConfig } from './helper';
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { AIConfig
|
|
2
|
-
/**
|
|
3
|
-
* Custom error class for AI configuration validation failures
|
|
4
|
-
*/
|
|
5
|
-
export declare class AIConfigValidationError extends Error {
|
|
6
|
-
readonly errors: AIConfigError[];
|
|
7
|
-
constructor(message: string, errors: AIConfigError[]);
|
|
8
|
-
}
|
|
1
|
+
import { AIConfig } from './types';
|
|
9
2
|
/**
|
|
10
3
|
* Validates an AI configuration object
|
|
11
4
|
*
|
|
12
5
|
* @param config - The configuration object to validate
|
|
13
|
-
* @throws {
|
|
6
|
+
* @throws {AippyRuntimeError} If validation fails
|
|
14
7
|
*/
|
|
15
8
|
export declare function validateAIConfig(config: unknown): asserts config is AIConfig;
|
|
16
9
|
/**
|
|
@@ -18,7 +11,7 @@ export declare function validateAIConfig(config: unknown): asserts config is AIC
|
|
|
18
11
|
*
|
|
19
12
|
* @param json - JSON string to parse
|
|
20
13
|
* @returns Validated AIConfig object
|
|
21
|
-
* @throws {
|
|
14
|
+
* @throws {AippyRuntimeError} If JSON is invalid or validation fails
|
|
22
15
|
*
|
|
23
16
|
* @example
|
|
24
17
|
* ```ts
|
|
@@ -34,7 +27,7 @@ export declare function parseAIConfig(json: string): AIConfig;
|
|
|
34
27
|
*
|
|
35
28
|
* @param config - Configuration object (usually from JSON import)
|
|
36
29
|
* @returns Validated AIConfig object
|
|
37
|
-
* @throws {
|
|
30
|
+
* @throws {AippyRuntimeError} If validation fails
|
|
38
31
|
*
|
|
39
32
|
* @example
|
|
40
33
|
* ```ts
|
|
@@ -49,7 +42,7 @@ export declare function loadAIConfig(config: unknown): AIConfig;
|
|
|
49
42
|
* @param config - The AIConfig object
|
|
50
43
|
* @param key - Configuration key to retrieve
|
|
51
44
|
* @returns The value of the configuration item
|
|
52
|
-
* @throws {
|
|
45
|
+
* @throws {AippyRuntimeError} If the key is not found
|
|
53
46
|
*
|
|
54
47
|
* @example
|
|
55
48
|
* ```ts
|
package/dist/ai/errors.d.ts
CHANGED
|
@@ -2,5 +2,6 @@ import { AISDKError } from 'ai';
|
|
|
2
2
|
/**
|
|
3
3
|
* Normalizes a backend error response into an AISDKError.
|
|
4
4
|
* Extracts and sends appMessage to container if present in the error response.
|
|
5
|
+
* Uses [Aippy Runtime] prefix - these errors are NOT reported to LLM.
|
|
5
6
|
*/
|
|
6
7
|
export declare function normalizeError(response: Response, body?: unknown): AISDKError;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -41,4 +41,4 @@ export type { AippyOpenAIConfig } from './openai';
|
|
|
41
41
|
export { aippyChatConfig, type AippyUseChatOptions, type AippyUIConfig, type AippyChatConfig, UI_CHAT_ENDPOINT, } from './ui';
|
|
42
42
|
export { DEFAULT_BASE_URL, DEFAULT_UI_BASE_URL, DEFAULT_CHAT_MODEL, DEFAULT_CHAT_SYSTEM, } from './shared';
|
|
43
43
|
export { normalizeError } from './errors';
|
|
44
|
-
export { type AIConfig, type AIConfigValue, type AIConfigItem, type NumberAIConfigItem, type BooleanAIConfigItem, type TextAIConfigItem, type EnumAIConfigItem, type AIConfigError, type AIConfigValues,
|
|
44
|
+
export { type AIConfig, type AIConfigValue, type AIConfigItem, type NumberAIConfigItem, type BooleanAIConfigItem, type TextAIConfigItem, type EnumAIConfigItem, type AIConfigError, type AIConfigValues, validateAIConfig, parseAIConfig, loadAIConfig, getAIConfigValue, sendAIConfigToContainer, createAIConfig, } from './config';
|
package/dist/ai/index.js
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as i, d as r, e, c as n, U as C, a as _, b as E, f as I, g as T, l as f, n as g, p, s as U, v as t } from "../helper-CCP_kta2.js";
|
|
2
2
|
import "react";
|
|
3
|
-
import "../bridge-
|
|
3
|
+
import "../bridge-CqV1iP30.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
r as
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
p as
|
|
17
|
-
t as parseAIConfig,
|
|
5
|
+
i as DEFAULT_BASE_URL,
|
|
6
|
+
r as DEFAULT_CHAT_MODEL,
|
|
7
|
+
e as DEFAULT_CHAT_SYSTEM,
|
|
8
|
+
n as DEFAULT_UI_BASE_URL,
|
|
9
|
+
C as UI_CHAT_ENDPOINT,
|
|
10
|
+
_ as aippyAIProvider,
|
|
11
|
+
E as aippyChatConfig,
|
|
12
|
+
I as createAIConfig,
|
|
13
|
+
T as getAIConfigValue,
|
|
14
|
+
f as loadAIConfig,
|
|
15
|
+
g as normalizeError,
|
|
16
|
+
p as parseAIConfig,
|
|
18
17
|
U as sendAIConfigToContainer,
|
|
19
|
-
|
|
18
|
+
t as validateAIConfig
|
|
20
19
|
};
|
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UAParser as
|
|
5
|
-
import { hasNativeBridge as
|
|
6
|
-
|
|
1
|
+
var w = Object.defineProperty;
|
|
2
|
+
var h = (t, e, n) => e in t ? w(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var u = (t, e, n) => h(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { UAParser as g } from "ua-parser-js";
|
|
5
|
+
import { hasNativeBridge as b } from "./native-bridge-BnvipFJc.js";
|
|
6
|
+
import { c as v, a as x } from "./errors-B3bDbQbD.js";
|
|
7
|
+
function y() {
|
|
7
8
|
try {
|
|
8
9
|
return typeof window < "u" && window.parent !== window;
|
|
9
10
|
} catch {
|
|
10
11
|
return !0;
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function f(t, e) {
|
|
14
15
|
const n = t.split(".").map(Number), r = e.split(".").map(Number), o = Math.max(n.length, r.length);
|
|
15
16
|
for (let i = 0; i < o; i++) {
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
17
|
+
const p = n[i] || 0, s = r[i] || 0;
|
|
18
|
+
if (p < s) return -1;
|
|
19
|
+
if (p > s) return 1;
|
|
19
20
|
}
|
|
20
21
|
return 0;
|
|
21
22
|
}
|
|
22
|
-
class
|
|
23
|
+
class A {
|
|
23
24
|
constructor() {
|
|
24
|
-
|
|
25
|
-
this.parser = new
|
|
25
|
+
u(this, "parser");
|
|
26
|
+
this.parser = new g();
|
|
26
27
|
}
|
|
27
28
|
/**
|
|
28
29
|
* Get platform information
|
|
@@ -104,7 +105,7 @@ class g {
|
|
|
104
105
|
checkAppEnvironment(e) {
|
|
105
106
|
const n = this.parseAippyInfo();
|
|
106
107
|
if (n) {
|
|
107
|
-
const r = e[n.platform], o =
|
|
108
|
+
const r = e[n.platform], o = f(n.version, r) >= 0;
|
|
108
109
|
return {
|
|
109
110
|
type: "new_app",
|
|
110
111
|
isValid: o,
|
|
@@ -112,7 +113,7 @@ class g {
|
|
|
112
113
|
message: o ? void 0 : `App version ${n.version} < ${r}`
|
|
113
114
|
};
|
|
114
115
|
}
|
|
115
|
-
return
|
|
116
|
+
return b() ? {
|
|
116
117
|
type: "old_ios_app",
|
|
117
118
|
isValid: !1,
|
|
118
119
|
message: "Native bridge exists but no Aippy info (old iOS version)"
|
|
@@ -120,7 +121,7 @@ class g {
|
|
|
120
121
|
type: "old_android_app",
|
|
121
122
|
isValid: !1,
|
|
122
123
|
message: "Android WebView detected but no Aippy info (old Android version)"
|
|
123
|
-
} :
|
|
124
|
+
} : y() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
|
|
124
125
|
}
|
|
125
126
|
/**
|
|
126
127
|
* Parse Aippy App info from User-Agent
|
|
@@ -155,35 +156,52 @@ class g {
|
|
|
155
156
|
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
const m = new A(), C = { iOS: "1.6.7", Android: "1.1.8" }, k = { iOS: "1.6.7", Android: "1.1.8" }, d = {
|
|
160
|
+
userCredentials: C,
|
|
161
|
+
userInfo: k
|
|
162
|
+
}, l = "https://cdn.aippy.ai/asset/fd292077086044ee9565bd36ac3a8b78.svg";
|
|
163
|
+
function P() {
|
|
164
|
+
const t = m.parseAippyInfo();
|
|
165
|
+
if (!t) return !1;
|
|
166
|
+
const e = d.userCredentials[t.platform];
|
|
167
|
+
return f(t.version, e) >= 0;
|
|
168
|
+
}
|
|
169
|
+
async function V(t, e = "update") {
|
|
162
170
|
const n = document.createElement("div");
|
|
163
|
-
n.style.cssText = "
|
|
164
|
-
|
|
171
|
+
n.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:12px;display:flex;align-items:flex-end;justify-content:center;z-index:999999;pointer-events:none";
|
|
172
|
+
const r = document.createElement("div");
|
|
173
|
+
r.style.cssText = "background:#323232;border-radius:32px;padding:12px 12px 12px 12px;width:370px;max-width:90%;display:flex;align-items:center;gap:8px;pointer-events:auto";
|
|
174
|
+
let o = !1;
|
|
165
175
|
try {
|
|
166
|
-
|
|
176
|
+
o = (await fetch(l, { method: "HEAD" })).ok;
|
|
167
177
|
} catch {
|
|
168
|
-
|
|
169
|
-
}
|
|
170
|
-
if (
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
}
|
|
174
|
-
const
|
|
175
|
-
|
|
178
|
+
o = !1;
|
|
179
|
+
}
|
|
180
|
+
if (o) {
|
|
181
|
+
const a = document.createElement("img");
|
|
182
|
+
a.src = l, a.style.cssText = "width:36px;height:36px;flex-shrink:0", r.appendChild(a);
|
|
183
|
+
}
|
|
184
|
+
const i = e === "signin" || e === "update" && P(), p = i ? t.replace(/\n/g, "") : t, s = document.createElement("span");
|
|
185
|
+
if (s.style.cssText = "font-size:14px;font-weight:600;color:#fff;line-height:1.4;white-space:pre-line", s.textContent = p, r.appendChild(s), i) {
|
|
186
|
+
const a = e === "signin" ? "Sign in" : "Update", c = document.createElement("button");
|
|
187
|
+
c.style.cssText = "background:#fff;color:#000;font-size:14px;font-weight:600;border:none;border-radius:32px;height:36px;min-width:80px;padding:0 16px;cursor:pointer;flex-shrink:0;white-space:nowrap", c.textContent = a, c.onclick = () => {
|
|
188
|
+
if (e === "signin")
|
|
189
|
+
try {
|
|
190
|
+
window.parent.postMessage({ type: "navigator.appstore" }, "*");
|
|
191
|
+
} catch {
|
|
192
|
+
}
|
|
193
|
+
else
|
|
194
|
+
window.webkit?.messageHandlers?.aippyListener?.postMessage({ command: "navigator.appstore" });
|
|
195
|
+
}, r.appendChild(c);
|
|
196
|
+
}
|
|
197
|
+
n.appendChild(r), document.body.appendChild(n);
|
|
176
198
|
}
|
|
177
|
-
|
|
178
|
-
userCredentials: x,
|
|
179
|
-
userInfo: y
|
|
180
|
-
};
|
|
181
|
-
function A(t) {
|
|
199
|
+
function _(t) {
|
|
182
200
|
const e = d[t];
|
|
183
201
|
return e || (console.warn(`[AppVersionChecker] Unknown feature: ${t}`), { iOS: "999.0.0", Android: "999.0.0" });
|
|
184
202
|
}
|
|
185
|
-
function
|
|
186
|
-
const e =
|
|
203
|
+
function R(t) {
|
|
204
|
+
const e = _(t), n = m.checkAppEnvironment(e), r = n.aippyInfo?.version, o = n.aippyInfo ? e[n.aippyInfo.platform] : void 0;
|
|
187
205
|
switch (n.type) {
|
|
188
206
|
case "new_app":
|
|
189
207
|
return {
|
|
@@ -207,24 +225,24 @@ function C(t) {
|
|
|
207
225
|
};
|
|
208
226
|
}
|
|
209
227
|
}
|
|
210
|
-
function
|
|
211
|
-
const e =
|
|
228
|
+
function L(t) {
|
|
229
|
+
const e = R(t);
|
|
212
230
|
if (!e.supported && (e.envCheck.type === "new_app" || e.envCheck.type === "old_ios_app" || e.envCheck.type === "old_android_app"))
|
|
213
|
-
throw console.warn(`[AppVersionChecker] ${e.message}`),
|
|
214
|
-
Update to view it
|
|
231
|
+
throw console.warn(`[AppVersionChecker] ${e.message}`), V(`This project needs a newer version.
|
|
232
|
+
Update to view it.`, "update"), v(`App version too old: ${e.message}`, x.NOT_SUPPORTED);
|
|
215
233
|
return e;
|
|
216
234
|
}
|
|
217
|
-
function
|
|
235
|
+
function M() {
|
|
218
236
|
return Object.keys(d);
|
|
219
237
|
}
|
|
220
238
|
export {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
239
|
+
A as P,
|
|
240
|
+
R as a,
|
|
241
|
+
M as b,
|
|
242
|
+
f as c,
|
|
243
|
+
_ as g,
|
|
244
|
+
y as i,
|
|
245
|
+
m as p,
|
|
246
|
+
L as r,
|
|
247
|
+
V as s
|
|
230
248
|
};
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import { r as
|
|
1
|
+
import { a as U } from "./runtime-CmoG3v2m.js";
|
|
2
|
+
import { r as v, s as L, i as p } from "./app-version-checker-Bz7FrEZz.js";
|
|
3
|
+
import { c as B, a as I } from "./errors-B3bDbQbD.js";
|
|
3
4
|
const f = {
|
|
4
5
|
apiBaseUrl: "https://api.aippy.dev/api",
|
|
5
6
|
authToken: "",
|
|
6
7
|
currentUserId: null
|
|
7
8
|
};
|
|
8
|
-
function
|
|
9
|
+
function E(n) {
|
|
9
10
|
Object.assign(f, n);
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function R(n) {
|
|
12
13
|
f.authToken = n;
|
|
13
14
|
}
|
|
14
15
|
function q(n) {
|
|
15
16
|
f.currentUserId = n;
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
let
|
|
18
|
+
const k = 3e3, T = 50, g = 500, c = { uid: "", token: "" };
|
|
19
|
+
let l = null, u = !1, a = null, t = null;
|
|
19
20
|
function w(n) {
|
|
20
21
|
if (!n || typeof n != "object") return null;
|
|
21
22
|
let e = n;
|
|
@@ -26,7 +27,7 @@ function w(n) {
|
|
|
26
27
|
const r = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl;
|
|
27
28
|
if (!r || !o) return null;
|
|
28
29
|
const i = { uid: String(r), token: o, apiBaseUrl: s };
|
|
29
|
-
return q(i.uid),
|
|
30
|
+
return q(i.uid), R(o), s && E({ apiBaseUrl: s }), i;
|
|
30
31
|
}
|
|
31
32
|
function m(n) {
|
|
32
33
|
if (console.log("🔄 [Bridge] processUserInfoData called with:", n), !n || typeof n != "object")
|
|
@@ -37,12 +38,12 @@ function m(n) {
|
|
|
37
38
|
if (!r)
|
|
38
39
|
return console.warn("⚠️ [Bridge] No uid found in data"), null;
|
|
39
40
|
const o = { uid: String(r), ...e };
|
|
40
|
-
return console.log("✅ [Bridge] Created userInfo:", o),
|
|
41
|
+
return console.log("✅ [Bridge] Created userInfo:", o), l = o, u = !0, console.log("✅ [Bridge] Cached userInfo, userInfoReceived = true"), o;
|
|
41
42
|
}
|
|
42
43
|
function A(n = g) {
|
|
43
|
-
return console.log("📱 [Bridge] requestCredentialsFromiOS called, timeout:", n),
|
|
44
|
-
const r =
|
|
45
|
-
|
|
44
|
+
return console.log("📱 [Bridge] requestCredentialsFromiOS called, timeout:", n), a ? (console.log("⏳ [Bridge] Pending credentials request exists, waiting..."), new Promise((e) => {
|
|
45
|
+
const r = a.resolve;
|
|
46
|
+
a.resolve = (o) => {
|
|
46
47
|
r(o), e(o);
|
|
47
48
|
};
|
|
48
49
|
})) : new Promise((e) => {
|
|
@@ -52,21 +53,21 @@ function A(n = g) {
|
|
|
52
53
|
hasWebkit: !!window.webkit,
|
|
53
54
|
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
54
55
|
hasAippyListener: !!r
|
|
55
|
-
}), r || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), r = await
|
|
56
|
+
}), r || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), r = await b(1500)), !r) {
|
|
56
57
|
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning empty credentials"), e(c);
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
59
60
|
const o = setTimeout(() => {
|
|
60
|
-
console.warn("⏰ [Bridge] Credentials request TIMEOUT after", n, "ms"),
|
|
61
|
+
console.warn("⏰ [Bridge] Credentials request TIMEOUT after", n, "ms"), a = null, e(c);
|
|
61
62
|
}, n);
|
|
62
|
-
|
|
63
|
+
a = {
|
|
63
64
|
resolve: (s) => {
|
|
64
|
-
console.log("✅ [Bridge] pendingCredentialsRequest.resolve called with:", s), clearTimeout(o),
|
|
65
|
+
console.log("✅ [Bridge] pendingCredentialsRequest.resolve called with:", s), clearTimeout(o), a = null, e(s);
|
|
65
66
|
}
|
|
66
|
-
}, console.log("📱 [Bridge] pendingCredentialsRequest set"),
|
|
67
|
+
}, console.log("📱 [Bridge] pendingCredentialsRequest set"), U.receiveChannel.once("user.credentials", (s) => {
|
|
67
68
|
console.log("📩 [Bridge] Received user.credentials via receiveChannel:", s), clearTimeout(o);
|
|
68
69
|
const i = w(s) || c;
|
|
69
|
-
|
|
70
|
+
a && a.resolve(i);
|
|
70
71
|
});
|
|
71
72
|
try {
|
|
72
73
|
const s = {
|
|
@@ -75,12 +76,12 @@ function A(n = g) {
|
|
|
75
76
|
};
|
|
76
77
|
console.log("📤 [Bridge] Sending credentials request:", s), r.postMessage(s), console.log("📤 [Bridge] Credentials postMessage sent successfully");
|
|
77
78
|
} catch (s) {
|
|
78
|
-
console.error("❌ [Bridge] Failed to send credentials postMessage:", s), clearTimeout(o),
|
|
79
|
+
console.error("❌ [Bridge] Failed to send credentials postMessage:", s), clearTimeout(o), a = null, e(c);
|
|
79
80
|
}
|
|
80
81
|
})();
|
|
81
82
|
});
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function S(n = g) {
|
|
84
85
|
return new Promise((e) => {
|
|
85
86
|
if (!p()) {
|
|
86
87
|
e(c);
|
|
@@ -99,9 +100,9 @@ function E(n = g) {
|
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
102
|
}
|
|
102
|
-
const
|
|
103
|
-
async function
|
|
104
|
-
if (!
|
|
103
|
+
const D = () => /Aippy\/[\d.]+\/\d+\/Android/i.test(navigator.userAgent);
|
|
104
|
+
async function b(n = 1500) {
|
|
105
|
+
if (!D())
|
|
105
106
|
return console.log("📱 [Bridge] Not Android, skipping waitForAippyListener"), window.webkit?.messageHandlers?.aippyListener || null;
|
|
106
107
|
const e = Date.now(), r = 50;
|
|
107
108
|
for (console.log("🤖 [Bridge] Android: Waiting for aippyListener (max", n, "ms)..."); Date.now() - e < n; ) {
|
|
@@ -112,8 +113,8 @@ async function k(n = 1500) {
|
|
|
112
113
|
}
|
|
113
114
|
return console.warn("⏰ [Bridge] aippyListener not available after", n, "ms"), null;
|
|
114
115
|
}
|
|
115
|
-
function
|
|
116
|
-
return console.log("📱 [Bridge] requestUserInfoFromiOS called:", { forceRefresh: n, timeoutMs: e }), console.log("📱 [Bridge] Cache state:", { userInfoReceived: u, cachedUserInfo:
|
|
116
|
+
function O(n = !1, e = g) {
|
|
117
|
+
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) => {
|
|
117
118
|
const o = t.resolve;
|
|
118
119
|
t.resolve = (s) => {
|
|
119
120
|
console.log("⏳ [Bridge] Pending request resolved:", s), o(s), r(s);
|
|
@@ -125,7 +126,7 @@ function S(n = !1, e = g) {
|
|
|
125
126
|
hasWebkit: !!window.webkit,
|
|
126
127
|
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
127
128
|
hasAippyListener: !!o
|
|
128
|
-
}), o || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), o = await
|
|
129
|
+
}), o || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), o = await b(1500)), !o) {
|
|
129
130
|
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning null"), r(null);
|
|
130
131
|
return;
|
|
131
132
|
}
|
|
@@ -135,7 +136,7 @@ function S(n = !1, e = g) {
|
|
|
135
136
|
}, e);
|
|
136
137
|
t = { resolve: (i) => {
|
|
137
138
|
console.log("✅ [Bridge] pendingUserInfoRequest.resolve called with:", i), clearTimeout(s), t = null, r(i);
|
|
138
|
-
} }, console.log("📱 [Bridge] pendingUserInfoRequest set"),
|
|
139
|
+
} }, console.log("📱 [Bridge] pendingUserInfoRequest set"), U.receiveChannel.once("user.info", (i) => {
|
|
139
140
|
console.log("📩 [Bridge] Received user.info via receiveChannel:", i), clearTimeout(s);
|
|
140
141
|
const d = m(i);
|
|
141
142
|
console.log("📩 [Bridge] Processed userInfo:", d), t ? t.resolve(d) : console.warn("⚠️ [Bridge] No pendingUserInfoRequest when receiveChannel fired");
|
|
@@ -152,7 +153,7 @@ function S(n = !1, e = g) {
|
|
|
152
153
|
})();
|
|
153
154
|
});
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function C(n = g) {
|
|
156
157
|
return new Promise((e) => {
|
|
157
158
|
if (!p()) {
|
|
158
159
|
e(null);
|
|
@@ -172,44 +173,43 @@ function T(n = g) {
|
|
|
172
173
|
});
|
|
173
174
|
}
|
|
174
175
|
async function P() {
|
|
175
|
-
const { envCheck: n } =
|
|
176
|
+
const { envCheck: n } = v("userCredentials");
|
|
176
177
|
switch (n.type) {
|
|
177
178
|
case "new_app": {
|
|
178
|
-
const e = await A(
|
|
179
|
-
if (!e?.token) throw
|
|
179
|
+
const e = await A(k);
|
|
180
|
+
if (!e?.token) throw B("Token unavailable in app", I.PERMISSION_DENIED);
|
|
180
181
|
return e.token;
|
|
181
182
|
}
|
|
182
183
|
case "iframe": {
|
|
183
|
-
const e = await
|
|
184
|
+
const e = await S(T);
|
|
184
185
|
if (e?.token) return e.token;
|
|
185
|
-
throw
|
|
186
|
-
Open this project in the app.`), new Error("Token unavailable: User needs to login");
|
|
186
|
+
throw L("Sign in to continue.Open this project in the app.", "signin"), B("Token unavailable: User needs to login", I.PERMISSION_DENIED);
|
|
187
187
|
}
|
|
188
188
|
default:
|
|
189
189
|
return "";
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
|
-
async function
|
|
193
|
-
if (console.log("🔍 [Bridge] getUserInfoAsync called, forceRefresh:", n), console.log("🔍 [Bridge] Current cache state:", { userInfoReceived: u, cachedUserInfo:
|
|
194
|
-
return console.log("✅ [Bridge] Returning cached userInfo"),
|
|
195
|
-
const { envCheck: e } =
|
|
192
|
+
async function _(n = !1) {
|
|
193
|
+
if (console.log("🔍 [Bridge] getUserInfoAsync called, forceRefresh:", n), console.log("🔍 [Bridge] Current cache state:", { userInfoReceived: u, cachedUserInfo: l }), u && l && !n)
|
|
194
|
+
return console.log("✅ [Bridge] Returning cached userInfo"), l;
|
|
195
|
+
const { envCheck: e } = v("userInfo");
|
|
196
196
|
switch (console.log("🔍 [Bridge] Environment check result:", e), e.type) {
|
|
197
197
|
case "new_app":
|
|
198
|
-
return console.log("📱 [Bridge] Detected new_app environment"), await
|
|
198
|
+
return console.log("📱 [Bridge] Detected new_app environment"), await O(n, k);
|
|
199
199
|
case "iframe":
|
|
200
|
-
return console.log("🖼️ [Bridge] Detected iframe environment"), await T
|
|
200
|
+
return console.log("🖼️ [Bridge] Detected iframe environment"), await C(T);
|
|
201
201
|
default:
|
|
202
|
-
return console.log("🌐 [Bridge] Detected web environment, returning cached:",
|
|
202
|
+
return console.log("🌐 [Bridge] Detected web environment, returning cached:", l), l;
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
|
-
async function
|
|
206
|
-
return p() ? await
|
|
205
|
+
async function H(n = g) {
|
|
206
|
+
return p() ? await C(n) : null;
|
|
207
207
|
}
|
|
208
|
-
function
|
|
208
|
+
function y(n) {
|
|
209
209
|
const e = w(n);
|
|
210
|
-
e &&
|
|
210
|
+
e && a && (a.resolve(e), a = null);
|
|
211
211
|
}
|
|
212
|
-
function
|
|
212
|
+
function h(n) {
|
|
213
213
|
console.log("📩 [Bridge] window.processUserInfo called with:", n), console.log("📩 [Bridge] pendingUserInfoRequest exists:", !!t);
|
|
214
214
|
const e = m(n);
|
|
215
215
|
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"));
|
|
@@ -219,8 +219,8 @@ function j() {
|
|
|
219
219
|
console.log("🔧 [Bridge] initUserBridge: window is undefined, skipping");
|
|
220
220
|
return;
|
|
221
221
|
}
|
|
222
|
-
console.log("🔧 [Bridge] initUserBridge: Initializing..."), console.log("🔧 [Bridge] UserAgent:", navigator.userAgent), window.processUserCredentials =
|
|
223
|
-
n.data?.type === "user-credentials" && (console.log("📩 [Bridge] Received postMessage user-credentials:", n.data),
|
|
222
|
+
console.log("🔧 [Bridge] initUserBridge: Initializing..."), console.log("🔧 [Bridge] UserAgent:", navigator.userAgent), window.processUserCredentials = y, window.processUserInfo = h, console.log("🔧 [Bridge] Exposed window.processUserCredentials and window.processUserInfo"), window.addEventListener("message", (n) => {
|
|
223
|
+
n.data?.type === "user-credentials" && (console.log("📩 [Bridge] Received postMessage user-credentials:", n.data), y(n.data)), n.data?.type === "user-info" && (console.log("📩 [Bridge] Received postMessage user-info:", n.data), h(n.data));
|
|
224
224
|
}), console.log("🔧 [Bridge] Added message event listener"), console.log("✅ [Bridge] initUserBridge complete");
|
|
225
225
|
}
|
|
226
226
|
j();
|
|
@@ -229,9 +229,9 @@ P().catch((n) => {
|
|
|
229
229
|
});
|
|
230
230
|
export {
|
|
231
231
|
P as getAuthTokenAsync,
|
|
232
|
-
|
|
233
|
-
|
|
232
|
+
_ as getUserInfoAsync,
|
|
233
|
+
H as getUserInfoFromParent,
|
|
234
234
|
p as isInIframe,
|
|
235
|
-
|
|
236
|
-
|
|
235
|
+
y as processUserCredentials,
|
|
236
|
+
h as processUserInfo
|
|
237
237
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "react";
|
|
2
|
-
import { getAuthTokenAsync as a } from "./bridge-
|
|
3
|
-
const r = "0.2.7-dev.
|
|
2
|
+
import { getAuthTokenAsync as a } from "./bridge-CqV1iP30.js";
|
|
3
|
+
const r = "0.2.7-dev.8", i = {
|
|
4
4
|
version: r
|
|
5
5
|
}, o = i.version, c = "@aippy/runtime";
|
|
6
6
|
function w() {
|
package/dist/core/errors.d.ts
CHANGED
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
import { AippyError } from './types';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Error prefix constants
|
|
4
|
+
* - RUNTIME: SDK internal errors (network, auth, permissions), NOT reported to LLM
|
|
5
|
+
* - CODE: Code-related errors (config validation, type errors), WILL be reported to LLM
|
|
6
|
+
*/
|
|
7
|
+
export declare const ERROR_PREFIX: {
|
|
8
|
+
readonly RUNTIME: "[Aippy Runtime]";
|
|
9
|
+
readonly CODE: "[Aippy Error]";
|
|
10
|
+
};
|
|
11
|
+
export type ErrorPrefix = typeof ERROR_PREFIX[keyof typeof ERROR_PREFIX];
|
|
12
|
+
/**
|
|
13
|
+
* Custom error class for Aippy Runtime SDK
|
|
4
14
|
*/
|
|
5
15
|
export declare class AippyRuntimeError extends Error implements AippyError {
|
|
6
16
|
readonly code: string;
|
|
7
17
|
readonly context?: Record<string, unknown>;
|
|
8
|
-
|
|
18
|
+
readonly prefix: ErrorPrefix;
|
|
19
|
+
constructor(message: string, code?: string, context?: Record<string, unknown>, prefix?: ErrorPrefix);
|
|
9
20
|
}
|
|
10
21
|
/**
|
|
11
22
|
* Common error codes
|
|
@@ -15,9 +26,17 @@ export declare const ERROR_CODES: {
|
|
|
15
26
|
readonly PERMISSION_DENIED: "PERMISSION_DENIED";
|
|
16
27
|
readonly INVALID_CONFIG: "INVALID_CONFIG";
|
|
17
28
|
readonly NETWORK_ERROR: "NETWORK_ERROR";
|
|
29
|
+
readonly TIMEOUT: "TIMEOUT";
|
|
30
|
+
readonly OPERATION_FAILED: "OPERATION_FAILED";
|
|
18
31
|
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
19
32
|
};
|
|
20
33
|
/**
|
|
21
|
-
* Create a
|
|
34
|
+
* Create a runtime error (NOT reported to LLM)
|
|
35
|
+
* Use for: network errors, auth errors, permission denied, API not supported
|
|
22
36
|
*/
|
|
23
37
|
export declare function createError(message: string, code?: keyof typeof ERROR_CODES, context?: Record<string, unknown>): AippyRuntimeError;
|
|
38
|
+
/**
|
|
39
|
+
* Create a code-related error (WILL be reported to LLM)
|
|
40
|
+
* Use for: config validation errors, type errors, missing keys
|
|
41
|
+
*/
|
|
42
|
+
export declare function createCodeError(message: string, code?: keyof typeof ERROR_CODES, context?: Record<string, unknown>): AippyRuntimeError;
|
package/dist/core/index.js
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
import { D as s, g as r, m as o } from "../config-B0A7gHQM.js";
|
|
2
|
-
import { A as p,
|
|
3
|
-
import { S as
|
|
4
|
-
import { A as
|
|
2
|
+
import { A as p, a as t, E as i, b as R, c as E } from "../errors-B3bDbQbD.js";
|
|
3
|
+
import { S as m, V as A, c as C, a as g, g as f, s as y } from "../container-message-C14NWxTG.js";
|
|
4
|
+
import { A as O, C as d, R as l, a as x, p as F } from "../runtime-CmoG3v2m.js";
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
O as AippyRuntime,
|
|
7
7
|
p as AippyRuntimeError,
|
|
8
|
-
|
|
8
|
+
d as Cancellable,
|
|
9
9
|
s as DEFAULT_CONFIG,
|
|
10
10
|
t as ERROR_CODES,
|
|
11
|
+
i as ERROR_PREFIX,
|
|
11
12
|
l as ReceiveChannel,
|
|
12
|
-
|
|
13
|
+
m as SDK_NAME,
|
|
13
14
|
A as VERSION,
|
|
14
15
|
x as aippyRuntime,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
C as createAippyHeaders,
|
|
17
|
+
g as createAippyHeadersAsync,
|
|
18
|
+
R as createCodeError,
|
|
19
|
+
E as createError,
|
|
18
20
|
r as getConfigFromEnv,
|
|
19
|
-
|
|
21
|
+
f as getVersionInfo,
|
|
20
22
|
o as mergeConfig,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
F as processMotionData,
|
|
24
|
+
y as sendMessageToContainer
|
|
23
25
|
};
|