@aippy/runtime 0.2.7-dev.4 → 0.2.7-dev.6
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 +3 -3
- package/dist/ai/errors.d.ts +1 -57
- package/dist/ai/index.d.ts +1 -3
- package/dist/ai/index.js +16 -21
- package/dist/ai/shared/fetch.d.ts +2 -25
- package/dist/ai/shared/index.d.ts +1 -1
- package/dist/{ui-y5N62DqC.js → app-version-checker-GLONqMxq.js} +87 -32
- package/dist/audio/index.d.ts +1 -1
- package/dist/audio/index.js +5 -6
- package/dist/audio/utils.d.ts +0 -7
- package/dist/bridge-BKcAlLAd.js +237 -0
- package/dist/config-B0A7gHQM.js +28 -0
- package/dist/container-message-WJolNXso.js +56 -0
- package/dist/core/headers.d.ts +31 -0
- package/dist/core/index.d.ts +1 -0
- package/dist/core/index.js +20 -50
- package/dist/helper-yKJ_6uB-.js +240 -0
- package/dist/hooks-DgadJdiM.js +98 -0
- package/dist/index/index.js +87 -85
- package/dist/url-c26cuIpu.js +7 -0
- package/dist/{useAudioContext-CNQQSTab.js → useAudioContext-D9F3x80Y.js} +38 -42
- 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 +1 -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/helper-CIt1_T-j.js +0 -275
- package/dist/hooks-CE9cjXHP.js +0 -46
package/README.md
CHANGED
|
@@ -93,13 +93,13 @@ button.onclick = async () => {
|
|
|
93
93
|
// Default base URL: https://api.aippy.dev/api/aisdk/v1
|
|
94
94
|
|
|
95
95
|
import { streamText, experimental_generateImage as generateImage } from 'ai';
|
|
96
|
-
import {
|
|
96
|
+
import { aippyAIProvider } from '@aippy/runtime/ai';
|
|
97
97
|
|
|
98
98
|
// Create provider (reads from env vars automatically)
|
|
99
|
-
const provider =
|
|
99
|
+
const provider = aippyAIProvider();
|
|
100
100
|
|
|
101
101
|
// Or override with config
|
|
102
|
-
// const provider =
|
|
102
|
+
// const provider = aippyAIProvider({ baseUrl: '...', userToken: '...' });
|
|
103
103
|
|
|
104
104
|
// Streaming text generation (uses Vercel AI SDK)
|
|
105
105
|
const result = await streamText({
|
package/dist/ai/errors.d.ts
CHANGED
|
@@ -1,62 +1,6 @@
|
|
|
1
1
|
import { AISDKError } from 'ai';
|
|
2
2
|
/**
|
|
3
3
|
* Normalizes a backend error response into an AISDKError.
|
|
4
|
-
*
|
|
5
|
-
* If the backend error response includes container message data (e.g., `appMessage` field),
|
|
6
|
-
* it will be automatically sent to the app container for user-facing UI (e.g., payment dialog,
|
|
7
|
-
* error popup, success notification).
|
|
8
|
-
*
|
|
9
|
-
* @example appMessage structure:
|
|
10
|
-
* ```ts
|
|
11
|
-
* interface AppMessage {
|
|
12
|
-
* // Message type determines UI behavior
|
|
13
|
-
* type: 'error' | 'success' | 'warning' | 'info';
|
|
14
|
-
*
|
|
15
|
-
* // Required: User-facing title and message
|
|
16
|
-
* title: string;
|
|
17
|
-
* message: string;
|
|
18
|
-
*
|
|
19
|
-
* // Optional: Action to trigger in the container
|
|
20
|
-
* action?: string; // e.g., 'showPaymentDialog', 'showUpgradeDialog', 'redirect'
|
|
21
|
-
*
|
|
22
|
-
* // Optional: URL for redirect actions
|
|
23
|
-
* redirectUrl?: string;
|
|
24
|
-
*
|
|
25
|
-
* // Optional: Custom button text for action dialogs
|
|
26
|
-
* buttonText?: string;
|
|
27
|
-
*
|
|
28
|
-
* // Optional: Auto-dismiss duration in milliseconds (for success/info messages)
|
|
29
|
-
* duration?: number;
|
|
30
|
-
*
|
|
31
|
-
* // Optional: Additional metadata for container processing
|
|
32
|
-
* metadata?: Record<string, unknown>;
|
|
33
|
-
* }
|
|
34
|
-
*
|
|
35
|
-
* // Example error message with payment action:
|
|
36
|
-
* {
|
|
37
|
-
* type: 'error',
|
|
38
|
-
* title: 'Insufficient Balance',
|
|
39
|
-
* message: 'Your account balance is insufficient. Please top up to continue.',
|
|
40
|
-
* action: 'showPaymentDialog',
|
|
41
|
-
* redirectUrl: '/payment',
|
|
42
|
-
* buttonText: 'Top Up Now'
|
|
43
|
-
* }
|
|
44
|
-
* ```
|
|
4
|
+
* Extracts and sends appMessage to container if present in the error response.
|
|
45
5
|
*/
|
|
46
6
|
export declare function normalizeError(response: Response, body?: unknown): AISDKError;
|
|
47
|
-
/**
|
|
48
|
-
* Creates an error for missing user token.
|
|
49
|
-
*/
|
|
50
|
-
export declare function missingTokenError(): AISDKError;
|
|
51
|
-
/**
|
|
52
|
-
* Creates an error for aborted requests.
|
|
53
|
-
*/
|
|
54
|
-
export declare function abortedError(): AISDKError;
|
|
55
|
-
/**
|
|
56
|
-
* Creates an error for network failures.
|
|
57
|
-
*/
|
|
58
|
-
export declare function networkError(cause?: unknown): AISDKError;
|
|
59
|
-
/**
|
|
60
|
-
* Creates an error for parse failures.
|
|
61
|
-
*/
|
|
62
|
-
export declare function parseError(message: string): AISDKError;
|
package/dist/ai/index.d.ts
CHANGED
|
@@ -38,9 +38,7 @@
|
|
|
38
38
|
*/
|
|
39
39
|
export { aippyAIProvider, type AippyProvider } from './openai';
|
|
40
40
|
export type { AippyOpenAIConfig } from './openai';
|
|
41
|
-
/** @deprecated Use aippyAIProvider() instead */
|
|
42
|
-
export { aippyAIProvider as aippy } from './openai';
|
|
43
41
|
export { aippyChatConfig, type AippyUseChatOptions, type AippyUIConfig, type AippyChatConfig, UI_CHAT_ENDPOINT, } from './ui';
|
|
44
42
|
export { DEFAULT_BASE_URL, DEFAULT_UI_BASE_URL, DEFAULT_CHAT_MODEL, DEFAULT_CHAT_SYSTEM, } from './shared';
|
|
45
|
-
export { normalizeError
|
|
43
|
+
export { normalizeError } from './errors';
|
|
46
44
|
export { type AIConfig, type AIConfigValue, type AIConfigItem, type NumberAIConfigItem, type BooleanAIConfigItem, type TextAIConfigItem, type EnumAIConfigItem, type AIConfigError, type AIConfigValues, AIConfigValidationError, validateAIConfig, parseAIConfig, loadAIConfig, getAIConfigValue, sendAIConfigToContainer, createAIConfig, } from './config';
|
package/dist/ai/index.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { A
|
|
1
|
+
import { A, D as r, d as n, e as C, c as e, U as E, a as I, b as _, f, g, l as T, n as p, p as t, s as U, v as D } from "../helper-yKJ_6uB-.js";
|
|
2
2
|
import "react";
|
|
3
|
-
import "../bridge-
|
|
3
|
+
import "../bridge-BKcAlLAd.js";
|
|
4
4
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
A as AIConfigValidationError,
|
|
6
|
+
r as DEFAULT_BASE_URL,
|
|
7
7
|
n as DEFAULT_CHAT_MODEL,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
T as
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
U as
|
|
19
|
-
|
|
20
|
-
D as normalizeError,
|
|
21
|
-
L as parseAIConfig,
|
|
22
|
-
l as parseError,
|
|
23
|
-
m as sendAIConfigToContainer,
|
|
24
|
-
F as validateAIConfig
|
|
8
|
+
C as DEFAULT_CHAT_SYSTEM,
|
|
9
|
+
e as DEFAULT_UI_BASE_URL,
|
|
10
|
+
E as UI_CHAT_ENDPOINT,
|
|
11
|
+
I as aippyAIProvider,
|
|
12
|
+
_ as aippyChatConfig,
|
|
13
|
+
f as createAIConfig,
|
|
14
|
+
g as getAIConfigValue,
|
|
15
|
+
T as loadAIConfig,
|
|
16
|
+
p as normalizeError,
|
|
17
|
+
t as parseAIConfig,
|
|
18
|
+
U as sendAIConfigToContainer,
|
|
19
|
+
D as validateAIConfig
|
|
25
20
|
};
|
|
@@ -3,32 +3,9 @@
|
|
|
3
3
|
* Used by both OpenAI-compatible (Core) and Data Stream Protocol (UI) paths.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param baseUrl - The base URL (e.g., 'https://api.aippy.dev/api/aisdk/v1/ui/')
|
|
10
|
-
* @param path - The path segment to append (e.g., '/chat' or 'chat')
|
|
11
|
-
* @returns The joined URL string
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* joinUrl('https://api.aippy.dev/api/aisdk/v1/ui/', '/chat')
|
|
15
|
-
* // => 'https://api.aippy.dev/api/aisdk/v1/ui/chat'
|
|
16
|
-
*/
|
|
17
|
-
export declare function joinUrl(baseUrl: string, path: string): string;
|
|
18
|
-
/**
|
|
19
|
-
* Creates a fetch wrapper that injects Authorization header with a fresh token.
|
|
20
|
-
* Token is fetched asynchronously on every request to ensure it's always current.
|
|
21
|
-
*
|
|
22
|
-
* This wrapper also automatically handles error responses by:
|
|
23
|
-
* 1. Detecting error responses (!response.ok)
|
|
24
|
-
* 2. Parsing error body and calling normalizeError() to extract appMessage
|
|
25
|
-
* 3. Sending appMessage to container if present
|
|
26
|
-
* 4. Returning the original response for downstream error handling
|
|
6
|
+
* Creates a fetch wrapper that injects Authorization header and handles error responses.
|
|
7
|
+
* Error responses are intercepted and normalized errors are thrown immediately.
|
|
27
8
|
*
|
|
28
9
|
* @returns A fetch function compatible with globalThis.fetch signature
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* const authFetch = createAuthFetch();
|
|
32
|
-
* const response = await authFetch('https://api.example.com/endpoint', { method: 'POST' });
|
|
33
10
|
*/
|
|
34
11
|
export declare function createAuthFetch(): typeof globalThis.fetch;
|
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Re-exports config and fetch utilities used by both protocol paths.
|
|
4
4
|
*/
|
|
5
5
|
export { DEFAULT_BASE_URL, DEFAULT_UI_BASE_URL, DEFAULT_CHAT_MODEL, DEFAULT_CHAT_SYSTEM, resolveOpenAIConfig, resolveUIConfig, type AippyOpenAIConfig, type AippyUIConfig, type AippyChatConfig, } from './config';
|
|
6
|
-
export {
|
|
6
|
+
export { createAuthFetch } from './fetch';
|
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
var
|
|
2
|
-
var l = (
|
|
3
|
-
var c = (
|
|
4
|
-
import { UAParser as
|
|
5
|
-
import { hasNativeBridge as
|
|
6
|
-
function
|
|
1
|
+
var u = Object.defineProperty;
|
|
2
|
+
var l = (t, e, n) => e in t ? u(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
|
|
3
|
+
var c = (t, e, n) => l(t, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { UAParser as m } from "ua-parser-js";
|
|
5
|
+
import { hasNativeBridge as f } from "./native-bridge-BnvipFJc.js";
|
|
6
|
+
function w() {
|
|
7
7
|
try {
|
|
8
8
|
return typeof window < "u" && window.parent !== window;
|
|
9
9
|
} catch {
|
|
10
10
|
return !0;
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
const n =
|
|
15
|
-
for (let i = 0; i <
|
|
13
|
+
function h(t, e) {
|
|
14
|
+
const n = t.split(".").map(Number), r = e.split(".").map(Number), o = Math.max(n.length, r.length);
|
|
15
|
+
for (let i = 0; i < o; i++) {
|
|
16
16
|
const s = n[i] || 0, a = r[i] || 0;
|
|
17
17
|
if (s < a) return -1;
|
|
18
18
|
if (s > a) return 1;
|
|
19
19
|
}
|
|
20
20
|
return 0;
|
|
21
21
|
}
|
|
22
|
-
class
|
|
22
|
+
class g {
|
|
23
23
|
constructor() {
|
|
24
24
|
c(this, "parser");
|
|
25
|
-
this.parser = new
|
|
25
|
+
this.parser = new m();
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Get platform information
|
|
29
29
|
*/
|
|
30
30
|
getPlatformInfo() {
|
|
31
|
-
const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name),
|
|
31
|
+
const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name), o = this.isMobileDevice(), i = !o;
|
|
32
32
|
return {
|
|
33
33
|
name: n,
|
|
34
34
|
version: e.os.version,
|
|
35
35
|
browser: r,
|
|
36
36
|
browserVersion: e.browser.version,
|
|
37
|
-
isMobile:
|
|
37
|
+
isMobile: o,
|
|
38
38
|
isDesktop: i
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -104,15 +104,15 @@ class w {
|
|
|
104
104
|
checkAppEnvironment(e) {
|
|
105
105
|
const n = this.parseAippyInfo();
|
|
106
106
|
if (n) {
|
|
107
|
-
const r = e[n.platform],
|
|
107
|
+
const r = e[n.platform], o = h(n.version, r) >= 0;
|
|
108
108
|
return {
|
|
109
109
|
type: "new_app",
|
|
110
|
-
isValid:
|
|
110
|
+
isValid: o,
|
|
111
111
|
aippyInfo: n,
|
|
112
|
-
message:
|
|
112
|
+
message: o ? void 0 : `App version ${n.version} < ${r}`
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
-
return
|
|
115
|
+
return f() ? {
|
|
116
116
|
type: "old_ios_app",
|
|
117
117
|
isValid: !1,
|
|
118
118
|
message: "Native bridge exists but no Aippy info (old iOS version)"
|
|
@@ -120,7 +120,7 @@ class w {
|
|
|
120
120
|
type: "old_android_app",
|
|
121
121
|
isValid: !1,
|
|
122
122
|
message: "Android WebView detected but no Aippy info (old Android version)"
|
|
123
|
-
} :
|
|
123
|
+
} : w() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
|
|
124
124
|
}
|
|
125
125
|
/**
|
|
126
126
|
* Parse Aippy App info from User-Agent
|
|
@@ -128,10 +128,10 @@ class w {
|
|
|
128
128
|
parseAippyInfo() {
|
|
129
129
|
const e = navigator.userAgent, n = /Aippy\/([^/]+)\/[^/]+\/(iOS|Android)/i, r = e.match(n);
|
|
130
130
|
if (r) {
|
|
131
|
-
const
|
|
131
|
+
const o = r[1];
|
|
132
132
|
return {
|
|
133
133
|
platform: r[2],
|
|
134
|
-
version:
|
|
134
|
+
version: o
|
|
135
135
|
};
|
|
136
136
|
}
|
|
137
137
|
return null;
|
|
@@ -155,21 +155,76 @@ class w {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
-
const
|
|
159
|
-
function v(
|
|
158
|
+
const b = new g(), p = "https://cdn.aippy.ai/asset/fd292077086044ee9565bd36ac3a8b78.svg";
|
|
159
|
+
async function v(t) {
|
|
160
160
|
const e = document.createElement("div");
|
|
161
|
-
e.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:
|
|
161
|
+
e.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";
|
|
162
162
|
const n = document.createElement("div");
|
|
163
|
-
n.style.cssText = "background:#
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
163
|
+
n.style.cssText = "background:#323232;border-radius:32px;padding:12px 30px 12px 24px;max-width:85%;display:flex;align-items:center;gap:12px;pointer-events:auto";
|
|
164
|
+
let r = !1;
|
|
165
|
+
try {
|
|
166
|
+
r = (await fetch(p, { method: "HEAD" })).ok;
|
|
167
|
+
} catch {
|
|
168
|
+
r = !1;
|
|
169
|
+
}
|
|
170
|
+
if (r) {
|
|
171
|
+
const i = document.createElement("img");
|
|
172
|
+
i.src = p, i.style.cssText = "width:36px;height:36px;flex-shrink:0", n.appendChild(i);
|
|
173
|
+
}
|
|
174
|
+
const o = document.createElement("span");
|
|
175
|
+
o.style.cssText = "font-size:16px;color:#fff;line-height:1.4;white-space:pre-line", o.textContent = t, n.appendChild(o), e.appendChild(n), document.body.appendChild(e);
|
|
176
|
+
}
|
|
177
|
+
const x = { iOS: "1.6.7", Android: "1.1.8" }, y = { iOS: "1.6.7", Android: "1.1.8" }, d = {
|
|
178
|
+
userCredentials: x,
|
|
179
|
+
userInfo: y
|
|
180
|
+
};
|
|
181
|
+
function A(t) {
|
|
182
|
+
const e = d[t];
|
|
183
|
+
return e || (console.warn(`[AppVersionChecker] Unknown feature: ${t}`), { iOS: "999.0.0", Android: "999.0.0" });
|
|
184
|
+
}
|
|
185
|
+
function C(t) {
|
|
186
|
+
const e = A(t), n = b.checkAppEnvironment(e), r = n.aippyInfo?.version, o = n.aippyInfo ? e[n.aippyInfo.platform] : void 0;
|
|
187
|
+
switch (n.type) {
|
|
188
|
+
case "new_app":
|
|
189
|
+
return {
|
|
190
|
+
supported: n.isValid,
|
|
191
|
+
envCheck: n,
|
|
192
|
+
currentVersion: r,
|
|
193
|
+
requiredVersion: o,
|
|
194
|
+
message: n.isValid ? void 0 : `App version ${r} does not support ${t}. Minimum required: ${o}`
|
|
195
|
+
};
|
|
196
|
+
case "old_ios_app":
|
|
197
|
+
case "old_android_app":
|
|
198
|
+
return {
|
|
199
|
+
supported: !1,
|
|
200
|
+
envCheck: n,
|
|
201
|
+
message: `Old app version detected. Please upgrade to use ${t}.`
|
|
202
|
+
};
|
|
203
|
+
default:
|
|
204
|
+
return {
|
|
205
|
+
supported: !0,
|
|
206
|
+
envCheck: n
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function _(t) {
|
|
211
|
+
const e = C(t);
|
|
212
|
+
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}`), v(`This project needs a newer version.
|
|
214
|
+
Update to view it.`), new Error(`App version too old: ${e.message}`);
|
|
215
|
+
return e;
|
|
216
|
+
}
|
|
217
|
+
function I() {
|
|
218
|
+
return Object.keys(d);
|
|
168
219
|
}
|
|
169
220
|
export {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
221
|
+
g as P,
|
|
222
|
+
C as a,
|
|
223
|
+
I as b,
|
|
224
|
+
h as c,
|
|
225
|
+
A as g,
|
|
226
|
+
w as i,
|
|
227
|
+
b as p,
|
|
228
|
+
_ as r,
|
|
174
229
|
v as s
|
|
175
230
|
};
|
package/dist/audio/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export { patchAudioContext } from './patchAudioContext';
|
|
10
10
|
export type { AudioContextPatchOptions, AutoPauseOptions, MediaElementType, PatchedAudioContext, } from './types';
|
|
11
|
-
export { createHiddenMediaElement,
|
|
11
|
+
export { createHiddenMediaElement, isMediaStreamAudioSupported, } from './utils';
|
|
12
12
|
export { useAudioContext } from './useAudioContext';
|
|
13
13
|
export type { UseAudioContextOptions, UseAudioContextReturn } from './useAudioContext';
|
|
14
14
|
export { isIOSDevice } from './utils';
|
package/dist/audio/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { c as i, a as t,
|
|
1
|
+
import { c as i, a as t, i as d, p as o, u as s } from "../useAudioContext-D9F3x80Y.js";
|
|
2
2
|
export {
|
|
3
3
|
i as createHiddenMediaElement,
|
|
4
|
-
t as
|
|
5
|
-
d as
|
|
6
|
-
o as
|
|
7
|
-
s as
|
|
8
|
-
n as useAudioContext
|
|
4
|
+
t as isIOSDevice,
|
|
5
|
+
d as isMediaStreamAudioSupported,
|
|
6
|
+
o as patchAudioContext,
|
|
7
|
+
s as useAudioContext
|
|
9
8
|
};
|
package/dist/audio/utils.d.ts
CHANGED
|
@@ -15,10 +15,3 @@ export declare function isMediaStreamAudioSupported(): boolean;
|
|
|
15
15
|
* @returns HTMLMediaElement (HTMLVideoElement or HTMLAudioElement)
|
|
16
16
|
*/
|
|
17
17
|
export declare function createHiddenMediaElement(type?: 'video' | 'audio', debug?: boolean): HTMLVideoElement | HTMLAudioElement;
|
|
18
|
-
/**
|
|
19
|
-
* @deprecated Use createHiddenMediaElement instead
|
|
20
|
-
* Creates a hidden video element for MediaStream playback
|
|
21
|
-
* @param debug - If true, makes the video element visible for debugging
|
|
22
|
-
* @returns HTMLVideoElement
|
|
23
|
-
*/
|
|
24
|
-
export declare function createHiddenVideoElement(debug?: boolean): HTMLVideoElement;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { a as y } from "./runtime-CmoG3v2m.js";
|
|
2
|
+
import { r as h, s as b, i as p } from "./app-version-checker-GLONqMxq.js";
|
|
3
|
+
const f = {
|
|
4
|
+
apiBaseUrl: "https://api.aippy.dev/api",
|
|
5
|
+
authToken: "",
|
|
6
|
+
currentUserId: null
|
|
7
|
+
};
|
|
8
|
+
function L(n) {
|
|
9
|
+
Object.assign(f, n);
|
|
10
|
+
}
|
|
11
|
+
function C(n) {
|
|
12
|
+
f.authToken = n;
|
|
13
|
+
}
|
|
14
|
+
function q(n) {
|
|
15
|
+
f.currentUserId = n;
|
|
16
|
+
}
|
|
17
|
+
const U = 3e3, v = 50, g = 500, c = { uid: "", token: "" };
|
|
18
|
+
let a = null, u = !1, l = null, t = null;
|
|
19
|
+
function w(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 d = e.user;
|
|
24
|
+
e = { uid: d.uid || d.userId || d.id, token: e.token, apiBaseUrl: e.apiBaseUrl };
|
|
25
|
+
}
|
|
26
|
+
const r = e.uid || e.userId || e.id || "", o = e.token || e.authToken || "", s = e.apiBaseUrl;
|
|
27
|
+
if (!r || !o) return null;
|
|
28
|
+
const i = { uid: String(r), token: o, apiBaseUrl: s };
|
|
29
|
+
return q(i.uid), C(o), s && L({ apiBaseUrl: s }), i;
|
|
30
|
+
}
|
|
31
|
+
function m(n) {
|
|
32
|
+
if (console.log("🔄 [Bridge] processUserInfoData called with:", n), !n || typeof n != "object")
|
|
33
|
+
return console.warn("⚠️ [Bridge] Invalid data (null or not object):", n), null;
|
|
34
|
+
let e = n;
|
|
35
|
+
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);
|
|
36
|
+
const r = e.uid || e.userId || e.id || "";
|
|
37
|
+
if (!r)
|
|
38
|
+
return console.warn("⚠️ [Bridge] No uid found in data"), null;
|
|
39
|
+
const o = { uid: String(r), ...e };
|
|
40
|
+
return console.log("✅ [Bridge] Created userInfo:", o), a = o, u = !0, console.log("✅ [Bridge] Cached userInfo, userInfoReceived = true"), o;
|
|
41
|
+
}
|
|
42
|
+
function A(n = g) {
|
|
43
|
+
return console.log("📱 [Bridge] requestCredentialsFromiOS called, timeout:", n), l ? (console.log("⏳ [Bridge] Pending credentials request exists, waiting..."), new Promise((e) => {
|
|
44
|
+
const r = l.resolve;
|
|
45
|
+
l.resolve = (o) => {
|
|
46
|
+
r(o), e(o);
|
|
47
|
+
};
|
|
48
|
+
})) : new Promise((e) => {
|
|
49
|
+
(async () => {
|
|
50
|
+
let r = window.webkit?.messageHandlers?.aippyListener;
|
|
51
|
+
if (console.log("📱 [Bridge] Checking aippyListener for credentials:", {
|
|
52
|
+
hasWebkit: !!window.webkit,
|
|
53
|
+
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
54
|
+
hasAippyListener: !!r
|
|
55
|
+
}), r || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), r = await k(1500)), !r) {
|
|
56
|
+
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning empty credentials"), e(c);
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const o = setTimeout(() => {
|
|
60
|
+
console.warn("⏰ [Bridge] Credentials request TIMEOUT after", n, "ms"), l = null, e(c);
|
|
61
|
+
}, n);
|
|
62
|
+
l = {
|
|
63
|
+
resolve: (s) => {
|
|
64
|
+
console.log("✅ [Bridge] pendingCredentialsRequest.resolve called with:", s), clearTimeout(o), l = null, e(s);
|
|
65
|
+
}
|
|
66
|
+
}, console.log("📱 [Bridge] pendingCredentialsRequest set"), y.receiveChannel.once("user.credentials", (s) => {
|
|
67
|
+
console.log("📩 [Bridge] Received user.credentials via receiveChannel:", s), clearTimeout(o);
|
|
68
|
+
const i = w(s) || c;
|
|
69
|
+
l && l.resolve(i);
|
|
70
|
+
});
|
|
71
|
+
try {
|
|
72
|
+
const s = {
|
|
73
|
+
command: "user.getCredentials",
|
|
74
|
+
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.credentials" })
|
|
75
|
+
};
|
|
76
|
+
console.log("📤 [Bridge] Sending credentials request:", s), r.postMessage(s), console.log("📤 [Bridge] Credentials postMessage sent successfully");
|
|
77
|
+
} catch (s) {
|
|
78
|
+
console.error("❌ [Bridge] Failed to send credentials postMessage:", s), clearTimeout(o), l = null, e(c);
|
|
79
|
+
}
|
|
80
|
+
})();
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
function E(n = g) {
|
|
84
|
+
return new Promise((e) => {
|
|
85
|
+
if (!p()) {
|
|
86
|
+
e(c);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const r = setTimeout(() => {
|
|
90
|
+
window.removeEventListener("message", o), e(c);
|
|
91
|
+
}, n), o = (s) => {
|
|
92
|
+
s.data?.type === "user-credentials-response" && (clearTimeout(r), window.removeEventListener("message", o), e(w(s.data) || c));
|
|
93
|
+
};
|
|
94
|
+
window.addEventListener("message", o);
|
|
95
|
+
try {
|
|
96
|
+
window.parent.postMessage({ type: "user-credentials-request", timestamp: Date.now() }, "*");
|
|
97
|
+
} catch {
|
|
98
|
+
clearTimeout(r), window.removeEventListener("message", o), e(c);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
const R = () => /Aippy\/[\d.]+\/\d+\/Android/i.test(navigator.userAgent);
|
|
103
|
+
async function k(n = 1500) {
|
|
104
|
+
if (!R())
|
|
105
|
+
return console.log("📱 [Bridge] Not Android, skipping waitForAippyListener"), window.webkit?.messageHandlers?.aippyListener || null;
|
|
106
|
+
const e = Date.now(), r = 50;
|
|
107
|
+
for (console.log("🤖 [Bridge] Android: Waiting for aippyListener (max", n, "ms)..."); Date.now() - e < n; ) {
|
|
108
|
+
const o = window.webkit?.messageHandlers?.aippyListener;
|
|
109
|
+
if (o)
|
|
110
|
+
return console.log("✅ [Bridge] aippyListener became available after", Date.now() - e, "ms"), o;
|
|
111
|
+
await new Promise((s) => setTimeout(s, r));
|
|
112
|
+
}
|
|
113
|
+
return console.warn("⏰ [Bridge] aippyListener not available after", n, "ms"), null;
|
|
114
|
+
}
|
|
115
|
+
function S(n = !1, e = g) {
|
|
116
|
+
return console.log("📱 [Bridge] requestUserInfoFromiOS called:", { forceRefresh: n, timeoutMs: e }), console.log("📱 [Bridge] Cache state:", { userInfoReceived: u, cachedUserInfo: a ? "(cached)" : null }), u && a && !n ? (console.log("✅ [Bridge] Returning cached userInfo from requestUserInfoFromiOS"), Promise.resolve(a)) : t ? (console.log("⏳ [Bridge] Pending userInfo request exists, waiting..."), new Promise((r) => {
|
|
117
|
+
const o = t.resolve;
|
|
118
|
+
t.resolve = (s) => {
|
|
119
|
+
console.log("⏳ [Bridge] Pending request resolved:", s), o(s), r(s);
|
|
120
|
+
};
|
|
121
|
+
})) : new Promise((r) => {
|
|
122
|
+
(async () => {
|
|
123
|
+
let o = window.webkit?.messageHandlers?.aippyListener;
|
|
124
|
+
if (console.log("📱 [Bridge] Checking aippyListener:", {
|
|
125
|
+
hasWebkit: !!window.webkit,
|
|
126
|
+
hasMessageHandlers: !!window.webkit?.messageHandlers,
|
|
127
|
+
hasAippyListener: !!o
|
|
128
|
+
}), o || (console.log("⏳ [Bridge] aippyListener not found, waiting for injection..."), o = await k(1500)), !o) {
|
|
129
|
+
console.warn("⚠️ [Bridge] No aippyListener found after waiting, returning null"), r(null);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
console.log("📱 [Bridge] Setting up timeout:", e, "ms");
|
|
133
|
+
const s = setTimeout(() => {
|
|
134
|
+
console.warn("⏰ [Bridge] UserInfo request TIMEOUT after", e, "ms"), t = null, r(null);
|
|
135
|
+
}, e);
|
|
136
|
+
t = { resolve: (i) => {
|
|
137
|
+
console.log("✅ [Bridge] pendingUserInfoRequest.resolve called with:", i), clearTimeout(s), t = null, r(i);
|
|
138
|
+
} }, console.log("📱 [Bridge] pendingUserInfoRequest set"), y.receiveChannel.once("user.info", (i) => {
|
|
139
|
+
console.log("📩 [Bridge] Received user.info via receiveChannel:", i), clearTimeout(s);
|
|
140
|
+
const d = m(i);
|
|
141
|
+
console.log("📩 [Bridge] Processed userInfo:", d), t ? t.resolve(d) : console.warn("⚠️ [Bridge] No pendingUserInfoRequest when receiveChannel fired");
|
|
142
|
+
}), console.log("📱 [Bridge] receiveChannel.once registered for user.info");
|
|
143
|
+
try {
|
|
144
|
+
const i = {
|
|
145
|
+
command: "user.getUserInfo",
|
|
146
|
+
parameters: JSON.stringify({ timestamp: Date.now(), endpoint: "user.info" })
|
|
147
|
+
};
|
|
148
|
+
console.log("📤 [Bridge] Sending to aippyListener:", i), o.postMessage(i), console.log("📤 [Bridge] postMessage sent successfully");
|
|
149
|
+
} catch (i) {
|
|
150
|
+
console.error("❌ [Bridge] Failed to send postMessage:", i), clearTimeout(s), t = null, r(null);
|
|
151
|
+
}
|
|
152
|
+
})();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
function T(n = g) {
|
|
156
|
+
return new Promise((e) => {
|
|
157
|
+
if (!p()) {
|
|
158
|
+
e(null);
|
|
159
|
+
return;
|
|
160
|
+
}
|
|
161
|
+
const r = setTimeout(() => {
|
|
162
|
+
window.removeEventListener("message", o), e(null);
|
|
163
|
+
}, n), o = (s) => {
|
|
164
|
+
s.data?.type === "user-info-response" && (clearTimeout(r), window.removeEventListener("message", o), e(m(s.data)));
|
|
165
|
+
};
|
|
166
|
+
window.addEventListener("message", o);
|
|
167
|
+
try {
|
|
168
|
+
window.parent.postMessage({ type: "user-info-request", timestamp: Date.now() }, "*");
|
|
169
|
+
} catch {
|
|
170
|
+
clearTimeout(r), window.removeEventListener("message", o), e(null);
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
async function P() {
|
|
175
|
+
const { envCheck: n } = h("userCredentials");
|
|
176
|
+
switch (n.type) {
|
|
177
|
+
case "new_app": {
|
|
178
|
+
const e = await A(U);
|
|
179
|
+
if (!e?.token) throw new Error("Token unavailable in app");
|
|
180
|
+
return e.token;
|
|
181
|
+
}
|
|
182
|
+
case "iframe": {
|
|
183
|
+
const e = await E(v);
|
|
184
|
+
if (e?.token) return e.token;
|
|
185
|
+
throw b(`Sign in to continue.
|
|
186
|
+
Open this project in the app.`), new Error("Token unavailable: User needs to login");
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
return "";
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
async function F(n = !1) {
|
|
193
|
+
if (console.log("🔍 [Bridge] getUserInfoAsync called, forceRefresh:", n), console.log("🔍 [Bridge] Current cache state:", { userInfoReceived: u, cachedUserInfo: a }), u && a && !n)
|
|
194
|
+
return console.log("✅ [Bridge] Returning cached userInfo"), a;
|
|
195
|
+
const { envCheck: e } = h("userInfo");
|
|
196
|
+
switch (console.log("🔍 [Bridge] Environment check result:", e), e.type) {
|
|
197
|
+
case "new_app":
|
|
198
|
+
return console.log("📱 [Bridge] Detected new_app environment"), await S(n, U);
|
|
199
|
+
case "iframe":
|
|
200
|
+
return console.log("🖼️ [Bridge] Detected iframe environment"), await T(v);
|
|
201
|
+
default:
|
|
202
|
+
return console.log("🌐 [Bridge] Detected web environment, returning cached:", a), a;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
async function M(n = g) {
|
|
206
|
+
return p() ? await T(n) : null;
|
|
207
|
+
}
|
|
208
|
+
function B(n) {
|
|
209
|
+
const e = w(n);
|
|
210
|
+
e && l && (l.resolve(e), l = null);
|
|
211
|
+
}
|
|
212
|
+
function I(n) {
|
|
213
|
+
console.log("📩 [Bridge] window.processUserInfo called with:", n), console.log("📩 [Bridge] pendingUserInfoRequest exists:", !!t);
|
|
214
|
+
const e = m(n);
|
|
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"));
|
|
216
|
+
}
|
|
217
|
+
function j() {
|
|
218
|
+
if (typeof window > "u") {
|
|
219
|
+
console.log("🔧 [Bridge] initUserBridge: window is undefined, skipping");
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
console.log("🔧 [Bridge] initUserBridge: Initializing..."), console.log("🔧 [Bridge] UserAgent:", navigator.userAgent), window.processUserCredentials = B, window.processUserInfo = I, 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), B(n.data)), n.data?.type === "user-info" && (console.log("📩 [Bridge] Received postMessage user-info:", n.data), I(n.data));
|
|
224
|
+
}), console.log("🔧 [Bridge] Added message event listener"), console.log("✅ [Bridge] initUserBridge complete");
|
|
225
|
+
}
|
|
226
|
+
j();
|
|
227
|
+
P().catch((n) => {
|
|
228
|
+
console.warn("[UserSDK] Auth check on load:", n.message);
|
|
229
|
+
});
|
|
230
|
+
export {
|
|
231
|
+
P as getAuthTokenAsync,
|
|
232
|
+
F as getUserInfoAsync,
|
|
233
|
+
M as getUserInfoFromParent,
|
|
234
|
+
p as isInIframe,
|
|
235
|
+
B as processUserCredentials,
|
|
236
|
+
I as processUserInfo
|
|
237
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const n = {
|
|
2
|
+
mode: "development",
|
|
3
|
+
debug: !1,
|
|
4
|
+
apiBaseUrl: void 0,
|
|
5
|
+
headers: {}
|
|
6
|
+
};
|
|
7
|
+
function o() {
|
|
8
|
+
const e = {};
|
|
9
|
+
return typeof process < "u" && process.env && (process.env.NODE_ENV && (e.mode = process.env.NODE_ENV), process.env.AIPPY_DEBUG && (e.debug = process.env.AIPPY_DEBUG === "true"), process.env.AIPPY_API_BASE_URL && (e.apiBaseUrl = process.env.AIPPY_API_BASE_URL)), e;
|
|
10
|
+
}
|
|
11
|
+
function r(e) {
|
|
12
|
+
const s = o();
|
|
13
|
+
return {
|
|
14
|
+
...n,
|
|
15
|
+
...s,
|
|
16
|
+
...e,
|
|
17
|
+
headers: {
|
|
18
|
+
...n.headers,
|
|
19
|
+
...s.headers,
|
|
20
|
+
...e?.headers
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
n as D,
|
|
26
|
+
o as g,
|
|
27
|
+
r as m
|
|
28
|
+
};
|