@aippy/runtime 0.2.7-dev.3 → 0.2.7-dev.5
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 -20
- package/dist/ai/index.d.ts +1 -3
- package/dist/ai/index.js +16 -21
- package/dist/ai/shared/fetch.d.ts +2 -15
- 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-Ca3H2iN1.js +197 -0
- package/dist/core/index.js +1 -1
- package/dist/helper-BENVYOU-.js +247 -0
- package/dist/hooks-CE9cjXHP.js +46 -0
- package/dist/index/index.js +72 -107
- package/dist/{ui-D6IZ1jrR.js → ui-y5N62DqC.js} +81 -25
- package/dist/{useAudioContext-CNQQSTab.js → useAudioContext-D9F3x80Y.js} +38 -42
- package/dist/user/bridge.d.ts +10 -141
- package/dist/user/config.d.ts +8 -17
- package/dist/user/hooks.d.ts +3 -65
- package/dist/user/index.d.ts +3 -9
- package/dist/user/index.js +7 -36
- package/dist/user/types.d.ts +2 -105
- package/dist/utils/index.js +11 -9
- package/dist/utils/platform.d.ts +42 -1
- package/package.json +1 -1
- package/dist/bridge-N9ELFpfV.js +0 -430
- package/dist/helper-CKiqfKle.js +0 -264
- package/dist/user/api.d.ts +0 -9
- package/dist/user/userSessionInfo.d.ts +0 -6
- package/dist/userSessionInfo-DFvsuELU.js +0 -229
package/dist/index/index.js
CHANGED
|
@@ -1,118 +1,83 @@
|
|
|
1
|
-
import { DEFAULT_CONFIG as
|
|
2
|
-
import { A
|
|
1
|
+
import { DEFAULT_CONFIG as o, SDK_NAME as r, VERSION as s, getConfigFromEnv as t, getVersionInfo as i, mergeConfig as n } from "../core/index.js";
|
|
2
|
+
import { A, E as f, c as m } from "../errors-CDEBaBxB.js";
|
|
3
3
|
import { s as C } from "../container-message-DGrno17o.js";
|
|
4
|
-
import { A as
|
|
5
|
-
import { CameraAPI as
|
|
6
|
-
import { P as
|
|
7
|
-
import { a as
|
|
8
|
-
import { a as
|
|
9
|
-
import { c as
|
|
10
|
-
import { reportScore as
|
|
11
|
-
import { A as
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { hasNativeBridge as
|
|
4
|
+
import { A as E, C as d, R as l, a as g, p as u } from "../runtime-CmoG3v2m.js";
|
|
5
|
+
import { CameraAPI as x, FileSystemAPI as T, GeolocationAPI as _, SensorsAPI as D, camera as U, fileSystem as M, geolocation as P, isMotionSupported as R, isOrientationSupported as y, requestMotionPermission as h, sensors as v, vibrate as O, watchMotion as F, watchOrientation as L } from "../device/index.js";
|
|
6
|
+
import { P as N, c as b, i as V, p as H, s as k } from "../ui-y5N62DqC.js";
|
|
7
|
+
import { a as G, P as q, p as z, b as K } from "../pwa-CilSlaik.js";
|
|
8
|
+
import { a as Y, b as j } from "../useTweaks-QxMRmg7i.js";
|
|
9
|
+
import { c as Q, a as X, i as Z, p as $, u as ee } from "../useAudioContext-D9F3x80Y.js";
|
|
10
|
+
import { reportScore as oe, sendEvent as re, updateScore as se } from "../leaderboard/index.js";
|
|
11
|
+
import { A as ie, D as ne, d as pe, e as Ae, c as fe, U as me, a as ce, b as Ce, f as Ie, g as Ee, l as de, n as le, p as ge, s as ue, v as Se } from "../helper-BENVYOU-.js";
|
|
12
|
+
import { c as Te, u as _e } from "../hooks-CE9cjXHP.js";
|
|
13
|
+
import { getAuthTokenAsync as Ue } from "../bridge-Ca3H2iN1.js";
|
|
14
|
+
import { hasNativeBridge as Pe } from "../native-bridge-BnvipFJc.js";
|
|
15
15
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
16
|
+
ie as AIConfigValidationError,
|
|
17
|
+
E as AippyRuntime,
|
|
18
|
+
A as AippyRuntimeError,
|
|
19
|
+
x as CameraAPI,
|
|
20
|
+
d as Cancellable,
|
|
21
21
|
ne as DEFAULT_BASE_URL,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
22
|
+
pe as DEFAULT_CHAT_MODEL,
|
|
23
|
+
Ae as DEFAULT_CHAT_SYSTEM,
|
|
24
|
+
o as DEFAULT_CONFIG,
|
|
25
|
+
fe as DEFAULT_UI_BASE_URL,
|
|
26
|
+
f as ERROR_CODES,
|
|
27
|
+
T as FileSystemAPI,
|
|
28
|
+
_ as GeolocationAPI,
|
|
29
|
+
G as PWAUtils,
|
|
30
|
+
q as PerformanceMonitor,
|
|
31
|
+
N as PlatformDetector,
|
|
32
32
|
l as ReceiveChannel,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
Ce as aippyAIProvider,
|
|
40
|
-
Ae as aippyChatConfig,
|
|
33
|
+
r as SDK_NAME,
|
|
34
|
+
D as SensorsAPI,
|
|
35
|
+
me as UI_CHAT_ENDPOINT,
|
|
36
|
+
s as VERSION,
|
|
37
|
+
ce as aippyAIProvider,
|
|
38
|
+
Ce as aippyChatConfig,
|
|
41
39
|
g as aippyRuntime,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
Ye as clearProfileCache,
|
|
48
|
-
Xe as clearUserInfoCache,
|
|
40
|
+
Y as aippyTweaks,
|
|
41
|
+
j as aippyTweaksRuntime,
|
|
42
|
+
U as camera,
|
|
43
|
+
Te as clearUserInfoCache,
|
|
44
|
+
b as compareVersions,
|
|
49
45
|
Ie as createAIConfig,
|
|
50
46
|
m as createError,
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
ce as getAIConfigValue,
|
|
57
|
-
_e as getAuthToken,
|
|
58
|
-
De as getAuthTokenAsync,
|
|
59
|
-
Re as getCachedCredentials,
|
|
60
|
-
Me as getCachedUserInfo,
|
|
47
|
+
Q as createHiddenMediaElement,
|
|
48
|
+
M as fileSystem,
|
|
49
|
+
P as geolocation,
|
|
50
|
+
Ee as getAIConfigValue,
|
|
51
|
+
Ue as getAuthTokenAsync,
|
|
61
52
|
t as getConfigFromEnv,
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
Ee as normalizeError,
|
|
83
|
-
Se as parseAIConfig,
|
|
84
|
-
he as parseError,
|
|
85
|
-
Z as patchAudioContext,
|
|
86
|
-
H as performanceMonitor,
|
|
87
|
-
L as platform,
|
|
88
|
-
U as processMotionData,
|
|
89
|
-
V as pwa,
|
|
90
|
-
re as reportScore,
|
|
91
|
-
Be as requestCredentialsFromParent,
|
|
92
|
-
He as requestCredentialsFromiOS,
|
|
93
|
-
R as requestMotionPermission,
|
|
94
|
-
Ve as requestUserInfoFromParent,
|
|
95
|
-
je as requestUserInfoFromiOS,
|
|
96
|
-
Pe as sendAIConfigToContainer,
|
|
97
|
-
ae as sendEvent,
|
|
53
|
+
i as getVersionInfo,
|
|
54
|
+
Pe as hasNativeBridge,
|
|
55
|
+
X as isIOSDevice,
|
|
56
|
+
V as isInIframe,
|
|
57
|
+
Z as isMediaStreamAudioSupported,
|
|
58
|
+
R as isMotionSupported,
|
|
59
|
+
y as isOrientationSupported,
|
|
60
|
+
de as loadAIConfig,
|
|
61
|
+
n as mergeConfig,
|
|
62
|
+
le as normalizeError,
|
|
63
|
+
ge as parseAIConfig,
|
|
64
|
+
$ as patchAudioContext,
|
|
65
|
+
z as performanceMonitor,
|
|
66
|
+
H as platform,
|
|
67
|
+
u as processMotionData,
|
|
68
|
+
K as pwa,
|
|
69
|
+
oe as reportScore,
|
|
70
|
+
h as requestMotionPermission,
|
|
71
|
+
ue as sendAIConfigToContainer,
|
|
72
|
+
re as sendEvent,
|
|
98
73
|
C as sendMessageToContainer,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
ze as setCurrentUserId,
|
|
102
|
-
q as showAlert,
|
|
103
|
-
Je as tryGetCredentialsFromParentStorage,
|
|
104
|
-
Ke as tryGetUserInfoFromParentStorage,
|
|
74
|
+
v as sensors,
|
|
75
|
+
k as showAlert,
|
|
105
76
|
se as updateScore,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
tr as useUserInfo,
|
|
113
|
-
nr as userSessionInfo,
|
|
114
|
-
ye as validateAIConfig,
|
|
115
|
-
k as vibrate,
|
|
116
|
-
O as watchMotion,
|
|
117
|
-
v as watchOrientation
|
|
77
|
+
ee as useAudioContext,
|
|
78
|
+
_e as useUserInfo,
|
|
79
|
+
Se as validateAIConfig,
|
|
80
|
+
O as vibrate,
|
|
81
|
+
F as watchMotion,
|
|
82
|
+
L as watchOrientation
|
|
118
83
|
};
|
|
@@ -1,26 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { UAParser as
|
|
5
|
-
|
|
1
|
+
var d = Object.defineProperty;
|
|
2
|
+
var l = (o, e, n) => e in o ? d(o, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[e] = n;
|
|
3
|
+
var c = (o, e, n) => l(o, typeof e != "symbol" ? e + "" : e, n);
|
|
4
|
+
import { UAParser as u } from "ua-parser-js";
|
|
5
|
+
import { hasNativeBridge as p } from "./native-bridge-BnvipFJc.js";
|
|
6
|
+
function m() {
|
|
7
|
+
try {
|
|
8
|
+
return typeof window < "u" && window.parent !== window;
|
|
9
|
+
} catch {
|
|
10
|
+
return !0;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
function f(o, e) {
|
|
14
|
+
const n = o.split(".").map(Number), r = e.split(".").map(Number), t = Math.max(n.length, r.length);
|
|
15
|
+
for (let i = 0; i < t; i++) {
|
|
16
|
+
const s = n[i] || 0, a = r[i] || 0;
|
|
17
|
+
if (s < a) return -1;
|
|
18
|
+
if (s > a) return 1;
|
|
19
|
+
}
|
|
20
|
+
return 0;
|
|
21
|
+
}
|
|
22
|
+
class w {
|
|
6
23
|
constructor() {
|
|
7
|
-
|
|
8
|
-
this.parser = new
|
|
24
|
+
c(this, "parser");
|
|
25
|
+
this.parser = new u();
|
|
9
26
|
}
|
|
10
27
|
/**
|
|
11
28
|
* Get platform information
|
|
12
29
|
*/
|
|
13
30
|
getPlatformInfo() {
|
|
14
|
-
const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name),
|
|
31
|
+
const e = this.parser.getResult(), n = this.normalizePlatformName(e.os.name), r = this.normalizeBrowserName(e.browser.name), t = this.isMobileDevice(), i = !t;
|
|
15
32
|
return {
|
|
16
33
|
name: n,
|
|
17
34
|
version: e.os.version,
|
|
18
|
-
browser:
|
|
35
|
+
browser: r,
|
|
19
36
|
browserVersion: e.browser.version,
|
|
20
|
-
isMobile:
|
|
37
|
+
isMobile: t,
|
|
21
38
|
isDesktop: i
|
|
22
39
|
};
|
|
23
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Get raw UA parser result
|
|
43
|
+
*/
|
|
44
|
+
getRawParserResult() {
|
|
45
|
+
return this.parser.getResult();
|
|
46
|
+
}
|
|
24
47
|
/**
|
|
25
48
|
* Get platform capabilities
|
|
26
49
|
*/
|
|
@@ -69,15 +92,46 @@ class l {
|
|
|
69
92
|
return e.name === "android" && e.browser === "chrome";
|
|
70
93
|
}
|
|
71
94
|
/**
|
|
72
|
-
*
|
|
95
|
+
* Check if running in Android WebView (old app version)
|
|
96
|
+
* Detects by checking if browser name contains "webview"
|
|
97
|
+
*/
|
|
98
|
+
isAndroidWebView() {
|
|
99
|
+
return (this.parser.getResult().browser.name || "").toLowerCase().includes("webview");
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Check app environment and validate version
|
|
103
|
+
*/
|
|
104
|
+
checkAppEnvironment(e) {
|
|
105
|
+
const n = this.parseAippyInfo();
|
|
106
|
+
if (n) {
|
|
107
|
+
const r = e[n.platform], t = f(n.version, r) >= 0;
|
|
108
|
+
return {
|
|
109
|
+
type: "new_app",
|
|
110
|
+
isValid: t,
|
|
111
|
+
aippyInfo: n,
|
|
112
|
+
message: t ? void 0 : `App version ${n.version} < ${r}`
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
return p() ? {
|
|
116
|
+
type: "old_ios_app",
|
|
117
|
+
isValid: !1,
|
|
118
|
+
message: "Native bridge exists but no Aippy info (old iOS version)"
|
|
119
|
+
} : this.isAndroidWebView() ? {
|
|
120
|
+
type: "old_android_app",
|
|
121
|
+
isValid: !1,
|
|
122
|
+
message: "Android WebView detected but no Aippy info (old Android version)"
|
|
123
|
+
} : m() ? { type: "iframe", isValid: !0 } : { type: "web", isValid: !0 };
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Parse Aippy App info from User-Agent
|
|
73
127
|
*/
|
|
74
128
|
parseAippyInfo() {
|
|
75
|
-
const e = navigator.userAgent, n = /Aippy\/([
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
129
|
+
const e = navigator.userAgent, n = /Aippy\/([^/]+)\/[^/]+\/(iOS|Android)/i, r = e.match(n);
|
|
130
|
+
if (r) {
|
|
131
|
+
const t = r[1];
|
|
78
132
|
return {
|
|
79
|
-
platform:
|
|
80
|
-
version:
|
|
133
|
+
platform: r[2],
|
|
134
|
+
version: t
|
|
81
135
|
};
|
|
82
136
|
}
|
|
83
137
|
return null;
|
|
@@ -101,19 +155,21 @@ class l {
|
|
|
101
155
|
}
|
|
102
156
|
}
|
|
103
157
|
}
|
|
104
|
-
const
|
|
105
|
-
function
|
|
158
|
+
const x = new w();
|
|
159
|
+
function v(o) {
|
|
106
160
|
const e = document.createElement("div");
|
|
107
161
|
e.style.cssText = "position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.5);display:flex;align-items:center;justify-content:center;z-index:999999";
|
|
108
162
|
const n = document.createElement("div");
|
|
109
163
|
n.style.cssText = "background:#fff;border-radius:12px;padding:24px 32px;max-width:80%;text-align:center;box-shadow:0 4px 20px rgba(0,0,0,0.15)";
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
const
|
|
113
|
-
|
|
164
|
+
const r = document.createElement("p");
|
|
165
|
+
r.style.cssText = "margin:0 0 20px;font-size:16px;color:#333;line-height:1.5", r.textContent = o;
|
|
166
|
+
const t = document.createElement("button");
|
|
167
|
+
t.style.cssText = "background:#007AFF;color:#fff;border:none;border-radius:8px;padding:10px 32px;font-size:15px;cursor:pointer", t.textContent = "OK", t.onclick = () => e.remove(), n.appendChild(r), n.appendChild(t), e.appendChild(n), document.body.appendChild(e);
|
|
114
168
|
}
|
|
115
169
|
export {
|
|
116
|
-
|
|
117
|
-
f as
|
|
118
|
-
|
|
170
|
+
w as P,
|
|
171
|
+
f as c,
|
|
172
|
+
m as i,
|
|
173
|
+
x as p,
|
|
174
|
+
v as s
|
|
119
175
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useState as k, useRef as
|
|
5
|
-
function
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var b = (e, t, n) => t in e ? D(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var i = (e, t, n) => b(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { useState as k, useRef as w, useEffect as p } from "react";
|
|
5
|
+
function T() {
|
|
6
6
|
const e = navigator.userAgent;
|
|
7
7
|
return !!(/iPad|iPhone|iPod/.test(e) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
|
|
8
8
|
}
|
|
@@ -16,33 +16,30 @@ function P() {
|
|
|
16
16
|
return !1;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function E(e = "video", t = !1) {
|
|
20
20
|
const n = document.createElement(e);
|
|
21
21
|
return n.muted = !1, n.autoplay = !0, e === "video" && (n.playsInline = !0), t ? n.style.cssText = "position:fixed;bottom:10px;right:10px;width:200px;background:#ff0000;z-index:9999;" : n.style.cssText = "position:fixed;width:1px;height:1px;opacity:0;pointer-events:none;", n;
|
|
22
22
|
}
|
|
23
|
-
function C(e = !1) {
|
|
24
|
-
return v("video", e);
|
|
25
|
-
}
|
|
26
23
|
class I {
|
|
27
|
-
constructor(t, n,
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
constructor(t, n, s, o = !1) {
|
|
25
|
+
i(this, "analyser");
|
|
26
|
+
i(this, "dataArray");
|
|
27
|
+
i(this, "rafId", null);
|
|
28
|
+
i(this, "silenceStartTime", 0);
|
|
29
|
+
i(this, "isPaused", !1);
|
|
30
|
+
i(this, "lastCheckTime", 0);
|
|
31
|
+
i(this, "silenceThreshold");
|
|
32
|
+
i(this, "silenceDuration");
|
|
33
|
+
i(this, "checkInterval");
|
|
34
|
+
i(this, "debug");
|
|
38
35
|
/**
|
|
39
36
|
* Check audio levels and pause/resume as needed
|
|
40
37
|
*/
|
|
41
|
-
|
|
38
|
+
i(this, "check", () => {
|
|
42
39
|
const t = performance.now();
|
|
43
40
|
t - this.lastCheckTime >= this.checkInterval && (this.lastCheckTime = t, this.getAudioLevel() < this.silenceThreshold ? this.silenceStartTime === 0 ? this.silenceStartTime = t : t - this.silenceStartTime >= this.silenceDuration && !this.isPaused && this.pauseMedia() : (this.silenceStartTime = 0, this.isPaused && this.resumeMedia())), this.rafId = requestAnimationFrame(this.check);
|
|
44
41
|
});
|
|
45
|
-
this.audioContext = t, this.mediaElement = n, this.silenceThreshold =
|
|
42
|
+
this.audioContext = t, this.mediaElement = n, this.silenceThreshold = s.silenceThreshold, this.silenceDuration = s.silenceDuration, this.checkInterval = s.checkInterval, this.debug = o, this.analyser = t.createAnalyser(), this.analyser.fftSize = 512, this.analyser.smoothingTimeConstant = 0.3, this.dataArray = new Uint8Array(this.analyser.frequencyBinCount);
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Connect the detector to the audio stream
|
|
@@ -75,8 +72,8 @@ class I {
|
|
|
75
72
|
this.analyser.getByteTimeDomainData(this.dataArray);
|
|
76
73
|
let t = 0;
|
|
77
74
|
for (let n = 0; n < this.dataArray.length; n++) {
|
|
78
|
-
const
|
|
79
|
-
t +=
|
|
75
|
+
const s = (this.dataArray[n] - 128) / 128;
|
|
76
|
+
t += s * s;
|
|
80
77
|
}
|
|
81
78
|
return Math.sqrt(t / this.dataArray.length);
|
|
82
79
|
}
|
|
@@ -106,7 +103,7 @@ class I {
|
|
|
106
103
|
function S(e, t = {}) {
|
|
107
104
|
const {
|
|
108
105
|
forceEnable: n = !1,
|
|
109
|
-
autoCleanup:
|
|
106
|
+
autoCleanup: s = !0,
|
|
110
107
|
debug: o = !1,
|
|
111
108
|
mediaElementType: m = "video",
|
|
112
109
|
autoPause: d = {}
|
|
@@ -116,7 +113,7 @@ function S(e, t = {}) {
|
|
|
116
113
|
silenceDuration: d.silenceDuration ?? 50,
|
|
117
114
|
checkInterval: d.checkInterval ?? 16
|
|
118
115
|
};
|
|
119
|
-
if (!(n ||
|
|
116
|
+
if (!(n || T()))
|
|
120
117
|
return Object.assign(e, {
|
|
121
118
|
unlock: async () => {
|
|
122
119
|
e.state === "suspended" && await e.resume();
|
|
@@ -138,7 +135,7 @@ function S(e, t = {}) {
|
|
|
138
135
|
});
|
|
139
136
|
const c = e.destination, y = e.createMediaStreamDestination(), f = e.createGain();
|
|
140
137
|
f.gain.value = 1, f.connect(y);
|
|
141
|
-
const l =
|
|
138
|
+
const l = E(m, o);
|
|
142
139
|
l.srcObject = y.stream, document.body.appendChild(l);
|
|
143
140
|
let u = null;
|
|
144
141
|
h.enabled && (u = new I(
|
|
@@ -155,7 +152,7 @@ function S(e, t = {}) {
|
|
|
155
152
|
enumerable: !0
|
|
156
153
|
});
|
|
157
154
|
let g = !1;
|
|
158
|
-
const
|
|
155
|
+
const v = async () => {
|
|
159
156
|
if (!g)
|
|
160
157
|
try {
|
|
161
158
|
await l.play(), e.state === "suspended" && await e.resume(), u && u.start(), g = !0;
|
|
@@ -169,55 +166,54 @@ function S(e, t = {}) {
|
|
|
169
166
|
console.error("[AudioContext] Cleanup error:", a);
|
|
170
167
|
}
|
|
171
168
|
};
|
|
172
|
-
if (
|
|
169
|
+
if (s) {
|
|
173
170
|
const a = e.close.bind(e);
|
|
174
171
|
e.close = async () => (A(), a());
|
|
175
172
|
}
|
|
176
173
|
return Object.assign(e, {
|
|
177
|
-
unlock:
|
|
174
|
+
unlock: v,
|
|
178
175
|
cleanup: A,
|
|
179
176
|
isPatched: !0,
|
|
180
177
|
originalDestination: c
|
|
181
178
|
});
|
|
182
179
|
}
|
|
183
|
-
function
|
|
184
|
-
const { autoUnlock: t = !0, ...n } = e, [
|
|
180
|
+
function C(e = {}) {
|
|
181
|
+
const { autoUnlock: t = !0, ...n } = e, [s, o] = k(null), [m, d] = k(!1), h = w(null);
|
|
185
182
|
return p(() => {
|
|
186
183
|
const r = new AudioContext(), c = S(r, n);
|
|
187
184
|
return o(c), () => {
|
|
188
185
|
c.cleanup(), c.close();
|
|
189
186
|
};
|
|
190
187
|
}, []), p(() => {
|
|
191
|
-
|
|
188
|
+
s && (h.current = async () => {
|
|
192
189
|
if (!m)
|
|
193
190
|
try {
|
|
194
|
-
await
|
|
191
|
+
await s.unlock(), d(!0);
|
|
195
192
|
} catch (r) {
|
|
196
193
|
if (r instanceof DOMException && r.name === "NotAllowedError")
|
|
197
194
|
return;
|
|
198
195
|
console.warn("Failed to unlock audio:", r);
|
|
199
196
|
}
|
|
200
197
|
});
|
|
201
|
-
}, [
|
|
202
|
-
if (!t || !
|
|
198
|
+
}, [s, m]), p(() => {
|
|
199
|
+
if (!t || !s) return;
|
|
203
200
|
const r = async (c) => {
|
|
204
201
|
c.isTrusted && await h.current?.();
|
|
205
202
|
};
|
|
206
203
|
return document.addEventListener("click", r, { once: !0, capture: !0 }), document.addEventListener("touchstart", r, { once: !0, capture: !0 }), () => {
|
|
207
204
|
document.removeEventListener("click", r, { capture: !0 }), document.removeEventListener("touchstart", r, { capture: !0 });
|
|
208
205
|
};
|
|
209
|
-
}, [t,
|
|
210
|
-
audioContext:
|
|
206
|
+
}, [t, s]), {
|
|
207
|
+
audioContext: s,
|
|
211
208
|
isUnlocked: m,
|
|
212
209
|
unlock: h.current || (async () => {
|
|
213
210
|
})
|
|
214
211
|
};
|
|
215
212
|
}
|
|
216
213
|
export {
|
|
217
|
-
|
|
218
|
-
E as
|
|
219
|
-
v as c,
|
|
214
|
+
T as a,
|
|
215
|
+
E as c,
|
|
220
216
|
P as i,
|
|
221
217
|
S as p,
|
|
222
|
-
|
|
218
|
+
C as u
|
|
223
219
|
};
|