@rqmii_immersive/agent-react-sdk 1.0.4 → 1.0.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Yp, { createContext as mg, useState as jr, useRef as
|
|
1
|
+
import Yp, { createContext as mg, useState as jr, useRef as Et, useEffect as xr, useCallback as Qe, useMemo as Jp, useContext as gg } from "react";
|
|
2
2
|
var Ai = { exports: {} }, Ys = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -150,7 +150,7 @@ function wg() {
|
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), Q = this.props.ref, Q !== void 0 ? Q : null;
|
|
152
152
|
}
|
|
153
|
-
function U(Q, Ae, et, gt, qt,
|
|
153
|
+
function U(Q, Ae, et, gt, qt, kt) {
|
|
154
154
|
var ot = et.ref;
|
|
155
155
|
return Q = {
|
|
156
156
|
$$typeof: ie,
|
|
@@ -180,10 +180,10 @@ function wg() {
|
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
183
|
+
value: kt
|
|
184
184
|
}), Object.freeze && (Object.freeze(Q.props), Object.freeze(Q)), Q;
|
|
185
185
|
}
|
|
186
|
-
function B(Q, Ae, et, gt, qt,
|
|
186
|
+
function B(Q, Ae, et, gt, qt, kt) {
|
|
187
187
|
var ot = Ae.children;
|
|
188
188
|
if (ot !== void 0)
|
|
189
189
|
if (gt)
|
|
@@ -216,8 +216,8 @@ React keys must be passed directly to JSX without using spread:
|
|
|
216
216
|
}
|
|
217
217
|
if (ot = null, et !== void 0 && (n(et), ot = "" + et), C(Ae) && (n(Ae.key), ot = "" + Ae.key), "key" in Ae) {
|
|
218
218
|
et = {};
|
|
219
|
-
for (var
|
|
220
|
-
|
|
219
|
+
for (var Yt in Ae)
|
|
220
|
+
Yt !== "key" && (et[Yt] = Ae[Yt]);
|
|
221
221
|
} else et = Ae;
|
|
222
222
|
return ot && R(
|
|
223
223
|
et,
|
|
@@ -228,7 +228,7 @@ React keys must be passed directly to JSX without using spread:
|
|
|
228
228
|
et,
|
|
229
229
|
f(),
|
|
230
230
|
qt,
|
|
231
|
-
|
|
231
|
+
kt
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
function te(Q) {
|
|
@@ -276,7 +276,7 @@ var gp;
|
|
|
276
276
|
function vg() {
|
|
277
277
|
return gp || (gp = 1, process.env.NODE_ENV === "production" ? Ai.exports = yg() : Ai.exports = wg()), Ai.exports;
|
|
278
278
|
}
|
|
279
|
-
var
|
|
279
|
+
var lr = vg();
|
|
280
280
|
const Dr = /* @__PURE__ */ Object.create(null);
|
|
281
281
|
Dr.open = "0";
|
|
282
282
|
Dr.close = "1";
|
|
@@ -491,13 +491,13 @@ Lt.prototype.listeners = function(c) {
|
|
|
491
491
|
Lt.prototype.hasListeners = function(c) {
|
|
492
492
|
return !!this.listeners(c).length;
|
|
493
493
|
};
|
|
494
|
-
const Vi = typeof Promise == "function" && typeof Promise.resolve == "function" ? (r) => Promise.resolve().then(r) : (r, n) => n(r, 0),
|
|
494
|
+
const Vi = typeof Promise == "function" && typeof Promise.resolve == "function" ? (r) => Promise.resolve().then(r) : (r, n) => n(r, 0), ur = typeof self < "u" ? self : typeof window < "u" ? window : Function("return this")(), Rg = "arraybuffer";
|
|
495
495
|
function af(c, ...r) {
|
|
496
496
|
return r.reduce((n, a) => (c.hasOwnProperty(a) && (n[a] = c[a]), n), {});
|
|
497
497
|
}
|
|
498
|
-
const Ag =
|
|
498
|
+
const Ag = ur.setTimeout, Mg = ur.clearTimeout;
|
|
499
499
|
function Gi(c, r) {
|
|
500
|
-
r.useNativeTimers ? (c.setTimeoutFn = Ag.bind(
|
|
500
|
+
r.useNativeTimers ? (c.setTimeoutFn = Ag.bind(ur), c.clearTimeoutFn = Mg.bind(ur)) : (c.setTimeoutFn = ur.setTimeout.bind(ur), c.clearTimeoutFn = ur.clearTimeout.bind(ur));
|
|
501
501
|
}
|
|
502
502
|
const Ig = 1.33;
|
|
503
503
|
function Pg(c) {
|
|
@@ -874,7 +874,7 @@ if (typeof document < "u") {
|
|
|
874
874
|
if (typeof attachEvent == "function")
|
|
875
875
|
attachEvent("onunload", _p);
|
|
876
876
|
else if (typeof addEventListener == "function") {
|
|
877
|
-
const c = "onpagehide" in
|
|
877
|
+
const c = "onpagehide" in ur ? "pagehide" : "unload";
|
|
878
878
|
addEventListener(c, _p, !1);
|
|
879
879
|
}
|
|
880
880
|
}
|
|
@@ -907,7 +907,7 @@ function uf(c) {
|
|
|
907
907
|
}
|
|
908
908
|
if (!r)
|
|
909
909
|
try {
|
|
910
|
-
return new
|
|
910
|
+
return new ur[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP");
|
|
911
911
|
} catch {
|
|
912
912
|
}
|
|
913
913
|
}
|
|
@@ -968,7 +968,7 @@ class qg extends Ao {
|
|
|
968
968
|
return this.opts.timestampRequests && (n[this.opts.timestampParam] = of()), this.supportsBinary || (n.b64 = 1), this.createUri(r, n);
|
|
969
969
|
}
|
|
970
970
|
}
|
|
971
|
-
const so =
|
|
971
|
+
const so = ur.WebSocket || ur.MozWebSocket;
|
|
972
972
|
class Wg extends qg {
|
|
973
973
|
createSocket(r, n, a) {
|
|
974
974
|
return df ? new so(r, n, a) : n ? new so(r, n) : new so(r);
|
|
@@ -2738,7 +2738,7 @@ const sn = {
|
|
|
2738
2738
|
RECONNECTING: "reconnecting",
|
|
2739
2739
|
FAILED: "failed",
|
|
2740
2740
|
ENDED: "ended"
|
|
2741
|
-
},
|
|
2741
|
+
}, rr = {
|
|
2742
2742
|
IDLE: "idle",
|
|
2743
2743
|
CONNECTING: "connecting",
|
|
2744
2744
|
LOADING: "loading",
|
|
@@ -2794,7 +2794,7 @@ const sn = {
|
|
|
2794
2794
|
isAudioPlaying: !1,
|
|
2795
2795
|
isAvatarSpeaking: !1,
|
|
2796
2796
|
cloudStream: {
|
|
2797
|
-
state:
|
|
2797
|
+
state: rr.IDLE,
|
|
2798
2798
|
error: null
|
|
2799
2799
|
},
|
|
2800
2800
|
transcript: null,
|
|
@@ -2821,6 +2821,13 @@ const sn = {
|
|
|
2821
2821
|
}, n.setOnEnd(() => {
|
|
2822
2822
|
f || r?.();
|
|
2823
2823
|
}), n._isDestroyed = () => f, n;
|
|
2824
|
+
}, vy = () => {
|
|
2825
|
+
try {
|
|
2826
|
+
const c = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
2827
|
+
return typeof c == "string" && c.trim() ? c.trim() : void 0;
|
|
2828
|
+
} catch {
|
|
2829
|
+
return;
|
|
2830
|
+
}
|
|
2824
2831
|
}, $p = async (c) => {
|
|
2825
2832
|
if (!c?.ok) {
|
|
2826
2833
|
let r = `HTTP ${c.status}`;
|
|
@@ -2833,7 +2840,7 @@ const sn = {
|
|
|
2833
2840
|
}
|
|
2834
2841
|
return c.json();
|
|
2835
2842
|
};
|
|
2836
|
-
function
|
|
2843
|
+
function _y({
|
|
2837
2844
|
children: c,
|
|
2838
2845
|
wsUrl: r,
|
|
2839
2846
|
restUrl: n,
|
|
@@ -2842,9 +2849,15 @@ function vy({
|
|
|
2842
2849
|
pcmOptions: v,
|
|
2843
2850
|
debug: C = !1
|
|
2844
2851
|
}) {
|
|
2845
|
-
const [R, _] = jr(Tp), U =
|
|
2852
|
+
const [R, _] = jr(Tp), U = Et(null), B = Et(null), te = Et(!1), X = Et(!1), ee = Et({
|
|
2853
|
+
...Sp,
|
|
2854
|
+
...a
|
|
2855
|
+
}), ie = Et(yy()), de = Et(null), le = Et(!1), Le = Et(null), Ce = Et(Tp.session.agentType);
|
|
2846
2856
|
xr(() => {
|
|
2847
|
-
ee.current = {
|
|
2857
|
+
ee.current = {
|
|
2858
|
+
...Sp,
|
|
2859
|
+
...a
|
|
2860
|
+
};
|
|
2848
2861
|
}, [a]), xr(() => {
|
|
2849
2862
|
Ce.current = R.session.agentType;
|
|
2850
2863
|
}, [R.session.agentType]);
|
|
@@ -2918,7 +2931,7 @@ function vy({
|
|
|
2918
2931
|
transcript: null,
|
|
2919
2932
|
partialTranscript: null,
|
|
2920
2933
|
cloudStream: {
|
|
2921
|
-
state:
|
|
2934
|
+
state: rr.IDLE,
|
|
2922
2935
|
error: null
|
|
2923
2936
|
},
|
|
2924
2937
|
session: {
|
|
@@ -2955,7 +2968,11 @@ function vy({
|
|
|
2955
2968
|
}), pe.on(lt.CONNECT_ERROR, (fe) => {
|
|
2956
2969
|
ce("socket connect_error", fe), Ne || (re(Vt.FAILED), ue(fe?.message || "Connection error"), ct(dt, fe));
|
|
2957
2970
|
}), pe.on(lt.DISCONNECT, (fe) => {
|
|
2958
|
-
ce("socket disconnected", fe), _((Ue) => ({
|
|
2971
|
+
ce("socket disconnected", fe), _((Ue) => ({
|
|
2972
|
+
...Ue,
|
|
2973
|
+
isConnected: !1,
|
|
2974
|
+
isSessionReady: !1
|
|
2975
|
+
})), !X.current && (ee.current.enabled ? re(Vt.RECONNECTING) : (re(Vt.FAILED), ue("Connection lost")));
|
|
2959
2976
|
}), pe.on(lt.SESSION_READY, (fe) => {
|
|
2960
2977
|
_((Ue) => ({
|
|
2961
2978
|
...Ue,
|
|
@@ -2963,7 +2980,9 @@ function vy({
|
|
|
2963
2980
|
error: null,
|
|
2964
2981
|
session: {
|
|
2965
2982
|
...Ue.session,
|
|
2966
|
-
agentType: io(
|
|
2983
|
+
agentType: io(
|
|
2984
|
+
fe?.agentType || Ue.session.agentType
|
|
2985
|
+
)
|
|
2967
2986
|
}
|
|
2968
2987
|
}));
|
|
2969
2988
|
}), pe.on(lt.SESSION_JOINED, () => {
|
|
@@ -2971,30 +2990,60 @@ function vy({
|
|
|
2971
2990
|
}), pe.on(lt.SESSION_TERMINATED, () => {
|
|
2972
2991
|
re(Vt.ENDED), _((fe) => ({ ...fe, isSessionReady: !1 }));
|
|
2973
2992
|
}), pe.on(lt.TRANSCRIPT, (fe) => {
|
|
2974
|
-
_((Ue) =>
|
|
2993
|
+
_((Ue) => {
|
|
2994
|
+
const Tt = { ...Ue, transcript: fe || null };
|
|
2995
|
+
if (fe?.is_final && fe?.text?.trim()) {
|
|
2996
|
+
const Rt = {
|
|
2997
|
+
id: `transcript-${Date.now()}`,
|
|
2998
|
+
role: "user",
|
|
2999
|
+
text: fe.text.trim(),
|
|
3000
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3001
|
+
};
|
|
3002
|
+
Tt.messages = [...Ue.messages, Rt];
|
|
3003
|
+
}
|
|
3004
|
+
return Tt;
|
|
3005
|
+
});
|
|
2975
3006
|
}), pe.on(lt.PARTIAL_TRANSCRIPT, (fe) => {
|
|
2976
3007
|
_((Ue) => ({ ...Ue, partialTranscript: fe || null }));
|
|
2977
3008
|
}), pe.on(lt.AGENT_RESPONSE_CHUNK, (fe) => {
|
|
2978
|
-
const { id: Ue, text:
|
|
2979
|
-
|
|
2980
|
-
|
|
3009
|
+
const { id: Ue, text: Tt } = ie.current.addChunk(
|
|
3010
|
+
fe?.requestId,
|
|
3011
|
+
fe?.text
|
|
3012
|
+
);
|
|
3013
|
+
_((Rt) => {
|
|
3014
|
+
const jt = Rt.messages.filter((cr) => cr.id !== Ue);
|
|
2981
3015
|
return {
|
|
2982
|
-
...
|
|
3016
|
+
...Rt,
|
|
2983
3017
|
messages: [
|
|
2984
|
-
...
|
|
2985
|
-
{
|
|
3018
|
+
...jt,
|
|
3019
|
+
{
|
|
3020
|
+
id: Ue,
|
|
3021
|
+
role: "assistant",
|
|
3022
|
+
text: Tt,
|
|
3023
|
+
streaming: !0,
|
|
3024
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3025
|
+
}
|
|
2986
3026
|
]
|
|
2987
3027
|
};
|
|
2988
3028
|
});
|
|
2989
3029
|
}), pe.on(lt.AGENT_RESPONSE, (fe) => {
|
|
2990
|
-
const { id: Ue, text:
|
|
2991
|
-
|
|
2992
|
-
|
|
3030
|
+
const { id: Ue, text: Tt } = ie.current.consume(
|
|
3031
|
+
fe?.requestId,
|
|
3032
|
+
fe?.text
|
|
3033
|
+
);
|
|
3034
|
+
_((Rt) => {
|
|
3035
|
+
const jt = Rt.messages.filter((cr) => cr.id !== Ue);
|
|
2993
3036
|
return {
|
|
2994
|
-
...
|
|
3037
|
+
...Rt,
|
|
2995
3038
|
messages: [
|
|
2996
|
-
...
|
|
2997
|
-
{
|
|
3039
|
+
...jt,
|
|
3040
|
+
{
|
|
3041
|
+
id: Ue,
|
|
3042
|
+
role: "assistant",
|
|
3043
|
+
text: Tt,
|
|
3044
|
+
streaming: !1,
|
|
3045
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3046
|
+
}
|
|
2998
3047
|
]
|
|
2999
3048
|
};
|
|
3000
3049
|
});
|
|
@@ -3007,14 +3056,14 @@ function vy({
|
|
|
3007
3056
|
const Ue = io(Ce.current);
|
|
3008
3057
|
if (Ue === sn.CLOUD_AVATAR || Ue === sn.DESKTOP_AVATAR)
|
|
3009
3058
|
return;
|
|
3010
|
-
const
|
|
3011
|
-
if (!
|
|
3012
|
-
const
|
|
3013
|
-
if (
|
|
3059
|
+
const Tt = gy(fe?.audio);
|
|
3060
|
+
if (!Tt) return;
|
|
3061
|
+
const Rt = he();
|
|
3062
|
+
if (Rt)
|
|
3014
3063
|
try {
|
|
3015
|
-
|
|
3016
|
-
} catch (
|
|
3017
|
-
ce("feed pcm failed",
|
|
3064
|
+
Rt.feed(Tt), _((jt) => ({ ...jt, isAudioPlaying: !0 }));
|
|
3065
|
+
} catch (jt) {
|
|
3066
|
+
ce("feed pcm failed", jt);
|
|
3018
3067
|
}
|
|
3019
3068
|
}), pe.on(lt.AGENT_AUDIO_COMPLETE, () => {
|
|
3020
3069
|
if (!f || !de.current) return;
|
|
@@ -3068,12 +3117,12 @@ function vy({
|
|
|
3068
3117
|
reject: ct
|
|
3069
3118
|
}), wt) {
|
|
3070
3119
|
const Ue = () => {
|
|
3071
|
-
fe.off(lt.RECONNECT_FAILED,
|
|
3072
|
-
},
|
|
3073
|
-
fe.off(lt.RECONNECT_SUCCESS, Ue), ct(new Error(
|
|
3120
|
+
fe.off(lt.RECONNECT_FAILED, Tt), dt();
|
|
3121
|
+
}, Tt = (Rt) => {
|
|
3122
|
+
fe.off(lt.RECONNECT_SUCCESS, Ue), ct(new Error(Rt?.reason || "Reconnect failed"));
|
|
3074
3123
|
};
|
|
3075
|
-
fe.once(lt.RECONNECT_SUCCESS, Ue), fe.once(lt.RECONNECT_FAILED,
|
|
3076
|
-
fe.off(lt.RECONNECT_SUCCESS, Ue), fe.off(lt.RECONNECT_FAILED,
|
|
3124
|
+
fe.once(lt.RECONNECT_SUCCESS, Ue), fe.once(lt.RECONNECT_FAILED, Tt), setTimeout(() => {
|
|
3125
|
+
fe.off(lt.RECONNECT_SUCCESS, Ue), fe.off(lt.RECONNECT_FAILED, Tt), ct(new Error("Reconnect timed out"));
|
|
3077
3126
|
}, ee.current.timeoutMs);
|
|
3078
3127
|
}
|
|
3079
3128
|
}),
|
|
@@ -3132,20 +3181,25 @@ function vy({
|
|
|
3132
3181
|
method: "POST",
|
|
3133
3182
|
headers: { "Content-Type": "application/json" },
|
|
3134
3183
|
body: JSON.stringify(ct)
|
|
3135
|
-
}).then($p), Ue = fe?.session_id || null,
|
|
3136
|
-
if (!Ue || !
|
|
3184
|
+
}).then($p), Ue = fe?.session_id || null, Tt = fe?.session_token;
|
|
3185
|
+
if (!Ue || !Tt)
|
|
3137
3186
|
throw new Error("Invalid initialize session response");
|
|
3138
|
-
|
|
3139
|
-
...
|
|
3187
|
+
_((jt) => ({
|
|
3188
|
+
...jt,
|
|
3140
3189
|
session: {
|
|
3141
|
-
...
|
|
3190
|
+
...jt.session,
|
|
3142
3191
|
sessionId: Ue,
|
|
3143
|
-
agentType: fe?.streaming_url ? sn.CLOUD_AVATAR :
|
|
3192
|
+
agentType: fe?.streaming_url ? sn.CLOUD_AVATAR : jt.session.agentType,
|
|
3144
3193
|
streamingUrl: fe?.streaming_url || null,
|
|
3145
3194
|
uniqueId: fe?.unique_id || null,
|
|
3146
3195
|
role: null
|
|
3147
3196
|
}
|
|
3148
|
-
})), re(Vt.CONNECTING), fe?.streaming_url ? Ke(
|
|
3197
|
+
})), re(Vt.CONNECTING), fe?.streaming_url ? Ke(rr.CONNECTING) : Ke(rr.IDLE);
|
|
3198
|
+
const Rt = vy();
|
|
3199
|
+
return await yt({
|
|
3200
|
+
authPayload: Rt ? { token: Tt, timezone: Rt } : { token: Tt },
|
|
3201
|
+
queryToken: Tt
|
|
3202
|
+
}), fe;
|
|
3149
3203
|
},
|
|
3150
3204
|
[
|
|
3151
3205
|
yt,
|
|
@@ -3178,7 +3232,10 @@ function vy({
|
|
|
3178
3232
|
role: "user",
|
|
3179
3233
|
agentType: sn.DESKTOP_AVATAR
|
|
3180
3234
|
}
|
|
3181
|
-
})), re(Vt.CONNECTING), Ke(
|
|
3235
|
+
})), re(Vt.CONNECTING), Ke(rr.IDLE), await yt({
|
|
3236
|
+
authPayload: { token: dt },
|
|
3237
|
+
queryToken: dt
|
|
3238
|
+
}), Ne;
|
|
3182
3239
|
},
|
|
3183
3240
|
[
|
|
3184
3241
|
yt,
|
|
@@ -3191,7 +3248,10 @@ function vy({
|
|
|
3191
3248
|
]
|
|
3192
3249
|
), rt = Qe(() => {
|
|
3193
3250
|
Be({ keepManualDisconnect: !0 });
|
|
3194
|
-
}, [Be]), Ze = Qe(async () => (rt(), { success: !0 }), [rt]), Q = Qe(
|
|
3251
|
+
}, [Be]), Ze = Qe(async () => (rt(), { success: !0 }), [rt]), Q = Qe(
|
|
3252
|
+
(pe, Ne = {}) => !U.current || !R.isConnected ? !1 : (U.current.emit(pe, Ne), !0),
|
|
3253
|
+
[R.isConnected]
|
|
3254
|
+
), Ae = Qe(
|
|
3195
3255
|
(pe) => {
|
|
3196
3256
|
if (!pe || !String(pe).trim()) return !1;
|
|
3197
3257
|
const Ne = {
|
|
@@ -3200,16 +3260,28 @@ function vy({
|
|
|
3200
3260
|
text: String(pe),
|
|
3201
3261
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3202
3262
|
};
|
|
3203
|
-
return _((wt) => ({
|
|
3263
|
+
return _((wt) => ({
|
|
3264
|
+
...wt,
|
|
3265
|
+
messages: [...wt.messages, Ne]
|
|
3266
|
+
})), Q(lt.USER_MESSAGE, { message: String(pe) });
|
|
3204
3267
|
},
|
|
3205
3268
|
[Q]
|
|
3206
|
-
), et = Qe(
|
|
3269
|
+
), et = Qe(
|
|
3270
|
+
(pe) => Q(lt.AUDIO_CHUNK, { audio: pe }),
|
|
3271
|
+
[Q]
|
|
3272
|
+
), gt = Qe(
|
|
3273
|
+
() => Q(lt.AUDIO_END, {}),
|
|
3274
|
+
[Q]
|
|
3275
|
+
), qt = Qe(() => (le.current = !0, Me(), _((pe) => ({ ...pe, isAudioPlaying: !1 })), Q(lt.INTERRUPT, {})), [Me, Q]), kt = Qe(
|
|
3207
3276
|
() => Q(lt.REFRESH_SESSION_ACTIVITY, {}),
|
|
3208
3277
|
[Q]
|
|
3209
|
-
), ot = Qe(
|
|
3278
|
+
), ot = Qe(
|
|
3279
|
+
() => Q(lt.CLEAR_SESSION_HISTORY, {}),
|
|
3280
|
+
[Q]
|
|
3281
|
+
), tt = Qe(
|
|
3210
3282
|
(pe) => pe ? Q(lt.CHANGE_SESSION_LANGUAGE, { language: pe }) : !1,
|
|
3211
3283
|
[Q]
|
|
3212
|
-
),
|
|
3284
|
+
), Yt = Qe(() => {
|
|
3213
3285
|
ie.current.clear(), _((pe) => ({ ...pe, messages: [] }));
|
|
3214
3286
|
}, []);
|
|
3215
3287
|
xr(() => () => {
|
|
@@ -3227,10 +3299,10 @@ function vy({
|
|
|
3227
3299
|
sendAudioChunk: et,
|
|
3228
3300
|
endAudioStream: gt,
|
|
3229
3301
|
interrupt: qt,
|
|
3230
|
-
refreshSessionActivity:
|
|
3302
|
+
refreshSessionActivity: kt,
|
|
3231
3303
|
clearSessionHistory: ot,
|
|
3232
3304
|
changeSessionLanguage: tt,
|
|
3233
|
-
clearMessages:
|
|
3305
|
+
clearMessages: Yt,
|
|
3234
3306
|
resumeAudioPlayback: me,
|
|
3235
3307
|
attachAudioElement: ut,
|
|
3236
3308
|
setCloudStreamState: Ke,
|
|
@@ -3239,7 +3311,7 @@ function vy({
|
|
|
3239
3311
|
}),
|
|
3240
3312
|
[
|
|
3241
3313
|
ut,
|
|
3242
|
-
|
|
3314
|
+
Yt,
|
|
3243
3315
|
ot,
|
|
3244
3316
|
rt,
|
|
3245
3317
|
Q,
|
|
@@ -3249,7 +3321,7 @@ function vy({
|
|
|
3249
3321
|
tt,
|
|
3250
3322
|
De,
|
|
3251
3323
|
Ze,
|
|
3252
|
-
|
|
3324
|
+
kt,
|
|
3253
3325
|
me,
|
|
3254
3326
|
et,
|
|
3255
3327
|
Ae,
|
|
@@ -3257,17 +3329,19 @@ function vy({
|
|
|
3257
3329
|
R
|
|
3258
3330
|
]
|
|
3259
3331
|
);
|
|
3260
|
-
return /* @__PURE__ */
|
|
3332
|
+
return /* @__PURE__ */ lr.jsx(pf.Provider, { value: vt, children: c });
|
|
3261
3333
|
}
|
|
3262
3334
|
const on = () => {
|
|
3263
3335
|
const c = gg(pf);
|
|
3264
3336
|
if (!c)
|
|
3265
|
-
throw new Error(
|
|
3337
|
+
throw new Error(
|
|
3338
|
+
"useRqmiiAgentContext must be used inside <RqmiiAgentProvider>"
|
|
3339
|
+
);
|
|
3266
3340
|
return c;
|
|
3267
|
-
},
|
|
3341
|
+
}, by = [
|
|
3268
3342
|
"Cannot read properties of null (reading 'state')",
|
|
3269
3343
|
"MicVAD has null stream"
|
|
3270
|
-
], xp = (c) => c ?
|
|
3344
|
+
], xp = (c) => c ? by.some((r) => String(c).includes(r)) : !1;
|
|
3271
3345
|
function ff() {
|
|
3272
3346
|
typeof window > "u" || window.__rqmiiAudioErrorSuppressorsInstalled || (window.__rqmiiAudioErrorSuppressorsInstalled = !0, window.addEventListener("error", (c) => {
|
|
3273
3347
|
if (xp(c?.message))
|
|
@@ -3278,18 +3352,18 @@ function ff() {
|
|
|
3278
3352
|
}));
|
|
3279
3353
|
}
|
|
3280
3354
|
ff();
|
|
3281
|
-
const
|
|
3355
|
+
const Sy = {
|
|
3282
3356
|
echoCancellation: !0,
|
|
3283
3357
|
noiseSuppression: !0,
|
|
3284
3358
|
autoGainControl: !0,
|
|
3285
3359
|
channelCount: 1,
|
|
3286
3360
|
sampleRate: 16e3
|
|
3287
|
-
},
|
|
3361
|
+
}, Ty = [
|
|
3288
3362
|
"audio/webm;codecs=opus",
|
|
3289
3363
|
"audio/webm",
|
|
3290
3364
|
"audio/mp4"
|
|
3291
|
-
],
|
|
3292
|
-
function
|
|
3365
|
+
], $y = () => typeof window > "u" || !window.MediaRecorder?.isTypeSupported ? "" : Ty.find((c) => window.MediaRecorder.isTypeSupported(c)) || "";
|
|
3366
|
+
function Uw(c = {}) {
|
|
3293
3367
|
const {
|
|
3294
3368
|
onAudioChunk: r,
|
|
3295
3369
|
onAudioEnd: n,
|
|
@@ -3297,8 +3371,8 @@ function Nw(c = {}) {
|
|
|
3297
3371
|
holdDelayMs: f = 220,
|
|
3298
3372
|
timesliceMs: v = 100,
|
|
3299
3373
|
interruptOnHoldStart: C = !0,
|
|
3300
|
-
audioConstraints: R =
|
|
3301
|
-
} = c, { sendAudioChunk: _, endAudioStream: U, interrupt: B } = on(), te =
|
|
3374
|
+
audioConstraints: R = Sy
|
|
3375
|
+
} = c, { sendAudioChunk: _, endAudioStream: U, interrupt: B } = on(), te = Et(null), X = Et(null), ee = Et(null), ie = Et(!0), [de, le] = jr(!1), [Le, Ce] = jr(!1), [ce, re] = jr(null), ue = Qe(
|
|
3302
3376
|
async (Be) => {
|
|
3303
3377
|
if (!Be || Be.size <= 0) return;
|
|
3304
3378
|
const Xe = await Be.arrayBuffer();
|
|
@@ -3341,7 +3415,7 @@ function Nw(c = {}) {
|
|
|
3341
3415
|
try {
|
|
3342
3416
|
const Be = await navigator.mediaDevices.getUserMedia({ audio: R });
|
|
3343
3417
|
X.current = Be;
|
|
3344
|
-
const Xe =
|
|
3418
|
+
const Xe = $y(), mt = Xe ? { mimeType: Xe } : void 0, yt = new window.MediaRecorder(Be, mt);
|
|
3345
3419
|
return yt.ondataavailable = (at) => {
|
|
3346
3420
|
ue(at.data);
|
|
3347
3421
|
}, yt.onerror = (at) => {
|
|
@@ -3506,7 +3580,7 @@ function Oo() {
|
|
|
3506
3580
|
return Gr.FrameProcessor = v, Gr;
|
|
3507
3581
|
}
|
|
3508
3582
|
var qr = {};
|
|
3509
|
-
function
|
|
3583
|
+
function dr(c) {
|
|
3510
3584
|
throw new Error('Could not dynamically require "' + c + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
|
|
3511
3585
|
}
|
|
3512
3586
|
var lo = { exports: {} };
|
|
@@ -3516,11 +3590,11 @@ var lo = { exports: {} };
|
|
|
3516
3590
|
* Licensed under the MIT License.
|
|
3517
3591
|
*/
|
|
3518
3592
|
var Mp;
|
|
3519
|
-
function
|
|
3593
|
+
function xy() {
|
|
3520
3594
|
return Mp || (Mp = 1, (function(c, r) {
|
|
3521
3595
|
var n = (() => {
|
|
3522
|
-
var a = Object.defineProperty, f = Object.getOwnPropertyDescriptor, v = Object.getOwnPropertyNames, C = Object.prototype.hasOwnProperty, R = ((e) => typeof
|
|
3523
|
-
if (typeof
|
|
3596
|
+
var a = Object.defineProperty, f = Object.getOwnPropertyDescriptor, v = Object.getOwnPropertyNames, C = Object.prototype.hasOwnProperty, R = ((e) => typeof dr < "u" ? dr : typeof Proxy < "u" ? new Proxy(e, { get: (t, s) => (typeof dr < "u" ? dr : t)[s] }) : e)(function(e) {
|
|
3597
|
+
if (typeof dr < "u") return dr.apply(this, arguments);
|
|
3524
3598
|
throw Error('Dynamic require of "' + e + '" is not supported');
|
|
3525
3599
|
}), _ = (e, t) => () => (e && (t = e(e = 0)), t), U = (e, t) => {
|
|
3526
3600
|
for (var s in t) a(e, s, { get: t[s], enumerable: !0 });
|
|
@@ -3624,7 +3698,7 @@ function $y() {
|
|
|
3624
3698
|
return i;
|
|
3625
3699
|
};
|
|
3626
3700
|
}), Xe, mt, yt, at, Ye, De, rt = _(() => {
|
|
3627
|
-
|
|
3701
|
+
Yt(), Xe = (e, t) => {
|
|
3628
3702
|
if (e === void 0) throw new Error("Image buffer must be defined");
|
|
3629
3703
|
if (t.height === void 0 || t.width === void 0) throw new Error("Image height and width must be defined");
|
|
3630
3704
|
if (t.tensorLayout === "NHWC") throw new Error("NHWC Tensor layout is not supported yet");
|
|
@@ -3703,8 +3777,8 @@ function $y() {
|
|
|
3703
3777
|
e && (Ze.set("int64", BigInt64Array), Q.set(BigInt64Array, "int64")), t && (Ze.set("uint64", BigUint64Array), Q.set(BigUint64Array, "uint64")), i ? (Ze.set("float16", s), Q.set(s, "float16")) : Ze.set("float16", Uint16Array);
|
|
3704
3778
|
}
|
|
3705
3779
|
};
|
|
3706
|
-
}), qt,
|
|
3707
|
-
|
|
3780
|
+
}), qt, kt, ot = _(() => {
|
|
3781
|
+
Yt(), qt = (e) => {
|
|
3708
3782
|
let t = 1;
|
|
3709
3783
|
for (let s = 0; s < e.length; s++) {
|
|
3710
3784
|
let i = e[s];
|
|
@@ -3713,7 +3787,7 @@ function $y() {
|
|
|
3713
3787
|
t *= i;
|
|
3714
3788
|
}
|
|
3715
3789
|
return t;
|
|
3716
|
-
},
|
|
3790
|
+
}, kt = (e, t) => {
|
|
3717
3791
|
switch (e.location) {
|
|
3718
3792
|
case "cpu":
|
|
3719
3793
|
return new tt(e.type, e.data, t);
|
|
@@ -3729,7 +3803,7 @@ function $y() {
|
|
|
3729
3803
|
throw new Error(`tensorReshape: tensor location ${e.location} is not supported`);
|
|
3730
3804
|
}
|
|
3731
3805
|
};
|
|
3732
|
-
}), tt,
|
|
3806
|
+
}), tt, Yt = _(() => {
|
|
3733
3807
|
Be(), rt(), gt(), ot(), tt = class {
|
|
3734
3808
|
constructor(e, t, s) {
|
|
3735
3809
|
et();
|
|
@@ -3868,12 +3942,12 @@ function $y() {
|
|
|
3868
3942
|
}
|
|
3869
3943
|
reshape(e) {
|
|
3870
3944
|
if (this.ensureValid(), this.downloader || this.disposer) throw new Error("Cannot reshape a tensor that owns GPU resource.");
|
|
3871
|
-
return
|
|
3945
|
+
return kt(this, e);
|
|
3872
3946
|
}
|
|
3873
3947
|
};
|
|
3874
3948
|
}), vt, pe = _(() => {
|
|
3875
|
-
|
|
3876
|
-
}), Ne, wt, dt, ct, fe, Ue,
|
|
3949
|
+
Yt(), vt = tt;
|
|
3950
|
+
}), Ne, wt, dt, ct, fe, Ue, Tt = _(() => {
|
|
3877
3951
|
Me(), Ne = (e, t) => {
|
|
3878
3952
|
(typeof he.trace > "u" ? !he.wasm.trace : !he.trace) || console.timeStamp(`${e}::ORT::${t}`);
|
|
3879
3953
|
}, wt = (e, t) => {
|
|
@@ -3895,8 +3969,8 @@ function $y() {
|
|
|
3895
3969
|
}, Ue = (e) => {
|
|
3896
3970
|
(typeof he.trace > "u" ? !he.wasm.trace : !he.trace) || console.timeEnd(`ORT::${e}`);
|
|
3897
3971
|
};
|
|
3898
|
-
}),
|
|
3899
|
-
Le(), pe(),
|
|
3972
|
+
}), Rt, jt = _(() => {
|
|
3973
|
+
Le(), pe(), Tt(), Rt = class gf {
|
|
3900
3974
|
constructor(t) {
|
|
3901
3975
|
this.handler = t;
|
|
3902
3976
|
}
|
|
@@ -3989,7 +4063,7 @@ function $y() {
|
|
|
3989
4063
|
}
|
|
3990
4064
|
};
|
|
3991
4065
|
}), cr, Wi = _(() => {
|
|
3992
|
-
|
|
4066
|
+
jt(), cr = Rt;
|
|
3993
4067
|
}), Hi = _(() => {
|
|
3994
4068
|
}), ji = _(() => {
|
|
3995
4069
|
}), Ki = _(() => {
|
|
@@ -3997,12 +4071,12 @@ function $y() {
|
|
|
3997
4071
|
}), ls = {};
|
|
3998
4072
|
U(ls, { InferenceSession: () => cr, TRACE: () => Ne, TRACE_EVENT_BEGIN: () => fe, TRACE_EVENT_END: () => Ue, TRACE_FUNC_BEGIN: () => dt, TRACE_FUNC_END: () => ct, Tensor: () => vt, env: () => me, registerBackend: () => ie });
|
|
3999
4073
|
var zt = _(() => {
|
|
4000
|
-
Ce(), ut(), Wi(), pe(), Hi(), ji(),
|
|
4074
|
+
Ce(), ut(), Wi(), pe(), Hi(), ji(), Tt(), Ki(), Qi();
|
|
4001
4075
|
}), ln = _(() => {
|
|
4002
4076
|
}), us = {};
|
|
4003
4077
|
U(us, { default: () => ds });
|
|
4004
4078
|
var un, dn, ds, Xi = _(() => {
|
|
4005
|
-
Zh(),
|
|
4079
|
+
Zh(), Jt(), mn(), un = "ort-wasm-proxy-worker", dn = globalThis.self?.name === un, dn && (self.onmessage = (e) => {
|
|
4006
4080
|
let { type: t, in: s } = e.data;
|
|
4007
4081
|
try {
|
|
4008
4082
|
switch (t) {
|
|
@@ -4101,7 +4175,7 @@ function $y() {
|
|
|
4101
4175
|
return [d ? h : void 0, await ms(h)];
|
|
4102
4176
|
}
|
|
4103
4177
|
};
|
|
4104
|
-
}), gn, Br, hr, yn, ws, vs, _s, wn, Oe,
|
|
4178
|
+
}), gn, Br, hr, yn, ws, vs, _s, wn, Oe, Jt = _(() => {
|
|
4105
4179
|
mn(), Br = !1, hr = !1, yn = !1, ws = () => {
|
|
4106
4180
|
if (typeof SharedArrayBuffer > "u") return !1;
|
|
4107
4181
|
try {
|
|
@@ -4158,8 +4232,8 @@ function $y() {
|
|
|
4158
4232
|
if (Br && gn) return gn;
|
|
4159
4233
|
throw new Error("WebAssembly is not initialized yet.");
|
|
4160
4234
|
};
|
|
4161
|
-
}),
|
|
4162
|
-
|
|
4235
|
+
}), Ct, Nr, ke, vn = _(() => {
|
|
4236
|
+
Jt(), Ct = (e, t) => {
|
|
4163
4237
|
let s = Oe(), i = s.lengthBytesUTF8(e) + 1, o = s._malloc(i);
|
|
4164
4238
|
return s.stringToUTF8(e, o, i), t.push(o), o;
|
|
4165
4239
|
}, Nr = (e, t, s, i) => {
|
|
@@ -4186,7 +4260,7 @@ function $y() {
|
|
|
4186
4260
|
}
|
|
4187
4261
|
};
|
|
4188
4262
|
}), bs, Yi = _(() => {
|
|
4189
|
-
|
|
4263
|
+
Jt(), vn(), bs = (e) => {
|
|
4190
4264
|
let t = Oe(), s = 0, i = [], o = e || {};
|
|
4191
4265
|
try {
|
|
4192
4266
|
if (e?.logSeverityLevel === void 0) o.logSeverityLevel = 2;
|
|
@@ -4195,8 +4269,8 @@ function $y() {
|
|
|
4195
4269
|
else if (typeof e.logVerbosityLevel != "number" || !Number.isInteger(e.logVerbosityLevel)) throw new Error(`log verbosity level is not valid: ${e.logVerbosityLevel}`);
|
|
4196
4270
|
e?.terminate === void 0 && (o.terminate = !1);
|
|
4197
4271
|
let l = 0;
|
|
4198
|
-
return e?.tag !== void 0 && (l =
|
|
4199
|
-
let h =
|
|
4272
|
+
return e?.tag !== void 0 && (l = Ct(e.tag, i)), s = t._OrtCreateRunOptions(o.logSeverityLevel, o.logVerbosityLevel, !!o.terminate, l), s === 0 && ke("Can't create run options."), e?.extra !== void 0 && Nr(e.extra, "", /* @__PURE__ */ new WeakSet(), (u, d) => {
|
|
4273
|
+
let h = Ct(u, i), p = Ct(d, i);
|
|
4200
4274
|
t._OrtAddRunConfigEntry(s, h, p) !== 0 && ke(`Can't set a run config entry: ${u} - ${d}.`);
|
|
4201
4275
|
}), [s, i];
|
|
4202
4276
|
} catch (l) {
|
|
@@ -4204,7 +4278,7 @@ function $y() {
|
|
|
4204
4278
|
}
|
|
4205
4279
|
};
|
|
4206
4280
|
}), Ss, Ts, $s, pr, xs, Es, Ji = _(() => {
|
|
4207
|
-
|
|
4281
|
+
Jt(), vn(), Ss = (e) => {
|
|
4208
4282
|
switch (e) {
|
|
4209
4283
|
case "disabled":
|
|
4210
4284
|
return 0;
|
|
@@ -4233,7 +4307,7 @@ function $y() {
|
|
|
4233
4307
|
let t = e.extra.session;
|
|
4234
4308
|
t.use_ort_model_bytes_directly || (t.use_ort_model_bytes_directly = "1"), e.executionProviders && e.executionProviders.some((s) => (typeof s == "string" ? s : s.name) === "webgpu") && (e.enableMemPattern = !1);
|
|
4235
4309
|
}, pr = (e, t, s, i) => {
|
|
4236
|
-
let o =
|
|
4310
|
+
let o = Ct(t, i), l = Ct(s, i);
|
|
4237
4311
|
Oe()._OrtAddSessionConfigEntry(e, o, l) !== 0 && ke(`Can't set a session config entry: ${t} - ${s}.`);
|
|
4238
4312
|
}, xs = async (e, t, s) => {
|
|
4239
4313
|
let i = t.executionProviders;
|
|
@@ -4261,7 +4335,7 @@ function $y() {
|
|
|
4261
4335
|
default:
|
|
4262
4336
|
throw new Error(`not supported execution provider: ${l}`);
|
|
4263
4337
|
}
|
|
4264
|
-
let d =
|
|
4338
|
+
let d = Ct(l, s), h = u.length, p = 0, g = 0;
|
|
4265
4339
|
if (h > 0) {
|
|
4266
4340
|
p = Oe()._malloc(h * Oe().PTR_SIZE), s.push(p), g = Oe()._malloc(h * Oe().PTR_SIZE), s.push(g);
|
|
4267
4341
|
for (let m = 0; m < h; m++) Oe().setValue(p + m * Oe().PTR_SIZE, u[m][0], "*"), Oe().setValue(g + m * Oe().PTR_SIZE, u[m][1], "*");
|
|
@@ -4272,11 +4346,11 @@ function $y() {
|
|
|
4272
4346
|
let t = Oe(), s = 0, i = [], o = e || {};
|
|
4273
4347
|
$s(o);
|
|
4274
4348
|
try {
|
|
4275
|
-
let l = Ss(o.graphOptimizationLevel ?? "all"), u = Ts(o.executionMode ?? "sequential"), d = typeof o.logId == "string" ?
|
|
4349
|
+
let l = Ss(o.graphOptimizationLevel ?? "all"), u = Ts(o.executionMode ?? "sequential"), d = typeof o.logId == "string" ? Ct(o.logId, i) : 0, h = o.logSeverityLevel ?? 2;
|
|
4276
4350
|
if (!Number.isInteger(h) || h < 0 || h > 4) throw new Error(`log severity level is not valid: ${h}`);
|
|
4277
4351
|
let p = o.logVerbosityLevel ?? 0;
|
|
4278
4352
|
if (!Number.isInteger(p) || p < 0 || p > 4) throw new Error(`log verbosity level is not valid: ${p}`);
|
|
4279
|
-
let g = typeof o.optimizedModelFilePath == "string" ?
|
|
4353
|
+
let g = typeof o.optimizedModelFilePath == "string" ? Ct(o.optimizedModelFilePath, i) : 0;
|
|
4280
4354
|
if (s = t._OrtCreateSessionOptions(l, !!o.enableCpuMemArena, !!o.enableMemPattern, u, !!o.enableProfiling, 0, d, h, p, g), s === 0 && ke("Can't create session options."), o.executionProviders && await xs(s, o, i), o.enableGraphCapture !== void 0) {
|
|
4281
4355
|
if (typeof o.enableGraphCapture != "boolean") throw new Error(`enableGraphCapture must be a boolean value: ${o.enableGraphCapture}`);
|
|
4282
4356
|
pr(s, "enableGraphCapture", o.enableGraphCapture.toString(), i);
|
|
@@ -4284,7 +4358,7 @@ function $y() {
|
|
|
4284
4358
|
if (o.freeDimensionOverrides) for (let [m, w] of Object.entries(o.freeDimensionOverrides)) {
|
|
4285
4359
|
if (typeof m != "string") throw new Error(`free dimension override name must be a string: ${m}`);
|
|
4286
4360
|
if (typeof w != "number" || !Number.isInteger(w) || w < 0) throw new Error(`free dimension override value must be a non-negative integer: ${w}`);
|
|
4287
|
-
let b =
|
|
4361
|
+
let b = Ct(m, i);
|
|
4288
4362
|
t._OrtAddFreeDimensionOverride(s, b, w) !== 0 && ke(`Can't set a free dimension override: ${m} - ${w}.`);
|
|
4289
4363
|
}
|
|
4290
4364
|
return o.extra !== void 0 && Nr(o.extra, "", /* @__PURE__ */ new WeakSet(), (m, w) => {
|
|
@@ -4294,8 +4368,8 @@ function $y() {
|
|
|
4294
4368
|
throw s !== 0 && t._OrtReleaseSessionOptions(s) !== 0 && ke("Can't release session options."), i.forEach((u) => t._free(u)), l;
|
|
4295
4369
|
}
|
|
4296
4370
|
};
|
|
4297
|
-
}),
|
|
4298
|
-
|
|
4371
|
+
}), Zt, er, tr, _n, bn, Sn, Tn, Un, Ie = _(() => {
|
|
4372
|
+
Zt = (e) => {
|
|
4299
4373
|
switch (e) {
|
|
4300
4374
|
case "int8":
|
|
4301
4375
|
return 3;
|
|
@@ -4330,7 +4404,7 @@ function $y() {
|
|
|
4330
4404
|
default:
|
|
4331
4405
|
throw new Error(`unsupported data type: ${e}`);
|
|
4332
4406
|
}
|
|
4333
|
-
},
|
|
4407
|
+
}, er = (e) => {
|
|
4334
4408
|
switch (e) {
|
|
4335
4409
|
case 3:
|
|
4336
4410
|
return "int8";
|
|
@@ -4365,7 +4439,7 @@ function $y() {
|
|
|
4365
4439
|
default:
|
|
4366
4440
|
throw new Error(`unsupported data type: ${e}`);
|
|
4367
4441
|
}
|
|
4368
|
-
},
|
|
4442
|
+
}, tr = (e, t) => {
|
|
4369
4443
|
let s = [-1, 4, 1, 1, 2, 2, 4, 8, -1, 1, 2, 8, 4, 8, -1, -1, -1, -1, -1, -1, -1, 0.5, 0.5][e], i = typeof t == "number" ? t : t.reduce((o, l) => o * l, 1);
|
|
4370
4444
|
return s > 0 ? Math.ceil(i * s) : void 0;
|
|
4371
4445
|
}, _n = (e) => {
|
|
@@ -4459,7 +4533,7 @@ function $y() {
|
|
|
4459
4533
|
}
|
|
4460
4534
|
} else return e instanceof Blob ? new Uint8Array(await e.arrayBuffer()) : e instanceof Uint8Array ? e : new Uint8Array(e);
|
|
4461
4535
|
};
|
|
4462
|
-
}), ks, Fn, Vn, Cr, Gn, qn, Je,
|
|
4536
|
+
}), ks, Fn, Vn, Cr, Gn, qn, Je, nr = _(() => {
|
|
4463
4537
|
Ie(), ks = ["V", "I", "W", "E", "F"], Fn = (e, t) => {
|
|
4464
4538
|
console.log(`[${ks[e]},${(/* @__PURE__ */ new Date()).toISOString()}]${t}`);
|
|
4465
4539
|
}, Gn = (e, t) => {
|
|
@@ -4638,7 +4712,7 @@ function $y() {
|
|
|
4638
4712
|
}), Rr, Xr = _(() => {
|
|
4639
4713
|
Ie(), Rr = (e, t) => new (_n(t))(e);
|
|
4640
4714
|
}), Ur, Yr, xn, En, mr, Ar, jn, Kn, Qn, As, Ms, hi = _(() => {
|
|
4641
|
-
Ie(),
|
|
4715
|
+
Ie(), nr(), Ur = /* @__PURE__ */ new Map([["float32", 32], ["float16", 16], ["int32", 32], ["uint32", 32], ["int64", 64], ["uint64", 64], ["int8", 8], ["uint8", 8], ["int4", 4], ["uint4", 4]]), Yr = (e, t) => {
|
|
4642
4716
|
if (t === "int32") return e;
|
|
4643
4717
|
let s = Ur.get(t);
|
|
4644
4718
|
if (!s) throw new Error(`WebNN backend does not support data type: ${t}`);
|
|
@@ -4854,7 +4928,7 @@ function $y() {
|
|
|
4854
4928
|
}
|
|
4855
4929
|
}, Ms = (...e) => new As(...e);
|
|
4856
4930
|
}), Jr, Is, Ps, Os = _(() => {
|
|
4857
|
-
Ie(),
|
|
4931
|
+
Ie(), Jt(), Xr(), hi(), nr(), Jr = /* @__PURE__ */ new Map([[1, "float32"], [10, "float16"], [6, "int32"], [12, "uint32"], [7, "int64"], [13, "uint64"], [22, "int4"], [21, "uint4"], [3, "int8"], [2, "uint8"], [9, "uint8"]]), Is = (e, t) => {
|
|
4858
4932
|
if (e === t) return !0;
|
|
4859
4933
|
if (e === void 0 || t === void 0) return !1;
|
|
4860
4934
|
let s = Object.keys(e).sort(), i = Object.keys(t).sort();
|
|
@@ -5021,7 +5095,7 @@ function $y() {
|
|
|
5021
5095
|
return s ? s.includes(t) : !1;
|
|
5022
5096
|
}
|
|
5023
5097
|
isGraphInputOutputTypeSupported(e, t, s = !0) {
|
|
5024
|
-
let i = Jr.get(
|
|
5098
|
+
let i = Jr.get(Zt(t)), o = this.mlOpSupportLimitsBySessionId.get(e);
|
|
5025
5099
|
return typeof i > "u" ? !1 : s ? !!o?.input.dataTypes.includes(i) : !!o?.output.dataTypes.includes(i);
|
|
5026
5100
|
}
|
|
5027
5101
|
flush() {
|
|
@@ -5029,7 +5103,7 @@ function $y() {
|
|
|
5029
5103
|
};
|
|
5030
5104
|
}), Xn = _(() => {
|
|
5031
5105
|
}), Yn, Jn, Cn, Zn, es, ts, zs, Ds, pi, Zi = _(() => {
|
|
5032
|
-
|
|
5106
|
+
nr(), Xn(), Yn = /* @__PURE__ */ new Map([[64, 250], [128, 200], [256, 200], [512, 200], [2048, 230], [4096, 200], [8192, 50], [16384, 50], [32768, 50], [65536, 50], [131072, 50], [262144, 50], [524288, 50], [1048576, 50], [2097152, 30], [4194304, 20], [8388608, 10], [12582912, 10], [16777216, 10], [26214400, 15], [33554432, 22], [44236800, 2], [58982400, 6], [67108864, 6], [134217728, 6], [167772160, 6]]), Jn = [], Cn = (e) => Math.ceil(Number(e) / 16) * 16, Zn = (e) => {
|
|
5033
5107
|
for (let t = 0; t < Jn.length; t++) {
|
|
5034
5108
|
let s = Jn[t];
|
|
5035
5109
|
if (e <= s) return s;
|
|
@@ -5360,7 +5434,7 @@ function $y() {
|
|
|
5360
5434
|
return this.uniforms.map((t) => [e(t.type), t.length ?? 1]);
|
|
5361
5435
|
}
|
|
5362
5436
|
}, qe = (e, t) => new $e(e, t);
|
|
5363
|
-
}), Bt, Nt, Mr, Zr, rs, Ls,
|
|
5437
|
+
}), Bt, Nt, Mr, Zr, rs, Ls, $t, ir, Bs, We = _(() => {
|
|
5364
5438
|
Ie(), Re(), A(), _e(), Bt = (e, t) => {
|
|
5365
5439
|
if (!e || e.length !== 1) throw new Error("Transpose requires 1 input.");
|
|
5366
5440
|
if (t.length !== 0 && t.length !== e[0].dims.length) throw new Error(`perm size ${t.length} does not match input rank ${e[0].dims.length}`);
|
|
@@ -5380,7 +5454,7 @@ function $y() {
|
|
|
5380
5454
|
s = e[i];
|
|
5381
5455
|
}
|
|
5382
5456
|
return !0;
|
|
5383
|
-
},
|
|
5457
|
+
}, $t = (e, t) => {
|
|
5384
5458
|
let s = e.dataType, i = e.dims.length, o = Nt(i, t), l = Mr(e.dims, o), u = e.dims, d = l, h = i < 2 || Ls(o, e.dims), p;
|
|
5385
5459
|
if (h) return p = (S) => {
|
|
5386
5460
|
let E = F("input", s, u, 4), I = oe("output", s, d, 4);
|
|
@@ -5444,11 +5518,11 @@ function $y() {
|
|
|
5444
5518
|
let S = H.size(l);
|
|
5445
5519
|
return { outputs: [{ dims: l, dataType: e.dataType }], dispatchGroup: { x: Math.ceil(S / 64) }, programUniforms: [{ type: 12, data: S }, ...L(u, d)] };
|
|
5446
5520
|
}, getShaderSource: p };
|
|
5447
|
-
},
|
|
5448
|
-
Bt(e.inputs, t.perm), e.compute(
|
|
5521
|
+
}, ir = (e, t) => {
|
|
5522
|
+
Bt(e.inputs, t.perm), e.compute($t(e.inputs[0], t.perm));
|
|
5449
5523
|
}, Bs = (e) => $({ perm: e.perm });
|
|
5450
|
-
}),
|
|
5451
|
-
Ie(), Re(), _e(), ta(), We(),
|
|
5524
|
+
}), sr, fi, gr, kn, At, Ht, ns, Rn, Ns, mi, Dt, yr, en, Mt, xt, ar, gi, yi, zo, Do, Lo, wm = _(() => {
|
|
5525
|
+
Ie(), Re(), _e(), ta(), We(), sr = { max: "select(bestValue, candidate, candidate > bestValue)", min: "select(bestValue, candidate, candidate < bestValue)", mean: "bestValue + candidate", sum: "bestValue + candidate", prod: "bestValue * candidate", sumSquare: "bestValue + candidate * candidate", logSumExp: "bestValue + exp(candidate)", l1: "bestValue + abs(candidate)", l2: "bestValue + candidate * candidate", logSum: "bestValue + candidate" }, fi = { max: "select(bestValue, candidate, candidate > bestValue)", min: "select(bestValue, candidate, candidate < bestValue)", mean: "bestValue + candidate", sum: "bestValue + candidate", prod: "bestValue * candidate", sumSquare: "bestValue + candidate", logSumExp: "bestValue + candidate", l1: "bestValue + candidate", l2: "bestValue + candidate", logSum: "bestValue + candidate" }, gr = { max: "_A[offset]", min: "_A[offset]", mean: "0", sum: "0", prod: "1", sumSquare: "0", logSumExp: "0", l1: "0", l2: "0", logSum: "0" }, kn = { max: "bestValue", min: "bestValue", sum: "bestValue", prod: "bestValue", sumSquare: "bestValue", logSumExp: "log(bestValue)", l1: "bestValue", l2: "sqrt(bestValue)", logSum: "log(bestValue)" }, At = (e, t) => {
|
|
5452
5526
|
let s = [];
|
|
5453
5527
|
for (let i = t - e; i < t; ++i) s.push(i);
|
|
5454
5528
|
return s;
|
|
@@ -5491,7 +5565,7 @@ function $y() {
|
|
|
5491
5565
|
let Length = uniforms.reduceSize;
|
|
5492
5566
|
for (var k = local_idx; k < Length; k = k + ${w}) {
|
|
5493
5567
|
let candidate = f32(${g.getByOffset("offset + k")});
|
|
5494
|
-
bestValue = ${
|
|
5568
|
+
bestValue = ${sr[i]};
|
|
5495
5569
|
}
|
|
5496
5570
|
aBestValues[local_idx] = bestValue;
|
|
5497
5571
|
workgroupBarrier();
|
|
@@ -5518,18 +5592,18 @@ function $y() {
|
|
|
5518
5592
|
let o = e.inputs.length === 1 ? s : ea(e.inputs, s), l = o.axes;
|
|
5519
5593
|
l.length === 0 && !o.noopWithEmptyAxes && (l = e.inputs[0].dims.map((b, S) => S));
|
|
5520
5594
|
let u = H.normalizeAxes(l, e.inputs[0].dims.length), d = u, h = e.inputs[0], p = Ns(d, e.inputs[0].dims.length);
|
|
5521
|
-
p.length > 0 && (h = e.compute(
|
|
5595
|
+
p.length > 0 && (h = e.compute($t(e.inputs[0], p), { inputs: [0], outputs: [-1] })[0], d = At(d.length, h.dims.length));
|
|
5522
5596
|
let [g, m] = Ht(h.dims, d), w = g;
|
|
5523
5597
|
o.keepDims && (w = ns(g, u)), e.compute(mi(t, o.cacheKey, [h], i, e.inputs[0].dataType, w, m), { inputs: [h] });
|
|
5524
5598
|
}, yr = (e, t) => {
|
|
5525
5599
|
Dt(e, "ReduceMeanShared", t, "mean");
|
|
5526
5600
|
}, en = (e, t) => {
|
|
5527
5601
|
Dt(e, "ReduceL1Shared", t, "l1");
|
|
5528
|
-
},
|
|
5602
|
+
}, Mt = (e, t) => {
|
|
5529
5603
|
Dt(e, "ReduceL2Shared", t, "l2");
|
|
5530
|
-
},
|
|
5604
|
+
}, xt = (e, t) => {
|
|
5531
5605
|
Dt(e, "ReduceLogSumExpShared", t, "logSumExp");
|
|
5532
|
-
},
|
|
5606
|
+
}, ar = (e, t) => {
|
|
5533
5607
|
Dt(e, "ReduceMaxShared", t, "max");
|
|
5534
5608
|
}, gi = (e, t) => {
|
|
5535
5609
|
Dt(e, "ReduceMinShared", t, "min");
|
|
@@ -5628,11 +5702,11 @@ function $y() {
|
|
|
5628
5702
|
}, Xo = (e, t) => {
|
|
5629
5703
|
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Uo(e, t) : en(e, t);
|
|
5630
5704
|
}, Yo = (e, t) => {
|
|
5631
|
-
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Fo(e, t) :
|
|
5705
|
+
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Fo(e, t) : Mt(e, t);
|
|
5632
5706
|
}, Jo = (e, t) => {
|
|
5633
|
-
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Vo(e, t) :
|
|
5707
|
+
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Vo(e, t) : xt(e, t);
|
|
5634
5708
|
}, Zo = (e, t) => {
|
|
5635
|
-
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Go(e, t) :
|
|
5709
|
+
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Go(e, t) : ar(e, t);
|
|
5636
5710
|
}, el = (e, t) => {
|
|
5637
5711
|
_r(e.inputs[0].dims, t.axes, t.noopWithEmptyAxes) ? Wo(e, t) : gi(e, t);
|
|
5638
5712
|
}, tl = (e, t) => {
|
|
@@ -6937,7 +7011,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
6937
7011
|
return { name: "MatMul", shaderCache: { hint: `${I};${t.activation};${E};${o}`, inputDependencies: ge }, getRunData: () => ({ outputs: [{ dims: l ? l(s) : s, dataType: e[0].dataType }], dispatchGroup: { x: x[0], y: x[1], z: x[2] }, programUniforms: ae }), getShaderSource: Ee };
|
|
6938
7012
|
};
|
|
6939
7013
|
}), Iu, Pu, Em = _(() => {
|
|
6940
|
-
Ie(),
|
|
7014
|
+
Ie(), nr(), _e(), Pn(), da(), xm(), ga(), Iu = (e, t, s, i, o = !1, l, u = 4, d = 4, h = 4, p = "f32") => {
|
|
6941
7015
|
let g = (ae) => {
|
|
6942
7016
|
switch (ae) {
|
|
6943
7017
|
case 1:
|
|
@@ -7077,7 +7151,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7077
7151
|
return { name: "Conv2DMatMul", shaderCache: { hint: `${t.cacheKey};${D};${E};${ae};${ge};${He};${W};${q};${Y}`, inputDependencies: it }, getRunData: () => ({ outputs: [{ dims: h ? h(s) : s, dataType: e[0].dataType }], dispatchGroup: { x: M[0], y: M[1], z: M[2] }, programUniforms: Pe }), getShaderSource: we };
|
|
7078
7152
|
};
|
|
7079
7153
|
}), Ou, ya, Gs, zu, wa, Du, Lu, Bu, Cm = _(() => {
|
|
7080
|
-
Ie(),
|
|
7154
|
+
Ie(), nr(), Re(), _e(), Pn(), da(), Ou = (e) => {
|
|
7081
7155
|
let t = 1;
|
|
7082
7156
|
for (let s = 0; s < e.length; s++) t *= e[s];
|
|
7083
7157
|
return t;
|
|
@@ -7408,7 +7482,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7408
7482
|
if (s.group !== 1) {
|
|
7409
7483
|
let W = [t[0]];
|
|
7410
7484
|
if (o) {
|
|
7411
|
-
let q = e.kernelCustomData.wT ?? e.compute(
|
|
7485
|
+
let q = e.kernelCustomData.wT ?? e.compute($t(t[1], Si), { inputs: [1], outputs: [s.wIsConst ? -2 : -1] })[0];
|
|
7412
7486
|
s.wIsConst && !e.kernelCustomData.wT && (e.kernelCustomData.wT = q), W.push(q);
|
|
7413
7487
|
} else W.push(t[1]);
|
|
7414
7488
|
t.length === 3 && W.push(t[2]), !e.adapterInfo.isArchitecture("ampere") && o && t[1].dims[0] === s.group && t[1].dims[1] === 1 && s.dilations[0] === 1 && s.dilations[1] === 1 ? e.compute(Uu(W, s, l, i), { inputs: W }) : e.compute(Nu(W, s, l, i), { inputs: W });
|
|
@@ -7418,7 +7492,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7418
7492
|
if (E || g === 1 && m === 1 && s.dilations[0] === 1 && s.dilations[1] === 1 && s.strides[0] === 1 && s.strides[1] === 1 && s.pads[0] === 0 && s.pads[1] === 0) {
|
|
7419
7493
|
let W = l[0], q, Y, ae, ge = [];
|
|
7420
7494
|
if (o) {
|
|
7421
|
-
let Pe = e.kernelCustomData.wT ?? e.compute(
|
|
7495
|
+
let Pe = e.kernelCustomData.wT ?? e.compute($t(t[1], Si), { inputs: [1], outputs: [s.wIsConst ? -2 : -1] })[0];
|
|
7422
7496
|
if (s.wIsConst && !e.kernelCustomData.wT && (e.kernelCustomData.wT = Pe), E) {
|
|
7423
7497
|
let it = d * h * p;
|
|
7424
7498
|
q = t[0].reshape([1, W, it]), Y = Pe.reshape([1, it, S]), ae = [1, W, S];
|
|
@@ -7430,7 +7504,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7430
7504
|
He < 8 && Ee < 8 ? e.compute(ca(ge, s, l, ae, o, i), { inputs: ge }) : e.compute(bi(ge, s, l, ae, o, i), { inputs: ge });
|
|
7431
7505
|
return;
|
|
7432
7506
|
}
|
|
7433
|
-
let I = !0, k = e.kernelCustomData.wT ?? e.compute(
|
|
7507
|
+
let I = !0, k = e.kernelCustomData.wT ?? e.compute($t(t[1], Si), { inputs: [1], outputs: [s.wIsConst ? -2 : -1] })[0];
|
|
7434
7508
|
s.wIsConst && !e.kernelCustomData.wT && (e.kernelCustomData.wT = k);
|
|
7435
7509
|
let x = [t[0], k];
|
|
7436
7510
|
u && x.push(t[2]);
|
|
@@ -7453,7 +7527,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7453
7527
|
}
|
|
7454
7528
|
};
|
|
7455
7529
|
}), Wu, Am = _(() => {
|
|
7456
|
-
Ie(),
|
|
7530
|
+
Ie(), nr(), Re(), _e(), Wu = (e, t, s) => {
|
|
7457
7531
|
let i = e.length > 2, o = t.outputShape, l = t.format === "NHWC", u = t.group, d = e[1].dims, h = d[2] / u, p = d[3], g = l ? V(h) : 1, m = l && p === 1 && h >= 4, w = m ? Math.floor(h / 4) * 4 : Math.floor(h / g) * g, b = h - w, S = l ? V(p) : 1, E = l ? p === 1 ? g : S : 1, I = H.size(o) / S, k = [Math.ceil(I / 64), 1, 1];
|
|
7458
7532
|
Je("verbose", () => `[conv2d_backprop_webgpu] dispatch = ${k}`);
|
|
7459
7533
|
let x = ["rank", "rank"], O = [t.strides[0], t.strides[1]], M = [t.kernelShape[l ? 1 : 2], t.kernelShape[l ? 2 : 3]], D = [t.dilations[0], t.dilations[1]], W = [M[0] + (t.dilations[0] <= 1 ? 0 : (t.kernelShape[l ? 1 : 2] - 1) * (t.dilations[0] - 1)), M[1] + (t.dilations[1] <= 1 ? 0 : (t.kernelShape[l ? 2 : 3] - 1) * (t.dilations[1] - 1))], q = [W[0] - 1 - Math.floor((t.pads[0] + t.pads[2]) / 2), W[1] - 1 - Math.floor((t.pads[1] + t.pads[3]) / 2)], Y = [{ type: 12, data: I }, { type: 12, data: O }, { type: 12, data: M }, { type: 12, data: D }, { type: 12, data: W }, { type: 6, data: q }, { type: 12, data: w }, { type: 12, data: h }, { type: 12, data: p }, ...L(e[0].dims, e[1].dims)];
|
|
@@ -7626,7 +7700,7 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
7626
7700
|
if (t.kernelShape.reduce((u, d) => u + d, 0) > 0 && t.kernelShape.length !== 0 && t.kernelShape.length !== e[1].dims.length - 2) throw new Error("invalid kernel shape");
|
|
7627
7701
|
if (t.outputShape.length !== 0 && t.outputShape.length !== e[0].dims.length - 2) throw new Error("invalid output shape");
|
|
7628
7702
|
}, Ta = (e, t, s, i) => {
|
|
7629
|
-
let o = e.kernelCustomData.wT ?? e.compute(
|
|
7703
|
+
let o = e.kernelCustomData.wT ?? e.compute($t(t[1], [2, 3, 0, 1]), { inputs: [1], outputs: [s.wIsConst ? -2 : -1] })[0];
|
|
7630
7704
|
s.wIsConst && !e.kernelCustomData.wT && (e.kernelCustomData.wT = o);
|
|
7631
7705
|
let l = [t[0], o];
|
|
7632
7706
|
t.length === 3 && l.push(t[2]), e.compute(Wu(l, s, i), { inputs: l });
|
|
@@ -8422,9 +8496,9 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
8422
8496
|
}, jd = (e, t) => {
|
|
8423
8497
|
Nd(e.inputs), e.compute(Hd(e.inputs, t));
|
|
8424
8498
|
}, Kd = (e) => $({ alignCorners: e.align_corners, mode: e.mode, paddingMode: e.padding_mode, format: e.format });
|
|
8425
|
-
}),
|
|
8426
|
-
Ie(), Re(), A(), Xn(), sa(), _e(), We(),
|
|
8427
|
-
let s = e[0], i =
|
|
8499
|
+
}), Kt, Qd, Xd, Ca, Yd, Ws, Jd, Zd = _(() => {
|
|
8500
|
+
Ie(), Re(), A(), Xn(), sa(), _e(), We(), Kt = (e, t) => e.length > t && e[t].dims.length > 0 ? e[t] : void 0, Qd = (e, t) => {
|
|
8501
|
+
let s = e[0], i = Kt(e, 1), o = Kt(e, 2), l = Kt(e, 3), u = Kt(e, 4), d = Kt(e, 5), h = Kt(e, 6), p = Kt(e, 7);
|
|
8428
8502
|
if (s.dims.length !== 3 && s.dims.length !== 5) throw new Error("Input query is expected to have 3 or 5 dimensions");
|
|
8429
8503
|
let g = s.dims[0], m = s.dims[1], w = s.dims.length === 3 ? s.dims[2] : t.numHeads * s.dims[4], b = m, S = 0, E = 0, I = Math.floor(w / t.numHeads);
|
|
8430
8504
|
if (h && p && H.size(h.dims) && H.size(p.dims)) {
|
|
@@ -8502,10 +8576,10 @@ fn main(@builtin(local_invocation_id) localId : vec3<u32>,
|
|
|
8502
8576
|
let h = l;
|
|
8503
8577
|
if (u && H.size(u.dims) > 0) {
|
|
8504
8578
|
if (i === 1) throw new Error("AddBiasReshape is not implemented. Please export your model with packed QKV or KV");
|
|
8505
|
-
return h = Yd(e, l, u, t, i, s * o, d), h = h.reshape([t, i, s, o]), s === 1 || i === 1 ? h : e.compute(
|
|
8506
|
-
} else return l.dims.length === 3 && (h = l.reshape([t, i, s, o])), s === 1 || i === 1 ? h : e.compute(
|
|
8579
|
+
return h = Yd(e, l, u, t, i, s * o, d), h = h.reshape([t, i, s, o]), s === 1 || i === 1 ? h : e.compute($t(h, Ca.perm), { inputs: [h], outputs: [-1] })[0];
|
|
8580
|
+
} else return l.dims.length === 3 && (h = l.reshape([t, i, s, o])), s === 1 || i === 1 ? h : e.compute($t(h, Ca.perm), { inputs: [h], outputs: [-1] })[0];
|
|
8507
8581
|
}, Jd = (e, t) => {
|
|
8508
|
-
let s = Qd(e.inputs, t), i = e.inputs[0], o =
|
|
8582
|
+
let s = Qd(e.inputs, t), i = e.inputs[0], o = Kt(e.inputs, 1), l = Kt(e.inputs, 2), u = Kt(e.inputs, 3), d = Kt(e.inputs, 4), h = Kt(e.inputs, 5), p = Kt(e.inputs, 6), g = Kt(e.inputs, 7);
|
|
8509
8583
|
if (i.dims.length === 5) throw new Error("Packed QKV is not implemented");
|
|
8510
8584
|
if (o?.dims.length === 5) throw new Error("Packed KV is not implemented");
|
|
8511
8585
|
let m = o && l && o.dims.length === 4 && l.dims.length === 4, w = Ws(e, s.batchSize, s.numHeads, s.sequenceLength, s.headSize, i, u, 0);
|
|
@@ -8683,7 +8757,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
8683
8757
|
return { batchSize: h, sequenceLength: p, pastSequenceLength: w, kvSequenceLength: m, totalSequenceLength: -1, maxSequenceLength: -1, inputHiddenSize: 0, hiddenSize: g, vHiddenSize: M, headSize: S, vHeadSize: Math.floor(M / t.kvNumHeads), numHeads: t.numHeads, kvNumHeads: t.kvNumHeads, nReps: t.numHeads / t.kvNumHeads, pastPresentShareBuffer: !1, maskType: x, scale: t.scale, broadcastResPosBias: !1, passPastInKv: O, qkvFormat: k };
|
|
8684
8758
|
}, cc = $({ perm: [0, 2, 1, 3] }), Ra = (e, t, s) => {
|
|
8685
8759
|
let i = t, o = s.kvNumHeads;
|
|
8686
|
-
return t.dims.length === 3 && s.kvSequenceLength !== 0 && (i = t.reshape([s.batchSize, s.kvSequenceLength, o, s.headSize]), i = e.compute(
|
|
8760
|
+
return t.dims.length === 3 && s.kvSequenceLength !== 0 && (i = t.reshape([s.batchSize, s.kvSequenceLength, o, s.headSize]), i = e.compute($t(i, cc.perm), { inputs: [i], outputs: [-1] })[0]), i;
|
|
8687
8761
|
}, hc = (e, t, s, i) => {
|
|
8688
8762
|
let o = 7, l = ["type", "type"], u = [e * t], d = e * t, h = [{ type: 12, data: d }, { type: 12, data: t }, { type: 12, data: e }], p = (g) => {
|
|
8689
8763
|
let m = F("seq_lens", s.dataType, s.dims), w = F("total_seq_lens", i.dataType, i.dims), b = oe("pos_ids", o, u), S = [{ name: "output_size", type: "u32" }, { name: "sequence_length", type: "u32" }, { name: "batch_size", type: "u32" }];
|
|
@@ -8800,7 +8874,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
8800
8874
|
let i = t[0].dims, o = i, l = i[0], u = i[i.length - 1], d = H.sizeFromDimension(i, 1) / u, h = V(u), p = H.size(o) / h, g = [{ type: 12, data: d }, { type: 12, data: Math.floor(u / h) }], m = ["type", "type"], w = !1, b = [0, i.length - 1];
|
|
8801
8875
|
for (let k = 0; k < i.length - 2; k++) w = w || i[k + 1] !== 1, b.push(k + 1);
|
|
8802
8876
|
w = w && i[i.length - 1] !== 1;
|
|
8803
|
-
let S = w ? e.compute(
|
|
8877
|
+
let S = w ? e.compute($t(e.inputs[0], b), { inputs: [e.inputs[0]], outputs: [-1] })[0] : e.inputs[0].reshape(Array.from({ length: i.length }, (k, x) => i[b[x]])), E = Aa(e, S, t[1], t[2], l, d, u, s.epsilon), I = (k) => {
|
|
8804
8878
|
let x = G(t[0].dataType), O = h === 1 ? "vec2f" : `mat${h}x2f`, M = (q) => {
|
|
8805
8879
|
let Y = q === 0 ? "x" : "y", ae = h === 1 ? "f32" : `vec${h}f`;
|
|
8806
8880
|
switch (h) {
|
|
@@ -10181,7 +10255,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
10181
10255
|
if (!e || e.length !== 1) throw new Error("Softmax op requires 1 input.");
|
|
10182
10256
|
}, Mh = (e, t) => {
|
|
10183
10257
|
let s = e.inputs[0], i = s.dims, o = H.size(i), l = i.length, u = H.normalizeAxis(t.axis, l), d = u < i.length - 1, h, p = [];
|
|
10184
|
-
d ? (p = Array.from({ length: l }, (q, Y) => Y), p[u] = l - 1, p[l - 1] = u, h = e.compute(
|
|
10258
|
+
d ? (p = Array.from({ length: l }, (q, Y) => Y), p[u] = l - 1, p[l - 1] = u, h = e.compute($t(s, p), { inputs: [s], outputs: [-1] })[0]) : h = s;
|
|
10185
10259
|
let g = h.dims, m = g[l - 1], w = o / m, b = V(m), S = m / b, E = 64;
|
|
10186
10260
|
w === 1 && (E = 256);
|
|
10187
10261
|
let I = (q, Y) => Y === 4 ? `max(max(${q}.x, ${q}.y), max(${q}.z, ${q}.w))` : Y === 2 ? `max(${q}.x, ${q}.y)` : Y === 3 ? `max(max(${q}.x, ${q}.y), ${q}.z)` : q, k = F("x", h.dataType, h.dims, b), x = oe("result", h.dataType, h.dims, b), O = k.type.value, M = G(h.dataType) === "f32" ? `var threadMax = ${O}(-3.4028234663852886e+38f);` : `var threadMax = ${O}(-65504.0h);`, D = (q) => `
|
|
@@ -10259,7 +10333,7 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
10259
10333
|
setValue(row, col, row_stride, value);
|
|
10260
10334
|
}
|
|
10261
10335
|
}`, W = e.compute({ name: "Softmax", shaderCache: { hint: `${b};${E}`, inputDependencies: ["type"] }, getRunData: () => ({ outputs: [{ dims: g, dataType: h.dataType }], dispatchGroup: { x: w }, programUniforms: [{ type: 6, data: S }] }), getShaderSource: D }, { inputs: [h], outputs: [d ? -1 : 0] })[0];
|
|
10262
|
-
d && e.compute(
|
|
10336
|
+
d && e.compute($t(W, p), { inputs: [W] });
|
|
10263
10337
|
}, Ih = (e, t) => {
|
|
10264
10338
|
Ah(e.inputs), Mh(e, t);
|
|
10265
10339
|
}, Ph = (e) => $({ axis: e.axis });
|
|
@@ -10347,9 +10421,9 @@ fn calculateOutputIndex(index: u32) -> u32 {
|
|
|
10347
10421
|
e.compute(Nh(e.inputs));
|
|
10348
10422
|
};
|
|
10349
10423
|
}), Fh, ig = _(() => {
|
|
10350
|
-
vm(), sa(), _m(), bm(), Sm(), Tm(), $m(), Rm(), Mm(), Im(), Pm(), Om(), zm(), Dm(), Lm(), Bm(), Nm(), Um(), Fm(), Vm(), Gm(), qm(), Wm(), Hm(), jm(), Zd(), Km(), Qm(), Xm(), Ym(), Jm(), ta(), Zm(), uc(), eg(), tg(), rg(), ac(), ng(), We(), la(), sg(), Fh = /* @__PURE__ */ new Map([["Abs", [bl]], ["Acos", [Sl]], ["Acosh", [Tl]], ["Add", [du]], ["ArgMax", [al, na]], ["ArgMin", [il, na]], ["Asin", [$l]], ["Asinh", [xl]], ["Atan", [El]], ["Atanh", [Cl]], ["Attention", [hl]], ["AveragePool", [Nc, Bc]], ["BatchNormalization", [gl]], ["BiasAdd", [vl]], ["BiasSplitGelu", [ou]], ["Cast", [Rl, kl]], ["Ceil", [Il]], ["Clip", [Ml]], ["Concat", [$u, xu]], ["Conv", [ba, va]], ["ConvTranspose", [Ju, Qu]], ["Cos", [Pl]], ["Cosh", [Ol]], ["CumSum", [ed, td]], ["DepthToSpace", [id, ad]], ["DequantizeLinear", [Kc, Qc]], ["Div", [cu]], ["Einsum", [hd, pd]], ["Elu", [zl, Fs]], ["Equal", [hu]], ["Erf", [Dl]], ["Exp", [Ll]], ["Expand", [yd]], ["FastGelu", [vd]], ["Floor", [Bl]], ["FusedConv", [ba, va]], ["Gather", [Td, Sd]], ["GatherElements", [Od, Pd]], ["GatherBlockQuantized", [Rd, Ad]], ["GatherND", [xd, Ed]], ["Gelu", [Nl]], ["Gemm", [Bd, Ld]], ["GlobalAveragePool", [Fc, Uc]], ["GlobalMaxPool", [Wc, qc]], ["Greater", [gu]], ["GreaterOrEqual", [wu]], ["GridSample", [jd, Kd]], ["GroupQueryAttention", [pc]], ["HardSigmoid", [jl, Hl]], ["InstanceNormalization", [gc]], ["LayerNormalization", [vc]], ["LeakyRelu", [Ul, Fs]], ["Less", [yu]], ["LessOrEqual", [vu]], ["Log", [tu]], ["MatMul", [bc]], ["MatMulNBits", [xc, Ec]], ["MaxPool", [Vc, Gc]], ["Mul", [pu]], ["MultiHeadAttention", [Jd, Xd]], ["Neg", [Vl]], ["Not", [Fl]], ["Pad", [zc]], ["Pow", [fu]], ["QuickGelu", [su, Fs]], ["Range", [Jc]], ["Reciprocal", [Gl]], ["ReduceMin", [el]], ["ReduceMean", [Qo]], ["ReduceMax", [Zo]], ["ReduceSum", [rl]], ["ReduceProd", [tl]], ["ReduceL1", [Xo]], ["ReduceL2", [Yo]], ["ReduceLogSum", [sl]], ["ReduceLogSumExp", [Jo]], ["ReduceSumSquare", [nl]], ["Relu", [ql]], ["Resize", [vh, _h]], ["RotaryEmbedding", [lc]], ["ScatterND", [rh, th]], ["Sigmoid", [Wl]], ["Sin", [Kl]], ["Sinh", [Ql]], ["Slice", [kh, Rh]], ["SkipLayerNormalization", [Th]], ["Split", [sc, ic]], ["Sqrt", [Xl]], ["Softmax", [Ih, Ph]], ["Sub", [mu]], ["Tan", [Yl]], ["Tanh", [Jl]], ["ThresholdedRelu", [eu, Fs]], ["Tile", [Lh]], ["Transpose", [
|
|
10424
|
+
vm(), sa(), _m(), bm(), Sm(), Tm(), $m(), Rm(), Mm(), Im(), Pm(), Om(), zm(), Dm(), Lm(), Bm(), Nm(), Um(), Fm(), Vm(), Gm(), qm(), Wm(), Hm(), jm(), Zd(), Km(), Qm(), Xm(), Ym(), Jm(), ta(), Zm(), uc(), eg(), tg(), rg(), ac(), ng(), We(), la(), sg(), Fh = /* @__PURE__ */ new Map([["Abs", [bl]], ["Acos", [Sl]], ["Acosh", [Tl]], ["Add", [du]], ["ArgMax", [al, na]], ["ArgMin", [il, na]], ["Asin", [$l]], ["Asinh", [xl]], ["Atan", [El]], ["Atanh", [Cl]], ["Attention", [hl]], ["AveragePool", [Nc, Bc]], ["BatchNormalization", [gl]], ["BiasAdd", [vl]], ["BiasSplitGelu", [ou]], ["Cast", [Rl, kl]], ["Ceil", [Il]], ["Clip", [Ml]], ["Concat", [$u, xu]], ["Conv", [ba, va]], ["ConvTranspose", [Ju, Qu]], ["Cos", [Pl]], ["Cosh", [Ol]], ["CumSum", [ed, td]], ["DepthToSpace", [id, ad]], ["DequantizeLinear", [Kc, Qc]], ["Div", [cu]], ["Einsum", [hd, pd]], ["Elu", [zl, Fs]], ["Equal", [hu]], ["Erf", [Dl]], ["Exp", [Ll]], ["Expand", [yd]], ["FastGelu", [vd]], ["Floor", [Bl]], ["FusedConv", [ba, va]], ["Gather", [Td, Sd]], ["GatherElements", [Od, Pd]], ["GatherBlockQuantized", [Rd, Ad]], ["GatherND", [xd, Ed]], ["Gelu", [Nl]], ["Gemm", [Bd, Ld]], ["GlobalAveragePool", [Fc, Uc]], ["GlobalMaxPool", [Wc, qc]], ["Greater", [gu]], ["GreaterOrEqual", [wu]], ["GridSample", [jd, Kd]], ["GroupQueryAttention", [pc]], ["HardSigmoid", [jl, Hl]], ["InstanceNormalization", [gc]], ["LayerNormalization", [vc]], ["LeakyRelu", [Ul, Fs]], ["Less", [yu]], ["LessOrEqual", [vu]], ["Log", [tu]], ["MatMul", [bc]], ["MatMulNBits", [xc, Ec]], ["MaxPool", [Vc, Gc]], ["Mul", [pu]], ["MultiHeadAttention", [Jd, Xd]], ["Neg", [Vl]], ["Not", [Fl]], ["Pad", [zc]], ["Pow", [fu]], ["QuickGelu", [su, Fs]], ["Range", [Jc]], ["Reciprocal", [Gl]], ["ReduceMin", [el]], ["ReduceMean", [Qo]], ["ReduceMax", [Zo]], ["ReduceSum", [rl]], ["ReduceProd", [tl]], ["ReduceL1", [Xo]], ["ReduceL2", [Yo]], ["ReduceLogSum", [sl]], ["ReduceLogSumExp", [Jo]], ["ReduceSumSquare", [nl]], ["Relu", [ql]], ["Resize", [vh, _h]], ["RotaryEmbedding", [lc]], ["ScatterND", [rh, th]], ["Sigmoid", [Wl]], ["Sin", [Kl]], ["Sinh", [Ql]], ["Slice", [kh, Rh]], ["SkipLayerNormalization", [Th]], ["Split", [sc, ic]], ["Sqrt", [Xl]], ["Softmax", [Ih, Ph]], ["Sub", [mu]], ["Tan", [Yl]], ["Tanh", [Jl]], ["ThresholdedRelu", [eu, Fs]], ["Tile", [Lh]], ["Transpose", [ir, Bs]], ["Where", [Uh]]]);
|
|
10351
10425
|
}), Vh, ag = _(() => {
|
|
10352
|
-
zt(),
|
|
10426
|
+
zt(), nr(), _e(), Vh = class {
|
|
10353
10427
|
constructor(e) {
|
|
10354
10428
|
this.backend = e, this.repo = /* @__PURE__ */ new Map(), this.attributesBound = !1;
|
|
10355
10429
|
}
|
|
@@ -10403,7 +10477,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10403
10477
|
}), Gh = {};
|
|
10404
10478
|
U(Gh, { WebGpuBackend: () => jh });
|
|
10405
10479
|
var qh, Wh, Hh, jh, og = _(() => {
|
|
10406
|
-
zt(), Ie(),
|
|
10480
|
+
zt(), Ie(), nr(), Xr(), Zi(), ig(), ag(), qh = (e, t) => {
|
|
10407
10481
|
if (t.length !== e.length) throw new Error(`inputDependencies length ${t.length} is not equal to inputTensors length ${e.length}.`);
|
|
10408
10482
|
let s = [];
|
|
10409
10483
|
for (let i = 0; i < e.length; ++i) {
|
|
@@ -10488,15 +10562,15 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10488
10562
|
typeof this.queryTimeBase > "u" && (this.queryTimeBase = w);
|
|
10489
10563
|
let S = Number(w - this.queryTimeBase), E = Number(b - this.queryTimeBase);
|
|
10490
10564
|
if (!Number.isSafeInteger(S) || !Number.isSafeInteger(E)) throw new RangeError("incorrect timestamp range");
|
|
10491
|
-
if (this.env.webgpu.profiling?.ondata) this.env.webgpu.profiling.ondata({ version: 1, inputsMetadata: g.map((I) => ({ dims: I.dims, dataType:
|
|
10565
|
+
if (this.env.webgpu.profiling?.ondata) this.env.webgpu.profiling.ondata({ version: 1, inputsMetadata: g.map((I) => ({ dims: I.dims, dataType: er(I.dataType) })), outputsMetadata: m.map((I) => ({ dims: I.dims, dataType: er(I.dataType) })), kernelId: l, kernelType: d, kernelName: h, programName: p, startTime: S, endTime: E });
|
|
10492
10566
|
else {
|
|
10493
10567
|
let I = "";
|
|
10494
10568
|
g.forEach((x, O) => {
|
|
10495
|
-
I += `input[${O}]: [${x.dims}] | ${
|
|
10569
|
+
I += `input[${O}]: [${x.dims}] | ${er(x.dataType)}, `;
|
|
10496
10570
|
});
|
|
10497
10571
|
let k = "";
|
|
10498
10572
|
m.forEach((x, O) => {
|
|
10499
|
-
k += `output[${O}]: [${x.dims}] | ${
|
|
10573
|
+
k += `output[${O}]: [${x.dims}] | ${er(x.dataType)}, `;
|
|
10500
10574
|
}), console.log(`[profiling] kernel "${l}|${d}|${h}|${p}" ${I}${k}start time: ${S} ns, execution time: ${E - S} ns`);
|
|
10501
10575
|
}
|
|
10502
10576
|
Ne("GPU", `${p}::${w}::${b}`);
|
|
@@ -10554,7 +10628,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10554
10628
|
else if (q.type === 12) new Uint32Array(D, ae, ge.length).set(ge);
|
|
10555
10629
|
else if (q.type === 10) new Uint16Array(D, ae, ge.length).set(ge);
|
|
10556
10630
|
else if (q.type === 1) new Float32Array(D, ae, ge.length).set(ge);
|
|
10557
|
-
else throw new Error(`Unsupported uniform type: ${
|
|
10631
|
+
else throw new Error(`Unsupported uniform type: ${er(q.type)}`);
|
|
10558
10632
|
});
|
|
10559
10633
|
let W = this.gpuDataManager.create(x, GPUBufferUsage.COPY_DST | GPUBufferUsage.UNIFORM);
|
|
10560
10634
|
this.device.queue.writeBuffer(W.buffer, 0, D, 0, x), this.gpuDataManager.release(W.id), b = { offset: 0, size: x, buffer: W.buffer };
|
|
@@ -10676,7 +10750,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10676
10750
|
}), Kh = {};
|
|
10677
10751
|
U(Kh, { init: () => Xh });
|
|
10678
10752
|
var Ei, Qh, Xh, lg = _(() => {
|
|
10679
|
-
Ie(),
|
|
10753
|
+
Ie(), nr(), Re(), Os(), Ei = class yf {
|
|
10680
10754
|
constructor(t, s, i, o) {
|
|
10681
10755
|
this.module = t, this.dataType = s, this.data = i, this.dims = o;
|
|
10682
10756
|
}
|
|
@@ -10727,7 +10801,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10727
10801
|
}
|
|
10728
10802
|
compute(e, t) {
|
|
10729
10803
|
let s = t?.inputs?.map((u) => typeof u == "number" ? this.inputs[u] : u) ?? this.inputs, i = t?.outputs ?? [], o = (u, d, h) => new Ei(this.module, d, this.output(u, h), h), l = (u, d) => {
|
|
10730
|
-
let h =
|
|
10804
|
+
let h = tr(u, d);
|
|
10731
10805
|
if (!h) throw new Error(`Unsupported data type: ${u}`);
|
|
10732
10806
|
let p = h > 0 ? this.backend.gpuDataManager.create(h).id : 0;
|
|
10733
10807
|
return new Ei(this.module, u, p, d);
|
|
@@ -10774,7 +10848,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10774
10848
|
}
|
|
10775
10849
|
};
|
|
10776
10850
|
}), Yh, Ga, qa, tn, Jh, Wa, Ci, Ha, ja, Ka, Qa, Xa, Ya, Zh = _(() => {
|
|
10777
|
-
zt(), Yi(), Ji(), Ie(),
|
|
10851
|
+
zt(), Yi(), Ji(), Ie(), Jt(), vn(), Cs(), Yh = (e, t) => {
|
|
10778
10852
|
Oe()._OrtInit(e, t) !== 0 && ke("Can't initialize onnxruntime.");
|
|
10779
10853
|
}, Ga = async (e) => {
|
|
10780
10854
|
Yh(e.wasm.numThreads, bn(e.logLevel));
|
|
@@ -10858,13 +10932,13 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10858
10932
|
let [D, W, q] = Wa(l, M);
|
|
10859
10933
|
D === 0 && ke("Can't get an input name."), p.push(D);
|
|
10860
10934
|
let Y = o.UTF8ToString(D);
|
|
10861
|
-
S.push(Y), I.push(W === 0 ? { name: Y, isTensor: !1 } : { name: Y, isTensor: !0, type:
|
|
10935
|
+
S.push(Y), I.push(W === 0 ? { name: Y, isTensor: !1 } : { name: Y, isTensor: !0, type: er(W), shape: q });
|
|
10862
10936
|
}
|
|
10863
10937
|
for (let M = 0; M < w; M++) {
|
|
10864
10938
|
let [D, W, q] = Wa(l, M + m);
|
|
10865
10939
|
D === 0 && ke("Can't get an output name."), g.push(D);
|
|
10866
10940
|
let Y = o.UTF8ToString(D);
|
|
10867
|
-
E.push(Y), k.push(W === 0 ? { name: Y, isTensor: !1 } : { name: Y, isTensor: !0, type:
|
|
10941
|
+
E.push(Y), k.push(W === 0 ? { name: Y, isTensor: !1 } : { name: Y, isTensor: !0, type: er(W), shape: q });
|
|
10868
10942
|
{
|
|
10869
10943
|
if (b && t?.preferredOutputLocation === void 0) {
|
|
10870
10944
|
x.push("gpu-buffer");
|
|
@@ -10902,7 +10976,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10902
10976
|
if (u && m !== "gpu-buffer") throw new Error(`External buffer must be provided for input/output index ${l} when enableGraphCapture is true.`);
|
|
10903
10977
|
if (m === "gpu-buffer") {
|
|
10904
10978
|
let k = e[2].gpuBuffer;
|
|
10905
|
-
S =
|
|
10979
|
+
S = tr(Zt(p), g);
|
|
10906
10980
|
{
|
|
10907
10981
|
let x = d.jsepRegisterBuffer;
|
|
10908
10982
|
if (!x) throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');
|
|
@@ -10910,25 +10984,25 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10910
10984
|
}
|
|
10911
10985
|
} else if (m === "ml-tensor") {
|
|
10912
10986
|
let k = e[2].mlTensor;
|
|
10913
|
-
S =
|
|
10987
|
+
S = tr(Zt(p), g);
|
|
10914
10988
|
let x = d.webnnRegisterMLTensor;
|
|
10915
10989
|
if (!x) throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');
|
|
10916
|
-
b = x(i, k,
|
|
10990
|
+
b = x(i, k, Zt(p), g);
|
|
10917
10991
|
} else {
|
|
10918
10992
|
let k = e[2];
|
|
10919
10993
|
if (Array.isArray(k)) {
|
|
10920
10994
|
S = h * k.length, b = d._malloc(S), s.push(b);
|
|
10921
10995
|
for (let x = 0; x < k.length; x++) {
|
|
10922
10996
|
if (typeof k[x] != "string") throw new TypeError(`tensor data at index ${x} is not a string`);
|
|
10923
|
-
d.setValue(b + x * h,
|
|
10997
|
+
d.setValue(b + x * h, Ct(k[x], s), "*");
|
|
10924
10998
|
}
|
|
10925
10999
|
} else {
|
|
10926
11000
|
let x = d.webnnIsGraphInput, O = d.webnnIsGraphOutput;
|
|
10927
11001
|
if (p !== "string" && x && O) {
|
|
10928
11002
|
let M = d.UTF8ToString(o);
|
|
10929
11003
|
if (x(i, M) || O(i, M)) {
|
|
10930
|
-
let D =
|
|
10931
|
-
S =
|
|
11004
|
+
let D = Zt(p);
|
|
11005
|
+
S = tr(D, g), w = "ml-tensor";
|
|
10932
11006
|
let W = d.webnnCreateTemporaryTensor, q = d.webnnUploadTensor;
|
|
10933
11007
|
if (!W || !q) throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');
|
|
10934
11008
|
let Y = await W(i, D, g);
|
|
@@ -10940,7 +11014,7 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10940
11014
|
let E = d.stackSave(), I = d.stackAlloc(4 * g.length);
|
|
10941
11015
|
try {
|
|
10942
11016
|
g.forEach((x, O) => d.setValue(I + O * h, x, h === 4 ? "i32" : "i64"));
|
|
10943
|
-
let k = d._OrtCreateTensor(
|
|
11017
|
+
let k = d._OrtCreateTensor(Zt(p), b, S, I, g.length, Un(w));
|
|
10944
11018
|
k === 0 && ke(`Can't create tensor for input/output. session=${i}, index=${l}.`), t.push(k);
|
|
10945
11019
|
} finally {
|
|
10946
11020
|
d.stackRestore(E);
|
|
@@ -10989,43 +11063,43 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
10989
11063
|
let pt = u.getValue(Fe + d * 2, "*"), Sr = Number(u.getValue(Fe + d * 3, ve)), Pr = [];
|
|
10990
11064
|
for (let Ft = 0; Ft < Sr; Ft++) Pr.push(Number(u.getValue(pt + Ft * d, ve)));
|
|
10991
11065
|
u._OrtFree(pt) !== 0 && ke("Can't free memory for tensor dims.");
|
|
10992
|
-
let nn = Pr.reduce((Ft,
|
|
10993
|
-
ht =
|
|
11066
|
+
let nn = Pr.reduce((Ft, It) => Ft * It, 1);
|
|
11067
|
+
ht = er(Ve);
|
|
10994
11068
|
let Xs = w?.outputPreferredLocations[i[we]];
|
|
10995
11069
|
if (ht === "string") {
|
|
10996
11070
|
if (Xs === "gpu-buffer" || Xs === "ml-tensor") throw new Error("String tensor is not supported on GPU.");
|
|
10997
11071
|
let Ft = [];
|
|
10998
|
-
for (let
|
|
10999
|
-
let Vr = u.getValue(ne +
|
|
11072
|
+
for (let It = 0; It < nn; It++) {
|
|
11073
|
+
let Vr = u.getValue(ne + It * d, "*"), pg = u.getValue(ne + (It + 1) * d, "*"), fg = It === nn - 1 ? void 0 : pg - Vr;
|
|
11000
11074
|
Ft.push(u.UTF8ToString(Vr, fg));
|
|
11001
11075
|
}
|
|
11002
11076
|
Pe.push([ht, Pr, Ft, "cpu"]);
|
|
11003
11077
|
} else if (Xs === "gpu-buffer" && nn > 0) {
|
|
11004
11078
|
let Ft = u.jsepGetBuffer;
|
|
11005
11079
|
if (!Ft) throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');
|
|
11006
|
-
let
|
|
11080
|
+
let It = Ft(ne), Vr = tr(Ve, nn);
|
|
11007
11081
|
if (Vr === void 0 || !Sn(ht)) throw new Error(`Unsupported data type: ${ht}`);
|
|
11008
|
-
ze = !0, Pe.push([ht, Pr, { gpuBuffer:
|
|
11082
|
+
ze = !0, Pe.push([ht, Pr, { gpuBuffer: It, download: u.jsepCreateDownloader(It, Vr, ht), dispose: () => {
|
|
11009
11083
|
u._OrtReleaseTensor(xe) !== 0 && ke("Can't release tensor.");
|
|
11010
11084
|
} }, "gpu-buffer"]);
|
|
11011
11085
|
} else if (Xs === "ml-tensor" && nn > 0) {
|
|
11012
|
-
let Ft = u.webnnEnsureTensor,
|
|
11013
|
-
if (!Ft || !
|
|
11014
|
-
if (
|
|
11015
|
-
if (!
|
|
11086
|
+
let Ft = u.webnnEnsureTensor, It = u.webnnIsGraphInputOutputTypeSupported;
|
|
11087
|
+
if (!Ft || !It) throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');
|
|
11088
|
+
if (tr(Ve, nn) === void 0 || !Tn(ht)) throw new Error(`Unsupported data type: ${ht}`);
|
|
11089
|
+
if (!It(e, ht, !1)) throw new Error(`preferredLocation "ml-tensor" for ${ht} output is not supported by current WebNN Context.`);
|
|
11016
11090
|
let Vr = await Ft(e, ne, Ve, Pr, !1);
|
|
11017
11091
|
ze = !0, Pe.push([ht, Pr, { mlTensor: Vr, download: u.webnnCreateMLTensorDownloader(ne, ht), dispose: () => {
|
|
11018
11092
|
u.webnnReleaseTensorId(ne), u._OrtReleaseTensor(xe);
|
|
11019
11093
|
} }, "ml-tensor"]);
|
|
11020
11094
|
} else if (Xs === "ml-tensor-cpu-output" && nn > 0) {
|
|
11021
|
-
let Ft = u.webnnCreateMLTensorDownloader(ne, ht)(),
|
|
11095
|
+
let Ft = u.webnnCreateMLTensorDownloader(ne, ht)(), It = Pe.length;
|
|
11022
11096
|
ze = !0, it.push((async () => {
|
|
11023
|
-
let Vr = [
|
|
11097
|
+
let Vr = [It, await Ft];
|
|
11024
11098
|
return u.webnnReleaseTensorId(ne), u._OrtReleaseTensor(xe), Vr;
|
|
11025
11099
|
})()), Pe.push([ht, Pr, [], "cpu"]);
|
|
11026
11100
|
} else {
|
|
11027
|
-
let Ft = _n(ht),
|
|
11028
|
-
new Uint8Array(
|
|
11101
|
+
let Ft = _n(ht), It = new Ft(nn);
|
|
11102
|
+
new Uint8Array(It.buffer, It.byteOffset, It.byteLength).set(u.HEAPU8.subarray(ne, ne + It.byteLength)), Pe.push([ht, Pr, It, "cpu"]);
|
|
11029
11103
|
}
|
|
11030
11104
|
} finally {
|
|
11031
11105
|
u.stackRestore(je), ht === "string" && ne && u._free(ne), ze || u._OrtReleaseTensor(xe);
|
|
@@ -11050,12 +11124,12 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
11050
11124
|
}
|
|
11051
11125
|
return t;
|
|
11052
11126
|
};
|
|
11053
|
-
}), rn,
|
|
11054
|
-
zt(), Zh(),
|
|
11127
|
+
}), rn, or, ss, Ks, Qs, ki, Ja, Ri, Dn, Ln, ep, tp, rp, np, sp, ip, ap, op, lp = _(() => {
|
|
11128
|
+
zt(), Zh(), Jt(), mn(), rn = () => !!me.wasm.proxy && typeof document < "u", ss = !1, Ks = !1, Qs = !1, Ri = /* @__PURE__ */ new Map(), Dn = (e, t) => {
|
|
11055
11129
|
let s = Ri.get(e);
|
|
11056
11130
|
s ? s.push(t) : Ri.set(e, [t]);
|
|
11057
11131
|
}, Ln = () => {
|
|
11058
|
-
if (ss || !Ks || Qs || !
|
|
11132
|
+
if (ss || !Ks || Qs || !or) throw new Error("worker not ready");
|
|
11059
11133
|
}, ep = (e) => {
|
|
11060
11134
|
switch (e.data.type) {
|
|
11061
11135
|
case "init-wasm":
|
|
@@ -11077,15 +11151,15 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
11077
11151
|
if (ss) throw new Error("multiple calls to 'initWasm()' detected.");
|
|
11078
11152
|
if (Qs) throw new Error("previous call to 'initWasm()' failed.");
|
|
11079
11153
|
if (ss = !0, rn()) return new Promise((e, t) => {
|
|
11080
|
-
|
|
11154
|
+
or?.terminate(), gs().then(([s, i]) => {
|
|
11081
11155
|
try {
|
|
11082
|
-
|
|
11156
|
+
or = i, or.onerror = (l) => t(l), or.onmessage = ep, Ja = [e, t];
|
|
11083
11157
|
let o = { type: "init-wasm", in: me };
|
|
11084
11158
|
if (!o.in.wasm.wasmPaths && s) {
|
|
11085
11159
|
let l = cn();
|
|
11086
11160
|
l && (o.in.wasm.wasmPaths = l);
|
|
11087
11161
|
}
|
|
11088
|
-
|
|
11162
|
+
or.postMessage(o), ki = s;
|
|
11089
11163
|
} catch (o) {
|
|
11090
11164
|
t(o);
|
|
11091
11165
|
}
|
|
@@ -11103,27 +11177,27 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
11103
11177
|
if (rn()) return Ln(), new Promise((t, s) => {
|
|
11104
11178
|
Dn("init-ep", [t, s]);
|
|
11105
11179
|
let i = { type: "init-ep", in: { epName: e, env: me } };
|
|
11106
|
-
|
|
11180
|
+
or.postMessage(i);
|
|
11107
11181
|
});
|
|
11108
11182
|
await qa(me, e);
|
|
11109
11183
|
}, np = async (e) => rn() ? (Ln(), new Promise((t, s) => {
|
|
11110
11184
|
Dn("copy-from", [t, s]);
|
|
11111
11185
|
let i = { type: "copy-from", in: { buffer: e } };
|
|
11112
|
-
|
|
11186
|
+
or.postMessage(i, [e.buffer]);
|
|
11113
11187
|
})) : Ci(e), sp = async (e, t) => {
|
|
11114
11188
|
if (rn()) {
|
|
11115
11189
|
if (t?.preferredOutputLocation) throw new Error('session option "preferredOutputLocation" is not supported for proxy.');
|
|
11116
11190
|
return Ln(), new Promise((s, i) => {
|
|
11117
11191
|
Dn("create", [s, i]);
|
|
11118
11192
|
let o = { type: "create", in: { model: e, options: { ...t } } }, l = [];
|
|
11119
|
-
e instanceof Uint8Array && l.push(e.buffer),
|
|
11193
|
+
e instanceof Uint8Array && l.push(e.buffer), or.postMessage(o, l);
|
|
11120
11194
|
});
|
|
11121
11195
|
} else return Ha(e, t);
|
|
11122
11196
|
}, ip = async (e) => {
|
|
11123
11197
|
if (rn()) return Ln(), new Promise((t, s) => {
|
|
11124
11198
|
Dn("release", [t, s]);
|
|
11125
11199
|
let i = { type: "release", in: e };
|
|
11126
|
-
|
|
11200
|
+
or.postMessage(i);
|
|
11127
11201
|
});
|
|
11128
11202
|
ja(e);
|
|
11129
11203
|
}, ap = async (e, t, s, i, o, l) => {
|
|
@@ -11133,14 +11207,14 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
11133
11207
|
return Ln(), new Promise((u, d) => {
|
|
11134
11208
|
Dn("run", [u, d]);
|
|
11135
11209
|
let h = s, p = { type: "run", in: { sessionId: e, inputIndices: t, inputs: h, outputIndices: i, options: l } };
|
|
11136
|
-
|
|
11210
|
+
or.postMessage(p, Ya(h));
|
|
11137
11211
|
});
|
|
11138
11212
|
} else return Qa(e, t, s, i, o, l);
|
|
11139
11213
|
}, op = async (e) => {
|
|
11140
11214
|
if (rn()) return Ln(), new Promise((t, s) => {
|
|
11141
11215
|
Dn("end-profiling", [t, s]);
|
|
11142
11216
|
let i = { type: "end-profiling", in: e };
|
|
11143
|
-
|
|
11217
|
+
or.postMessage(i);
|
|
11144
11218
|
});
|
|
11145
11219
|
Xa(e);
|
|
11146
11220
|
};
|
|
@@ -11292,11 +11366,11 @@ ${l}`, d = s.createShaderModule({ code: u, label: e.name });
|
|
|
11292
11366
|
})(lo)), lo.exports;
|
|
11293
11367
|
}
|
|
11294
11368
|
var Bn = {}, uo = {}, Ip;
|
|
11295
|
-
function
|
|
11369
|
+
function Ey() {
|
|
11296
11370
|
return Ip || (Ip = 1, Object.defineProperty(uo, "__esModule", { value: !0 })), uo;
|
|
11297
11371
|
}
|
|
11298
11372
|
var si = {}, Pp;
|
|
11299
|
-
function
|
|
11373
|
+
function Cy() {
|
|
11300
11374
|
if (Pp) return si;
|
|
11301
11375
|
Pp = 1;
|
|
11302
11376
|
var c;
|
|
@@ -11332,7 +11406,7 @@ function Ey() {
|
|
|
11332
11406
|
}, si;
|
|
11333
11407
|
}
|
|
11334
11408
|
var ii = {}, Op;
|
|
11335
|
-
function
|
|
11409
|
+
function ky() {
|
|
11336
11410
|
if (Op) return ii;
|
|
11337
11411
|
Op = 1;
|
|
11338
11412
|
var c;
|
|
@@ -11388,12 +11462,12 @@ function wf() {
|
|
|
11388
11462
|
})), n = Bn && Bn.__exportStar || function(v, C) {
|
|
11389
11463
|
for (var R in v) R !== "default" && !Object.prototype.hasOwnProperty.call(C, R) && r(C, v, R);
|
|
11390
11464
|
};
|
|
11391
|
-
Object.defineProperty(c, "__esModule", { value: !0 }), c.SileroV5 = c.SileroLegacy = void 0, n(
|
|
11392
|
-
var a =
|
|
11465
|
+
Object.defineProperty(c, "__esModule", { value: !0 }), c.SileroV5 = c.SileroLegacy = void 0, n(Ey(), c);
|
|
11466
|
+
var a = Cy();
|
|
11393
11467
|
Object.defineProperty(c, "SileroLegacy", { enumerable: !0, get: function() {
|
|
11394
11468
|
return a.SileroLegacy;
|
|
11395
11469
|
} });
|
|
11396
|
-
var f =
|
|
11470
|
+
var f = ky();
|
|
11397
11471
|
Object.defineProperty(c, "SileroV5", { enumerable: !0, get: function() {
|
|
11398
11472
|
return f.SileroV5;
|
|
11399
11473
|
} });
|
|
@@ -11441,7 +11515,7 @@ function vf() {
|
|
|
11441
11515
|
return ai.Resampler = r, ai;
|
|
11442
11516
|
}
|
|
11443
11517
|
var Lp;
|
|
11444
|
-
function
|
|
11518
|
+
function Ry() {
|
|
11445
11519
|
return Lp || (Lp = 1, (function(c) {
|
|
11446
11520
|
var r = qr && qr.__createBinding || (Object.create ? (function(X, ee, ie, de) {
|
|
11447
11521
|
de === void 0 && (de = ie);
|
|
@@ -11462,7 +11536,7 @@ function ky() {
|
|
|
11462
11536
|
return n(ee, X), ee;
|
|
11463
11537
|
};
|
|
11464
11538
|
Object.defineProperty(c, "__esModule", { value: !0 }), c.NonRealTimeVAD = c.defaultNonRealTimeVADOptions = void 0;
|
|
11465
|
-
const f = a(
|
|
11539
|
+
const f = a(xy()), v = mf(), C = Po(), R = Oo(), _ = qi(), U = wf(), B = vf();
|
|
11466
11540
|
c.defaultNonRealTimeVADOptions = {
|
|
11467
11541
|
...R.defaultFrameProcessorOptions,
|
|
11468
11542
|
modelURL: v.baseAssetPath + "silero_vad_legacy.onnx",
|
|
@@ -11530,7 +11604,7 @@ function ky() {
|
|
|
11530
11604
|
})(qr)), qr;
|
|
11531
11605
|
}
|
|
11532
11606
|
var Tr = {}, Bp;
|
|
11533
|
-
function
|
|
11607
|
+
function Ay() {
|
|
11534
11608
|
if (Bp) return Tr;
|
|
11535
11609
|
Bp = 1, Object.defineProperty(Tr, "__esModule", { value: !0 }), Tr.audioFileToArray = Tr.encodeWAV = Tr.arrayBufferToBase64 = Tr.minFramesForTargetMS = void 0;
|
|
11536
11610
|
function c(R, _, U = 16e3) {
|
|
@@ -11604,11 +11678,11 @@ var Wr = {}, co = { exports: {} };
|
|
|
11604
11678
|
* Licensed under the MIT License.
|
|
11605
11679
|
*/
|
|
11606
11680
|
var Np;
|
|
11607
|
-
function
|
|
11681
|
+
function My() {
|
|
11608
11682
|
return Np || (Np = 1, (function(c, r) {
|
|
11609
11683
|
var n = (() => {
|
|
11610
|
-
var a = Object.defineProperty, f = Object.getOwnPropertyDescriptor, v = Object.getOwnPropertyNames, C = Object.prototype.hasOwnProperty, R = ((y) => typeof
|
|
11611
|
-
if (typeof
|
|
11684
|
+
var a = Object.defineProperty, f = Object.getOwnPropertyDescriptor, v = Object.getOwnPropertyNames, C = Object.prototype.hasOwnProperty, R = ((y) => typeof dr < "u" ? dr : typeof Proxy < "u" ? new Proxy(y, { get: ($, A) => (typeof dr < "u" ? dr : $)[A] }) : y)(function(y) {
|
|
11685
|
+
if (typeof dr < "u") return dr.apply(this, arguments);
|
|
11612
11686
|
throw Error('Dynamic require of "' + y + '" is not supported');
|
|
11613
11687
|
}), _ = (y, $) => () => (y && ($ = y(y = 0)), $), U = (y, $) => {
|
|
11614
11688
|
for (var A in $) a(y, A, { get: $[A], enumerable: !0 });
|
|
@@ -11712,7 +11786,7 @@ function Ay() {
|
|
|
11712
11786
|
return z;
|
|
11713
11787
|
};
|
|
11714
11788
|
}), Xe, mt, yt, at, Ye, De, rt = _(() => {
|
|
11715
|
-
|
|
11789
|
+
Yt(), Xe = (y, $) => {
|
|
11716
11790
|
if (y === void 0) throw new Error("Image buffer must be defined");
|
|
11717
11791
|
if ($.height === void 0 || $.width === void 0) throw new Error("Image height and width must be defined");
|
|
11718
11792
|
if ($.tensorLayout === "NHWC") throw new Error("NHWC Tensor layout is not supported yet");
|
|
@@ -11791,8 +11865,8 @@ function Ay() {
|
|
|
11791
11865
|
y && (Ze.set("int64", BigInt64Array), Q.set(BigInt64Array, "int64")), $ && (Ze.set("uint64", BigUint64Array), Q.set(BigUint64Array, "uint64")), z ? (Ze.set("float16", A), Q.set(A, "float16")) : Ze.set("float16", Uint16Array);
|
|
11792
11866
|
}
|
|
11793
11867
|
};
|
|
11794
|
-
}), qt,
|
|
11795
|
-
|
|
11868
|
+
}), qt, kt, ot = _(() => {
|
|
11869
|
+
Yt(), qt = (y) => {
|
|
11796
11870
|
let $ = 1;
|
|
11797
11871
|
for (let A = 0; A < y.length; A++) {
|
|
11798
11872
|
let z = y[A];
|
|
@@ -11801,7 +11875,7 @@ function Ay() {
|
|
|
11801
11875
|
$ *= z;
|
|
11802
11876
|
}
|
|
11803
11877
|
return $;
|
|
11804
|
-
},
|
|
11878
|
+
}, kt = (y, $) => {
|
|
11805
11879
|
switch (y.location) {
|
|
11806
11880
|
case "cpu":
|
|
11807
11881
|
return new tt(y.type, y.data, $);
|
|
@@ -11817,7 +11891,7 @@ function Ay() {
|
|
|
11817
11891
|
throw new Error(`tensorReshape: tensor location ${y.location} is not supported`);
|
|
11818
11892
|
}
|
|
11819
11893
|
};
|
|
11820
|
-
}), tt,
|
|
11894
|
+
}), tt, Yt = _(() => {
|
|
11821
11895
|
Be(), rt(), gt(), ot(), tt = class {
|
|
11822
11896
|
constructor(y, $, A) {
|
|
11823
11897
|
et();
|
|
@@ -11956,12 +12030,12 @@ function Ay() {
|
|
|
11956
12030
|
}
|
|
11957
12031
|
reshape(y) {
|
|
11958
12032
|
if (this.ensureValid(), this.downloader || this.disposer) throw new Error("Cannot reshape a tensor that owns GPU resource.");
|
|
11959
|
-
return
|
|
12033
|
+
return kt(this, y);
|
|
11960
12034
|
}
|
|
11961
12035
|
};
|
|
11962
12036
|
}), vt, pe = _(() => {
|
|
11963
|
-
|
|
11964
|
-
}), Ne, wt, dt, ct, fe, Ue,
|
|
12037
|
+
Yt(), vt = tt;
|
|
12038
|
+
}), Ne, wt, dt, ct, fe, Ue, Tt = _(() => {
|
|
11965
12039
|
Me(), Ne = (y, $) => {
|
|
11966
12040
|
(typeof he.trace > "u" ? !he.wasm.trace : !he.trace) || console.timeStamp(`${y}::ORT::${$}`);
|
|
11967
12041
|
}, wt = (y, $) => {
|
|
@@ -11983,8 +12057,8 @@ function Ay() {
|
|
|
11983
12057
|
}, Ue = (y) => {
|
|
11984
12058
|
(typeof he.trace > "u" ? !he.wasm.trace : !he.trace) || console.timeEnd(`ORT::${y}`);
|
|
11985
12059
|
};
|
|
11986
|
-
}),
|
|
11987
|
-
Le(), pe(),
|
|
12060
|
+
}), Rt, jt = _(() => {
|
|
12061
|
+
Le(), pe(), Tt(), Rt = class _f {
|
|
11988
12062
|
constructor($) {
|
|
11989
12063
|
this.handler = $;
|
|
11990
12064
|
}
|
|
@@ -12077,7 +12151,7 @@ function Ay() {
|
|
|
12077
12151
|
}
|
|
12078
12152
|
};
|
|
12079
12153
|
}), cr, Wi = _(() => {
|
|
12080
|
-
|
|
12154
|
+
jt(), cr = Rt;
|
|
12081
12155
|
}), Hi = _(() => {
|
|
12082
12156
|
}), ji = _(() => {
|
|
12083
12157
|
}), Ki = _(() => {
|
|
@@ -12085,12 +12159,12 @@ function Ay() {
|
|
|
12085
12159
|
}), ls = {};
|
|
12086
12160
|
U(ls, { InferenceSession: () => cr, TRACE: () => Ne, TRACE_EVENT_BEGIN: () => fe, TRACE_EVENT_END: () => Ue, TRACE_FUNC_BEGIN: () => dt, TRACE_FUNC_END: () => ct, Tensor: () => vt, env: () => me, registerBackend: () => ie });
|
|
12087
12161
|
var zt = _(() => {
|
|
12088
|
-
Ce(), ut(), Wi(), pe(), Hi(), ji(),
|
|
12162
|
+
Ce(), ut(), Wi(), pe(), Hi(), ji(), Tt(), Ki(), Qi();
|
|
12089
12163
|
}), ln = _(() => {
|
|
12090
12164
|
}), us = {};
|
|
12091
12165
|
U(us, { default: () => ds });
|
|
12092
12166
|
var un, dn, ds, Xi = _(() => {
|
|
12093
|
-
Rs(),
|
|
12167
|
+
Rs(), Jt(), mn(), un = "ort-wasm-proxy-worker", dn = globalThis.self?.name === un, dn && (self.onmessage = (y) => {
|
|
12094
12168
|
let { type: $, in: A } = y.data;
|
|
12095
12169
|
try {
|
|
12096
12170
|
switch ($) {
|
|
@@ -12121,7 +12195,7 @@ function Ay() {
|
|
|
12121
12195
|
}
|
|
12122
12196
|
case "create": {
|
|
12123
12197
|
let { model: z, options: P } = A;
|
|
12124
|
-
|
|
12198
|
+
nr(z, P).then((G) => {
|
|
12125
12199
|
postMessage({ type: $, out: G });
|
|
12126
12200
|
}, (G) => {
|
|
12127
12201
|
postMessage({ type: $, err: G });
|
|
@@ -12189,7 +12263,7 @@ function Ay() {
|
|
|
12189
12263
|
return [L ? V : void 0, await ms(V)];
|
|
12190
12264
|
}
|
|
12191
12265
|
};
|
|
12192
|
-
}), gn, Br, hr, yn, ws, vs, _s, wn, Oe,
|
|
12266
|
+
}), gn, Br, hr, yn, ws, vs, _s, wn, Oe, Jt = _(() => {
|
|
12193
12267
|
mn(), Br = !1, hr = !1, yn = !1, ws = () => {
|
|
12194
12268
|
if (typeof SharedArrayBuffer > "u") return !1;
|
|
12195
12269
|
try {
|
|
@@ -12246,8 +12320,8 @@ function Ay() {
|
|
|
12246
12320
|
if (Br && gn) return gn;
|
|
12247
12321
|
throw new Error("WebAssembly is not initialized yet.");
|
|
12248
12322
|
};
|
|
12249
|
-
}),
|
|
12250
|
-
|
|
12323
|
+
}), Ct, Nr, ke, vn = _(() => {
|
|
12324
|
+
Jt(), Ct = (y, $) => {
|
|
12251
12325
|
let A = Oe(), z = A.lengthBytesUTF8(y) + 1, P = A._malloc(z);
|
|
12252
12326
|
return A.stringToUTF8(y, P, z), $.push(P), P;
|
|
12253
12327
|
}, Nr = (y, $, A, z) => {
|
|
@@ -12274,7 +12348,7 @@ function Ay() {
|
|
|
12274
12348
|
}
|
|
12275
12349
|
};
|
|
12276
12350
|
}), bs, Yi = _(() => {
|
|
12277
|
-
|
|
12351
|
+
Jt(), vn(), bs = (y) => {
|
|
12278
12352
|
let $ = Oe(), A = 0, z = [], P = y || {};
|
|
12279
12353
|
try {
|
|
12280
12354
|
if (y?.logSeverityLevel === void 0) P.logSeverityLevel = 2;
|
|
@@ -12283,8 +12357,8 @@ function Ay() {
|
|
|
12283
12357
|
else if (typeof y.logVerbosityLevel != "number" || !Number.isInteger(y.logVerbosityLevel)) throw new Error(`log verbosity level is not valid: ${y.logVerbosityLevel}`);
|
|
12284
12358
|
y?.terminate === void 0 && (P.terminate = !1);
|
|
12285
12359
|
let G = 0;
|
|
12286
|
-
return y?.tag !== void 0 && (G =
|
|
12287
|
-
let V =
|
|
12360
|
+
return y?.tag !== void 0 && (G = Ct(y.tag, z)), A = $._OrtCreateRunOptions(P.logSeverityLevel, P.logVerbosityLevel, !!P.terminate, G), A === 0 && ke("Can't create run options."), y?.extra !== void 0 && Nr(y.extra, "", /* @__PURE__ */ new WeakSet(), (N, L) => {
|
|
12361
|
+
let V = Ct(N, z), Z = Ct(L, z);
|
|
12288
12362
|
$._OrtAddRunConfigEntry(A, V, Z) !== 0 && ke(`Can't set a run config entry: ${N} - ${L}.`);
|
|
12289
12363
|
}), [A, z];
|
|
12290
12364
|
} catch (G) {
|
|
@@ -12292,7 +12366,7 @@ function Ay() {
|
|
|
12292
12366
|
}
|
|
12293
12367
|
};
|
|
12294
12368
|
}), Ss, Ts, $s, pr, xs, Es, Ji = _(() => {
|
|
12295
|
-
|
|
12369
|
+
Jt(), vn(), Ss = (y) => {
|
|
12296
12370
|
switch (y) {
|
|
12297
12371
|
case "disabled":
|
|
12298
12372
|
return 0;
|
|
@@ -12321,7 +12395,7 @@ function Ay() {
|
|
|
12321
12395
|
let $ = y.extra.session;
|
|
12322
12396
|
$.use_ort_model_bytes_directly || ($.use_ort_model_bytes_directly = "1"), y.executionProviders && y.executionProviders.some((A) => (typeof A == "string" ? A : A.name) === "webgpu") && (y.enableMemPattern = !1);
|
|
12323
12397
|
}, pr = (y, $, A, z) => {
|
|
12324
|
-
let P =
|
|
12398
|
+
let P = Ct($, z), G = Ct(A, z);
|
|
12325
12399
|
Oe()._OrtAddSessionConfigEntry(y, P, G) !== 0 && ke(`Can't set a session config entry: ${$} - ${A}.`);
|
|
12326
12400
|
}, xs = async (y, $, A) => {
|
|
12327
12401
|
let z = $.executionProviders;
|
|
@@ -12349,7 +12423,7 @@ function Ay() {
|
|
|
12349
12423
|
default:
|
|
12350
12424
|
throw new Error(`not supported execution provider: ${G}`);
|
|
12351
12425
|
}
|
|
12352
|
-
let L =
|
|
12426
|
+
let L = Ct(G, A), V = N.length, Z = 0, se = 0;
|
|
12353
12427
|
if (V > 0) {
|
|
12354
12428
|
Z = Oe()._malloc(V * Oe().PTR_SIZE), A.push(Z), se = Oe()._malloc(V * Oe().PTR_SIZE), A.push(se);
|
|
12355
12429
|
for (let J = 0; J < V; J++) Oe().setValue(Z + J * Oe().PTR_SIZE, N[J][0], "*"), Oe().setValue(se + J * Oe().PTR_SIZE, N[J][1], "*");
|
|
@@ -12360,11 +12434,11 @@ function Ay() {
|
|
|
12360
12434
|
let $ = Oe(), A = 0, z = [], P = y || {};
|
|
12361
12435
|
$s(P);
|
|
12362
12436
|
try {
|
|
12363
|
-
let G = Ss(P.graphOptimizationLevel ?? "all"), N = Ts(P.executionMode ?? "sequential"), L = typeof P.logId == "string" ?
|
|
12437
|
+
let G = Ss(P.graphOptimizationLevel ?? "all"), N = Ts(P.executionMode ?? "sequential"), L = typeof P.logId == "string" ? Ct(P.logId, z) : 0, V = P.logSeverityLevel ?? 2;
|
|
12364
12438
|
if (!Number.isInteger(V) || V < 0 || V > 4) throw new Error(`log severity level is not valid: ${V}`);
|
|
12365
12439
|
let Z = P.logVerbosityLevel ?? 0;
|
|
12366
12440
|
if (!Number.isInteger(Z) || Z < 0 || Z > 4) throw new Error(`log verbosity level is not valid: ${Z}`);
|
|
12367
|
-
let se = typeof P.optimizedModelFilePath == "string" ?
|
|
12441
|
+
let se = typeof P.optimizedModelFilePath == "string" ? Ct(P.optimizedModelFilePath, z) : 0;
|
|
12368
12442
|
if (A = $._OrtCreateSessionOptions(G, !!P.enableCpuMemArena, !!P.enableMemPattern, N, !!P.enableProfiling, 0, L, V, Z, se), A === 0 && ke("Can't create session options."), P.executionProviders && await xs(A, P, z), P.enableGraphCapture !== void 0) {
|
|
12369
12443
|
if (typeof P.enableGraphCapture != "boolean") throw new Error(`enableGraphCapture must be a boolean value: ${P.enableGraphCapture}`);
|
|
12370
12444
|
pr(A, "enableGraphCapture", P.enableGraphCapture.toString(), z);
|
|
@@ -12372,7 +12446,7 @@ function Ay() {
|
|
|
12372
12446
|
if (P.freeDimensionOverrides) for (let [J, j] of Object.entries(P.freeDimensionOverrides)) {
|
|
12373
12447
|
if (typeof J != "string") throw new Error(`free dimension override name must be a string: ${J}`);
|
|
12374
12448
|
if (typeof j != "number" || !Number.isInteger(j) || j < 0) throw new Error(`free dimension override value must be a non-negative integer: ${j}`);
|
|
12375
|
-
let Te =
|
|
12449
|
+
let Te = Ct(J, z);
|
|
12376
12450
|
$._OrtAddFreeDimensionOverride(A, Te, j) !== 0 && ke(`Can't set a free dimension override: ${J} - ${j}.`);
|
|
12377
12451
|
}
|
|
12378
12452
|
return P.extra !== void 0 && Nr(P.extra, "", /* @__PURE__ */ new WeakSet(), (J, j) => {
|
|
@@ -12382,8 +12456,8 @@ function Ay() {
|
|
|
12382
12456
|
throw A !== 0 && $._OrtReleaseSessionOptions(A) !== 0 && ke("Can't release session options."), z.forEach((N) => $._free(N)), G;
|
|
12383
12457
|
}
|
|
12384
12458
|
};
|
|
12385
|
-
}),
|
|
12386
|
-
|
|
12459
|
+
}), Zt, er, tr, _n, bn, Sn, Tn, Un, Ie = _(() => {
|
|
12460
|
+
Zt = (y) => {
|
|
12387
12461
|
switch (y) {
|
|
12388
12462
|
case "int8":
|
|
12389
12463
|
return 3;
|
|
@@ -12418,7 +12492,7 @@ function Ay() {
|
|
|
12418
12492
|
default:
|
|
12419
12493
|
throw new Error(`unsupported data type: ${y}`);
|
|
12420
12494
|
}
|
|
12421
|
-
},
|
|
12495
|
+
}, er = (y) => {
|
|
12422
12496
|
switch (y) {
|
|
12423
12497
|
case 3:
|
|
12424
12498
|
return "int8";
|
|
@@ -12453,7 +12527,7 @@ function Ay() {
|
|
|
12453
12527
|
default:
|
|
12454
12528
|
throw new Error(`unsupported data type: ${y}`);
|
|
12455
12529
|
}
|
|
12456
|
-
},
|
|
12530
|
+
}, tr = (y, $) => {
|
|
12457
12531
|
let A = [-1, 4, 1, 1, 2, 2, 4, 8, -1, 1, 2, 8, 4, 8, -1, -1, -1, -1, -1, -1, -1, 0.5, 0.5][y], z = typeof $ == "number" ? $ : $.reduce((P, G) => P * G, 1);
|
|
12458
12532
|
return A > 0 ? Math.ceil(z * A) : void 0;
|
|
12459
12533
|
}, _n = (y) => {
|
|
@@ -12547,8 +12621,8 @@ function Ay() {
|
|
|
12547
12621
|
}
|
|
12548
12622
|
} else return y instanceof Blob ? new Uint8Array(await y.arrayBuffer()) : y instanceof Uint8Array ? y : new Uint8Array(y);
|
|
12549
12623
|
};
|
|
12550
|
-
}), ks, Fn, Vn, Cr, Gn, qn, Je,
|
|
12551
|
-
zt(), Yi(), Ji(), Ie(),
|
|
12624
|
+
}), ks, Fn, Vn, Cr, Gn, qn, Je, nr, Wn, kr, H, Qr, Hn, Rs = _(() => {
|
|
12625
|
+
zt(), Yi(), Ji(), Ie(), Jt(), vn(), Cs(), ks = (y, $) => {
|
|
12552
12626
|
Oe()._OrtInit(y, $) !== 0 && ke("Can't initialize onnxruntime.");
|
|
12553
12627
|
}, Fn = async (y) => {
|
|
12554
12628
|
ks(y.wasm.numThreads, bn(y.logLevel));
|
|
@@ -12600,7 +12674,7 @@ function Ay() {
|
|
|
12600
12674
|
let $ = Oe(), A = $._malloc(y.byteLength);
|
|
12601
12675
|
if (A === 0) throw new Error(`Can't create a session. failed to allocate a buffer of size ${y.byteLength}.`);
|
|
12602
12676
|
return $.HEAPU8.set(y, A), [A, y.byteLength];
|
|
12603
|
-
},
|
|
12677
|
+
}, nr = async (y, $) => {
|
|
12604
12678
|
let A, z, P = Oe();
|
|
12605
12679
|
Array.isArray(y) ? [A, z] = y : y.buffer === P.HEAPU8.buffer ? [A, z] = [y.byteOffset, y.byteLength] : [A, z] = Je(y);
|
|
12606
12680
|
let G = 0, N = 0, L = [], V = [], Z = [];
|
|
@@ -12628,13 +12702,13 @@ function Ay() {
|
|
|
12628
12702
|
let [qe, _e, Bt] = qn(G, $e);
|
|
12629
12703
|
qe === 0 && ke("Can't get an input name."), V.push(qe);
|
|
12630
12704
|
let Nt = P.UTF8ToString(qe);
|
|
12631
|
-
Te.push(Nt), oe.push(_e === 0 ? { name: Nt, isTensor: !1 } : { name: Nt, isTensor: !0, type:
|
|
12705
|
+
Te.push(Nt), oe.push(_e === 0 ? { name: Nt, isTensor: !1 } : { name: Nt, isTensor: !0, type: er(_e), shape: Bt });
|
|
12632
12706
|
}
|
|
12633
12707
|
for (let $e = 0; $e < J; $e++) {
|
|
12634
12708
|
let [qe, _e, Bt] = qn(G, $e + se);
|
|
12635
12709
|
qe === 0 && ke("Can't get an output name."), Z.push(qe);
|
|
12636
12710
|
let Nt = P.UTF8ToString(qe);
|
|
12637
|
-
F.push(Nt), bt.push(_e === 0 ? { name: Nt, isTensor: !1 } : { name: Nt, isTensor: !0, type:
|
|
12711
|
+
F.push(Nt), bt.push(_e === 0 ? { name: Nt, isTensor: !1 } : { name: Nt, isTensor: !0, type: er(_e), shape: Bt });
|
|
12638
12712
|
}
|
|
12639
12713
|
return Cr.set(G, [G, V, Z, null, j, !1]), [G, Te, F, oe, bt];
|
|
12640
12714
|
} catch (se) {
|
|
@@ -12657,7 +12731,7 @@ function Ay() {
|
|
|
12657
12731
|
if (N && J !== "gpu-buffer") throw new Error(`External buffer must be provided for input/output index ${G} when enableGraphCapture is true.`);
|
|
12658
12732
|
if (J === "gpu-buffer") {
|
|
12659
12733
|
let Ge = y[2].gpuBuffer;
|
|
12660
|
-
F =
|
|
12734
|
+
F = tr(Zt(Z), se);
|
|
12661
12735
|
{
|
|
12662
12736
|
let $e = L.jsepRegisterBuffer;
|
|
12663
12737
|
if (!$e) throw new Error('Tensor location "gpu-buffer" is not supported without using WebGPU.');
|
|
@@ -12665,25 +12739,25 @@ function Ay() {
|
|
|
12665
12739
|
}
|
|
12666
12740
|
} else if (J === "ml-tensor") {
|
|
12667
12741
|
let Ge = y[2].mlTensor;
|
|
12668
|
-
F =
|
|
12742
|
+
F = tr(Zt(Z), se);
|
|
12669
12743
|
let $e = L.webnnRegisterMLTensor;
|
|
12670
12744
|
if (!$e) throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');
|
|
12671
|
-
Te = $e(z, Ge,
|
|
12745
|
+
Te = $e(z, Ge, Zt(Z), se);
|
|
12672
12746
|
} else {
|
|
12673
12747
|
let Ge = y[2];
|
|
12674
12748
|
if (Array.isArray(Ge)) {
|
|
12675
12749
|
F = V * Ge.length, Te = L._malloc(F), A.push(Te);
|
|
12676
12750
|
for (let $e = 0; $e < Ge.length; $e++) {
|
|
12677
12751
|
if (typeof Ge[$e] != "string") throw new TypeError(`tensor data at index ${$e} is not a string`);
|
|
12678
|
-
L.setValue(Te + $e * V,
|
|
12752
|
+
L.setValue(Te + $e * V, Ct(Ge[$e], A), "*");
|
|
12679
12753
|
}
|
|
12680
12754
|
} else {
|
|
12681
12755
|
let $e = L.webnnIsGraphInput, qe = L.webnnIsGraphOutput;
|
|
12682
12756
|
if (Z !== "string" && $e && qe) {
|
|
12683
12757
|
let _e = L.UTF8ToString(P);
|
|
12684
12758
|
if ($e(z, _e) || qe(z, _e)) {
|
|
12685
|
-
let Bt =
|
|
12686
|
-
F =
|
|
12759
|
+
let Bt = Zt(Z);
|
|
12760
|
+
F = tr(Bt, se), j = "ml-tensor";
|
|
12687
12761
|
let Nt = L.webnnCreateTemporaryTensor, Mr = L.webnnUploadTensor;
|
|
12688
12762
|
if (!Nt || !Mr) throw new Error('Tensor location "ml-tensor" is not supported without using WebNN.');
|
|
12689
12763
|
let Zr = await Nt(z, Bt, se);
|
|
@@ -12695,7 +12769,7 @@ function Ay() {
|
|
|
12695
12769
|
let oe = L.stackSave(), bt = L.stackAlloc(4 * se.length);
|
|
12696
12770
|
try {
|
|
12697
12771
|
se.forEach(($e, qe) => L.setValue(bt + qe * V, $e, V === 4 ? "i32" : "i64"));
|
|
12698
|
-
let Ge = L._OrtCreateTensor(
|
|
12772
|
+
let Ge = L._OrtCreateTensor(Zt(Z), Te, F, bt, se.length, Un(j));
|
|
12699
12773
|
Ge === 0 && ke(`Can't create tensor for input/output. session=${z}, index=${G}.`), $.push(Ge);
|
|
12700
12774
|
} finally {
|
|
12701
12775
|
L.stackRestore(oe);
|
|
@@ -12714,71 +12788,71 @@ function Ay() {
|
|
|
12714
12788
|
for (let We = 0; We < F; We++) N.setValue(Mr + We * L, $e[We], "*"), N.setValue(Zr + We * L, se[$[We]], "*");
|
|
12715
12789
|
for (let We = 0; We < oe; We++) N.setValue(rs + We * L, qe[We], "*"), N.setValue(Ls + We * L, J[z[We]], "*");
|
|
12716
12790
|
N.jsepOnRunStart?.(Z), N.webnnOnRunStart?.(Z);
|
|
12717
|
-
let
|
|
12718
|
-
|
|
12719
|
-
let
|
|
12791
|
+
let $t;
|
|
12792
|
+
$t = await N._OrtRun(Z, Zr, Mr, F, Ls, oe, rs, bt), $t !== 0 && ke("failed to call OrtRun().");
|
|
12793
|
+
let ir = [], Bs = [];
|
|
12720
12794
|
fe("wasm ProcessOutputTensor");
|
|
12721
12795
|
for (let We = 0; We < oe; We++) {
|
|
12722
|
-
let
|
|
12723
|
-
if (
|
|
12724
|
-
|
|
12796
|
+
let sr = Number(N.getValue(rs + We * L, "*"));
|
|
12797
|
+
if (sr === qe[We] || Bt.includes(qe[We])) {
|
|
12798
|
+
ir.push(P[We]), sr !== qe[We] && N._OrtReleaseTensor(sr) !== 0 && ke("Can't release tensor.");
|
|
12725
12799
|
continue;
|
|
12726
12800
|
}
|
|
12727
|
-
let fi = N.stackSave(), gr = N.stackAlloc(4 * L), kn = !1,
|
|
12801
|
+
let fi = N.stackSave(), gr = N.stackAlloc(4 * L), kn = !1, At, Ht = 0;
|
|
12728
12802
|
try {
|
|
12729
|
-
N._OrtGetTensorData(
|
|
12803
|
+
N._OrtGetTensorData(sr, gr, gr + L, gr + 2 * L, gr + 3 * L) !== 0 && ke(`Can't access output tensor data on index ${We}.`);
|
|
12730
12804
|
let ns = L === 4 ? "i32" : "i64", Rn = Number(N.getValue(gr, ns));
|
|
12731
12805
|
Ht = N.getValue(gr + L, "*");
|
|
12732
12806
|
let Ns = N.getValue(gr + L * 2, "*"), mi = Number(N.getValue(gr + L * 3, ns)), Dt = [];
|
|
12733
|
-
for (let
|
|
12807
|
+
for (let Mt = 0; Mt < mi; Mt++) Dt.push(Number(N.getValue(Ns + Mt * L, ns)));
|
|
12734
12808
|
N._OrtFree(Ns) !== 0 && ke("Can't free memory for tensor dims.");
|
|
12735
|
-
let yr = Dt.reduce((
|
|
12736
|
-
|
|
12809
|
+
let yr = Dt.reduce((Mt, xt) => Mt * xt, 1);
|
|
12810
|
+
At = er(Rn);
|
|
12737
12811
|
let en = j?.outputPreferredLocations[z[We]];
|
|
12738
|
-
if (
|
|
12812
|
+
if (At === "string") {
|
|
12739
12813
|
if (en === "gpu-buffer" || en === "ml-tensor") throw new Error("String tensor is not supported on GPU.");
|
|
12740
|
-
let
|
|
12741
|
-
for (let
|
|
12742
|
-
let
|
|
12743
|
-
|
|
12814
|
+
let Mt = [];
|
|
12815
|
+
for (let xt = 0; xt < yr; xt++) {
|
|
12816
|
+
let ar = N.getValue(Ht + xt * L, "*"), gi = N.getValue(Ht + (xt + 1) * L, "*"), yi = xt === yr - 1 ? void 0 : gi - ar;
|
|
12817
|
+
Mt.push(N.UTF8ToString(ar, yi));
|
|
12744
12818
|
}
|
|
12745
|
-
|
|
12819
|
+
ir.push([At, Dt, Mt, "cpu"]);
|
|
12746
12820
|
} else if (en === "gpu-buffer" && yr > 0) {
|
|
12747
|
-
let
|
|
12748
|
-
if (!
|
|
12749
|
-
let
|
|
12750
|
-
if (
|
|
12751
|
-
kn = !0,
|
|
12752
|
-
N._OrtReleaseTensor(
|
|
12821
|
+
let Mt = N.jsepGetBuffer;
|
|
12822
|
+
if (!Mt) throw new Error('preferredLocation "gpu-buffer" is not supported without using WebGPU.');
|
|
12823
|
+
let xt = Mt(Ht), ar = tr(Rn, yr);
|
|
12824
|
+
if (ar === void 0 || !Sn(At)) throw new Error(`Unsupported data type: ${At}`);
|
|
12825
|
+
kn = !0, ir.push([At, Dt, { gpuBuffer: xt, download: N.jsepCreateDownloader(xt, ar, At), dispose: () => {
|
|
12826
|
+
N._OrtReleaseTensor(sr) !== 0 && ke("Can't release tensor.");
|
|
12753
12827
|
} }, "gpu-buffer"]);
|
|
12754
12828
|
} else if (en === "ml-tensor" && yr > 0) {
|
|
12755
|
-
let
|
|
12756
|
-
if (!
|
|
12757
|
-
if (
|
|
12758
|
-
if (
|
|
12759
|
-
let
|
|
12760
|
-
kn = !0,
|
|
12761
|
-
N.webnnReleaseTensorId(Ht), N._OrtReleaseTensor(
|
|
12829
|
+
let Mt = N.webnnEnsureTensor, xt = N.webnnIsGraphInputOutputTypeSupported;
|
|
12830
|
+
if (!Mt || !xt) throw new Error('preferredLocation "ml-tensor" is not supported without using WebNN.');
|
|
12831
|
+
if (tr(Rn, yr) === void 0 || !Tn(At)) throw new Error(`Unsupported data type: ${At}`);
|
|
12832
|
+
if (!xt(y, At, !1)) throw new Error(`preferredLocation "ml-tensor" for ${At} output is not supported by current WebNN Context.`);
|
|
12833
|
+
let ar = await Mt(y, Ht, Rn, Dt, !1);
|
|
12834
|
+
kn = !0, ir.push([At, Dt, { mlTensor: ar, download: N.webnnCreateMLTensorDownloader(Ht, At), dispose: () => {
|
|
12835
|
+
N.webnnReleaseTensorId(Ht), N._OrtReleaseTensor(sr);
|
|
12762
12836
|
} }, "ml-tensor"]);
|
|
12763
12837
|
} else if (en === "ml-tensor-cpu-output" && yr > 0) {
|
|
12764
|
-
let
|
|
12838
|
+
let Mt = N.webnnCreateMLTensorDownloader(Ht, At)(), xt = ir.length;
|
|
12765
12839
|
kn = !0, Bs.push((async () => {
|
|
12766
|
-
let
|
|
12767
|
-
return N.webnnReleaseTensorId(Ht), N._OrtReleaseTensor(
|
|
12768
|
-
})()),
|
|
12840
|
+
let ar = [xt, await Mt];
|
|
12841
|
+
return N.webnnReleaseTensorId(Ht), N._OrtReleaseTensor(sr), ar;
|
|
12842
|
+
})()), ir.push([At, Dt, [], "cpu"]);
|
|
12769
12843
|
} else {
|
|
12770
|
-
let
|
|
12771
|
-
new Uint8Array(
|
|
12844
|
+
let Mt = _n(At), xt = new Mt(yr);
|
|
12845
|
+
new Uint8Array(xt.buffer, xt.byteOffset, xt.byteLength).set(N.HEAPU8.subarray(Ht, Ht + xt.byteLength)), ir.push([At, Dt, xt, "cpu"]);
|
|
12772
12846
|
}
|
|
12773
12847
|
} finally {
|
|
12774
|
-
N.stackRestore(fi),
|
|
12848
|
+
N.stackRestore(fi), At === "string" && Ht && N._free(Ht), kn || N._OrtReleaseTensor(sr);
|
|
12775
12849
|
}
|
|
12776
12850
|
}
|
|
12777
12851
|
j && !Te && (N._OrtClearBoundOutputs(j.handle) !== 0 && ke("Can't clear bound outputs."), Cr.set(y, [Z, se, J, j, Te, !1]));
|
|
12778
|
-
for (let [We,
|
|
12779
|
-
return Ue("wasm ProcessOutputTensor"),
|
|
12852
|
+
for (let [We, sr] of await Promise.all(Bs)) ir[We][2] = sr;
|
|
12853
|
+
return Ue("wasm ProcessOutputTensor"), ir;
|
|
12780
12854
|
} finally {
|
|
12781
|
-
N.webnnOnRunEnd?.(Z), N.stackRestore(Nt), $e.forEach((
|
|
12855
|
+
N.webnnOnRunEnd?.(Z), N.stackRestore(Nt), $e.forEach(($t) => N._OrtReleaseTensor($t)), qe.forEach(($t) => N._OrtReleaseTensor($t)), _e.forEach(($t) => N._free($t)), bt !== 0 && N._OrtReleaseRunOptions(bt), Ge.forEach(($t) => N._free($t));
|
|
12782
12856
|
}
|
|
12783
12857
|
}, Qr = (y) => {
|
|
12784
12858
|
let $ = Oe(), A = Cr.get(y);
|
|
@@ -12794,7 +12868,7 @@ function Ay() {
|
|
|
12794
12868
|
return $;
|
|
12795
12869
|
};
|
|
12796
12870
|
}), fr, Re, Rr, Xr, Ur, Yr, xn, En, mr, Ar, jn, Kn, Qn, As, Ms, hi, Jr, Is, Ps = _(() => {
|
|
12797
|
-
zt(), Rs(),
|
|
12871
|
+
zt(), Rs(), Jt(), mn(), fr = () => !!me.wasm.proxy && typeof document < "u", Rr = !1, Xr = !1, Ur = !1, En = /* @__PURE__ */ new Map(), mr = (y, $) => {
|
|
12798
12872
|
let A = En.get(y);
|
|
12799
12873
|
A ? A.push($) : En.set(y, [$]);
|
|
12800
12874
|
}, Ar = () => {
|
|
@@ -12861,7 +12935,7 @@ function Ay() {
|
|
|
12861
12935
|
let P = { type: "create", in: { model: y, options: { ...$ } } }, G = [];
|
|
12862
12936
|
y instanceof Uint8Array && G.push(y.buffer), Re.postMessage(P, G);
|
|
12863
12937
|
});
|
|
12864
|
-
} else return
|
|
12938
|
+
} else return nr(y, $);
|
|
12865
12939
|
}, hi = async (y) => {
|
|
12866
12940
|
if (fr()) return Ar(), new Promise(($, A) => {
|
|
12867
12941
|
mr("release", [$, A]);
|
|
@@ -12987,7 +13061,7 @@ function Ay() {
|
|
|
12987
13061
|
})(co)), co.exports;
|
|
12988
13062
|
}
|
|
12989
13063
|
var Up;
|
|
12990
|
-
function
|
|
13064
|
+
function Iy() {
|
|
12991
13065
|
return Up || (Up = 1, (function(c) {
|
|
12992
13066
|
var r = Wr && Wr.__createBinding || (Object.create ? (function(ce, re, ue, he) {
|
|
12993
13067
|
he === void 0 && (he = ue);
|
|
@@ -13008,7 +13082,7 @@ function My() {
|
|
|
13008
13082
|
return n(re, ce), re;
|
|
13009
13083
|
};
|
|
13010
13084
|
Object.defineProperty(c, "__esModule", { value: !0 }), c.MicVAD = c.getDefaultRealTimeVADOptions = c.ort = c.DEFAULT_MODEL = void 0;
|
|
13011
|
-
const f = a(
|
|
13085
|
+
const f = a(My()), v = Po(), C = Oo(), R = di(), _ = qi(), U = wf(), B = vf();
|
|
13012
13086
|
c.DEFAULT_MODEL = "legacy", c.ort = f;
|
|
13013
13087
|
const te = "vad.worklet.bundle.min.js", X = "silero_vad_v5.onnx", ee = "silero_vad_legacy.onnx", ie = (ce) => ({
|
|
13014
13088
|
...C.defaultFrameProcessorOptions,
|
|
@@ -13266,18 +13340,18 @@ function Vp() {
|
|
|
13266
13340
|
Object.defineProperty(c, "Message", { enumerable: !0, get: function() {
|
|
13267
13341
|
return f.Message;
|
|
13268
13342
|
} });
|
|
13269
|
-
var v =
|
|
13343
|
+
var v = Ry();
|
|
13270
13344
|
Object.defineProperty(c, "NonRealTimeVAD", { enumerable: !0, get: function() {
|
|
13271
13345
|
return v.NonRealTimeVAD;
|
|
13272
13346
|
} });
|
|
13273
|
-
const C =
|
|
13347
|
+
const C = Ay();
|
|
13274
13348
|
c.utils = {
|
|
13275
13349
|
audioFileToArray: C.audioFileToArray,
|
|
13276
13350
|
minFramesForTargetMS: C.minFramesForTargetMS,
|
|
13277
13351
|
arrayBufferToBase64: C.arrayBufferToBase64,
|
|
13278
13352
|
encodeWAV: C.encodeWAV
|
|
13279
13353
|
};
|
|
13280
|
-
var R =
|
|
13354
|
+
var R = Iy();
|
|
13281
13355
|
Object.defineProperty(c, "DEFAULT_MODEL", { enumerable: !0, get: function() {
|
|
13282
13356
|
return R.DEFAULT_MODEL;
|
|
13283
13357
|
} }), Object.defineProperty(c, "MicVAD", { enumerable: !0, get: function() {
|
|
@@ -13288,7 +13362,7 @@ function Vp() {
|
|
|
13288
13362
|
})(oo)), oo;
|
|
13289
13363
|
}
|
|
13290
13364
|
var Gp;
|
|
13291
|
-
function
|
|
13365
|
+
function Py() {
|
|
13292
13366
|
return Gp || (Gp = 1, (function(c) {
|
|
13293
13367
|
Object.defineProperty(c, "__esModule", { value: !0 }), c.useMicVAD = c.getDefaultReactRealTimeVADOptions = c.utils = void 0;
|
|
13294
13368
|
const r = Vp(), n = Yp;
|
|
@@ -13405,15 +13479,15 @@ function Iy() {
|
|
|
13405
13479
|
c.useMicVAD = R;
|
|
13406
13480
|
})(ao)), ao;
|
|
13407
13481
|
}
|
|
13408
|
-
var
|
|
13482
|
+
var Oy = Py();
|
|
13409
13483
|
ff();
|
|
13410
13484
|
const qp = {
|
|
13411
13485
|
echoCancellation: !0,
|
|
13412
13486
|
noiseSuppression: !0,
|
|
13413
13487
|
autoGainControl: !0,
|
|
13414
13488
|
channelCount: 1
|
|
13415
|
-
}, Ni = 16e3, bf = 512, Sf = 700,
|
|
13416
|
-
function
|
|
13489
|
+
}, Ni = 16e3, bf = 512, Sf = 700, zy = 300, Dy = bf / Ni * 1e3, Ly = Math.ceil(Sf / Dy);
|
|
13490
|
+
function Fw(c = {}) {
|
|
13417
13491
|
const {
|
|
13418
13492
|
onAudioChunk: r,
|
|
13419
13493
|
onAudioEnd: n,
|
|
@@ -13423,7 +13497,7 @@ function Uw(c = {}) {
|
|
|
13423
13497
|
onError: C,
|
|
13424
13498
|
interruptOnSpeechStart: R = !0,
|
|
13425
13499
|
forceAudioMp4: _ = !1
|
|
13426
|
-
} = c, { sendAudioChunk: U, endAudioStream: B, interrupt: te } = on(), [X, ee] = jr(!1), [ie, de] = jr(null), le =
|
|
13500
|
+
} = c, { sendAudioChunk: U, endAudioStream: B, interrupt: te } = on(), [X, ee] = jr(!1), [ie, de] = jr(null), le = Et(null), Le = Et(null), Ce = Et(null), ce = Et(!1), re = Et(null), ue = Et([]), he = Qe(() => {
|
|
13427
13501
|
if (!(typeof window > "u")) {
|
|
13428
13502
|
if (!Ce.current) {
|
|
13429
13503
|
const De = window.AudioContext || window.webkitAudioContext;
|
|
@@ -13473,21 +13547,21 @@ function Uw(c = {}) {
|
|
|
13473
13547
|
try {
|
|
13474
13548
|
const et = rt.createMediaStreamDestination();
|
|
13475
13549
|
if (Ze.length > 0) {
|
|
13476
|
-
const
|
|
13477
|
-
|
|
13550
|
+
const kt = rt.createBuffer(1, Ze.length, Ni);
|
|
13551
|
+
kt.getChannelData(0).set(Ze);
|
|
13478
13552
|
const ot = rt.createBufferSource();
|
|
13479
|
-
ot.buffer =
|
|
13553
|
+
ot.buffer = kt, ot.connect(et), ot.start(0);
|
|
13480
13554
|
}
|
|
13481
13555
|
const gt = rt.createMediaStreamSource(De);
|
|
13482
13556
|
if (Q > 0) {
|
|
13483
|
-
const
|
|
13484
|
-
|
|
13557
|
+
const kt = rt.createDelay(Q + 0.1);
|
|
13558
|
+
kt.delayTime.value = Q, gt.connect(kt).connect(et);
|
|
13485
13559
|
} else
|
|
13486
13560
|
gt.connect(et);
|
|
13487
13561
|
const qt = new MediaRecorder(et.stream, Ae ? { mimeType: Ae } : {});
|
|
13488
|
-
qt.ondataavailable = async (
|
|
13489
|
-
if (!
|
|
13490
|
-
const ot = await
|
|
13562
|
+
qt.ondataavailable = async (kt) => {
|
|
13563
|
+
if (!kt.data || kt.data.size <= 0) return;
|
|
13564
|
+
const ot = await kt.data.arrayBuffer();
|
|
13491
13565
|
r ? r(ot) : U(ot);
|
|
13492
13566
|
}, Le.current = qt, qt.start(100);
|
|
13493
13567
|
} catch (et) {
|
|
@@ -13516,7 +13590,7 @@ function Uw(c = {}) {
|
|
|
13516
13590
|
}), Ce.current = null);
|
|
13517
13591
|
}, []), yt = Qe(() => {
|
|
13518
13592
|
le.current && (le.current.getTracks().forEach((De) => De.stop()), le.current = null);
|
|
13519
|
-
}, []), at =
|
|
13593
|
+
}, []), at = Oy.useMicVAD({
|
|
13520
13594
|
model: "v5",
|
|
13521
13595
|
startOnLoad: !1,
|
|
13522
13596
|
processorType: "auto",
|
|
@@ -13539,7 +13613,7 @@ function Uw(c = {}) {
|
|
|
13539
13613
|
onFrameProcessed: (De, rt) => {
|
|
13540
13614
|
if (!rt) return;
|
|
13541
13615
|
const Ze = ue.current;
|
|
13542
|
-
Ze.push(new Float32Array(rt)), Ze.length >
|
|
13616
|
+
Ze.push(new Float32Array(rt)), Ze.length > Ly && Ze.shift();
|
|
13543
13617
|
},
|
|
13544
13618
|
onSpeechStart: () => {
|
|
13545
13619
|
ce.current || (re.current && (clearTimeout(re.current), re.current = null), ee(!0), R && te(), ft(), a?.());
|
|
@@ -13549,7 +13623,7 @@ function Uw(c = {}) {
|
|
|
13549
13623
|
ee(!1), Be(), ce.current = !0, setTimeout(() => {
|
|
13550
13624
|
ce.current = !1;
|
|
13551
13625
|
}, 300), f?.();
|
|
13552
|
-
},
|
|
13626
|
+
}, zy);
|
|
13553
13627
|
},
|
|
13554
13628
|
onVADMisfire: () => {
|
|
13555
13629
|
re.current && (clearTimeout(re.current), re.current = null), ee(!1), Xe(), v?.();
|
|
@@ -13570,7 +13644,7 @@ function Uw(c = {}) {
|
|
|
13570
13644
|
userSpeaking: at.userSpeaking
|
|
13571
13645
|
};
|
|
13572
13646
|
}
|
|
13573
|
-
const
|
|
13647
|
+
const Vw = () => on(), By = () => {
|
|
13574
13648
|
const {
|
|
13575
13649
|
connectionState: c,
|
|
13576
13650
|
isConnected: r,
|
|
@@ -13603,14 +13677,14 @@ const Fw = () => on(), Ly = () => {
|
|
|
13603
13677
|
clearSessionHistory: X,
|
|
13604
13678
|
changeSessionLanguage: ee
|
|
13605
13679
|
};
|
|
13606
|
-
},
|
|
13680
|
+
}, Gw = () => {
|
|
13607
13681
|
const { messages: c, sendTextMessage: r, clearMessages: n } = on();
|
|
13608
13682
|
return {
|
|
13609
13683
|
messages: c,
|
|
13610
13684
|
sendTextMessage: r,
|
|
13611
13685
|
clearMessages: n
|
|
13612
13686
|
};
|
|
13613
|
-
},
|
|
13687
|
+
}, qw = () => {
|
|
13614
13688
|
const {
|
|
13615
13689
|
sendAudioChunk: c,
|
|
13616
13690
|
endAudioStream: r,
|
|
@@ -13631,8 +13705,8 @@ const Fw = () => on(), Ly = () => {
|
|
|
13631
13705
|
resumeAudioPlayback: C,
|
|
13632
13706
|
attachAudioElement: R
|
|
13633
13707
|
};
|
|
13634
|
-
},
|
|
13635
|
-
const { session: c, isAvatarSpeaking: r, cloudStream: n, setCloudStreamState: a } = on(), f = n?.state ||
|
|
13708
|
+
}, Ny = () => {
|
|
13709
|
+
const { session: c, isAvatarSpeaking: r, cloudStream: n, setCloudStreamState: a } = on(), f = n?.state || rr.IDLE;
|
|
13636
13710
|
return {
|
|
13637
13711
|
streamingUrl: c.streamingUrl,
|
|
13638
13712
|
isAvatarSpeaking: r,
|
|
@@ -13641,11 +13715,11 @@ const Fw = () => on(), Ly = () => {
|
|
|
13641
13715
|
isDesktopAvatar: c.agentType === sn.DESKTOP_AVATAR,
|
|
13642
13716
|
cloudStreamState: f,
|
|
13643
13717
|
cloudStreamError: n?.error || null,
|
|
13644
|
-
isCloudStreamConnected: f ===
|
|
13645
|
-
isCloudStreamLoading: f ===
|
|
13718
|
+
isCloudStreamConnected: f === rr.CONNECTED,
|
|
13719
|
+
isCloudStreamLoading: f === rr.CONNECTING || f === rr.LOADING,
|
|
13646
13720
|
setCloudStreamState: a
|
|
13647
13721
|
};
|
|
13648
|
-
},
|
|
13722
|
+
}, Ww = (c) => {
|
|
13649
13723
|
const { attachAudioElement: r, resumeAudioPlayback: n } = on();
|
|
13650
13724
|
xr(() => {
|
|
13651
13725
|
if (!c?.current) return;
|
|
@@ -13658,8 +13732,8 @@ const Fw = () => on(), Ly = () => {
|
|
|
13658
13732
|
};
|
|
13659
13733
|
}, [r, c, n]);
|
|
13660
13734
|
};
|
|
13661
|
-
function
|
|
13662
|
-
const { initializeSession: v, joinDesktopSession: C, disconnect: R } =
|
|
13735
|
+
function Uy({ connect: c = !0, session: r, onError: n, onInitialized: a, children: f }) {
|
|
13736
|
+
const { initializeSession: v, joinDesktopSession: C, disconnect: R } = By(), _ = Et(!1);
|
|
13663
13737
|
return xr(() => {
|
|
13664
13738
|
if (!c || _.current) return;
|
|
13665
13739
|
let U = !1;
|
|
@@ -13685,7 +13759,7 @@ function Ny({ connect: c = !0, session: r, onError: n, onInitialized: a, childre
|
|
|
13685
13759
|
};
|
|
13686
13760
|
}, [c, R, v, C, n, a, r]), f;
|
|
13687
13761
|
}
|
|
13688
|
-
function
|
|
13762
|
+
function Hw({
|
|
13689
13763
|
children: c,
|
|
13690
13764
|
wsUrl: r,
|
|
13691
13765
|
restUrl: n,
|
|
@@ -13698,8 +13772,8 @@ function Ww({
|
|
|
13698
13772
|
onError: U,
|
|
13699
13773
|
onInitialized: B
|
|
13700
13774
|
}) {
|
|
13701
|
-
return /* @__PURE__ */
|
|
13702
|
-
|
|
13775
|
+
return /* @__PURE__ */ lr.jsx(
|
|
13776
|
+
_y,
|
|
13703
13777
|
{
|
|
13704
13778
|
wsUrl: r,
|
|
13705
13779
|
restUrl: n,
|
|
@@ -13707,8 +13781,8 @@ function Ww({
|
|
|
13707
13781
|
enableAudio: C,
|
|
13708
13782
|
pcmOptions: R,
|
|
13709
13783
|
debug: _,
|
|
13710
|
-
children: /* @__PURE__ */
|
|
13711
|
-
|
|
13784
|
+
children: /* @__PURE__ */ lr.jsx(
|
|
13785
|
+
Uy,
|
|
13712
13786
|
{
|
|
13713
13787
|
connect: f,
|
|
13714
13788
|
session: a,
|
|
@@ -13721,7 +13795,7 @@ function Ww({
|
|
|
13721
13795
|
);
|
|
13722
13796
|
}
|
|
13723
13797
|
var ho = { exports: {} }, Wp;
|
|
13724
|
-
function
|
|
13798
|
+
function Fy() {
|
|
13725
13799
|
return Wp || (Wp = 1, (function(c) {
|
|
13726
13800
|
const r = {};
|
|
13727
13801
|
r.generateIdentifier = function() {
|
|
@@ -14110,10 +14184,10 @@ t=0 0\r
|
|
|
14110
14184
|
}, c.exports = r;
|
|
14111
14185
|
})(ho)), ho.exports;
|
|
14112
14186
|
}
|
|
14113
|
-
var Hp =
|
|
14187
|
+
var Hp = Fy(), Er, Ot, Ui = { d: (c, r) => {
|
|
14114
14188
|
for (var n in r) Ui.o(r, n) && !Ui.o(c, n) && Object.defineProperty(c, n, { enumerable: !0, get: r[n] });
|
|
14115
14189
|
}, o: (c, r) => Object.prototype.hasOwnProperty.call(c, r) }, be = {};
|
|
14116
|
-
Ui.d(be, { Dz: () => im, g$: () => kf, Lt: () => Ef, Q9: () => Cf, qf: () => $o, hV: () => dm, z$: () =>
|
|
14190
|
+
Ui.d(be, { Dz: () => im, g$: () => kf, Lt: () => Ef, Q9: () => Cf, qf: () => $o, hV: () => dm, z$: () => Ow, J0: () => Eo, De: () => ow, $C: () => Nn, al: () => Lf, _W: () => Bf, Gv: () => Jf, m: () => Zf, tz: () => Df, Nu: () => lm, zg: () => pm, vp: () => sm, vU: () => K, wF: () => jf, rv: () => am, Nh: () => om, ss: () => hm, qW: () => em, QL: () => Yf, cf: () => mm, eM: () => Hf, Yd: () => T, Tk: () => Se, iM: () => Tf, qy: () => Kr, ce: () => Yy, sK: () => ye, Ok: () => St, q5: () => um, g: () => Pw, xl: () => qf, I: () => Wf, bx: () => xo, dD: () => rm, Ib: () => ci, Az: () => Pt, Iw: () => Or, qY: () => To, db: () => xf, mR: () => ui, Tn: () => So, rV: () => Kf, gh: () => Uf, Mi: () => Ff, j: () => Vf, YB: () => Gf, Yt: () => Xf, i5: () => Qf, x_: () => Hr, Am: () => Co, eR: () => Rf, r8: () => Nf, u3: () => fm, vd: () => Mf, iV: () => Pf, jZ: () => If, SW: () => zf, ZH: () => Of, Ni: () => gm, lh: () => Af, ZP: () => nm, bq: () => $f, $f: () => ym, eu: () => tm, Ax: () => rw, Mc: () => tw });
|
|
14117
14191
|
class T {
|
|
14118
14192
|
static GetStackTrace() {
|
|
14119
14193
|
const r = new Error();
|
|
@@ -14161,27 +14235,27 @@ class Kr {
|
|
|
14161
14235
|
` + JSON.stringify(this, this.sendFilter, 4), 6), JSON.stringify(this, this.sendFilter);
|
|
14162
14236
|
}
|
|
14163
14237
|
}
|
|
14164
|
-
class
|
|
14238
|
+
class Vy extends Kr {
|
|
14165
14239
|
constructor() {
|
|
14166
14240
|
super(), this.type = Er.LIST_STREAMERS;
|
|
14167
14241
|
}
|
|
14168
14242
|
}
|
|
14169
|
-
class
|
|
14243
|
+
class Gy extends Kr {
|
|
14170
14244
|
constructor(r) {
|
|
14171
14245
|
super(), this.type = Er.SUBSCRIBE, this.streamerId = r;
|
|
14172
14246
|
}
|
|
14173
14247
|
}
|
|
14174
|
-
class
|
|
14248
|
+
class qy extends Kr {
|
|
14175
14249
|
constructor() {
|
|
14176
14250
|
super(), this.type = Er.UNSUBSCRIBE;
|
|
14177
14251
|
}
|
|
14178
14252
|
}
|
|
14179
|
-
class
|
|
14253
|
+
class Wy extends Kr {
|
|
14180
14254
|
constructor(r) {
|
|
14181
14255
|
super(), this.type = Er.PONG, this.time = r;
|
|
14182
14256
|
}
|
|
14183
14257
|
}
|
|
14184
|
-
class
|
|
14258
|
+
class Hy extends Kr {
|
|
14185
14259
|
constructor(r, n) {
|
|
14186
14260
|
super(), this.type = Er.OFFER, this.minBitrate = 0, this.maxBitrate = 0, r && (this.type = r.type, this.sdp = r.sdp, this.minBitrate = n.minBitrateBps, this.maxBitrate = n.maxBitrateBps);
|
|
14187
14261
|
}
|
|
@@ -14189,7 +14263,7 @@ class Wy extends Kr {
|
|
|
14189
14263
|
if (r != "minBitrate" && r != "maxBitrate" || !(n <= 0)) return n;
|
|
14190
14264
|
}
|
|
14191
14265
|
}
|
|
14192
|
-
class
|
|
14266
|
+
class jy extends Kr {
|
|
14193
14267
|
constructor(r, n) {
|
|
14194
14268
|
super(), this.type = Er.ANSWER, this.minBitrate = 0, this.maxBitrate = 0, r && (this.type = r.type, this.sdp = r.sdp, this.minBitrate = n.minBitrateBps, this.maxBitrate = n.maxBitrateBps);
|
|
14195
14269
|
}
|
|
@@ -14197,17 +14271,17 @@ class Hy extends Kr {
|
|
|
14197
14271
|
if (r != "minBitrate" && r != "maxBitrate" || !(n <= 0)) return n;
|
|
14198
14272
|
}
|
|
14199
14273
|
}
|
|
14200
|
-
class
|
|
14274
|
+
class Ky extends Kr {
|
|
14201
14275
|
constructor() {
|
|
14202
14276
|
super(), this.type = Er.DATACHANNELREQUEST;
|
|
14203
14277
|
}
|
|
14204
14278
|
}
|
|
14205
|
-
class
|
|
14279
|
+
class Qy extends Kr {
|
|
14206
14280
|
constructor() {
|
|
14207
14281
|
super(), this.type = Er.SFURECVDATACHANNELREADY;
|
|
14208
14282
|
}
|
|
14209
14283
|
}
|
|
14210
|
-
class
|
|
14284
|
+
class Xy {
|
|
14211
14285
|
constructor(r) {
|
|
14212
14286
|
this.type = Er.ICE_CANDIDATE, this.candidate = r;
|
|
14213
14287
|
}
|
|
@@ -14218,10 +14292,10 @@ class Qy {
|
|
|
14218
14292
|
}
|
|
14219
14293
|
(function(c) {
|
|
14220
14294
|
c.CONFIG = "config", c.STREAMER_LIST = "streamerList", c.STREAMER_ID_CHANGED = "streamerIDChanged", c.PLAYER_COUNT = "playerCount", c.OFFER = "offer", c.ANSWER = "answer", c.ICE_CANDIDATE = "iceCandidate", c.PEER_DATA_CHANNELS = "peerDataChannels", c.PING = "ping", c.WARNING = "warning";
|
|
14221
|
-
})(
|
|
14295
|
+
})(Ot || (Ot = {}));
|
|
14222
14296
|
class Tf {
|
|
14223
14297
|
}
|
|
14224
|
-
class
|
|
14298
|
+
class Yy extends Tf {
|
|
14225
14299
|
}
|
|
14226
14300
|
class So {
|
|
14227
14301
|
constructor() {
|
|
@@ -14234,41 +14308,41 @@ class So {
|
|
|
14234
14308
|
this.FromUEMessageHandlers.has(r) ? this.FromUEMessageHandlers.get(r)(n) : T.Error(T.GetStackTrace(), `Message type of ${r} does not have a message handler registered on the frontend - ignoring message.`);
|
|
14235
14309
|
}
|
|
14236
14310
|
static setupDefaultHandlers(r) {
|
|
14237
|
-
r.signallingProtocol.addMessageHandler(
|
|
14238
|
-
const a = new
|
|
14239
|
-
T.Log(T.GetStackTrace(),
|
|
14240
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14241
|
-
T.Log(T.GetStackTrace(),
|
|
14311
|
+
r.signallingProtocol.addMessageHandler(Ot.PING, ((n) => {
|
|
14312
|
+
const a = new Wy((/* @__PURE__ */ new Date()).getTime()).payload();
|
|
14313
|
+
T.Log(T.GetStackTrace(), Ot.PING + ": " + n, 6), r.webSocket.send(a);
|
|
14314
|
+
})), r.signallingProtocol.addMessageHandler(Ot.CONFIG, ((n) => {
|
|
14315
|
+
T.Log(T.GetStackTrace(), Ot.CONFIG, 6);
|
|
14242
14316
|
const a = JSON.parse(n);
|
|
14243
14317
|
r.onConfig(a);
|
|
14244
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14245
|
-
T.Log(T.GetStackTrace(),
|
|
14318
|
+
})), r.signallingProtocol.addMessageHandler(Ot.STREAMER_LIST, ((n) => {
|
|
14319
|
+
T.Log(T.GetStackTrace(), Ot.STREAMER_LIST, 6);
|
|
14246
14320
|
const a = JSON.parse(n);
|
|
14247
14321
|
r.onStreamerList(a);
|
|
14248
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14249
|
-
T.Log(T.GetStackTrace(),
|
|
14322
|
+
})), r.signallingProtocol.addMessageHandler(Ot.STREAMER_ID_CHANGED, ((n) => {
|
|
14323
|
+
T.Log(T.GetStackTrace(), Ot.STREAMER_ID_CHANGED, 6);
|
|
14250
14324
|
const a = JSON.parse(n);
|
|
14251
14325
|
r.onStreamerIDChanged(a);
|
|
14252
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14253
|
-
T.Log(T.GetStackTrace(),
|
|
14326
|
+
})), r.signallingProtocol.addMessageHandler(Ot.PLAYER_COUNT, ((n) => {
|
|
14327
|
+
T.Log(T.GetStackTrace(), Ot.PLAYER_COUNT, 6);
|
|
14254
14328
|
const a = JSON.parse(n);
|
|
14255
14329
|
T.Log(T.GetStackTrace(), "Player Count: " + a.count, 6), r.onPlayerCount(a);
|
|
14256
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14257
|
-
T.Log(T.GetStackTrace(),
|
|
14330
|
+
})), r.signallingProtocol.addMessageHandler(Ot.ANSWER, ((n) => {
|
|
14331
|
+
T.Log(T.GetStackTrace(), Ot.ANSWER, 6);
|
|
14258
14332
|
const a = JSON.parse(n);
|
|
14259
14333
|
r.onWebRtcAnswer(a);
|
|
14260
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14261
|
-
T.Log(T.GetStackTrace(),
|
|
14334
|
+
})), r.signallingProtocol.addMessageHandler(Ot.OFFER, ((n) => {
|
|
14335
|
+
T.Log(T.GetStackTrace(), Ot.OFFER, 6);
|
|
14262
14336
|
const a = JSON.parse(n);
|
|
14263
14337
|
r.onWebRtcOffer(a);
|
|
14264
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14265
|
-
T.Log(T.GetStackTrace(),
|
|
14338
|
+
})), r.signallingProtocol.addMessageHandler(Ot.ICE_CANDIDATE, ((n) => {
|
|
14339
|
+
T.Log(T.GetStackTrace(), Ot.ICE_CANDIDATE, 6);
|
|
14266
14340
|
const a = JSON.parse(n);
|
|
14267
14341
|
r.onIceCandidate(a.candidate);
|
|
14268
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14342
|
+
})), r.signallingProtocol.addMessageHandler(Ot.WARNING, ((n) => {
|
|
14269
14343
|
T.Warning(T.GetStackTrace(), `Warning received: ${n}`);
|
|
14270
|
-
})), r.signallingProtocol.addMessageHandler(
|
|
14271
|
-
T.Log(T.GetStackTrace(),
|
|
14344
|
+
})), r.signallingProtocol.addMessageHandler(Ot.PEER_DATA_CHANNELS, ((n) => {
|
|
14345
|
+
T.Log(T.GetStackTrace(), Ot.PEER_DATA_CHANNELS, 6);
|
|
14272
14346
|
const a = JSON.parse(n);
|
|
14273
14347
|
r.onWebRtcPeerDataChannels(a);
|
|
14274
14348
|
}));
|
|
@@ -14310,36 +14384,36 @@ class $f {
|
|
|
14310
14384
|
T.Log(T.GetStackTrace(), "Disconnected to the signalling server via WebSocket: " + JSON.stringify(r.code) + " - " + r.reason), this.onClose.dispatchEvent(new CustomEvent("close", { detail: r }));
|
|
14311
14385
|
}
|
|
14312
14386
|
requestStreamerList() {
|
|
14313
|
-
const r = new
|
|
14387
|
+
const r = new Vy();
|
|
14314
14388
|
this.webSocket.send(r.payload());
|
|
14315
14389
|
}
|
|
14316
14390
|
sendSubscribe(r) {
|
|
14317
|
-
const n = new
|
|
14391
|
+
const n = new Gy(r);
|
|
14318
14392
|
this.webSocket.send(n.payload());
|
|
14319
14393
|
}
|
|
14320
14394
|
sendUnsubscribe() {
|
|
14321
|
-
const r = new
|
|
14395
|
+
const r = new qy();
|
|
14322
14396
|
this.webSocket.send(r.payload());
|
|
14323
14397
|
}
|
|
14324
14398
|
sendWebRtcOffer(r, n) {
|
|
14325
|
-
const a = new
|
|
14399
|
+
const a = new Hy(r, n);
|
|
14326
14400
|
this.webSocket.send(a.payload());
|
|
14327
14401
|
}
|
|
14328
14402
|
sendWebRtcAnswer(r, n) {
|
|
14329
|
-
const a = new
|
|
14403
|
+
const a = new jy(r, n);
|
|
14330
14404
|
this.webSocket.send(a.payload());
|
|
14331
14405
|
}
|
|
14332
14406
|
sendWebRtcDatachannelRequest() {
|
|
14333
|
-
const r = new
|
|
14407
|
+
const r = new Ky();
|
|
14334
14408
|
this.webSocket.send(r.payload());
|
|
14335
14409
|
}
|
|
14336
14410
|
sendSFURecvDataChannelReady() {
|
|
14337
|
-
const r = new
|
|
14411
|
+
const r = new Qy();
|
|
14338
14412
|
this.webSocket.send(r.payload());
|
|
14339
14413
|
}
|
|
14340
14414
|
sendIceCandidate(r) {
|
|
14341
14415
|
if (T.Log(T.GetStackTrace(), "Sending Ice Candidate"), this.webSocket && this.webSocket.readyState === this.WS_OPEN_STATE) {
|
|
14342
|
-
const n = new
|
|
14416
|
+
const n = new Xy(r);
|
|
14343
14417
|
this.webSocket.send(n.payload());
|
|
14344
14418
|
}
|
|
14345
14419
|
}
|
|
@@ -14364,7 +14438,7 @@ class $f {
|
|
|
14364
14438
|
onPlayerCount(r) {
|
|
14365
14439
|
}
|
|
14366
14440
|
}
|
|
14367
|
-
class
|
|
14441
|
+
class Jy {
|
|
14368
14442
|
constructor(r) {
|
|
14369
14443
|
this.videoElementProvider = r, this.audioElement = document.createElement("Audio"), this.videoElementProvider.setAudioElement(this.audioElement);
|
|
14370
14444
|
}
|
|
@@ -14379,7 +14453,7 @@ class Yy {
|
|
|
14379
14453
|
n.srcObject != r && n.srcObject && n.srcObject !== r && (this.audioElement.srcObject = r, T.Log(T.GetStackTrace(), "Created new audio element to play separate audio stream."));
|
|
14380
14454
|
}
|
|
14381
14455
|
}
|
|
14382
|
-
class
|
|
14456
|
+
class Zy {
|
|
14383
14457
|
constructor(r) {
|
|
14384
14458
|
this.freezeFrameHeight = 0, this.freezeFrameWidth = 0, this.rootDiv = r, this.rootElement = document.createElement("div"), this.rootElement.id = "freezeFrame", this.rootElement.style.display = "none", this.rootElement.style.pointerEvents = "none", this.rootElement.style.position = "absolute", this.rootElement.style.zIndex = "20", this.imageElement = document.createElement("img"), this.imageElement.style.position = "absolute", this.rootElement.appendChild(this.imageElement), this.rootDiv.appendChild(this.rootElement);
|
|
14385
14459
|
}
|
|
@@ -14404,9 +14478,9 @@ class Jy {
|
|
|
14404
14478
|
}
|
|
14405
14479
|
}
|
|
14406
14480
|
}
|
|
14407
|
-
class
|
|
14481
|
+
class ew {
|
|
14408
14482
|
constructor(r) {
|
|
14409
|
-
this.receiving = !1, this.size = 0, this.jpeg = void 0, this.valid = !1, this.freezeFrameDelay = 50, this.freezeFrame = new
|
|
14483
|
+
this.receiving = !1, this.size = 0, this.jpeg = void 0, this.valid = !1, this.freezeFrameDelay = 50, this.freezeFrame = new Zy(r);
|
|
14410
14484
|
}
|
|
14411
14485
|
showFreezeFrame() {
|
|
14412
14486
|
this.valid && this.freezeFrame.setElementForShow();
|
|
@@ -14448,7 +14522,7 @@ class ci {
|
|
|
14448
14522
|
this._value = r, this.onChange(this._value, this), this.onChangeEmit(this._value);
|
|
14449
14523
|
}
|
|
14450
14524
|
}
|
|
14451
|
-
class
|
|
14525
|
+
class Pt extends ci {
|
|
14452
14526
|
constructor(r, n, a, f, v, C = (() => {
|
|
14453
14527
|
})) {
|
|
14454
14528
|
super(r, n, a, f, C);
|
|
@@ -14739,12 +14813,12 @@ class ui extends Event {
|
|
|
14739
14813
|
super("settingsChanged"), this.data = r;
|
|
14740
14814
|
}
|
|
14741
14815
|
}
|
|
14742
|
-
class
|
|
14816
|
+
class tw extends Event {
|
|
14743
14817
|
constructor() {
|
|
14744
14818
|
super("xrSessionStarted");
|
|
14745
14819
|
}
|
|
14746
14820
|
}
|
|
14747
|
-
class
|
|
14821
|
+
class rw extends Event {
|
|
14748
14822
|
constructor() {
|
|
14749
14823
|
super("xrSessionEnded");
|
|
14750
14824
|
}
|
|
@@ -14778,20 +14852,20 @@ class sm extends EventTarget {
|
|
|
14778
14852
|
class K {
|
|
14779
14853
|
}
|
|
14780
14854
|
K.AutoConnect = "AutoConnect", K.AutoPlayVideo = "AutoPlayVideo", K.AFKDetection = "TimeoutIfIdle", K.BrowserSendOffer = "OfferToReceive", K.HoveringMouseMode = "HoveringMouse", K.ForceMonoAudio = "ForceMonoAudio", K.ForceTURN = "ForceTURN", K.FakeMouseWithTouches = "FakeMouseWithTouches", K.IsQualityController = "ControlsQuality", K.MatchViewportResolution = "MatchViewportRes", K.StartVideoMuted = "StartVideoMuted", K.SuppressBrowserKeys = "SuppressBrowserKeys", K.UseMic = "UseMic", K.KeyboardInput = "KeyboardInput", K.MouseInput = "MouseInput", K.TouchInput = "TouchInput", K.GamepadInput = "GamepadInput", K.XRControllerInput = "XRControllerInput", K.WaitForStreamer = "WaitForStreamer", K.HideUI = "HideUI";
|
|
14781
|
-
const
|
|
14855
|
+
const nw = (c) => Object.getOwnPropertyNames(K).some(((r) => K[r] === c));
|
|
14782
14856
|
class ye {
|
|
14783
14857
|
}
|
|
14784
14858
|
ye.AFKTimeoutSecs = "AFKTimeout", ye.AFKCountdownSecs = "AFKCountdown", ye.MinQP = "MinQP", ye.MaxQP = "MaxQP", ye.WebRTCFPS = "WebRTCFPS", ye.WebRTCMinBitrate = "WebRTCMinBitrate", ye.WebRTCMaxBitrate = "WebRTCMaxBitrate", ye.MaxReconnectAttempts = "MaxReconnectAttempts", ye.StreamerAutoJoinInterval = "StreamerAutoJoinInterval";
|
|
14785
|
-
const
|
|
14859
|
+
const sw = (c) => Object.getOwnPropertyNames(ye).some(((r) => ye[r] === c));
|
|
14786
14860
|
class Hr {
|
|
14787
14861
|
}
|
|
14788
14862
|
Hr.SignallingServerUrl = "ss";
|
|
14789
|
-
const
|
|
14863
|
+
const iw = (c) => Object.getOwnPropertyNames(Hr).some(((r) => Hr[r] === c));
|
|
14790
14864
|
class St {
|
|
14791
14865
|
}
|
|
14792
14866
|
St.PreferredCodec = "PreferredCodec", St.StreamerId = "StreamerId";
|
|
14793
|
-
const
|
|
14794
|
-
class
|
|
14867
|
+
const aw = (c) => Object.getOwnPropertyNames(St).some(((r) => St[r] === c));
|
|
14868
|
+
class ow {
|
|
14795
14869
|
constructor(r = {}) {
|
|
14796
14870
|
this.flags = /* @__PURE__ */ new Map(), this.numericParameters = /* @__PURE__ */ new Map(), this.textParameters = /* @__PURE__ */ new Map(), this.optionParameters = /* @__PURE__ */ new Map();
|
|
14797
14871
|
const { initialSettings: n, useUrlParams: a } = r;
|
|
@@ -14809,9 +14883,9 @@ class aw {
|
|
|
14809
14883
|
const C = v.mimeType.split("/")[1] + " " + (v.sdpFmtpLine || "");
|
|
14810
14884
|
f.exec(C) !== null && a.push(C);
|
|
14811
14885
|
})), a;
|
|
14812
|
-
})(), r)), this.flags.set(K.AutoConnect, new
|
|
14886
|
+
})(), r)), this.flags.set(K.AutoConnect, new Pt(K.AutoConnect, "Auto connect to stream", "Whether we should attempt to auto connect to the signalling server or show a click to start prompt.", !(!n || !n.hasOwnProperty(K.AutoConnect)) && n[K.AutoConnect], r)), this.flags.set(K.AutoPlayVideo, new Pt(K.AutoPlayVideo, "Auto play video", "When video is ready automatically start playing it as opposed to showing a play button.", !n || !n.hasOwnProperty(K.AutoPlayVideo) || n[K.AutoPlayVideo], r)), this.flags.set(K.BrowserSendOffer, new Pt(K.BrowserSendOffer, "Browser send offer", "Browser will initiate the WebRTC handshake by sending the offer to the streamer", !(!n || !n.hasOwnProperty(K.BrowserSendOffer)) && n[K.BrowserSendOffer], r)), this.flags.set(K.UseMic, new Pt(K.UseMic, "Use microphone", "Make browser request microphone access and open an input audio track.", !(!n || !n.hasOwnProperty(K.UseMic)) && n[K.UseMic], r)), this.flags.set(K.StartVideoMuted, new Pt(K.StartVideoMuted, "Start video muted", "Video will start muted if true.", !(!n || !n.hasOwnProperty(K.StartVideoMuted)) && n[K.StartVideoMuted], r)), this.flags.set(K.SuppressBrowserKeys, new Pt(K.SuppressBrowserKeys, "Suppress browser keys", "Suppress certain browser keys that we use in UE, for example F5 to show shader complexity instead of refresh the page.", !n || !n.hasOwnProperty(K.SuppressBrowserKeys) || n[K.SuppressBrowserKeys], r)), this.flags.set(K.IsQualityController, new Pt(K.IsQualityController, "Is quality controller?", "True if this peer controls stream quality", !n || !n.hasOwnProperty(K.IsQualityController) || n[K.IsQualityController], r)), this.flags.set(K.ForceMonoAudio, new Pt(K.ForceMonoAudio, "Force mono audio", "Force browser to request mono audio in the SDP", !(!n || !n.hasOwnProperty(K.ForceMonoAudio)) && n[K.ForceMonoAudio], r)), this.flags.set(K.ForceTURN, new Pt(K.ForceTURN, "Force TURN", "Only generate TURN/Relayed ICE candidates.", !(!n || !n.hasOwnProperty(K.ForceTURN)) && n[K.ForceTURN], r)), this.flags.set(K.AFKDetection, new Pt(K.AFKDetection, "AFK if idle", "Timeout the experience if user is AFK for a period.", !(!n || !n.hasOwnProperty(K.AFKDetection)) && n[K.AFKDetection], r)), this.flags.set(K.MatchViewportResolution, new Pt(K.MatchViewportResolution, "Match viewport resolution", "Pixel Streaming will be instructed to dynamically resize the video stream to match the size of the video element.", !(!n || !n.hasOwnProperty(K.MatchViewportResolution)) && n[K.MatchViewportResolution], r)), this.flags.set(K.HoveringMouseMode, new Pt(K.HoveringMouseMode, "Control Scheme: Locked Mouse", "Either locked mouse, where the pointer is consumed by the video and locked to it, or hovering mouse, where the mouse is not consumed.", !(!n || !n.hasOwnProperty(K.HoveringMouseMode)) && n[K.HoveringMouseMode], r, ((a, f) => {
|
|
14813
14887
|
f.label = `Control Scheme: ${a ? "Hovering" : "Locked"} Mouse`;
|
|
14814
|
-
}))), this.flags.set(K.FakeMouseWithTouches, new
|
|
14888
|
+
}))), this.flags.set(K.FakeMouseWithTouches, new Pt(K.FakeMouseWithTouches, "Fake mouse with touches", "A single finger touch is converted into a mouse event. This allows a non-touch application to be controlled partially via a touch device.", !(!n || !n.hasOwnProperty(K.FakeMouseWithTouches)) && n[K.FakeMouseWithTouches], r)), this.flags.set(K.KeyboardInput, new Pt(K.KeyboardInput, "Keyboard input", "If enabled, send keyboard events to streamer", !n || !n.hasOwnProperty(K.KeyboardInput) || n[K.KeyboardInput], r)), this.flags.set(K.MouseInput, new Pt(K.MouseInput, "Mouse input", "If enabled, send mouse events to streamer", !n || !n.hasOwnProperty(K.MouseInput) || n[K.MouseInput], r)), this.flags.set(K.TouchInput, new Pt(K.TouchInput, "Touch input", "If enabled, send touch events to streamer", !n || !n.hasOwnProperty(K.TouchInput) || n[K.TouchInput], r)), this.flags.set(K.GamepadInput, new Pt(K.GamepadInput, "Gamepad input", "If enabled, send gamepad events to streamer", !n || !n.hasOwnProperty(K.GamepadInput) || n[K.GamepadInput], r)), this.flags.set(K.XRControllerInput, new Pt(K.XRControllerInput, "XR controller input", "If enabled, send XR controller events to streamer", !n || !n.hasOwnProperty(K.XRControllerInput) || n[K.XRControllerInput], r)), this.flags.set(K.WaitForStreamer, new Pt(K.WaitForStreamer, "Wait for streamer", "Will continue trying to connect to the first streamer available.", !n || !n.hasOwnProperty(K.WaitForStreamer) || n[K.WaitForStreamer], r)), this.flags.set(K.HideUI, new Pt(K.HideUI, "Hide the UI overlay", "Will hide all UI overlay details", !(!n || !n.hasOwnProperty(K.HideUI)) && n[K.HideUI], r)), this.numericParameters.set(ye.AFKTimeoutSecs, new Or(ye.AFKTimeoutSecs, "AFK timeout", "The time (in seconds) it takes for the application to time out if AFK timeout is enabled.", 0, null, n && n.hasOwnProperty(ye.AFKTimeoutSecs) ? n[ye.AFKTimeoutSecs] : 120, r)), this.numericParameters.set(ye.AFKCountdownSecs, new Or(ye.AFKCountdownSecs, "AFK countdown", "The time (in seconds) for a user to respond before the stream is ended after an AFK timeout.", 10, null, 10, r)), this.numericParameters.set(ye.MaxReconnectAttempts, new Or(ye.MaxReconnectAttempts, "Max Reconnects", "Maximum number of reconnects the application will attempt when a streamer disconnects.", 0, 999, n && n.hasOwnProperty(ye.MaxReconnectAttempts) ? n[ye.MaxReconnectAttempts] : 3, r)), this.numericParameters.set(ye.MinQP, new Or(ye.MinQP, "Min QP", "The lower bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.", 0, 51, n && n.hasOwnProperty(ye.MinQP) ? n[ye.MinQP] : 0, r)), this.numericParameters.set(ye.MaxQP, new Or(ye.MaxQP, "Max QP", "The upper bound for the quantization parameter (QP) of the encoder. 0 = Best quality, 51 = worst quality.", 0, 51, n && n.hasOwnProperty(ye.MaxQP) ? n[ye.MaxQP] : 51, r)), this.numericParameters.set(ye.WebRTCFPS, new Or(ye.WebRTCFPS, "Max FPS", "The maximum FPS that WebRTC will try to transmit frames at.", 1, 999, n && n.hasOwnProperty(ye.WebRTCFPS) ? n[ye.WebRTCFPS] : 60, r)), this.numericParameters.set(ye.WebRTCMinBitrate, new Or(ye.WebRTCMinBitrate, "Min Bitrate (kbps)", "The minimum bitrate that WebRTC should use.", 0, 5e5, n && n.hasOwnProperty(ye.WebRTCMinBitrate) ? n[ye.WebRTCMinBitrate] : 0, r)), this.numericParameters.set(ye.WebRTCMaxBitrate, new Or(ye.WebRTCMaxBitrate, "Max Bitrate (kbps)", "The maximum bitrate that WebRTC should use.", 0, 5e5, n && n.hasOwnProperty(ye.WebRTCMaxBitrate) ? n[ye.WebRTCMaxBitrate] : 0, r)), this.numericParameters.set(ye.StreamerAutoJoinInterval, new Or(ye.StreamerAutoJoinInterval, "Streamer Auto Join Interval (ms)", "Delay between retries when waiting for an available streamer.", 500, 9e5, n && n.hasOwnProperty(ye.StreamerAutoJoinInterval) ? n[ye.StreamerAutoJoinInterval] : 3e3, r));
|
|
14815
14889
|
}
|
|
14816
14890
|
_addOnNumericSettingChangedListener(r, n) {
|
|
14817
14891
|
this.numericParameters.has(r) && this.numericParameters.get(r).addOnChangedListener(n);
|
|
@@ -14862,7 +14936,7 @@ class aw {
|
|
|
14862
14936
|
this.flags.has(r) ? this.flags.get(r).label = n : T.Warning(T.GetStackTrace(), `Cannot set label for flag called ${r} - it does not exist in the Config.flags map.`);
|
|
14863
14937
|
}
|
|
14864
14938
|
setSettings(r) {
|
|
14865
|
-
for (const n of Object.keys(r))
|
|
14939
|
+
for (const n of Object.keys(r)) nw(n) ? this.setFlagEnabled(n, r[n]) : sw(n) ? this.setNumericSetting(n, r[n]) : iw(n) ? this.setTextSetting(n, r[n]) : aw(n) && this.setOptionSettingValue(n, r[n]);
|
|
14866
14940
|
}
|
|
14867
14941
|
getSettings() {
|
|
14868
14942
|
const r = {};
|
|
@@ -14979,13 +15053,13 @@ class Eo {
|
|
|
14979
15053
|
}
|
|
14980
15054
|
class um {
|
|
14981
15055
|
}
|
|
14982
|
-
class ow {
|
|
14983
|
-
}
|
|
14984
15056
|
class lw {
|
|
14985
15057
|
}
|
|
15058
|
+
class uw {
|
|
15059
|
+
}
|
|
14986
15060
|
class dm {
|
|
14987
15061
|
constructor() {
|
|
14988
|
-
this.inboundVideoStats = new om(), this.inboundAudioStats = new am(), this.DataChannelStats = new lm(), this.outBoundVideoStats = new um(), this.sessionStats = new
|
|
15062
|
+
this.inboundVideoStats = new om(), this.inboundAudioStats = new am(), this.DataChannelStats = new lm(), this.outBoundVideoStats = new um(), this.sessionStats = new lw(), this.streamStats = new uw(), this.codecs = /* @__PURE__ */ new Map();
|
|
14989
15063
|
}
|
|
14990
15064
|
processStats(r) {
|
|
14991
15065
|
this.localCandidates = new Array(), this.remoteCandidates = new Array(), this.candidatePairs = new Array(), r.forEach(((n) => {
|
|
@@ -15134,7 +15208,7 @@ var is, Se, fo = function(c, r, n, a) {
|
|
|
15134
15208
|
_((a = a.apply(c, [])).next());
|
|
15135
15209
|
}));
|
|
15136
15210
|
};
|
|
15137
|
-
class
|
|
15211
|
+
class dw {
|
|
15138
15212
|
constructor(r, n, a) {
|
|
15139
15213
|
this.config = n, this.createPeerConnection(r, a);
|
|
15140
15214
|
}
|
|
@@ -15298,13 +15372,13 @@ class uw {
|
|
|
15298
15372
|
}
|
|
15299
15373
|
class hm {
|
|
15300
15374
|
constructor() {
|
|
15301
|
-
this.PixelStreamingSettings = new
|
|
15375
|
+
this.PixelStreamingSettings = new cw(), this.EncoderSettings = new pm(), this.WebRTCSettings = new fm();
|
|
15302
15376
|
}
|
|
15303
15377
|
ueCompatible() {
|
|
15304
15378
|
this.WebRTCSettings.MaxFPS != null && (this.WebRTCSettings.FPS = this.WebRTCSettings.MaxFPS);
|
|
15305
15379
|
}
|
|
15306
15380
|
}
|
|
15307
|
-
class
|
|
15381
|
+
class cw {
|
|
15308
15382
|
}
|
|
15309
15383
|
class pm {
|
|
15310
15384
|
}
|
|
@@ -15349,7 +15423,7 @@ class mo {
|
|
|
15349
15423
|
} else n.data.length > n.chunks && (n.receiving = !1, T.Error(T.GetStackTrace(), `Received bigger file than advertised: ${n.data.length}/${n.chunks}`));
|
|
15350
15424
|
}
|
|
15351
15425
|
}
|
|
15352
|
-
class
|
|
15426
|
+
class hw {
|
|
15353
15427
|
constructor() {
|
|
15354
15428
|
this.mimetype = "", this.extension = "", this.receiving = !1, this.chunks = 0, this.data = [], this.valid = !1;
|
|
15355
15429
|
}
|
|
@@ -15357,9 +15431,9 @@ class cw {
|
|
|
15357
15431
|
class Wt {
|
|
15358
15432
|
}
|
|
15359
15433
|
Wt.mainButton = 0, Wt.auxiliaryButton = 1, Wt.secondaryButton = 2, Wt.fourthButton = 3, Wt.fifthButton = 4;
|
|
15360
|
-
class
|
|
15434
|
+
class Qt {
|
|
15361
15435
|
}
|
|
15362
|
-
|
|
15436
|
+
Qt.primaryButton = 1, Qt.secondaryButton = 2, Qt.auxiliaryButton = 4, Qt.fourthButton = 8, Qt.fifthButton = 16;
|
|
15363
15437
|
class os {
|
|
15364
15438
|
constructor() {
|
|
15365
15439
|
this.unregisterCallbacks = [];
|
|
@@ -15372,7 +15446,7 @@ class os {
|
|
|
15372
15446
|
this.unregisterCallbacks = [];
|
|
15373
15447
|
}
|
|
15374
15448
|
}
|
|
15375
|
-
class
|
|
15449
|
+
class pw {
|
|
15376
15450
|
constructor(r, n, a) {
|
|
15377
15451
|
this.touchEventListenerTracker = new os(), this.toStreamerMessagesProvider = r, this.videoElementProvider = n, this.coordinateConverter = a;
|
|
15378
15452
|
const f = (R) => this.onTouchStart(R), v = (R) => this.onTouchEnd(R), C = (R) => this.onTouchMove(R);
|
|
@@ -15388,7 +15462,7 @@ class hw {
|
|
|
15388
15462
|
if (this.videoElementProvider.isVideoReady() && r.target === this.videoElementProvider.getVideoElement()) {
|
|
15389
15463
|
if (this.fakeTouchFinger == null) {
|
|
15390
15464
|
const n = r.changedTouches[0];
|
|
15391
|
-
this.fakeTouchFinger = new
|
|
15465
|
+
this.fakeTouchFinger = new fw(n.identifier, n.clientX - this.videoElementParentClientRect.left, n.clientY - this.videoElementParentClientRect.top);
|
|
15392
15466
|
const a = this.videoElementProvider.getVideoParentElement(), f = new MouseEvent("mouseenter", n);
|
|
15393
15467
|
a.dispatchEvent(f);
|
|
15394
15468
|
const v = this.coordinateConverter.normalizeAndQuantizeUnsigned(this.fakeTouchFinger.x, this.fakeTouchFinger.y);
|
|
@@ -15426,15 +15500,15 @@ class hw {
|
|
|
15426
15500
|
r.preventDefault();
|
|
15427
15501
|
}
|
|
15428
15502
|
}
|
|
15429
|
-
class
|
|
15503
|
+
class fw {
|
|
15430
15504
|
constructor(r, n, a) {
|
|
15431
15505
|
this.id = r, this.x = n, this.y = a;
|
|
15432
15506
|
}
|
|
15433
15507
|
}
|
|
15434
|
-
class
|
|
15508
|
+
class Xt {
|
|
15435
15509
|
}
|
|
15436
|
-
|
|
15437
|
-
class
|
|
15510
|
+
Xt.backSpace = 8, Xt.shift = 16, Xt.control = 17, Xt.alt = 18, Xt.rightShift = 253, Xt.rightControl = 254, Xt.rightAlt = 255;
|
|
15511
|
+
class mw {
|
|
15438
15512
|
constructor(r, n, a) {
|
|
15439
15513
|
this.keyboardEventListenerTracker = new os(), this.CodeToKeyCode = { Escape: 27, Digit0: 48, Digit1: 49, Digit2: 50, Digit3: 51, Digit4: 52, Digit5: 53, Digit6: 54, Digit7: 55, Digit8: 56, Digit9: 57, Minus: 173, Equal: 187, Backspace: 8, Tab: 9, KeyQ: 81, KeyW: 87, KeyE: 69, KeyR: 82, KeyT: 84, KeyY: 89, KeyU: 85, KeyI: 73, KeyO: 79, KeyP: 80, BracketLeft: 219, BracketRight: 221, Enter: 13, ControlLeft: 17, KeyA: 65, KeyS: 83, KeyD: 68, KeyF: 70, KeyG: 71, KeyH: 72, KeyJ: 74, KeyK: 75, KeyL: 76, Semicolon: 186, Quote: 222, Backquote: 192, ShiftLeft: 16, Backslash: 220, KeyZ: 90, KeyX: 88, KeyC: 67, KeyV: 86, KeyB: 66, KeyN: 78, KeyM: 77, Comma: 188, Period: 190, Slash: 191, ShiftRight: 253, AltLeft: 18, Space: 32, CapsLock: 20, F1: 112, F2: 113, F3: 114, F4: 115, F5: 116, F6: 117, F7: 118, F8: 119, F9: 120, F10: 121, F11: 122, F12: 123, Pause: 19, ScrollLock: 145, NumpadDivide: 111, NumpadMultiply: 106, NumpadSubtract: 109, NumpadAdd: 107, NumpadDecimal: 110, Numpad9: 105, Numpad8: 104, Numpad7: 103, Numpad6: 102, Numpad5: 101, Numpad4: 100, Numpad3: 99, Numpad2: 98, Numpad1: 97, Numpad0: 96, NumLock: 144, ControlRight: 254, AltRight: 255, Home: 36, End: 35, ArrowUp: 38, ArrowLeft: 37, ArrowRight: 39, ArrowDown: 40, PageUp: 33, PageDown: 34, Insert: 45, Delete: 46, ContextMenu: 93 }, this.toStreamerMessagesProvider = r, this.config = n, this.activeKeysProvider = a;
|
|
15440
15514
|
}
|
|
@@ -15447,7 +15521,7 @@ class fw {
|
|
|
15447
15521
|
}
|
|
15448
15522
|
handleOnKeyDown(r) {
|
|
15449
15523
|
const n = this.getKeycode(r);
|
|
15450
|
-
n && n !== 229 && (T.Log(T.GetStackTrace(), `key down ${n}, repeat = ${r.repeat}`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyDown")([this.getKeycode(r), r.repeat ? 1 : 0]), this.activeKeysProvider.getActiveKeys().push(n), n ===
|
|
15524
|
+
n && n !== 229 && (T.Log(T.GetStackTrace(), `key down ${n}, repeat = ${r.repeat}`, 6), this.toStreamerMessagesProvider.toStreamerHandlers.get("KeyDown")([this.getKeycode(r), r.repeat ? 1 : 0]), this.activeKeysProvider.getActiveKeys().push(n), n === Xt.backSpace && document.dispatchEvent(new KeyboardEvent("keypress", { charCode: Xt.backSpace })), this.config.isFlagEnabled(K.SuppressBrowserKeys) && this.isKeyCodeBrowserKey(n) && r.preventDefault());
|
|
15451
15525
|
}
|
|
15452
15526
|
handleOnKeyUp(r) {
|
|
15453
15527
|
const n = this.getKeycode(r);
|
|
@@ -15468,13 +15542,13 @@ class fw {
|
|
|
15468
15542
|
const n = r;
|
|
15469
15543
|
return n.code in this.CodeToKeyCode ? this.CodeToKeyCode[n.code] : (T.Warning(T.GetStackTrace(), `Keyboard code of ${n.code} is not supported in our mapping, ignoring this key.`), null);
|
|
15470
15544
|
}
|
|
15471
|
-
return r.keyCode ===
|
|
15545
|
+
return r.keyCode === Xt.shift && r.code === "ShiftRight" ? Xt.rightShift : r.keyCode === Xt.control && r.code === "ControlRight" ? Xt.rightControl : r.keyCode === Xt.alt && r.code === "AltRight" ? Xt.rightAlt : r.keyCode;
|
|
15472
15546
|
}
|
|
15473
15547
|
isKeyCodeBrowserKey(r) {
|
|
15474
15548
|
return r >= 112 && r <= 123 || r === 9;
|
|
15475
15549
|
}
|
|
15476
15550
|
}
|
|
15477
|
-
class
|
|
15551
|
+
class gw {
|
|
15478
15552
|
constructor(r, n, a) {
|
|
15479
15553
|
this.x = 0, this.y = 0, this.updateMouseMovePositionEvent = (v) => {
|
|
15480
15554
|
this.updateMouseMovePosition(v);
|
|
@@ -15524,7 +15598,7 @@ class mw {
|
|
|
15524
15598
|
this.videoElementProvider.isVideoReady() && this.mouseController.releaseMouseButtons(r.buttons, this.x, this.y);
|
|
15525
15599
|
}
|
|
15526
15600
|
}
|
|
15527
|
-
class
|
|
15601
|
+
class yw {
|
|
15528
15602
|
constructor(r) {
|
|
15529
15603
|
this.mouseController = r;
|
|
15530
15604
|
}
|
|
@@ -15568,7 +15642,7 @@ class gw {
|
|
|
15568
15642
|
this.mouseController.videoElementProvider.isVideoReady() && (T.Log(T.GetStackTrace(), "onMouse release", 6), this.mouseController.releaseMouseButtons(r.buttons, r.offsetX, r.offsetY));
|
|
15569
15643
|
}
|
|
15570
15644
|
}
|
|
15571
|
-
class
|
|
15645
|
+
class ww {
|
|
15572
15646
|
constructor(r, n, a, f) {
|
|
15573
15647
|
this.mouseEventListenerTracker = new os(), this.toStreamerMessagesProvider = r, this.coordinateConverter = a, this.videoElementProvider = n, this.activeKeysProvider = f, this.registerMouseEnterAndLeaveEvents();
|
|
15574
15648
|
}
|
|
@@ -15576,7 +15650,7 @@ class yw {
|
|
|
15576
15650
|
this.mouseEventListenerTracker.unregisterAll();
|
|
15577
15651
|
}
|
|
15578
15652
|
registerLockedMouseEvents(r) {
|
|
15579
|
-
const n = this.videoElementProvider.getVideoParentElement(), a = new
|
|
15653
|
+
const n = this.videoElementProvider.getVideoParentElement(), a = new gw(this.videoElementProvider, r, this.activeKeysProvider);
|
|
15580
15654
|
if (n.requestPointerLock = n.requestPointerLock || n.mozRequestPointerLock, document.exitPointerLock = document.exitPointerLock || document.mozExitPointerLock, n.requestPointerLock) {
|
|
15581
15655
|
const U = () => {
|
|
15582
15656
|
n.requestPointerLock();
|
|
@@ -15591,7 +15665,7 @@ class yw {
|
|
|
15591
15665
|
}));
|
|
15592
15666
|
}
|
|
15593
15667
|
registerHoveringMouseEvents(r) {
|
|
15594
|
-
const n = this.videoElementProvider.getVideoParentElement(), a = new
|
|
15668
|
+
const n = this.videoElementProvider.getVideoParentElement(), a = new yw(r), f = (B) => a.updateMouseMovePosition(B), v = (B) => a.handleMouseDown(B), C = (B) => a.handleMouseUp(B), R = (B) => a.handleContextMenu(B), _ = (B) => a.handleMouseWheel(B), U = (B) => a.handleMouseDouble(B);
|
|
15595
15669
|
n.addEventListener("mousemove", f), n.addEventListener("mousedown", v), n.addEventListener("mouseup", C), n.addEventListener("contextmenu", R), n.addEventListener("wheel", _), n.addEventListener("dblclick", U), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("mousemove", f))), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("mousedown", v))), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("mouseup", C))), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("contextmenu", R))), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("wheel", _))), this.mouseEventListenerTracker.addUnregisterCallback((() => n.removeEventListener("dblclick", U))), this.mouseEventListenerTracker.addUnregisterCallback((() => a.unregisterMouseEvents()));
|
|
15596
15670
|
}
|
|
15597
15671
|
registerMouseEnterAndLeaveEvents() {
|
|
@@ -15604,12 +15678,12 @@ class yw {
|
|
|
15604
15678
|
}
|
|
15605
15679
|
releaseMouseButtons(r, n, a) {
|
|
15606
15680
|
const f = this.coordinateConverter.normalizeAndQuantizeUnsigned(n, a);
|
|
15607
|
-
r &
|
|
15681
|
+
r & Qt.primaryButton && this.sendMouseUp(Wt.mainButton, f.x, f.y), r & Qt.secondaryButton && this.sendMouseUp(Wt.secondaryButton, f.x, f.y), r & Qt.auxiliaryButton && this.sendMouseUp(Wt.auxiliaryButton, f.x, f.y), r & Qt.fourthButton && this.sendMouseUp(Wt.fourthButton, f.x, f.y), r & Qt.fifthButton && this.sendMouseUp(Wt.fifthButton, f.x, f.y);
|
|
15608
15682
|
}
|
|
15609
15683
|
pressMouseButtons(r, n, a) {
|
|
15610
15684
|
if (!this.videoElementProvider.isVideoReady()) return;
|
|
15611
15685
|
const f = this.coordinateConverter.normalizeAndQuantizeUnsigned(n, a);
|
|
15612
|
-
r &
|
|
15686
|
+
r & Qt.primaryButton && this.sendMouseDown(Wt.mainButton, f.x, f.y), r & Qt.secondaryButton && this.sendMouseDown(Wt.secondaryButton, f.x, f.y), r & Qt.auxiliaryButton && this.sendMouseDown(Wt.auxiliaryButton, f.x, f.y), r & Qt.fourthButton && this.sendMouseDown(Wt.fourthButton, f.x, f.y), r & Qt.fifthButton && this.sendMouseDown(Wt.fifthButton, f.x, f.y);
|
|
15613
15687
|
}
|
|
15614
15688
|
sendMouseEnter() {
|
|
15615
15689
|
this.videoElementProvider.isVideoReady() && this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseEnter")();
|
|
@@ -15627,7 +15701,7 @@ class yw {
|
|
|
15627
15701
|
this.toStreamerMessagesProvider.toStreamerHandlers.get("MouseUp")([r, f.x, f.y]);
|
|
15628
15702
|
}
|
|
15629
15703
|
}
|
|
15630
|
-
class
|
|
15704
|
+
class vw {
|
|
15631
15705
|
constructor(r, n, a) {
|
|
15632
15706
|
this.fingers = [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], this.fingerIds = /* @__PURE__ */ new Map(), this.maxByteValue = 255, this.touchEventListenerTracker = new os(), this.toStreamerMessagesProvider = r, this.videoElementProvider = n, this.coordinateConverter = a, this.videoElementParent = n.getVideoElement();
|
|
15633
15707
|
const f = (_) => this.onTouchStart(_), v = (_) => this.onTouchEnd(_), C = (_) => this.onTouchMove(_);
|
|
@@ -15685,7 +15759,7 @@ class ww {
|
|
|
15685
15759
|
}
|
|
15686
15760
|
}
|
|
15687
15761
|
}
|
|
15688
|
-
class
|
|
15762
|
+
class _w {
|
|
15689
15763
|
constructor(r) {
|
|
15690
15764
|
this.gamePadEventListenerTracker = new os(), this.toStreamerMessagesProvider = r, this.requestAnimationFrame = (window.mozRequestAnimationFrame || window.webkitRequestAnimationFrame || window.requestAnimationFrame).bind(window);
|
|
15691
15765
|
const n = window;
|
|
@@ -15753,18 +15827,18 @@ class vw {
|
|
|
15753
15827
|
(function(c) {
|
|
15754
15828
|
c[c.RightClusterBottomButton = 0] = "RightClusterBottomButton", c[c.RightClusterRightButton = 1] = "RightClusterRightButton", c[c.RightClusterLeftButton = 2] = "RightClusterLeftButton", c[c.RightClusterTopButton = 3] = "RightClusterTopButton", c[c.LeftShoulder = 4] = "LeftShoulder", c[c.RightShoulder = 5] = "RightShoulder", c[c.LeftTrigger = 6] = "LeftTrigger", c[c.RightTrigger = 7] = "RightTrigger", c[c.SelectOrBack = 8] = "SelectOrBack", c[c.StartOrForward = 9] = "StartOrForward", c[c.LeftAnalogPress = 10] = "LeftAnalogPress", c[c.RightAnalogPress = 11] = "RightAnalogPress", c[c.LeftClusterTopButton = 12] = "LeftClusterTopButton", c[c.LeftClusterBottomButton = 13] = "LeftClusterBottomButton", c[c.LeftClusterLeftButton = 14] = "LeftClusterLeftButton", c[c.LeftClusterRightButton = 15] = "LeftClusterRightButton", c[c.CentreButton = 16] = "CentreButton", c[c.LeftStickHorizontal = 0] = "LeftStickHorizontal", c[c.LeftStickVertical = 1] = "LeftStickVertical", c[c.RightStickHorizontal = 2] = "RightStickHorizontal", c[c.RightStickVertical = 3] = "RightStickVertical";
|
|
15755
15829
|
})(is || (is = {}));
|
|
15756
|
-
class
|
|
15830
|
+
class bw {
|
|
15757
15831
|
constructor(r, n, a) {
|
|
15758
|
-
this.activeKeys = new
|
|
15832
|
+
this.activeKeys = new Sw(), this.toStreamerMessagesProvider = r, this.videoElementProvider = n, this.coordinateConverter = a;
|
|
15759
15833
|
}
|
|
15760
15834
|
registerKeyBoard(r) {
|
|
15761
15835
|
T.Log(T.GetStackTrace(), "Register Keyboard Events", 7);
|
|
15762
|
-
const n = new
|
|
15836
|
+
const n = new mw(this.toStreamerMessagesProvider, r, this.activeKeys);
|
|
15763
15837
|
return n.registerKeyBoardEvents(), n;
|
|
15764
15838
|
}
|
|
15765
15839
|
registerMouse(r) {
|
|
15766
15840
|
T.Log(T.GetStackTrace(), "Register Mouse Events", 7);
|
|
15767
|
-
const n = new
|
|
15841
|
+
const n = new ww(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter, this.activeKeys);
|
|
15768
15842
|
switch (r) {
|
|
15769
15843
|
case Nn.LockedMouse:
|
|
15770
15844
|
n.registerLockedMouseEvents(n);
|
|
@@ -15779,16 +15853,16 @@ class _w {
|
|
|
15779
15853
|
}
|
|
15780
15854
|
registerTouch(r, n) {
|
|
15781
15855
|
if (T.Log(T.GetStackTrace(), "Registering Touch", 6), r) {
|
|
15782
|
-
const a = new
|
|
15856
|
+
const a = new pw(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter);
|
|
15783
15857
|
return a.setVideoElementParentClientRect(n), a;
|
|
15784
15858
|
}
|
|
15785
|
-
return new
|
|
15859
|
+
return new vw(this.toStreamerMessagesProvider, this.videoElementProvider, this.coordinateConverter);
|
|
15786
15860
|
}
|
|
15787
15861
|
registerGamePad() {
|
|
15788
|
-
return T.Log(T.GetStackTrace(), "Register Game Pad", 7), new
|
|
15862
|
+
return T.Log(T.GetStackTrace(), "Register Game Pad", 7), new _w(this.toStreamerMessagesProvider);
|
|
15789
15863
|
}
|
|
15790
15864
|
}
|
|
15791
|
-
class
|
|
15865
|
+
class Sw {
|
|
15792
15866
|
constructor() {
|
|
15793
15867
|
this.activeKeys = [], this.activeKeys = [];
|
|
15794
15868
|
}
|
|
@@ -15796,7 +15870,7 @@ class bw {
|
|
|
15796
15870
|
return this.activeKeys;
|
|
15797
15871
|
}
|
|
15798
15872
|
}
|
|
15799
|
-
class
|
|
15873
|
+
class Tw {
|
|
15800
15874
|
constructor(r, n) {
|
|
15801
15875
|
this.lastTimeResized = (/* @__PURE__ */ new Date()).getTime(), this.videoElement = document.createElement("video"), this.config = n, this.videoElement.id = "streamingVideo", this.videoElement.disablePictureInPicture = !0, this.videoElement.playsInline = !0, this.videoElement.style.width = "100%", this.videoElement.style.height = "100%", this.videoElement.style.position = "absolute", this.videoElement.style.pointerEvents = "all", r.appendChild(this.videoElement), this.onResizePlayerCallback = () => {
|
|
15802
15876
|
console.log("Resolution changed, restyling player, did you forget to override this function?");
|
|
@@ -15854,7 +15928,7 @@ class Sw {
|
|
|
15854
15928
|
} else T.Log(T.GetStackTrace(), "Resizing too often - skipping", 6), clearTimeout(this.resizeTimeoutHandle), this.resizeTimeoutHandle = window.setTimeout((() => this.updateVideoStreamSize()), 100);
|
|
15855
15929
|
}
|
|
15856
15930
|
}
|
|
15857
|
-
class
|
|
15931
|
+
class $w {
|
|
15858
15932
|
constructor() {
|
|
15859
15933
|
this.toStreamerHandlers = /* @__PURE__ */ new Map(), this.fromStreamerHandlers = /* @__PURE__ */ new Map(), this.toStreamerMessages = /* @__PURE__ */ new Map(), this.fromStreamerMessages = /* @__PURE__ */ new Map();
|
|
15860
15934
|
}
|
|
@@ -15877,7 +15951,7 @@ class Tw {
|
|
|
15877
15951
|
(function(c) {
|
|
15878
15952
|
c[c.ToStreamer = 0] = "ToStreamer", c[c.FromStreamer = 1] = "FromStreamer";
|
|
15879
15953
|
})(Se || (Se = {}));
|
|
15880
|
-
class
|
|
15954
|
+
class xw {
|
|
15881
15955
|
constructor() {
|
|
15882
15956
|
this.responseEventListeners = /* @__PURE__ */ new Map();
|
|
15883
15957
|
}
|
|
@@ -15895,7 +15969,7 @@ class $w {
|
|
|
15895
15969
|
}));
|
|
15896
15970
|
}
|
|
15897
15971
|
}
|
|
15898
|
-
class
|
|
15972
|
+
class Ew {
|
|
15899
15973
|
constructor(r, n) {
|
|
15900
15974
|
this.dataChannelSender = r, this.toStreamerMessagesMapProvider = n;
|
|
15901
15975
|
}
|
|
@@ -15963,7 +16037,7 @@ class xw {
|
|
|
15963
16037
|
})), this.dataChannelSender.canSend() ? this.dataChannelSender.sendData(C.buffer) : T.Info(T.GetStackTrace(), `Data channel cannot send yet, skipping sending message: ${r} - ${new Uint8Array(C.buffer)}`);
|
|
15964
16038
|
}
|
|
15965
16039
|
}
|
|
15966
|
-
class
|
|
16040
|
+
class Cw {
|
|
15967
16041
|
constructor(r) {
|
|
15968
16042
|
this.sendMessageController = r;
|
|
15969
16043
|
}
|
|
@@ -15986,7 +16060,7 @@ class Ew {
|
|
|
15986
16060
|
this.sendMessageController.sendMessageToStreamer("RequestInitialSettings");
|
|
15987
16061
|
}
|
|
15988
16062
|
}
|
|
15989
|
-
class
|
|
16063
|
+
class kw {
|
|
15990
16064
|
constructor(r) {
|
|
15991
16065
|
this.dataChannelProvider = r;
|
|
15992
16066
|
}
|
|
@@ -16000,7 +16074,7 @@ class Cw {
|
|
|
16000
16074
|
resetAfkWarningTimerOnDataSend() {
|
|
16001
16075
|
}
|
|
16002
16076
|
}
|
|
16003
|
-
class
|
|
16077
|
+
class Rw {
|
|
16004
16078
|
constructor(r) {
|
|
16005
16079
|
this.videoElementProvider = r, this.normalizeAndQuantizeUnsignedFunc = () => {
|
|
16006
16080
|
throw new Error("Normalize and quantize unsigned, method not implemented.");
|
|
@@ -16067,14 +16141,14 @@ class Xp {
|
|
|
16067
16141
|
}
|
|
16068
16142
|
class gm {
|
|
16069
16143
|
constructor(r, n) {
|
|
16070
|
-
this.shouldShowPlayOverlay = !0, this.autoJoinTimer = void 0, this.config = r, this.pixelStreaming = n, this.responseController = new
|
|
16144
|
+
this.shouldShowPlayOverlay = !0, this.autoJoinTimer = void 0, this.config = r, this.pixelStreaming = n, this.responseController = new xw(), this.file = new hw(), this.sdpConstraints = { offerToReceiveAudio: !0, offerToReceiveVideo: !0 }, this.afkController = new im(this.config, this.pixelStreaming, this.onAfkTriggered.bind(this)), this.afkController.onAFKTimedOutCallback = () => {
|
|
16071
16145
|
this.closeSignalingServer("You have been disconnected due to inactivity");
|
|
16072
|
-
}, this.freezeFrameController = new
|
|
16146
|
+
}, this.freezeFrameController = new ew(this.pixelStreaming.videoElementParent), this.videoPlayer = new Tw(this.pixelStreaming.videoElementParent, this.config), this.videoPlayer.onVideoInitialized = () => this.handleVideoInitialized(), this.videoPlayer.onMatchViewportResolutionCallback = (a, f) => {
|
|
16073
16147
|
const v = { "Resolution.Width": a, "Resolution.Height": f };
|
|
16074
16148
|
this.streamMessageController.toStreamerHandlers.get("Command")([JSON.stringify(v)]);
|
|
16075
16149
|
}, this.videoPlayer.onResizePlayerCallback = () => {
|
|
16076
16150
|
this.setUpMouseAndFreezeFrame();
|
|
16077
|
-
}, this.streamController = new
|
|
16151
|
+
}, this.streamController = new Jy(this.videoPlayer), this.coordinateConverter = new Rw(this.videoPlayer), this.sendrecvDataChannelController = new jp(), this.recvDataChannelController = new jp(), this.registerDataChannelEventEmitters(this.sendrecvDataChannelController), this.registerDataChannelEventEmitters(this.recvDataChannelController), this.dataChannelSender = new kw(this.sendrecvDataChannelController), this.dataChannelSender.resetAfkWarningTimerOnDataSend = () => this.afkController.resetAfkWarningTimer(), this.streamMessageController = new $w(), this.webSocketController = new $f(), this.webSocketController.onConfig = (a) => this.handleOnConfigMessage(a), this.webSocketController.onStreamerList = (a) => this.handleStreamerListMessage(a), this.webSocketController.onStreamerIDChanged = (a) => this.handleStreamerIDChangedMessage(a), this.webSocketController.onPlayerCount = (a) => {
|
|
16078
16152
|
this.pixelStreaming._onPlayerCount(a.count);
|
|
16079
16153
|
}, this.webSocketController.onOpen.addEventListener("open", (() => {
|
|
16080
16154
|
this.config.isFlagEnabled(K.BrowserSendOffer) || this.webSocketController.requestStreamerList();
|
|
@@ -16083,7 +16157,7 @@ class gm {
|
|
|
16083
16157
|
this.pixelStreaming._onDisconnect(v, !f && !this.isReconnecting), this.afkController.stopAfkWarningTimer(), this.statsTimerHandle && this.statsTimerHandle !== void 0 && window.clearInterval(this.statsTimerHandle), this.setVideoEncoderAvgQP(0), this.setTouchInputEnabled(!1), this.setMouseInputEnabled(!1), this.setKeyboardInputEnabled(!1), this.setGamePadInputEnabled(!1), f && setTimeout((() => {
|
|
16084
16158
|
this.isReconnecting = !0, this.reconnectAttempt++, this.tryReconnect(a.detail.reason);
|
|
16085
16159
|
}), 2e3);
|
|
16086
|
-
})), this.sendMessageController = new
|
|
16160
|
+
})), this.sendMessageController = new Ew(this.dataChannelSender, this.streamMessageController), this.toStreamerMessagesController = new Cw(this.sendMessageController), this.registerMessageHandlers(), this.streamMessageController.populateDefaultProtocol(), this.inputClassesFactory = new bw(this.streamMessageController, this.videoPlayer, this.coordinateConverter), this.isUsingSFU = !1, this.isQualityController = !1, this.preferredCodec = "", this.shouldReconnect = !0, this.isReconnecting = !1, this.reconnectAttempt = 0, this.config._addOnOptionSettingChangedListener(St.StreamerId, ((a) => {
|
|
16087
16161
|
a !== "" && (this.peerConnectionController.peerConnection.close(), this.peerConnectionController.createPeerConnection(this.peerConfig, this.preferredCodec), this.subscribedStream = a, this.webSocketController.sendSubscribe(a));
|
|
16088
16162
|
})), this.setVideoEncoderAvgQP(-1), this.signallingUrlBuilder = () => {
|
|
16089
16163
|
let a = this.config.getTextSettingValue(Hr.SignallingServerUrl);
|
|
@@ -16222,7 +16296,7 @@ class gm {
|
|
|
16222
16296
|
}
|
|
16223
16297
|
startSession(r) {
|
|
16224
16298
|
if (this.peerConfig = r, this.config.isFlagEnabled(K.ForceTURN) && !this.checkTurnServerAvailability(r)) return T.Info(T.GetStackTrace(), "No turn server was found in the Peer Connection Options. TURN cannot be forced, closing connection. Please use STUN instead"), void this.closeSignalingServer("TURN cannot be forced, closing connection. Please use STUN instead.");
|
|
16225
|
-
this.peerConnectionController = new
|
|
16299
|
+
this.peerConnectionController = new dw(this.peerConfig, this.config, this.preferredCodec), this.peerConnectionController.onVideoStats = (a) => this.handleVideoStats(a), this.peerConnectionController.onSendWebRTCOffer = (a) => this.handleSendWebRTCOffer(a), this.peerConnectionController.onSendWebRTCAnswer = (a) => this.handleSendWebRTCAnswer(a), this.peerConnectionController.onPeerIceCandidate = (a) => this.handleSendIceCandidate(a), this.peerConnectionController.onDataChannel = (a) => this.handleDataChannel(a), this.peerConnectionController.showTextOverlayConnecting = () => this.pixelStreaming._onWebRtcConnecting(), this.peerConnectionController.showTextOverlaySetupFailure = () => this.pixelStreaming._onWebRtcFailed();
|
|
16226
16300
|
let n = !1;
|
|
16227
16301
|
this.peerConnectionController.onIceConnectionStateChange = () => {
|
|
16228
16302
|
!n && ["connected", "completed"].includes(this.peerConnectionController.peerConnection.iceConnectionState) && (this.pixelStreaming._onWebRtcConnected(), n = !0);
|
|
@@ -16568,7 +16642,7 @@ class ym {
|
|
|
16568
16642
|
return location.protocol !== "https:" && T.Info(null, "WebXR requires https, if you want WebXR use https."), navigator.xr ? navigator.xr.isSessionSupported(r) : new Promise((() => !1));
|
|
16569
16643
|
}
|
|
16570
16644
|
}
|
|
16571
|
-
class
|
|
16645
|
+
class Aw {
|
|
16572
16646
|
constructor(r) {
|
|
16573
16647
|
this.editTextButton = null, this.hiddenInput = null, "ontouchstart" in document.documentElement && this.createOnScreenKeyboardHelpers(r);
|
|
16574
16648
|
}
|
|
@@ -16588,7 +16662,7 @@ class Rw {
|
|
|
16588
16662
|
} else this.editTextButton.style.display = "none", this.hiddenInput.blur();
|
|
16589
16663
|
}
|
|
16590
16664
|
}
|
|
16591
|
-
class
|
|
16665
|
+
class Mw {
|
|
16592
16666
|
constructor(r) {
|
|
16593
16667
|
this.seq = r.Seq, this.playerSentTimestamp = Date.now(), this.requestFillerSize = r.Filler ? r.Filler.length : 0;
|
|
16594
16668
|
}
|
|
@@ -16596,7 +16670,7 @@ class Aw {
|
|
|
16596
16670
|
this.playerReceivedTimestamp = Date.now(), this.streamerReceivedTimestamp = r.ReceivedTimestamp, this.streamerSentTimestamp = r.SentTimestamp, this.responseFillerSize = r.Filler ? r.Filler.length : 0;
|
|
16597
16671
|
}
|
|
16598
16672
|
}
|
|
16599
|
-
class
|
|
16673
|
+
class Iw {
|
|
16600
16674
|
constructor(r, n) {
|
|
16601
16675
|
this.sink = r, this.callback = n, this.records = /* @__PURE__ */ new Map(), this.seq = 0;
|
|
16602
16676
|
}
|
|
@@ -16629,16 +16703,16 @@ class Mw {
|
|
|
16629
16703
|
n && n.update(r);
|
|
16630
16704
|
}
|
|
16631
16705
|
sendRequest(r, n) {
|
|
16632
|
-
let a = this.createRequest(r, n), f = new
|
|
16706
|
+
let a = this.createRequest(r, n), f = new Mw(a);
|
|
16633
16707
|
this.records.set(f.seq, f), this.sink(a);
|
|
16634
16708
|
}
|
|
16635
16709
|
createRequest(r, n) {
|
|
16636
16710
|
return { Seq: this.seq++, FillResponseSize: n, Filler: r ? "A".repeat(r) : "" };
|
|
16637
16711
|
}
|
|
16638
16712
|
}
|
|
16639
|
-
class
|
|
16713
|
+
class Pw {
|
|
16640
16714
|
constructor(r, n) {
|
|
16641
|
-
this.allowConsoleCommands = !1, this.config = r, n?.videoElementParent && (this._videoElementParent = n.videoElementParent), this._eventEmitter = new sm(), this.configureSettings(), this.setWebRtcPlayerController(new gm(this.config, this)), this.onScreenKeyboardHelper = new
|
|
16715
|
+
this.allowConsoleCommands = !1, this.config = r, n?.videoElementParent && (this._videoElementParent = n.videoElementParent), this._eventEmitter = new sm(), this.configureSettings(), this.setWebRtcPlayerController(new gm(this.config, this)), this.onScreenKeyboardHelper = new Aw(this.videoElementParent), this.onScreenKeyboardHelper.unquantizeAndDenormalizeUnsigned = (a, f) => this._webRtcController.requestUnquantizedAndDenormalizeUnsigned(a, f), this._activateOnScreenKeyboard = (a) => this.onScreenKeyboardHelper.showOnScreenKeyboard(a), this._webXrController = new ym(this._webRtcController), this._setupWebRtcTCPRelayDetection = this._setupWebRtcTCPRelayDetection.bind(this), this._eventEmitter.addEventListener("webRtcConnected", ((a) => {
|
|
16642
16716
|
this._eventEmitter.addEventListener("statsReceived", this._setupWebRtcTCPRelayDetection);
|
|
16643
16717
|
}));
|
|
16644
16718
|
}
|
|
@@ -16772,7 +16846,7 @@ class Iw {
|
|
|
16772
16846
|
return !!this._webRtcController.videoPlayer.isVideoReady() && (this._webRtcController.sendLatencyTest(), !0);
|
|
16773
16847
|
}
|
|
16774
16848
|
requestDataChannelLatencyTest(r) {
|
|
16775
|
-
return !!this._webRtcController.videoPlayer.isVideoReady() && (this._dataChannelLatencyTestController || (this._dataChannelLatencyTestController = new
|
|
16849
|
+
return !!this._webRtcController.videoPlayer.isVideoReady() && (this._dataChannelLatencyTestController || (this._dataChannelLatencyTestController = new Iw(this._webRtcController.sendDataChannelLatencyTest.bind(this._webRtcController), ((n) => {
|
|
16776
16850
|
this._eventEmitter.dispatchEvent(new Zf({ result: n }));
|
|
16777
16851
|
})), this.addEventListener("dataChannelLatencyTestResponse", (({ data: { response: n } }) => {
|
|
16778
16852
|
this._dataChannelLatencyTestController.receive(n);
|
|
@@ -16830,7 +16904,7 @@ class Iw {
|
|
|
16830
16904
|
return this._webRtcController.isReconnecting;
|
|
16831
16905
|
}
|
|
16832
16906
|
}
|
|
16833
|
-
class
|
|
16907
|
+
class Ow {
|
|
16834
16908
|
}
|
|
16835
16909
|
be.Dz;
|
|
16836
16910
|
be.g$;
|
|
@@ -16840,7 +16914,7 @@ be.qf;
|
|
|
16840
16914
|
be.hV;
|
|
16841
16915
|
be.z$;
|
|
16842
16916
|
be.J0;
|
|
16843
|
-
var
|
|
16917
|
+
var zw = be.De;
|
|
16844
16918
|
be.$C;
|
|
16845
16919
|
be.al;
|
|
16846
16920
|
be._W;
|
|
@@ -16867,7 +16941,7 @@ be.ce;
|
|
|
16867
16941
|
be.sK;
|
|
16868
16942
|
be.Ok;
|
|
16869
16943
|
be.q5;
|
|
16870
|
-
var
|
|
16944
|
+
var Dw = be.g;
|
|
16871
16945
|
be.xl;
|
|
16872
16946
|
be.I;
|
|
16873
16947
|
be.bx;
|
|
@@ -16904,7 +16978,7 @@ be.$f;
|
|
|
16904
16978
|
be.eu;
|
|
16905
16979
|
be.Ax;
|
|
16906
16980
|
be.Mc;
|
|
16907
|
-
const
|
|
16981
|
+
const Lw = ({
|
|
16908
16982
|
signallingUrl: c,
|
|
16909
16983
|
autoConnect: r = !0,
|
|
16910
16984
|
width: n,
|
|
@@ -16916,14 +16990,14 @@ const Dw = ({
|
|
|
16916
16990
|
onError: _,
|
|
16917
16991
|
muted: U = !1
|
|
16918
16992
|
}) => {
|
|
16919
|
-
const B =
|
|
16993
|
+
const B = Et(null), te = Et(null), X = Et(!1), [ee, ie] = jr(!1), [de, le] = jr(!1), [Le, Ce] = jr(null);
|
|
16920
16994
|
return xr(() => {
|
|
16921
16995
|
if (!(!B.current || !c)) {
|
|
16922
16996
|
f && f(), console.log("🎮 Initializing Epic Pixel Streaming with URL:", c), navigator.mediaDevices || (navigator.mediaDevices = {}), navigator.mediaDevices.getUserMedia || (navigator.mediaDevices.getUserMedia = function() {
|
|
16923
16997
|
return Promise.reject(new Error("getUserMedia is not supported"));
|
|
16924
16998
|
});
|
|
16925
16999
|
try {
|
|
16926
|
-
const ce = new
|
|
17000
|
+
const ce = new zw({
|
|
16927
17001
|
useUrlParams: !1,
|
|
16928
17002
|
initialSettings: {
|
|
16929
17003
|
ss: c,
|
|
@@ -16945,7 +17019,7 @@ const Dw = ({
|
|
|
16945
17019
|
WaitForStreamer: !0
|
|
16946
17020
|
// Wait and auto-subscribe when streamer becomes available
|
|
16947
17021
|
}
|
|
16948
|
-
}), re = new
|
|
17022
|
+
}), re = new Dw(ce, {
|
|
16949
17023
|
videoElementParent: B.current
|
|
16950
17024
|
});
|
|
16951
17025
|
re.addEventListener("webRtcConnected", () => {
|
|
@@ -17008,7 +17082,7 @@ const Dw = ({
|
|
|
17008
17082
|
} catch (ce) {
|
|
17009
17083
|
console.error("Error controlling audio:", ce);
|
|
17010
17084
|
}
|
|
17011
|
-
}, [U]), /* @__PURE__ */
|
|
17085
|
+
}, [U]), /* @__PURE__ */ lr.jsxs(
|
|
17012
17086
|
"div",
|
|
17013
17087
|
{
|
|
17014
17088
|
className: "pixel-streaming-container",
|
|
@@ -17027,7 +17101,7 @@ const Dw = ({
|
|
|
17027
17101
|
userSelect: "none"
|
|
17028
17102
|
},
|
|
17029
17103
|
children: [
|
|
17030
|
-
/* @__PURE__ */
|
|
17104
|
+
/* @__PURE__ */ lr.jsx(
|
|
17031
17105
|
"div",
|
|
17032
17106
|
{
|
|
17033
17107
|
ref: B,
|
|
@@ -17043,16 +17117,16 @@ const Dw = ({
|
|
|
17043
17117
|
}
|
|
17044
17118
|
}
|
|
17045
17119
|
),
|
|
17046
|
-
de && /* @__PURE__ */
|
|
17047
|
-
/* @__PURE__ */
|
|
17048
|
-
/* @__PURE__ */
|
|
17120
|
+
de && /* @__PURE__ */ lr.jsxs("div", { className: "loading-overlay", children: [
|
|
17121
|
+
/* @__PURE__ */ lr.jsx("div", { className: "loading-spinner" }),
|
|
17122
|
+
/* @__PURE__ */ lr.jsx("div", { className: "loading-text", children: "Connecting to stream..." })
|
|
17049
17123
|
] }),
|
|
17050
|
-
!ee && !de && Le && /* @__PURE__ */
|
|
17124
|
+
!ee && !de && Le && /* @__PURE__ */ lr.jsx("div", { className: "connection-overlay", children: /* @__PURE__ */ lr.jsx("div", { className: "error-message", children: Le }) })
|
|
17051
17125
|
]
|
|
17052
17126
|
}
|
|
17053
17127
|
);
|
|
17054
17128
|
};
|
|
17055
|
-
function
|
|
17129
|
+
function jw({
|
|
17056
17130
|
className: c,
|
|
17057
17131
|
style: r,
|
|
17058
17132
|
autoConnect: n = !0,
|
|
@@ -17061,22 +17135,22 @@ function Hw({
|
|
|
17061
17135
|
onDisconnected: v,
|
|
17062
17136
|
onError: C
|
|
17063
17137
|
}) {
|
|
17064
|
-
const { streamingUrl: R, setCloudStreamState: _ } =
|
|
17138
|
+
const { streamingUrl: R, setCloudStreamState: _ } = Ny();
|
|
17065
17139
|
if (!R)
|
|
17066
17140
|
return null;
|
|
17067
17141
|
const U = () => {
|
|
17068
|
-
_(
|
|
17142
|
+
_(rr.CONNECTING);
|
|
17069
17143
|
}, B = () => {
|
|
17070
|
-
_(
|
|
17144
|
+
_(rr.LOADING);
|
|
17071
17145
|
}, te = () => {
|
|
17072
|
-
_(
|
|
17146
|
+
_(rr.CONNECTED), f?.();
|
|
17073
17147
|
}, X = () => {
|
|
17074
|
-
_(
|
|
17148
|
+
_(rr.DISCONNECTED), v?.();
|
|
17075
17149
|
}, ee = (ie) => {
|
|
17076
|
-
_(
|
|
17150
|
+
_(rr.ERROR, ie), C?.(ie);
|
|
17077
17151
|
};
|
|
17078
|
-
return /* @__PURE__ */
|
|
17079
|
-
|
|
17152
|
+
return /* @__PURE__ */ lr.jsx("div", { className: c, style: r, children: /* @__PURE__ */ lr.jsx(
|
|
17153
|
+
Lw,
|
|
17080
17154
|
{
|
|
17081
17155
|
signallingUrl: R,
|
|
17082
17156
|
autoConnect: n,
|
|
@@ -17091,21 +17165,21 @@ function Hw({
|
|
|
17091
17165
|
}
|
|
17092
17166
|
export {
|
|
17093
17167
|
sn as AGENT_TYPES,
|
|
17094
|
-
|
|
17168
|
+
rr as CLOUD_STREAM_STATE,
|
|
17095
17169
|
Vt as CONNECTION_STATE,
|
|
17096
|
-
|
|
17097
|
-
|
|
17098
|
-
|
|
17099
|
-
|
|
17170
|
+
Lw as EpicPixelStreamingPlayer,
|
|
17171
|
+
_y as RqmiiAgentProvider,
|
|
17172
|
+
Hw as RqmiiAgentRoom,
|
|
17173
|
+
jw as RqmiiCloudAvatarPlayer,
|
|
17100
17174
|
lt as SOCKET_EVENTS,
|
|
17101
|
-
|
|
17175
|
+
Vw as useRqmiiAgent,
|
|
17102
17176
|
on as useRqmiiAgentContext,
|
|
17103
|
-
|
|
17104
|
-
|
|
17105
|
-
|
|
17106
|
-
|
|
17107
|
-
|
|
17108
|
-
|
|
17109
|
-
|
|
17177
|
+
Ww as useRqmiiAudioElement,
|
|
17178
|
+
Ny as useRqmiiAvatar,
|
|
17179
|
+
By as useRqmiiConnection,
|
|
17180
|
+
Gw as useRqmiiMessages,
|
|
17181
|
+
Uw as useRqmiiPressToTalk,
|
|
17182
|
+
Fw as useRqmiiVAD,
|
|
17183
|
+
qw as useRqmiiVoice
|
|
17110
17184
|
};
|
|
17111
17185
|
//# sourceMappingURL=rqmii-react-agent-sdk.js.map
|