@aippy/runtime 0.2.5-dev.0 โ 0.2.6-dev.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 +34 -0
- package/dist/ai/errors.d.ts +21 -0
- package/dist/ai/index.d.ts +45 -0
- package/dist/ai/index.js +20 -0
- package/dist/ai/openai/index.d.ts +11 -0
- package/dist/ai/openai/provider.d.ts +51 -0
- package/dist/ai/shared/config.d.ts +50 -0
- package/dist/ai/shared/index.d.ts +5 -0
- package/dist/ai/ui/config.d.ts +81 -0
- package/dist/ai/ui/endpoints.d.ts +16 -0
- package/dist/ai/ui/index.d.ts +15 -0
- package/dist/ai/ui/types.d.ts +46 -0
- package/dist/ai.d.ts +2 -0
- package/dist/bridge-DdAH4txB.js +222 -0
- package/dist/core/index.js +15 -14
- package/dist/core/native-bridge.d.ts +9 -0
- package/dist/device/index.js +138 -107
- package/dist/device/sensors.d.ts +56 -8
- package/dist/errors-3xwlPAB-.js +148 -0
- package/dist/errors-CDEBaBxB.js +26 -0
- package/dist/index/index.js +93 -47
- package/dist/index.d.ts +2 -0
- package/dist/leaderboard/index.js +18 -22
- package/dist/leaderboard/types.d.ts +0 -2
- package/dist/native-bridge-JAmH-zTN.js +6 -0
- package/dist/{runtime-DjBdOttl.js โ runtime-CmoG3v2m.js} +55 -76
- package/dist/user/api.d.ts +9 -0
- package/dist/user/bridge.d.ts +80 -0
- package/dist/user/config.d.ts +21 -0
- package/dist/user/hooks.d.ts +38 -0
- package/dist/user/index.d.ts +11 -0
- package/dist/user/index.js +28 -0
- package/dist/user/types.d.ts +111 -0
- package/dist/user/userSessionInfo.d.ts +6 -0
- package/dist/user.d.ts +2 -0
- package/dist/userSessionInfo-CBk9ywXi.js +186 -0
- package/package.json +25 -12
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createOpenAICompatible as A } from "@ai-sdk/openai-compatible";
|
|
2
|
+
import "react";
|
|
3
|
+
import { h as i } from "./bridge-DdAH4txB.js";
|
|
4
|
+
import { DefaultChatTransport as f, AISDKError as n } from "ai";
|
|
5
|
+
const m = "https://api.aippy.dev", l = `${m}/api/aisdk/v1/`, d = `${m}/api/aisdk/v1/ui/`, g = "gpt-5", _ = "";
|
|
6
|
+
function h(e = {}) {
|
|
7
|
+
return {
|
|
8
|
+
baseUrl: e.baseUrl ?? l
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function u(e = {}) {
|
|
12
|
+
return {
|
|
13
|
+
baseUrl: e.baseUrl ?? d
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
const y = [
|
|
17
|
+
"gpt-image-1",
|
|
18
|
+
"gpt-image-1-mini",
|
|
19
|
+
"gpt-image-1.5"
|
|
20
|
+
];
|
|
21
|
+
function U(e) {
|
|
22
|
+
try {
|
|
23
|
+
const r = JSON.parse(e);
|
|
24
|
+
if (r.model && y.some((t) => r.model.startsWith(t))) {
|
|
25
|
+
const { response_format: t, ...s } = r;
|
|
26
|
+
return JSON.stringify(s);
|
|
27
|
+
}
|
|
28
|
+
} catch {
|
|
29
|
+
}
|
|
30
|
+
return e;
|
|
31
|
+
}
|
|
32
|
+
function w(e = {}) {
|
|
33
|
+
const { baseUrl: r } = h(e);
|
|
34
|
+
return A({
|
|
35
|
+
name: "aippy",
|
|
36
|
+
baseURL: r,
|
|
37
|
+
fetch: async (s, a) => {
|
|
38
|
+
const o = await i(), c = new Headers(a?.headers);
|
|
39
|
+
c.set("Authorization", `Bearer ${o}`);
|
|
40
|
+
let p = a;
|
|
41
|
+
return s.toString().includes("/images/generations") && a?.method?.toUpperCase() === "POST" && a?.body && (p = {
|
|
42
|
+
...a,
|
|
43
|
+
body: U(a.body)
|
|
44
|
+
}), globalThis.fetch(s, {
|
|
45
|
+
...p,
|
|
46
|
+
headers: c
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
const I = "/chat", T = "/completion", E = "/object";
|
|
52
|
+
async function C(e = {}) {
|
|
53
|
+
const { baseUrl: r } = u(e), t = await i(), s = e.model ?? g, a = e.system ?? _, o = e.api ?? `${r}${I}`, c = { Authorization: `Bearer ${t}` }, p = { model: s, system: a };
|
|
54
|
+
return {
|
|
55
|
+
transport: new f({
|
|
56
|
+
api: o,
|
|
57
|
+
headers: c,
|
|
58
|
+
body: p
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
async function N(e = {}) {
|
|
63
|
+
const { baseUrl: r } = u(e), t = await i();
|
|
64
|
+
return {
|
|
65
|
+
api: `${r}${T}`,
|
|
66
|
+
headers: { Authorization: `Bearer ${t}` }
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
async function k(e) {
|
|
70
|
+
const { schemaId: r, ...t } = e, { baseUrl: s } = u(t), a = await i();
|
|
71
|
+
return {
|
|
72
|
+
api: `${s}${E}`,
|
|
73
|
+
headers: { Authorization: `Bearer ${a}` },
|
|
74
|
+
schemaId: r
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
async function B(e = {}) {
|
|
78
|
+
const { baseUrl: r } = u(e), t = await i();
|
|
79
|
+
return {
|
|
80
|
+
api: `${r}${E}`,
|
|
81
|
+
headers: { Authorization: `Bearer ${t}` }
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function D(e, r) {
|
|
85
|
+
const t = e.status;
|
|
86
|
+
if (r && typeof r == "object" && "error" in r) {
|
|
87
|
+
const s = r, a = s.error.code, o = a != null ? `AippyAIError_${a}` : `AippyAIError_${t}`;
|
|
88
|
+
return new n({
|
|
89
|
+
name: o,
|
|
90
|
+
message: s.error.message,
|
|
91
|
+
cause: {
|
|
92
|
+
type: s.error.type ?? void 0,
|
|
93
|
+
param: s.error.param ?? void 0,
|
|
94
|
+
status: t
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
return new n({
|
|
99
|
+
name: `AippyAIError_${t}`,
|
|
100
|
+
message: `Request failed with status ${t}`,
|
|
101
|
+
cause: { status: t }
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
function L() {
|
|
105
|
+
return new n({
|
|
106
|
+
name: "AippyAIError_MISSING_TOKEN",
|
|
107
|
+
message: "User token is required. Ensure user credentials are available via initUserBridge()."
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
function v() {
|
|
111
|
+
return new n({
|
|
112
|
+
name: "AippyAIError_REQUEST_ABORTED",
|
|
113
|
+
message: "Request was aborted"
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function F(e) {
|
|
117
|
+
const r = e instanceof Error ? e.message : "Network request failed";
|
|
118
|
+
return new n({
|
|
119
|
+
name: "AippyAIError_NETWORK_ERROR",
|
|
120
|
+
message: r,
|
|
121
|
+
cause: e instanceof Error ? e : String(e)
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function P(e) {
|
|
125
|
+
return new n({
|
|
126
|
+
name: "AippyAIError_PARSE_ERROR",
|
|
127
|
+
message: `Failed to parse response: ${e}`
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
export {
|
|
131
|
+
l as D,
|
|
132
|
+
I as U,
|
|
133
|
+
w as a,
|
|
134
|
+
C as b,
|
|
135
|
+
N as c,
|
|
136
|
+
k as d,
|
|
137
|
+
B as e,
|
|
138
|
+
T as f,
|
|
139
|
+
E as g,
|
|
140
|
+
d as h,
|
|
141
|
+
g as i,
|
|
142
|
+
_ as j,
|
|
143
|
+
v as k,
|
|
144
|
+
F as l,
|
|
145
|
+
L as m,
|
|
146
|
+
D as n,
|
|
147
|
+
P as p
|
|
148
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
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/index/index.js
CHANGED
|
@@ -1,55 +1,101 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { a as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
1
|
+
import { DEFAULT_CONFIG as r, SDK_NAME as s, VERSION as o, getConfigFromEnv as t, getVersionInfo as i, mergeConfig as n } from "../core/index.js";
|
|
2
|
+
import { A as m, E as d, c as u } from "../errors-CDEBaBxB.js";
|
|
3
|
+
import { A as C, C as c, R as E, a as l, p as A } from "../runtime-CmoG3v2m.js";
|
|
4
|
+
import { CameraAPI as I, FileSystemAPI as U, GeolocationAPI as S, SensorsAPI as T, camera as P, fileSystem as y, geolocation as h, isMotionSupported as _, isOrientationSupported as O, requestMotionPermission as D, sensors as x, vibrate as R, watchMotion as k, watchOrientation as M } from "../device/index.js";
|
|
5
|
+
import { c as F, a as N, P as L, b as B, p as v, d as w } from "../pwa-8DGmPqLV.js";
|
|
6
|
+
import { a as H, b as j } from "../useTweaks-QxMRmg7i.js";
|
|
7
|
+
import { c as Q, a as V, b as J, i as z, p as K, u as W } from "../useAudioContext-CNQQSTab.js";
|
|
8
|
+
import { reportScore as X, sendEvent as Z, updateScore as $ } from "../leaderboard/index.js";
|
|
9
|
+
import { D as ae, i as re, j as se, h as oe, U as te, f as ie, g as ne, k as pe, a as me, b as de, c as ue, e as fe, d as Ce, m as ce, l as Ee, n as le, p as Ae } from "../errors-3xwlPAB-.js";
|
|
10
|
+
import { f as Ie, b as Ue, h as Se, l as Te, j as Pe, g as ye, k as he, e as _e, i as Oe, c as De, d as xe, r as Re, s as ke, a as Me, t as be } from "../bridge-DdAH4txB.js";
|
|
11
|
+
import { e as Ne, f as Le, g as Be, a as ve, u as we, b as Ge, d as He, c as je, h as qe } from "../userSessionInfo-CBk9ywXi.js";
|
|
12
|
+
import { h as Ve } from "../native-bridge-JAmH-zTN.js";
|
|
8
13
|
export {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
C as AippyRuntime,
|
|
15
|
+
m as AippyRuntimeError,
|
|
16
|
+
I as CameraAPI,
|
|
17
|
+
c as Cancellable,
|
|
18
|
+
ae as DEFAULT_BASE_URL,
|
|
19
|
+
re as DEFAULT_CHAT_MODEL,
|
|
20
|
+
se as DEFAULT_CHAT_SYSTEM,
|
|
21
|
+
r as DEFAULT_CONFIG,
|
|
22
|
+
oe as DEFAULT_UI_BASE_URL,
|
|
23
|
+
d as ERROR_CODES,
|
|
24
|
+
U as FileSystemAPI,
|
|
25
|
+
S as GeolocationAPI,
|
|
26
|
+
F as PWAUtils,
|
|
27
|
+
N as PerformanceMonitor,
|
|
28
|
+
L as PlatformDetector,
|
|
29
|
+
E as ReceiveChannel,
|
|
30
|
+
s as SDK_NAME,
|
|
31
|
+
T as SensorsAPI,
|
|
32
|
+
te as UI_CHAT_ENDPOINT,
|
|
33
|
+
ie as UI_COMPLETION_ENDPOINT,
|
|
34
|
+
ne as UI_OBJECT_ENDPOINT,
|
|
35
|
+
o as VERSION,
|
|
36
|
+
pe as abortedError,
|
|
37
|
+
me as aippy,
|
|
38
|
+
de as aippyChatConfig,
|
|
39
|
+
ue as aippyCompletionConfig,
|
|
40
|
+
fe as aippyObjectBaseConfig,
|
|
41
|
+
Ce as aippyObjectConfig,
|
|
24
42
|
l as aippyRuntime,
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
H as aippyTweaks,
|
|
44
|
+
j as aippyTweaksRuntime,
|
|
45
|
+
Ie as autoRequestCredentials,
|
|
27
46
|
P as camera,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
47
|
+
Ne as clearProfileCache,
|
|
48
|
+
u as createError,
|
|
49
|
+
Q as createHiddenMediaElement,
|
|
50
|
+
V as createHiddenVideoElement,
|
|
51
|
+
Le as fetchUserProfile,
|
|
52
|
+
y as fileSystem,
|
|
53
|
+
h as geolocation,
|
|
54
|
+
Ue as getAuthToken,
|
|
55
|
+
Se as getAuthTokenAsync,
|
|
56
|
+
Te as getCachedCredentials,
|
|
57
|
+
t as getConfigFromEnv,
|
|
58
|
+
Be as getCurrentUserId,
|
|
59
|
+
Pe as getCurrentUserIdAsync,
|
|
60
|
+
ye as getUserSdkConfig,
|
|
61
|
+
i as getVersionInfo,
|
|
62
|
+
he as hasCredentials,
|
|
63
|
+
Ve as hasNativeBridge,
|
|
64
|
+
_e as initUserBridge,
|
|
65
|
+
Oe as initUserSdk,
|
|
66
|
+
J as isIOSDevice,
|
|
67
|
+
De as isInIframe,
|
|
37
68
|
z as isMediaStreamAudioSupported,
|
|
38
|
-
|
|
39
|
-
|
|
69
|
+
_ as isMotionSupported,
|
|
70
|
+
O as isOrientationSupported,
|
|
40
71
|
n as mergeConfig,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
v as
|
|
72
|
+
ce as missingTokenError,
|
|
73
|
+
Ee as networkError,
|
|
74
|
+
le as normalizeError,
|
|
75
|
+
Ae as parseError,
|
|
76
|
+
K as patchAudioContext,
|
|
77
|
+
B as performanceMonitor,
|
|
78
|
+
v as platform,
|
|
79
|
+
A as processMotionData,
|
|
80
|
+
w as pwa,
|
|
81
|
+
X as reportScore,
|
|
82
|
+
xe as requestCredentialsFromParent,
|
|
83
|
+
Re as requestCredentialsFromiOS,
|
|
84
|
+
D as requestMotionPermission,
|
|
48
85
|
Z as sendEvent,
|
|
49
|
-
|
|
86
|
+
x as sensors,
|
|
87
|
+
ke as setAuthToken,
|
|
88
|
+
Me as setCurrentUserId,
|
|
89
|
+
be as tryGetCredentialsFromParentStorage,
|
|
50
90
|
$ as updateScore,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
91
|
+
W as useAudioContext,
|
|
92
|
+
ve as useAuthToken,
|
|
93
|
+
we as useCurrentUserId,
|
|
94
|
+
Ge as useGetCurrentUserProfileQuery,
|
|
95
|
+
He as useGetJoinedUserProfilesQuery,
|
|
96
|
+
je as useGetUserProfileByIdQuery,
|
|
97
|
+
qe as userSessionInfo,
|
|
98
|
+
R as vibrate,
|
|
99
|
+
k as watchMotion,
|
|
100
|
+
M as watchOrientation
|
|
55
101
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,46 +1,42 @@
|
|
|
1
1
|
function r(e, o) {
|
|
2
2
|
try {
|
|
3
3
|
if (window.parent && window.parent !== window) {
|
|
4
|
-
const
|
|
4
|
+
const n = {
|
|
5
5
|
__aippyGame: !0,
|
|
6
6
|
payload: e
|
|
7
7
|
};
|
|
8
|
-
window.parent.postMessage(
|
|
8
|
+
window.parent.postMessage(n, "*");
|
|
9
9
|
}
|
|
10
|
-
const
|
|
11
|
-
|
|
10
|
+
const a = window.webkit?.messageHandlers?.aippyListener;
|
|
11
|
+
a && a.postMessage({
|
|
12
12
|
command: o,
|
|
13
13
|
parameters: JSON.stringify(e)
|
|
14
14
|
});
|
|
15
|
-
} catch (
|
|
16
|
-
console.warn("[Aippy Leaderboard] Failed to send game event:",
|
|
15
|
+
} catch (a) {
|
|
16
|
+
console.warn("[Aippy Leaderboard] Failed to send game event:", a);
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
function t(e) {
|
|
20
|
-
|
|
20
|
+
r({
|
|
21
21
|
type: "score",
|
|
22
|
-
score: e
|
|
23
|
-
|
|
24
|
-
};
|
|
25
|
-
r(o, "leaderboard.reportScore"), console.log(`[Aippy Leaderboard] Score reported: ${e}, URL: ${window.location.href}`);
|
|
22
|
+
score: e
|
|
23
|
+
}, "leaderboard.reportScore"), console.log(`[Aippy Leaderboard] Score reported: ${e}`);
|
|
26
24
|
}
|
|
27
|
-
function
|
|
28
|
-
|
|
25
|
+
function p(e) {
|
|
26
|
+
r({
|
|
29
27
|
type: "score",
|
|
30
|
-
score: e
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
r(o, "leaderboard.updateScore"), console.log(`[Aippy Leaderboard] Score updated: ${e}, URL: ${window.location.href}`);
|
|
28
|
+
score: e
|
|
29
|
+
}, "leaderboard.updateScore"), console.log(`[Aippy Leaderboard] Score updated: ${e}`);
|
|
34
30
|
}
|
|
35
|
-
function
|
|
36
|
-
const
|
|
31
|
+
function d(e, o) {
|
|
32
|
+
const a = {
|
|
37
33
|
type: e,
|
|
38
34
|
...o
|
|
39
35
|
};
|
|
40
|
-
r(
|
|
36
|
+
r(a, "leaderboard.event"), console.log(`[Aippy Leaderboard] Event sent: ${e}`, o);
|
|
41
37
|
}
|
|
42
38
|
export {
|
|
43
39
|
t as reportScore,
|
|
44
|
-
|
|
45
|
-
|
|
40
|
+
d as sendEvent,
|
|
41
|
+
p as updateScore
|
|
46
42
|
};
|
|
@@ -9,8 +9,6 @@ export interface ScorePayload {
|
|
|
9
9
|
type: 'score';
|
|
10
10
|
/** The score value */
|
|
11
11
|
score: number;
|
|
12
|
-
/** The URL of the current H5 application */
|
|
13
|
-
url?: string;
|
|
14
12
|
/** Score unit (e.g., 'points', 'coins') */
|
|
15
13
|
unit?: string;
|
|
16
14
|
/** Whether bigger score is better for leaderboard ranking */
|
|
@@ -1,24 +1,6 @@
|
|
|
1
1
|
var u = Object.defineProperty;
|
|
2
|
-
var m = (o, e,
|
|
3
|
-
var r = (o, e,
|
|
4
|
-
class d extends Error {
|
|
5
|
-
constructor(n, i = "AIPPY_ERROR", t) {
|
|
6
|
-
super(n);
|
|
7
|
-
r(this, "code");
|
|
8
|
-
r(this, "context");
|
|
9
|
-
this.name = "AippyRuntimeError", this.code = i, this.context = t;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
const R = {
|
|
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 g(o, e = "UNKNOWN_ERROR", n) {
|
|
20
|
-
return new d(o, R[e], n);
|
|
21
|
-
}
|
|
2
|
+
var m = (o, e, t) => e in o ? u(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var r = (o, e, t) => m(o, typeof e != "symbol" ? e + "" : e, t);
|
|
22
4
|
class a {
|
|
23
5
|
constructor(e) {
|
|
24
6
|
r(this, "cancelled", !1);
|
|
@@ -31,28 +13,28 @@ class a {
|
|
|
31
13
|
return this.cancelled;
|
|
32
14
|
}
|
|
33
15
|
}
|
|
34
|
-
class
|
|
16
|
+
class d {
|
|
35
17
|
constructor() {
|
|
36
18
|
r(this, "listeners", /* @__PURE__ */ new Map());
|
|
37
19
|
}
|
|
38
|
-
addEventListener(e,
|
|
39
|
-
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(
|
|
20
|
+
addEventListener(e, t) {
|
|
21
|
+
this.listeners.has(e) || this.listeners.set(e, []), this.listeners.get(e).push(t);
|
|
40
22
|
}
|
|
41
|
-
removeEventListener(e,
|
|
23
|
+
removeEventListener(e, t) {
|
|
42
24
|
const i = this.listeners.get(e);
|
|
43
25
|
if (i) {
|
|
44
|
-
const
|
|
45
|
-
|
|
26
|
+
const n = i.indexOf(t);
|
|
27
|
+
n > -1 && i.splice(n, 1);
|
|
46
28
|
}
|
|
47
29
|
}
|
|
48
|
-
emit(e,
|
|
30
|
+
emit(e, t) {
|
|
49
31
|
const i = this.listeners.get(e);
|
|
50
|
-
i && i.forEach((
|
|
32
|
+
i && i.forEach((n) => n(t));
|
|
51
33
|
}
|
|
52
34
|
}
|
|
53
|
-
class
|
|
35
|
+
class f {
|
|
54
36
|
constructor() {
|
|
55
|
-
r(this, "emitter", new
|
|
37
|
+
r(this, "emitter", new d());
|
|
56
38
|
}
|
|
57
39
|
/**
|
|
58
40
|
* Emit a message to subscribers
|
|
@@ -63,9 +45,9 @@ class y {
|
|
|
63
45
|
/**
|
|
64
46
|
* Subscribe to messages on a specific endpoint
|
|
65
47
|
*/
|
|
66
|
-
subscribe(e,
|
|
67
|
-
const i = (
|
|
68
|
-
n
|
|
48
|
+
subscribe(e, t) {
|
|
49
|
+
const i = (n) => {
|
|
50
|
+
t(n);
|
|
69
51
|
};
|
|
70
52
|
return this.emitter.addEventListener(e, i), new a(() => {
|
|
71
53
|
this.emitter.removeEventListener(e, i);
|
|
@@ -74,16 +56,16 @@ class y {
|
|
|
74
56
|
/**
|
|
75
57
|
* Subscribe to a single message (auto-unsubscribe after first message)
|
|
76
58
|
*/
|
|
77
|
-
once(e,
|
|
78
|
-
const i = this.subscribe(e, (
|
|
79
|
-
i.cancel(), n
|
|
59
|
+
once(e, t) {
|
|
60
|
+
const i = this.subscribe(e, (n) => {
|
|
61
|
+
i.cancel(), t(n);
|
|
80
62
|
});
|
|
81
63
|
return i;
|
|
82
64
|
}
|
|
83
65
|
}
|
|
84
|
-
class
|
|
66
|
+
class y {
|
|
85
67
|
constructor() {
|
|
86
|
-
r(this, "receiveChannel", new
|
|
68
|
+
r(this, "receiveChannel", new f());
|
|
87
69
|
r(this, "seq", 0);
|
|
88
70
|
r(this, "motionListeners", []);
|
|
89
71
|
r(this, "noListenersWarned", !1);
|
|
@@ -116,9 +98,9 @@ class h {
|
|
|
116
98
|
isTweaksMessage(e) {
|
|
117
99
|
if (typeof e != "object" || e === null || "endpoint" in e || "payload" in e)
|
|
118
100
|
return !1;
|
|
119
|
-
const
|
|
120
|
-
return
|
|
121
|
-
const c = e[
|
|
101
|
+
const t = Object.keys(e);
|
|
102
|
+
return t.length === 0 ? !1 : t.some((n) => {
|
|
103
|
+
const c = e[n];
|
|
122
104
|
return typeof c == "object" && c !== null && "value" in c;
|
|
123
105
|
});
|
|
124
106
|
}
|
|
@@ -129,18 +111,18 @@ class h {
|
|
|
129
111
|
* @param callback - Callback to handle received data
|
|
130
112
|
* @returns Cancellable subscription
|
|
131
113
|
*/
|
|
132
|
-
createSubscription(e,
|
|
133
|
-
const
|
|
134
|
-
command:
|
|
114
|
+
createSubscription(e, t, i) {
|
|
115
|
+
const n = (this.seq++).toString(), c = {
|
|
116
|
+
command: t.command,
|
|
135
117
|
parameters: {
|
|
136
|
-
type:
|
|
118
|
+
type: t.type,
|
|
137
119
|
action: "subscribe",
|
|
138
|
-
endpoint:
|
|
120
|
+
endpoint: n
|
|
139
121
|
}
|
|
140
122
|
};
|
|
141
123
|
console.log("๐จ [Aippy Runtime] Creating subscription with message:", JSON.stringify(c, null, 2));
|
|
142
|
-
const
|
|
143
|
-
if (console.log(`๐ฌ [Aippy Runtime] Received data on endpoint ${
|
|
124
|
+
const p = this.receiveChannel.subscribe(n, (s) => {
|
|
125
|
+
if (console.log(`๐ฌ [Aippy Runtime] Received data on endpoint ${n}:`, s), s.error !== void 0) {
|
|
144
126
|
console.warn("โ ๏ธ [Aippy Runtime] Received error, skipping:", s.error);
|
|
145
127
|
return;
|
|
146
128
|
}
|
|
@@ -152,14 +134,14 @@ class h {
|
|
|
152
134
|
console.error("โ [Aippy Runtime] Failed to send postMessage:", s);
|
|
153
135
|
}
|
|
154
136
|
return new a(() => {
|
|
155
|
-
console.log(`๐ [Aippy Runtime] Unsubscribing from endpoint ${
|
|
137
|
+
console.log(`๐ [Aippy Runtime] Unsubscribing from endpoint ${n}`), p.cancel();
|
|
156
138
|
try {
|
|
157
139
|
const s = {
|
|
158
|
-
command:
|
|
140
|
+
command: t.command,
|
|
159
141
|
parameters: {
|
|
160
|
-
type:
|
|
142
|
+
type: t.type,
|
|
161
143
|
action: "unsubscribe",
|
|
162
|
-
endpoint:
|
|
144
|
+
endpoint: n
|
|
163
145
|
}
|
|
164
146
|
};
|
|
165
147
|
e.postMessage(s), console.log("โ
[Aippy Runtime] Unsubscribe message sent:", s);
|
|
@@ -175,27 +157,27 @@ class h {
|
|
|
175
157
|
*/
|
|
176
158
|
addMotionListener(e) {
|
|
177
159
|
console.log("๐ฌ [Aippy Runtime] addMotionListener called"), this.motionListeners.push(e), console.log(`๐ [Aippy Runtime] Total motion listeners: ${this.motionListeners.length}`);
|
|
178
|
-
const
|
|
179
|
-
if (!
|
|
160
|
+
const t = window.webkit?.messageHandlers?.aippyListener;
|
|
161
|
+
if (!t)
|
|
180
162
|
return console.warn("โ ๏ธ [Aippy Runtime] No webkit message handler found, using fallback mode"), () => {
|
|
181
|
-
const
|
|
182
|
-
|
|
163
|
+
const n = this.motionListeners.indexOf(e);
|
|
164
|
+
n > -1 && this.motionListeners.splice(n, 1);
|
|
183
165
|
};
|
|
184
166
|
console.log("โ
[Aippy Runtime] Webkit handler found, creating subscription");
|
|
185
167
|
const i = this.createSubscription(
|
|
186
|
-
|
|
168
|
+
t,
|
|
187
169
|
{
|
|
188
170
|
command: "navigator.motion",
|
|
189
171
|
type: "motion"
|
|
190
172
|
},
|
|
191
|
-
(
|
|
192
|
-
console.log("๐ฅ [Aippy Runtime] Received motion data from native:",
|
|
173
|
+
(n) => {
|
|
174
|
+
console.log("๐ฅ [Aippy Runtime] Received motion data from native:", n), n.motion && e(n.motion);
|
|
193
175
|
}
|
|
194
176
|
);
|
|
195
177
|
return () => {
|
|
196
178
|
console.log("๐งน [Aippy Runtime] Cleaning up motion listener"), i.cancel();
|
|
197
|
-
const
|
|
198
|
-
|
|
179
|
+
const n = this.motionListeners.indexOf(e);
|
|
180
|
+
n > -1 && this.motionListeners.splice(n, 1);
|
|
199
181
|
};
|
|
200
182
|
}
|
|
201
183
|
/**
|
|
@@ -208,17 +190,17 @@ class h {
|
|
|
208
190
|
this.noListenersWarned || (console.warn("โ ๏ธ [Aippy Runtime] No motion listeners to broadcast to"), this.noListenersWarned = !0);
|
|
209
191
|
return;
|
|
210
192
|
}
|
|
211
|
-
const
|
|
193
|
+
const t = e.motion || e;
|
|
212
194
|
this.motionListeners.forEach((i) => {
|
|
213
195
|
try {
|
|
214
|
-
i(
|
|
215
|
-
} catch (
|
|
216
|
-
console.error("โ ๏ธ [Aippy Runtime] Error in motion listener:",
|
|
196
|
+
i(t);
|
|
197
|
+
} catch (n) {
|
|
198
|
+
console.error("โ ๏ธ [Aippy Runtime] Error in motion listener:", n);
|
|
217
199
|
}
|
|
218
200
|
});
|
|
219
201
|
}
|
|
220
202
|
}
|
|
221
|
-
function
|
|
203
|
+
function h(o) {
|
|
222
204
|
if (!o || typeof o != "object") {
|
|
223
205
|
console.warn("โ ๏ธ [Aippy Runtime] Invalid motion data type:", typeof o);
|
|
224
206
|
return;
|
|
@@ -227,17 +209,14 @@ function w(o) {
|
|
|
227
209
|
console.warn("โ ๏ธ [Aippy Runtime] Motion data missing valid motion field");
|
|
228
210
|
return;
|
|
229
211
|
}
|
|
230
|
-
|
|
212
|
+
l.broadcastMotionData(o);
|
|
231
213
|
}
|
|
232
|
-
const
|
|
233
|
-
typeof window < "u" && (window.aippyRuntime =
|
|
214
|
+
const l = new y();
|
|
215
|
+
typeof window < "u" && (window.aippyRuntime = l, window.processMotionData = h);
|
|
234
216
|
export {
|
|
235
|
-
|
|
217
|
+
y as A,
|
|
236
218
|
a as C,
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
h as
|
|
240
|
-
p as b,
|
|
241
|
-
g as c,
|
|
242
|
-
w as p
|
|
219
|
+
f as R,
|
|
220
|
+
l as a,
|
|
221
|
+
h as p
|
|
243
222
|
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { UserProfile } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch user profile by ID from API
|
|
4
|
+
*/
|
|
5
|
+
export declare function fetchUserProfile(userId: string): Promise<UserProfile | null>;
|
|
6
|
+
/**
|
|
7
|
+
* Clear profile cache
|
|
8
|
+
*/
|
|
9
|
+
export declare function clearProfileCache(userId?: string): void;
|