@aippy/runtime 0.4.1-dev.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 +66 -56
- 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/tweaks/index.js +1 -1
- package/dist/{useTweaks-v5wEZGGm.js → useTweaks-C7BEMpV3.js} +21 -27
- 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 +15 -3
- package/dist/bridge-CtB9L5kL.js +0 -259
- package/dist/container-message-KgL1paGV.js +0 -56
- package/dist/helper-CZqFi-QF.js +0 -241
package/dist/tweaks/index.js
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
var m = (i, e, t) => e in i ?
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var m = (i, e, t) => e in i ? h(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
|
|
3
3
|
var r = (i, e, t) => m(i, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
import { useReducer as
|
|
4
|
+
import { useReducer as g, useEffect as v } from "react";
|
|
5
5
|
import { b as T, a as C } from "./errors-B3bDbQbD.js";
|
|
6
|
-
const I = /* @__PURE__ */ new Set(["number", "color", "boolean", "text"
|
|
7
|
-
function
|
|
6
|
+
const I = /* @__PURE__ */ new Set(["number", "color", "boolean", "text"]), O = /^#(?:[0-9a-f]{3}|[0-9a-f]{4}|[0-9a-f]{6}|[0-9a-f]{8})$/i;
|
|
7
|
+
function R(i) {
|
|
8
8
|
const e = i.value;
|
|
9
|
-
|
|
10
|
-
if (typeof e == "number") return "number";
|
|
11
|
-
if (typeof e == "string") {
|
|
12
|
-
if (O.test(e)) return "color";
|
|
13
|
-
if (R.test(e)) return "image";
|
|
14
|
-
}
|
|
15
|
-
return "text";
|
|
9
|
+
return typeof e == "boolean" ? "boolean" : typeof e == "number" ? "number" : typeof e == "string" && O.test(e) ? "color" : "text";
|
|
16
10
|
}
|
|
17
|
-
function
|
|
11
|
+
function A(i) {
|
|
18
12
|
const e = {};
|
|
19
13
|
for (const [t, n] of Object.entries(i))
|
|
20
14
|
if (I.has(n.type))
|
|
21
15
|
e[t] = n;
|
|
22
16
|
else {
|
|
23
|
-
const a =
|
|
17
|
+
const a = R(n);
|
|
24
18
|
console.warn(
|
|
25
19
|
`⚠️ [Aippy Tweaks] Invalid type "${n.type}" for key "${t}", auto-corrected to "${a}"`
|
|
26
20
|
), e[t] = { ...n, type: a };
|
|
@@ -53,7 +47,7 @@ class k {
|
|
|
53
47
|
});
|
|
54
48
|
}
|
|
55
49
|
}
|
|
56
|
-
class
|
|
50
|
+
class E {
|
|
57
51
|
constructor(e, t) {
|
|
58
52
|
r(this, "values", {});
|
|
59
53
|
r(this, "subject", new k());
|
|
@@ -81,7 +75,7 @@ class S {
|
|
|
81
75
|
}
|
|
82
76
|
// React Hook integration
|
|
83
77
|
useState(e) {
|
|
84
|
-
const [t, n] =
|
|
78
|
+
const [t, n] = g(() => this.getValue(e), this.getValue(e));
|
|
85
79
|
return v(() => {
|
|
86
80
|
const a = this.subject.subscribe((s) => {
|
|
87
81
|
s === e && n();
|
|
@@ -92,7 +86,7 @@ class S {
|
|
|
92
86
|
}, [e]), t;
|
|
93
87
|
}
|
|
94
88
|
}
|
|
95
|
-
class
|
|
89
|
+
class S {
|
|
96
90
|
constructor() {
|
|
97
91
|
r(this, "tweaksInstance", null);
|
|
98
92
|
r(this, "tweaksDidWarn", !1);
|
|
@@ -104,8 +98,8 @@ class N {
|
|
|
104
98
|
tweaks(e) {
|
|
105
99
|
if (this.tweaksInstance)
|
|
106
100
|
return this.tweaksDidWarn || (this.tweaksDidWarn = !0, console.warn("⚠️ [Aippy Tweaks] tweaks() is expected to only be called once, returning previous value")), this.tweaksInstance;
|
|
107
|
-
e =
|
|
108
|
-
const t = new k(), n = new
|
|
101
|
+
e = A(e), this.originalConfig = { ...e };
|
|
102
|
+
const t = new k(), n = new E(t, e), a = {};
|
|
109
103
|
for (const s of Object.keys(e))
|
|
110
104
|
a[s] = {
|
|
111
105
|
useState: () => n.useState(s)
|
|
@@ -173,15 +167,15 @@ class N {
|
|
|
173
167
|
let a = 0;
|
|
174
168
|
for (const [o, c] of Object.entries(e))
|
|
175
169
|
if (c && typeof c == "object" && "value" in c) {
|
|
176
|
-
const
|
|
170
|
+
const p = c, w = this.originalConfig[o];
|
|
177
171
|
if (!w) {
|
|
178
172
|
console.warn(`⚠️ [Aippy Tweaks] Key "${o}" not found in original config, skipping`);
|
|
179
173
|
continue;
|
|
180
174
|
}
|
|
181
175
|
const b = /* @__PURE__ */ new Set(["tweakKey", "valueBefore", "tweaksType", "editType"]), f = { ...w };
|
|
182
|
-
for (const [d, l] of Object.entries(
|
|
176
|
+
for (const [d, l] of Object.entries(p))
|
|
183
177
|
b.has(d) || l != null && (f[d] = l);
|
|
184
|
-
n[o] = f, t[o] =
|
|
178
|
+
n[o] = f, t[o] = p.value, a++;
|
|
185
179
|
}
|
|
186
180
|
if (a === 0) {
|
|
187
181
|
console.warn("⚠️ [Aippy Tweaks] No valid values found in iOS data:", e);
|
|
@@ -197,11 +191,11 @@ class N {
|
|
|
197
191
|
}
|
|
198
192
|
}
|
|
199
193
|
}
|
|
200
|
-
const
|
|
201
|
-
tweaks: (i) =>
|
|
202
|
-
},
|
|
203
|
-
typeof window < "u" && (window.aippyTweaksRuntime = y, window.processNativeData =
|
|
194
|
+
const u = new S(), y = {
|
|
195
|
+
tweaks: (i) => u.tweaks(i)
|
|
196
|
+
}, V = y.tweaks;
|
|
197
|
+
typeof window < "u" && (window.aippyTweaksRuntime = y, window.processNativeData = u.processNativeData.bind(u));
|
|
204
198
|
export {
|
|
205
|
-
|
|
199
|
+
V as a,
|
|
206
200
|
y as b
|
|
207
201
|
};
|
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"
|
|
@@ -67,12 +71,14 @@
|
|
|
67
71
|
"url": "https://discord.com/invite/G94ZAx6gVq"
|
|
68
72
|
},
|
|
69
73
|
"devDependencies": {
|
|
74
|
+
"@ai-sdk/react": "^3.0.210",
|
|
70
75
|
"@eslint/js": "^9.36.0",
|
|
71
76
|
"@types/node": "^24.5.2",
|
|
72
77
|
"@types/react": "^19.2.2",
|
|
73
78
|
"@types/ua-parser-js": "^0.7.39",
|
|
74
79
|
"@typescript-eslint/eslint-plugin": "^8.44.1",
|
|
75
80
|
"@typescript-eslint/parser": "^8.44.1",
|
|
81
|
+
"ai": "^6.0.208",
|
|
76
82
|
"eslint": "^9.36.0",
|
|
77
83
|
"prettier": "^3.6.2",
|
|
78
84
|
"react": "^19.1.1",
|
|
@@ -82,14 +88,20 @@
|
|
|
82
88
|
"zod": "^3.25.76"
|
|
83
89
|
},
|
|
84
90
|
"dependencies": {
|
|
85
|
-
"@ai-sdk/openai-compatible": "^2.0.
|
|
86
|
-
"ai": "^6.0.14",
|
|
91
|
+
"@ai-sdk/openai-compatible": "^2.0.51",
|
|
87
92
|
"ua-parser-js": "^2.0.5"
|
|
88
93
|
},
|
|
89
94
|
"peerDependencies": {
|
|
95
|
+
"@ai-sdk/react": "^3.0.0",
|
|
96
|
+
"ai": "^6.0.0",
|
|
90
97
|
"react": "^19.1.1",
|
|
91
98
|
"typescript": ">=5.0.0"
|
|
92
99
|
},
|
|
100
|
+
"peerDependenciesMeta": {
|
|
101
|
+
"@ai-sdk/react": {
|
|
102
|
+
"optional": true
|
|
103
|
+
}
|
|
104
|
+
},
|
|
93
105
|
"engines": {
|
|
94
106
|
"node": ">=20.0.0",
|
|
95
107
|
"pnpm": ">=10.0.0"
|
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-dev.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
|
-
};
|