@spatialwalk/avatarkit 1.0.0-beta.34 → 1.0.0-beta.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/README.md +53 -14
- package/dist/{StreamingAudioPlayer-D_anvcr1.js → StreamingAudioPlayer-GTu9p5GZ.js} +54 -7
- package/dist/animation/AnimationWebSocketClient.d.ts +3 -0
- package/dist/audio/StreamingAudioPlayer.d.ts +4 -0
- package/dist/core/AvatarController.d.ts +2 -0
- package/dist/core/AvatarView.d.ts +10 -1
- package/dist/generated/common/v1/models.d.ts +29 -0
- package/dist/generated/driveningress/v2/driveningress.d.ts +81 -0
- package/dist/{index-D8QhzqfR.js → index-B7llDHtO.js} +1370 -218
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +10 -1
- package/dist/utils/id-manager.d.ts +1 -0
- package/package.json +1 -1
|
@@ -605,15 +605,7 @@ function assertFloat32(arg) {
|
|
|
605
605
|
if (Number.isFinite(arg) && (arg > FLOAT32_MAX || arg < FLOAT32_MIN))
|
|
606
606
|
throw new Error("invalid float32: " + arg);
|
|
607
607
|
}
|
|
608
|
-
|
|
609
|
-
MessageType2[MessageType2["MESSAGE_UNSPECIFIED"] = 0] = "MESSAGE_UNSPECIFIED";
|
|
610
|
-
MessageType2[MessageType2["MESSAGE_ERROR"] = 2] = "MESSAGE_ERROR";
|
|
611
|
-
MessageType2[MessageType2["MESSAGE_SERVER_RESPONSE_ANIMATION"] = 1004] = "MESSAGE_SERVER_RESPONSE_ANIMATION";
|
|
612
|
-
MessageType2[MessageType2["MESSAGE_CLIENT_AUDIO_INPUT"] = 2003] = "MESSAGE_CLIENT_AUDIO_INPUT";
|
|
613
|
-
MessageType2[MessageType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
614
|
-
return MessageType2;
|
|
615
|
-
})(MessageType || {});
|
|
616
|
-
function messageTypeFromJSON(object) {
|
|
608
|
+
function messageTypeFromJSON$1(object) {
|
|
617
609
|
switch (object) {
|
|
618
610
|
case 0:
|
|
619
611
|
case "MESSAGE_UNSPECIFIED":
|
|
@@ -633,7 +625,7 @@ function messageTypeFromJSON(object) {
|
|
|
633
625
|
return -1;
|
|
634
626
|
}
|
|
635
627
|
}
|
|
636
|
-
function messageTypeToJSON(object) {
|
|
628
|
+
function messageTypeToJSON$1(object) {
|
|
637
629
|
switch (object) {
|
|
638
630
|
case 0:
|
|
639
631
|
return "MESSAGE_UNSPECIFIED";
|
|
@@ -702,9 +694,9 @@ const ClientAudioInputData = {
|
|
|
702
694
|
},
|
|
703
695
|
fromJSON(object) {
|
|
704
696
|
return {
|
|
705
|
-
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
706
|
-
audio: isSet(object.audio) ? bytesFromBase64(object.audio) : new Uint8Array(0),
|
|
707
|
-
end: isSet(object.end) ? globalThis.Boolean(object.end) : false
|
|
697
|
+
reqId: isSet$1(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
698
|
+
audio: isSet$1(object.audio) ? bytesFromBase64$1(object.audio) : new Uint8Array(0),
|
|
699
|
+
end: isSet$1(object.end) ? globalThis.Boolean(object.end) : false
|
|
708
700
|
};
|
|
709
701
|
},
|
|
710
702
|
toJSON(message) {
|
|
@@ -713,7 +705,7 @@ const ClientAudioInputData = {
|
|
|
713
705
|
obj.reqId = message.reqId;
|
|
714
706
|
}
|
|
715
707
|
if (message.audio.length !== 0) {
|
|
716
|
-
obj.audio = base64FromBytes(message.audio);
|
|
708
|
+
obj.audio = base64FromBytes$1(message.audio);
|
|
717
709
|
}
|
|
718
710
|
if (message.end !== false) {
|
|
719
711
|
obj.end = message.end;
|
|
@@ -731,10 +723,10 @@ const ClientAudioInputData = {
|
|
|
731
723
|
return message;
|
|
732
724
|
}
|
|
733
725
|
};
|
|
734
|
-
function createBaseFlame() {
|
|
726
|
+
function createBaseFlame$1() {
|
|
735
727
|
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
736
728
|
}
|
|
737
|
-
const Flame = {
|
|
729
|
+
const Flame$1 = {
|
|
738
730
|
encode(message, writer = new BinaryWriter()) {
|
|
739
731
|
writer.uint32(18).fork();
|
|
740
732
|
for (const v of message.translation) {
|
|
@@ -776,7 +768,7 @@ const Flame = {
|
|
|
776
768
|
decode(input, length) {
|
|
777
769
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
778
770
|
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
779
|
-
const message = createBaseFlame();
|
|
771
|
+
const message = createBaseFlame$1();
|
|
780
772
|
while (reader.pos < end) {
|
|
781
773
|
const tag = reader.uint32();
|
|
782
774
|
switch (tag >>> 3) {
|
|
@@ -924,11 +916,11 @@ const Flame = {
|
|
|
924
916
|
return obj;
|
|
925
917
|
},
|
|
926
918
|
create(base) {
|
|
927
|
-
return Flame.fromPartial(base ?? {});
|
|
919
|
+
return Flame$1.fromPartial(base ?? {});
|
|
928
920
|
},
|
|
929
921
|
fromPartial(object) {
|
|
930
922
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
931
|
-
const message = createBaseFlame();
|
|
923
|
+
const message = createBaseFlame$1();
|
|
932
924
|
message.translation = ((_a = object.translation) == null ? void 0 : _a.map((e) => e)) || [];
|
|
933
925
|
message.rotation = ((_b = object.rotation) == null ? void 0 : _b.map((e) => e)) || [];
|
|
934
926
|
message.neckPose = ((_c = object.neckPose) == null ? void 0 : _c.map((e) => e)) || [];
|
|
@@ -939,20 +931,20 @@ const Flame = {
|
|
|
939
931
|
return message;
|
|
940
932
|
}
|
|
941
933
|
};
|
|
942
|
-
function createBaseFlameAnimation() {
|
|
934
|
+
function createBaseFlameAnimation$1() {
|
|
943
935
|
return { keyframes: [] };
|
|
944
936
|
}
|
|
945
|
-
const FlameAnimation = {
|
|
937
|
+
const FlameAnimation$1 = {
|
|
946
938
|
encode(message, writer = new BinaryWriter()) {
|
|
947
939
|
for (const v of message.keyframes) {
|
|
948
|
-
Flame.encode(v, writer.uint32(10).fork()).join();
|
|
940
|
+
Flame$1.encode(v, writer.uint32(10).fork()).join();
|
|
949
941
|
}
|
|
950
942
|
return writer;
|
|
951
943
|
},
|
|
952
944
|
decode(input, length) {
|
|
953
945
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
954
946
|
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
955
|
-
const message = createBaseFlameAnimation();
|
|
947
|
+
const message = createBaseFlameAnimation$1();
|
|
956
948
|
while (reader.pos < end) {
|
|
957
949
|
const tag = reader.uint32();
|
|
958
950
|
switch (tag >>> 3) {
|
|
@@ -960,7 +952,7 @@ const FlameAnimation = {
|
|
|
960
952
|
if (tag !== 10) {
|
|
961
953
|
break;
|
|
962
954
|
}
|
|
963
|
-
message.keyframes.push(Flame.decode(reader, reader.uint32()));
|
|
955
|
+
message.keyframes.push(Flame$1.decode(reader, reader.uint32()));
|
|
964
956
|
continue;
|
|
965
957
|
}
|
|
966
958
|
}
|
|
@@ -973,24 +965,24 @@ const FlameAnimation = {
|
|
|
973
965
|
},
|
|
974
966
|
fromJSON(object) {
|
|
975
967
|
return {
|
|
976
|
-
keyframes: globalThis.Array.isArray(object == null ? void 0 : object.keyframes) ? object.keyframes.map((e) => Flame.fromJSON(e)) : []
|
|
968
|
+
keyframes: globalThis.Array.isArray(object == null ? void 0 : object.keyframes) ? object.keyframes.map((e) => Flame$1.fromJSON(e)) : []
|
|
977
969
|
};
|
|
978
970
|
},
|
|
979
971
|
toJSON(message) {
|
|
980
972
|
var _a;
|
|
981
973
|
const obj = {};
|
|
982
974
|
if ((_a = message.keyframes) == null ? void 0 : _a.length) {
|
|
983
|
-
obj.keyframes = message.keyframes.map((e) => Flame.toJSON(e));
|
|
975
|
+
obj.keyframes = message.keyframes.map((e) => Flame$1.toJSON(e));
|
|
984
976
|
}
|
|
985
977
|
return obj;
|
|
986
978
|
},
|
|
987
979
|
create(base) {
|
|
988
|
-
return FlameAnimation.fromPartial(base ?? {});
|
|
980
|
+
return FlameAnimation$1.fromPartial(base ?? {});
|
|
989
981
|
},
|
|
990
982
|
fromPartial(object) {
|
|
991
983
|
var _a;
|
|
992
|
-
const message = createBaseFlameAnimation();
|
|
993
|
-
message.keyframes = ((_a = object.keyframes) == null ? void 0 : _a.map((e) => Flame.fromPartial(e))) || [];
|
|
984
|
+
const message = createBaseFlameAnimation$1();
|
|
985
|
+
message.keyframes = ((_a = object.keyframes) == null ? void 0 : _a.map((e) => Flame$1.fromPartial(e))) || [];
|
|
994
986
|
return message;
|
|
995
987
|
}
|
|
996
988
|
};
|
|
@@ -1003,7 +995,7 @@ const ServerResponseAnimationData = {
|
|
|
1003
995
|
writer.uint32(10).string(message.reqId);
|
|
1004
996
|
}
|
|
1005
997
|
if (message.animation !== void 0) {
|
|
1006
|
-
FlameAnimation.encode(message.animation, writer.uint32(18).fork()).join();
|
|
998
|
+
FlameAnimation$1.encode(message.animation, writer.uint32(18).fork()).join();
|
|
1007
999
|
}
|
|
1008
1000
|
return writer;
|
|
1009
1001
|
},
|
|
@@ -1025,7 +1017,7 @@ const ServerResponseAnimationData = {
|
|
|
1025
1017
|
if (tag !== 18) {
|
|
1026
1018
|
break;
|
|
1027
1019
|
}
|
|
1028
|
-
message.animation = FlameAnimation.decode(reader, reader.uint32());
|
|
1020
|
+
message.animation = FlameAnimation$1.decode(reader, reader.uint32());
|
|
1029
1021
|
continue;
|
|
1030
1022
|
}
|
|
1031
1023
|
}
|
|
@@ -1038,8 +1030,8 @@ const ServerResponseAnimationData = {
|
|
|
1038
1030
|
},
|
|
1039
1031
|
fromJSON(object) {
|
|
1040
1032
|
return {
|
|
1041
|
-
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
1042
|
-
animation: isSet(object.animation) ? FlameAnimation.fromJSON(object.animation) : void 0
|
|
1033
|
+
reqId: isSet$1(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
1034
|
+
animation: isSet$1(object.animation) ? FlameAnimation$1.fromJSON(object.animation) : void 0
|
|
1043
1035
|
};
|
|
1044
1036
|
},
|
|
1045
1037
|
toJSON(message) {
|
|
@@ -1048,7 +1040,7 @@ const ServerResponseAnimationData = {
|
|
|
1048
1040
|
obj.reqId = message.reqId;
|
|
1049
1041
|
}
|
|
1050
1042
|
if (message.animation !== void 0) {
|
|
1051
|
-
obj.animation = FlameAnimation.toJSON(message.animation);
|
|
1043
|
+
obj.animation = FlameAnimation$1.toJSON(message.animation);
|
|
1052
1044
|
}
|
|
1053
1045
|
return obj;
|
|
1054
1046
|
},
|
|
@@ -1058,7 +1050,7 @@ const ServerResponseAnimationData = {
|
|
|
1058
1050
|
fromPartial(object) {
|
|
1059
1051
|
const message = createBaseServerResponseAnimationData();
|
|
1060
1052
|
message.reqId = object.reqId ?? "";
|
|
1061
|
-
message.animation = object.animation !== void 0 && object.animation !== null ? FlameAnimation.fromPartial(object.animation) : void 0;
|
|
1053
|
+
message.animation = object.animation !== void 0 && object.animation !== null ? FlameAnimation$1.fromPartial(object.animation) : void 0;
|
|
1062
1054
|
return message;
|
|
1063
1055
|
}
|
|
1064
1056
|
};
|
|
@@ -1116,9 +1108,9 @@ const ErrorInfo = {
|
|
|
1116
1108
|
},
|
|
1117
1109
|
fromJSON(object) {
|
|
1118
1110
|
return {
|
|
1119
|
-
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
1120
|
-
code: isSet(object.code) ? globalThis.Number(object.code) : 0,
|
|
1121
|
-
reason: isSet(object.reason) ? globalThis.String(object.reason) : ""
|
|
1111
|
+
reqId: isSet$1(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
1112
|
+
code: isSet$1(object.code) ? globalThis.Number(object.code) : 0,
|
|
1113
|
+
reason: isSet$1(object.reason) ? globalThis.String(object.reason) : ""
|
|
1122
1114
|
};
|
|
1123
1115
|
},
|
|
1124
1116
|
toJSON(message) {
|
|
@@ -1145,10 +1137,10 @@ const ErrorInfo = {
|
|
|
1145
1137
|
return message;
|
|
1146
1138
|
}
|
|
1147
1139
|
};
|
|
1148
|
-
function createBaseMessage() {
|
|
1140
|
+
function createBaseMessage$1() {
|
|
1149
1141
|
return { type: 0, error: void 0, serverResponseAnimation: void 0, clientAudioInput: void 0 };
|
|
1150
1142
|
}
|
|
1151
|
-
const Message = {
|
|
1143
|
+
const Message$1 = {
|
|
1152
1144
|
encode(message, writer = new BinaryWriter()) {
|
|
1153
1145
|
if (message.type !== 0) {
|
|
1154
1146
|
writer.uint32(8).int32(message.type);
|
|
@@ -1167,7 +1159,7 @@ const Message = {
|
|
|
1167
1159
|
decode(input, length) {
|
|
1168
1160
|
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1169
1161
|
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
1170
|
-
const message = createBaseMessage();
|
|
1162
|
+
const message = createBaseMessage$1();
|
|
1171
1163
|
while (reader.pos < end) {
|
|
1172
1164
|
const tag = reader.uint32();
|
|
1173
1165
|
switch (tag >>> 3) {
|
|
@@ -1209,16 +1201,16 @@ const Message = {
|
|
|
1209
1201
|
},
|
|
1210
1202
|
fromJSON(object) {
|
|
1211
1203
|
return {
|
|
1212
|
-
type: isSet(object.type) ? messageTypeFromJSON(object.type) : 0,
|
|
1213
|
-
error: isSet(object.error) ? ErrorInfo.fromJSON(object.error) : void 0,
|
|
1214
|
-
serverResponseAnimation: isSet(object.serverResponseAnimation) ? ServerResponseAnimationData.fromJSON(object.serverResponseAnimation) : void 0,
|
|
1215
|
-
clientAudioInput: isSet(object.clientAudioInput) ? ClientAudioInputData.fromJSON(object.clientAudioInput) : void 0
|
|
1204
|
+
type: isSet$1(object.type) ? messageTypeFromJSON$1(object.type) : 0,
|
|
1205
|
+
error: isSet$1(object.error) ? ErrorInfo.fromJSON(object.error) : void 0,
|
|
1206
|
+
serverResponseAnimation: isSet$1(object.serverResponseAnimation) ? ServerResponseAnimationData.fromJSON(object.serverResponseAnimation) : void 0,
|
|
1207
|
+
clientAudioInput: isSet$1(object.clientAudioInput) ? ClientAudioInputData.fromJSON(object.clientAudioInput) : void 0
|
|
1216
1208
|
};
|
|
1217
1209
|
},
|
|
1218
1210
|
toJSON(message) {
|
|
1219
1211
|
const obj = {};
|
|
1220
1212
|
if (message.type !== 0) {
|
|
1221
|
-
obj.type = messageTypeToJSON(message.type);
|
|
1213
|
+
obj.type = messageTypeToJSON$1(message.type);
|
|
1222
1214
|
}
|
|
1223
1215
|
if (message.error !== void 0) {
|
|
1224
1216
|
obj.error = ErrorInfo.toJSON(message.error);
|
|
@@ -1232,10 +1224,10 @@ const Message = {
|
|
|
1232
1224
|
return obj;
|
|
1233
1225
|
},
|
|
1234
1226
|
create(base) {
|
|
1235
|
-
return Message.fromPartial(base ?? {});
|
|
1227
|
+
return Message$1.fromPartial(base ?? {});
|
|
1236
1228
|
},
|
|
1237
1229
|
fromPartial(object) {
|
|
1238
|
-
const message = createBaseMessage();
|
|
1230
|
+
const message = createBaseMessage$1();
|
|
1239
1231
|
message.type = object.type ?? 0;
|
|
1240
1232
|
message.error = object.error !== void 0 && object.error !== null ? ErrorInfo.fromPartial(object.error) : void 0;
|
|
1241
1233
|
message.serverResponseAnimation = object.serverResponseAnimation !== void 0 && object.serverResponseAnimation !== null ? ServerResponseAnimationData.fromPartial(object.serverResponseAnimation) : void 0;
|
|
@@ -1243,7 +1235,7 @@ const Message = {
|
|
|
1243
1235
|
return message;
|
|
1244
1236
|
}
|
|
1245
1237
|
};
|
|
1246
|
-
function bytesFromBase64(b64) {
|
|
1238
|
+
function bytesFromBase64$1(b64) {
|
|
1247
1239
|
const bin = globalThis.atob(b64);
|
|
1248
1240
|
const arr = new Uint8Array(bin.length);
|
|
1249
1241
|
for (let i = 0; i < bin.length; ++i) {
|
|
@@ -1251,14 +1243,14 @@ function bytesFromBase64(b64) {
|
|
|
1251
1243
|
}
|
|
1252
1244
|
return arr;
|
|
1253
1245
|
}
|
|
1254
|
-
function base64FromBytes(arr) {
|
|
1246
|
+
function base64FromBytes$1(arr) {
|
|
1255
1247
|
const bin = [];
|
|
1256
1248
|
arr.forEach((byte) => {
|
|
1257
1249
|
bin.push(globalThis.String.fromCharCode(byte));
|
|
1258
1250
|
});
|
|
1259
1251
|
return globalThis.btoa(bin.join(""));
|
|
1260
1252
|
}
|
|
1261
|
-
function isSet(value) {
|
|
1253
|
+
function isSet$1(value) {
|
|
1262
1254
|
return value !== null && value !== void 0;
|
|
1263
1255
|
}
|
|
1264
1256
|
var ResourceType = /* @__PURE__ */ ((ResourceType2) => {
|
|
@@ -1310,6 +1302,7 @@ var ConnectionState = /* @__PURE__ */ ((ConnectionState2) => {
|
|
|
1310
1302
|
var ConversationState = /* @__PURE__ */ ((ConversationState2) => {
|
|
1311
1303
|
ConversationState2["idle"] = "idle";
|
|
1312
1304
|
ConversationState2["playing"] = "playing";
|
|
1305
|
+
ConversationState2["pausing"] = "pausing";
|
|
1313
1306
|
return ConversationState2;
|
|
1314
1307
|
})(ConversationState || {});
|
|
1315
1308
|
var AvatarState = /* @__PURE__ */ ((AvatarState2) => {
|
|
@@ -1321,6 +1314,7 @@ var AvatarState = /* @__PURE__ */ ((AvatarState2) => {
|
|
|
1321
1314
|
})(AvatarState || {});
|
|
1322
1315
|
var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
|
|
1323
1316
|
ErrorCode2["appIDUnrecognized"] = "appIDUnrecognized";
|
|
1317
|
+
ErrorCode2["avatarIDUnrecognized"] = "avatarIDUnrecognized";
|
|
1324
1318
|
ErrorCode2["sessionTokenInvalid"] = "sessionTokenInvalid";
|
|
1325
1319
|
ErrorCode2["sessionTokenExpired"] = "sessionTokenExpired";
|
|
1326
1320
|
ErrorCode2["failedToFetchAvatarMetadata"] = "failedToFetchAvatarMetadata";
|
|
@@ -2826,6 +2820,9 @@ class IdManager {
|
|
|
2826
2820
|
this.ids.connectionId = generateConversationId();
|
|
2827
2821
|
return this.ids.connectionId;
|
|
2828
2822
|
}
|
|
2823
|
+
setConnectionId(connectionId) {
|
|
2824
|
+
this.ids.connectionId = connectionId;
|
|
2825
|
+
}
|
|
2829
2826
|
getConnectionId() {
|
|
2830
2827
|
return this.ids.connectionId;
|
|
2831
2828
|
}
|
|
@@ -2977,10 +2974,12 @@ const _AnimationPlayer = class _AnimationPlayer {
|
|
|
2977
2974
|
if (this.streamingPlayer) {
|
|
2978
2975
|
return;
|
|
2979
2976
|
}
|
|
2980
|
-
const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-
|
|
2977
|
+
const { StreamingAudioPlayer } = await import("./StreamingAudioPlayer-GTu9p5GZ.js");
|
|
2978
|
+
const { AvatarSDK: AvatarSDK2 } = await Promise.resolve().then(() => AvatarSDK$1);
|
|
2979
|
+
const audioFormat = AvatarSDK2.getAudioFormat();
|
|
2981
2980
|
this.streamingPlayer = new StreamingAudioPlayer({
|
|
2982
|
-
sampleRate:
|
|
2983
|
-
channelCount:
|
|
2981
|
+
sampleRate: audioFormat.sampleRate,
|
|
2982
|
+
channelCount: audioFormat.channelCount,
|
|
2984
2983
|
debug: false
|
|
2985
2984
|
});
|
|
2986
2985
|
try {
|
|
@@ -4261,126 +4260,1086 @@ class AvatarSDK {
|
|
|
4261
4260
|
return prefix.endsWith("/") ? prefix + path : `${prefix}/${path}`;
|
|
4262
4261
|
}
|
|
4263
4262
|
}
|
|
4264
|
-
});
|
|
4265
|
-
await this._avatarCore.loadWASMModule();
|
|
4266
|
-
logger.log("[AvatarSDK] WASM module initialized successfully");
|
|
4267
|
-
} catch (error) {
|
|
4268
|
-
logger.error("Failed to initialize WASM module:", error instanceof Error ? error.message : String(error));
|
|
4269
|
-
throw new Error(`WASM module initialization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
4270
|
-
}
|
|
4271
|
-
}
|
|
4272
|
-
static async initializeTemplateResources() {
|
|
4273
|
-
if (!this._avatarCore) {
|
|
4274
|
-
throw new Error("AvatarCore not available");
|
|
4275
|
-
}
|
|
4276
|
-
logger.log("[AvatarSDK] Loading template resources...");
|
|
4277
|
-
try {
|
|
4278
|
-
const { AvatarDownloader: AvatarDownloader2 } = await Promise.resolve().then(() => AvatarDownloader$1);
|
|
4279
|
-
const downloader = new AvatarDownloader2();
|
|
4280
|
-
const templateResources = await downloader.loadGlobalFlameResources();
|
|
4281
|
-
const success = await this._avatarCore.loadTemplateResourcesFromBuffers(templateResources);
|
|
4282
|
-
if (success) {
|
|
4283
|
-
logger.log("[AvatarSDK] Template resources initialized successfully");
|
|
4284
|
-
} else {
|
|
4285
|
-
logger.log("[AvatarSDK] Template resources already initialized, skipping...");
|
|
4263
|
+
});
|
|
4264
|
+
await this._avatarCore.loadWASMModule();
|
|
4265
|
+
logger.log("[AvatarSDK] WASM module initialized successfully");
|
|
4266
|
+
} catch (error) {
|
|
4267
|
+
logger.error("Failed to initialize WASM module:", error instanceof Error ? error.message : String(error));
|
|
4268
|
+
throw new Error(`WASM module initialization failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
4269
|
+
}
|
|
4270
|
+
}
|
|
4271
|
+
static async initializeTemplateResources() {
|
|
4272
|
+
if (!this._avatarCore) {
|
|
4273
|
+
throw new Error("AvatarCore not available");
|
|
4274
|
+
}
|
|
4275
|
+
logger.log("[AvatarSDK] Loading template resources...");
|
|
4276
|
+
try {
|
|
4277
|
+
const { AvatarDownloader: AvatarDownloader2 } = await Promise.resolve().then(() => AvatarDownloader$1);
|
|
4278
|
+
const downloader = new AvatarDownloader2();
|
|
4279
|
+
const templateResources = await downloader.loadGlobalFlameResources();
|
|
4280
|
+
const success = await this._avatarCore.loadTemplateResourcesFromBuffers(templateResources);
|
|
4281
|
+
if (success) {
|
|
4282
|
+
logger.log("[AvatarSDK] Template resources initialized successfully");
|
|
4283
|
+
} else {
|
|
4284
|
+
logger.log("[AvatarSDK] Template resources already initialized, skipping...");
|
|
4285
|
+
}
|
|
4286
|
+
} catch (error) {
|
|
4287
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
4288
|
+
logger.error("[AvatarSDK] Failed to initialize template resources:", errorMessage);
|
|
4289
|
+
logEvent("template_init", "error", {
|
|
4290
|
+
reason: errorMessage,
|
|
4291
|
+
stage: "sdk_init"
|
|
4292
|
+
});
|
|
4293
|
+
throw new Error(`SDK initialization failed: Template resources loading failed - ${errorMessage}`);
|
|
4294
|
+
}
|
|
4295
|
+
}
|
|
4296
|
+
static setSessionToken(token) {
|
|
4297
|
+
idManager.setSessionToken(token);
|
|
4298
|
+
}
|
|
4299
|
+
static setUserId(userId) {
|
|
4300
|
+
idManager.setUserId(userId);
|
|
4301
|
+
}
|
|
4302
|
+
static get isInitialized() {
|
|
4303
|
+
return this._isInitialized;
|
|
4304
|
+
}
|
|
4305
|
+
static get appId() {
|
|
4306
|
+
return idManager.getAppId();
|
|
4307
|
+
}
|
|
4308
|
+
static get configuration() {
|
|
4309
|
+
return this._configuration;
|
|
4310
|
+
}
|
|
4311
|
+
static get sessionToken() {
|
|
4312
|
+
return idManager.getSessionToken();
|
|
4313
|
+
}
|
|
4314
|
+
static get userId() {
|
|
4315
|
+
return idManager.getUserId();
|
|
4316
|
+
}
|
|
4317
|
+
static get version() {
|
|
4318
|
+
return this._version;
|
|
4319
|
+
}
|
|
4320
|
+
static getPlaybackMode() {
|
|
4321
|
+
var _a;
|
|
4322
|
+
return ((_a = this._configuration) == null ? void 0 : _a.drivingServiceMode) ?? DrivingServiceMode.sdk;
|
|
4323
|
+
}
|
|
4324
|
+
static getAudioFormat() {
|
|
4325
|
+
var _a;
|
|
4326
|
+
return ((_a = this._configuration) == null ? void 0 : _a.audioFormat) ?? { channelCount: 1, sampleRate: 16e3 };
|
|
4327
|
+
}
|
|
4328
|
+
static getAvatarCore() {
|
|
4329
|
+
return this._avatarCore;
|
|
4330
|
+
}
|
|
4331
|
+
static cleanup() {
|
|
4332
|
+
if (!this._isInitialized) {
|
|
4333
|
+
return;
|
|
4334
|
+
}
|
|
4335
|
+
try {
|
|
4336
|
+
heartbeatManager.stop();
|
|
4337
|
+
if (this._avatarCore) {
|
|
4338
|
+
this._avatarCore.release();
|
|
4339
|
+
this._avatarCore = null;
|
|
4340
|
+
}
|
|
4341
|
+
this._configuration = null;
|
|
4342
|
+
this._dynamicSdkConfig = null;
|
|
4343
|
+
this._isInitialized = false;
|
|
4344
|
+
idManager.clear();
|
|
4345
|
+
clearSdkConfigCache();
|
|
4346
|
+
cleanupCLS();
|
|
4347
|
+
logger.log("[AvatarSDK] Cleanup completed");
|
|
4348
|
+
} catch (error) {
|
|
4349
|
+
logger.error("Failed to cleanup AvatarSDK:", error instanceof Error ? error.message : String(error));
|
|
4350
|
+
}
|
|
4351
|
+
}
|
|
4352
|
+
static async _fetchSdkConfig() {
|
|
4353
|
+
try {
|
|
4354
|
+
this._dynamicSdkConfig = await fetchSdkConfig(this._version);
|
|
4355
|
+
} catch (error) {
|
|
4356
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
4357
|
+
logger.warn("Failed to fetch SDK config from remote, using defaults:", message);
|
|
4358
|
+
logEvent("sdk_config", "warning", {
|
|
4359
|
+
reason: message
|
|
4360
|
+
});
|
|
4361
|
+
}
|
|
4362
|
+
}
|
|
4363
|
+
static getEnvironmentConfig() {
|
|
4364
|
+
if (!this._configuration) {
|
|
4365
|
+
throw new Error("AvatarSDK not initialized");
|
|
4366
|
+
}
|
|
4367
|
+
if (!this._dynamicSdkConfig) {
|
|
4368
|
+
throw new Error("SDK configuration not loaded. Please ensure AvatarSDK.initialize() has completed.");
|
|
4369
|
+
}
|
|
4370
|
+
const dynamicConfig = this._dynamicSdkConfig[this._configuration.environment];
|
|
4371
|
+
if (!dynamicConfig) {
|
|
4372
|
+
throw new Error(`No configuration found for environment: ${this._configuration.environment}`);
|
|
4373
|
+
}
|
|
4374
|
+
const sdkApiBaseUrl = dynamicConfig;
|
|
4375
|
+
const wsBaseUrl = dynamicConfig.replace(/^https?:\/\//, (match) => {
|
|
4376
|
+
return match === "https://" ? "wss://" : "ws://";
|
|
4377
|
+
});
|
|
4378
|
+
const driveningressWsUrl = `${wsBaseUrl}/v2/driveningress/websocket`;
|
|
4379
|
+
return {
|
|
4380
|
+
sdkApiBaseUrl,
|
|
4381
|
+
driveningressWsUrl
|
|
4382
|
+
};
|
|
4383
|
+
}
|
|
4384
|
+
}
|
|
4385
|
+
__publicField(AvatarSDK, "_isInitialized", false);
|
|
4386
|
+
__publicField(AvatarSDK, "_configuration", null);
|
|
4387
|
+
__publicField(AvatarSDK, "_version", "1.0.0-beta.36");
|
|
4388
|
+
__publicField(AvatarSDK, "_avatarCore", null);
|
|
4389
|
+
__publicField(AvatarSDK, "_dynamicSdkConfig", null);
|
|
4390
|
+
const AvatarSDK$1 = Object.freeze(Object.defineProperty({
|
|
4391
|
+
__proto__: null,
|
|
4392
|
+
AvatarSDK
|
|
4393
|
+
}, Symbol.toStringTag, { value: "Module" }));
|
|
4394
|
+
var MessageType = /* @__PURE__ */ ((MessageType2) => {
|
|
4395
|
+
MessageType2[MessageType2["MESSAGE_UNSPECIFIED"] = 0] = "MESSAGE_UNSPECIFIED";
|
|
4396
|
+
MessageType2[MessageType2["MESSAGE_CLIENT_CONFIGURE_SESSION"] = 1] = "MESSAGE_CLIENT_CONFIGURE_SESSION";
|
|
4397
|
+
MessageType2[MessageType2["MESSAGE_SERVER_CONFIRM_SESSION"] = 2] = "MESSAGE_SERVER_CONFIRM_SESSION";
|
|
4398
|
+
MessageType2[MessageType2["MESSAGE_CLIENT_AUDIO_INPUT"] = 3] = "MESSAGE_CLIENT_AUDIO_INPUT";
|
|
4399
|
+
MessageType2[MessageType2["MESSAGE_SERVER_ERROR"] = 4] = "MESSAGE_SERVER_ERROR";
|
|
4400
|
+
MessageType2[MessageType2["MESSAGE_SERVER_RESPONSE_ANIMATION"] = 5] = "MESSAGE_SERVER_RESPONSE_ANIMATION";
|
|
4401
|
+
MessageType2[MessageType2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
4402
|
+
return MessageType2;
|
|
4403
|
+
})(MessageType || {});
|
|
4404
|
+
function messageTypeFromJSON(object) {
|
|
4405
|
+
switch (object) {
|
|
4406
|
+
case 0:
|
|
4407
|
+
case "MESSAGE_UNSPECIFIED":
|
|
4408
|
+
return 0;
|
|
4409
|
+
case 1:
|
|
4410
|
+
case "MESSAGE_CLIENT_CONFIGURE_SESSION":
|
|
4411
|
+
return 1;
|
|
4412
|
+
case 2:
|
|
4413
|
+
case "MESSAGE_SERVER_CONFIRM_SESSION":
|
|
4414
|
+
return 2;
|
|
4415
|
+
case 3:
|
|
4416
|
+
case "MESSAGE_CLIENT_AUDIO_INPUT":
|
|
4417
|
+
return 3;
|
|
4418
|
+
case 4:
|
|
4419
|
+
case "MESSAGE_SERVER_ERROR":
|
|
4420
|
+
return 4;
|
|
4421
|
+
case 5:
|
|
4422
|
+
case "MESSAGE_SERVER_RESPONSE_ANIMATION":
|
|
4423
|
+
return 5;
|
|
4424
|
+
case -1:
|
|
4425
|
+
case "UNRECOGNIZED":
|
|
4426
|
+
default:
|
|
4427
|
+
return -1;
|
|
4428
|
+
}
|
|
4429
|
+
}
|
|
4430
|
+
function messageTypeToJSON(object) {
|
|
4431
|
+
switch (object) {
|
|
4432
|
+
case 0:
|
|
4433
|
+
return "MESSAGE_UNSPECIFIED";
|
|
4434
|
+
case 1:
|
|
4435
|
+
return "MESSAGE_CLIENT_CONFIGURE_SESSION";
|
|
4436
|
+
case 2:
|
|
4437
|
+
return "MESSAGE_SERVER_CONFIRM_SESSION";
|
|
4438
|
+
case 3:
|
|
4439
|
+
return "MESSAGE_CLIENT_AUDIO_INPUT";
|
|
4440
|
+
case 4:
|
|
4441
|
+
return "MESSAGE_SERVER_ERROR";
|
|
4442
|
+
case 5:
|
|
4443
|
+
return "MESSAGE_SERVER_RESPONSE_ANIMATION";
|
|
4444
|
+
case -1:
|
|
4445
|
+
default:
|
|
4446
|
+
return "UNRECOGNIZED";
|
|
4447
|
+
}
|
|
4448
|
+
}
|
|
4449
|
+
var AudioFormat = /* @__PURE__ */ ((AudioFormat2) => {
|
|
4450
|
+
AudioFormat2[AudioFormat2["AUDIO_FORMAT_PCM_S16LE"] = 0] = "AUDIO_FORMAT_PCM_S16LE";
|
|
4451
|
+
AudioFormat2[AudioFormat2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
4452
|
+
return AudioFormat2;
|
|
4453
|
+
})(AudioFormat || {});
|
|
4454
|
+
function audioFormatFromJSON(object) {
|
|
4455
|
+
switch (object) {
|
|
4456
|
+
case 0:
|
|
4457
|
+
case "AUDIO_FORMAT_PCM_S16LE":
|
|
4458
|
+
return 0;
|
|
4459
|
+
case -1:
|
|
4460
|
+
case "UNRECOGNIZED":
|
|
4461
|
+
default:
|
|
4462
|
+
return -1;
|
|
4463
|
+
}
|
|
4464
|
+
}
|
|
4465
|
+
function audioFormatToJSON(object) {
|
|
4466
|
+
switch (object) {
|
|
4467
|
+
case 0:
|
|
4468
|
+
return "AUDIO_FORMAT_PCM_S16LE";
|
|
4469
|
+
case -1:
|
|
4470
|
+
default:
|
|
4471
|
+
return "UNRECOGNIZED";
|
|
4472
|
+
}
|
|
4473
|
+
}
|
|
4474
|
+
var TransportCompression = /* @__PURE__ */ ((TransportCompression2) => {
|
|
4475
|
+
TransportCompression2[TransportCompression2["TRANSPORT_COMPRESSION_NONE"] = 0] = "TRANSPORT_COMPRESSION_NONE";
|
|
4476
|
+
TransportCompression2[TransportCompression2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
4477
|
+
return TransportCompression2;
|
|
4478
|
+
})(TransportCompression || {});
|
|
4479
|
+
function transportCompressionFromJSON(object) {
|
|
4480
|
+
switch (object) {
|
|
4481
|
+
case 0:
|
|
4482
|
+
case "TRANSPORT_COMPRESSION_NONE":
|
|
4483
|
+
return 0;
|
|
4484
|
+
case -1:
|
|
4485
|
+
case "UNRECOGNIZED":
|
|
4486
|
+
default:
|
|
4487
|
+
return -1;
|
|
4488
|
+
}
|
|
4489
|
+
}
|
|
4490
|
+
function transportCompressionToJSON(object) {
|
|
4491
|
+
switch (object) {
|
|
4492
|
+
case 0:
|
|
4493
|
+
return "TRANSPORT_COMPRESSION_NONE";
|
|
4494
|
+
case -1:
|
|
4495
|
+
default:
|
|
4496
|
+
return "UNRECOGNIZED";
|
|
4497
|
+
}
|
|
4498
|
+
}
|
|
4499
|
+
function createBaseClientConfigureSession() {
|
|
4500
|
+
return { sampleRate: 0, bitrate: 0, audioFormat: 0, transportCompression: 0 };
|
|
4501
|
+
}
|
|
4502
|
+
const ClientConfigureSession = {
|
|
4503
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4504
|
+
if (message.sampleRate !== 0) {
|
|
4505
|
+
writer.uint32(8).int32(message.sampleRate);
|
|
4506
|
+
}
|
|
4507
|
+
if (message.bitrate !== 0) {
|
|
4508
|
+
writer.uint32(16).int32(message.bitrate);
|
|
4509
|
+
}
|
|
4510
|
+
if (message.audioFormat !== 0) {
|
|
4511
|
+
writer.uint32(24).int32(message.audioFormat);
|
|
4512
|
+
}
|
|
4513
|
+
if (message.transportCompression !== 0) {
|
|
4514
|
+
writer.uint32(32).int32(message.transportCompression);
|
|
4515
|
+
}
|
|
4516
|
+
return writer;
|
|
4517
|
+
},
|
|
4518
|
+
decode(input, length) {
|
|
4519
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4520
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
4521
|
+
const message = createBaseClientConfigureSession();
|
|
4522
|
+
while (reader.pos < end) {
|
|
4523
|
+
const tag = reader.uint32();
|
|
4524
|
+
switch (tag >>> 3) {
|
|
4525
|
+
case 1: {
|
|
4526
|
+
if (tag !== 8) {
|
|
4527
|
+
break;
|
|
4528
|
+
}
|
|
4529
|
+
message.sampleRate = reader.int32();
|
|
4530
|
+
continue;
|
|
4531
|
+
}
|
|
4532
|
+
case 2: {
|
|
4533
|
+
if (tag !== 16) {
|
|
4534
|
+
break;
|
|
4535
|
+
}
|
|
4536
|
+
message.bitrate = reader.int32();
|
|
4537
|
+
continue;
|
|
4538
|
+
}
|
|
4539
|
+
case 3: {
|
|
4540
|
+
if (tag !== 24) {
|
|
4541
|
+
break;
|
|
4542
|
+
}
|
|
4543
|
+
message.audioFormat = reader.int32();
|
|
4544
|
+
continue;
|
|
4545
|
+
}
|
|
4546
|
+
case 4: {
|
|
4547
|
+
if (tag !== 32) {
|
|
4548
|
+
break;
|
|
4549
|
+
}
|
|
4550
|
+
message.transportCompression = reader.int32();
|
|
4551
|
+
continue;
|
|
4552
|
+
}
|
|
4553
|
+
}
|
|
4554
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4555
|
+
break;
|
|
4556
|
+
}
|
|
4557
|
+
reader.skip(tag & 7);
|
|
4558
|
+
}
|
|
4559
|
+
return message;
|
|
4560
|
+
},
|
|
4561
|
+
fromJSON(object) {
|
|
4562
|
+
return {
|
|
4563
|
+
sampleRate: isSet(object.sampleRate) ? globalThis.Number(object.sampleRate) : 0,
|
|
4564
|
+
bitrate: isSet(object.bitrate) ? globalThis.Number(object.bitrate) : 0,
|
|
4565
|
+
audioFormat: isSet(object.audioFormat) ? audioFormatFromJSON(object.audioFormat) : 0,
|
|
4566
|
+
transportCompression: isSet(object.transportCompression) ? transportCompressionFromJSON(object.transportCompression) : 0
|
|
4567
|
+
};
|
|
4568
|
+
},
|
|
4569
|
+
toJSON(message) {
|
|
4570
|
+
const obj = {};
|
|
4571
|
+
if (message.sampleRate !== 0) {
|
|
4572
|
+
obj.sampleRate = Math.round(message.sampleRate);
|
|
4573
|
+
}
|
|
4574
|
+
if (message.bitrate !== 0) {
|
|
4575
|
+
obj.bitrate = Math.round(message.bitrate);
|
|
4576
|
+
}
|
|
4577
|
+
if (message.audioFormat !== 0) {
|
|
4578
|
+
obj.audioFormat = audioFormatToJSON(message.audioFormat);
|
|
4579
|
+
}
|
|
4580
|
+
if (message.transportCompression !== 0) {
|
|
4581
|
+
obj.transportCompression = transportCompressionToJSON(message.transportCompression);
|
|
4582
|
+
}
|
|
4583
|
+
return obj;
|
|
4584
|
+
},
|
|
4585
|
+
create(base) {
|
|
4586
|
+
return ClientConfigureSession.fromPartial(base ?? {});
|
|
4587
|
+
},
|
|
4588
|
+
fromPartial(object) {
|
|
4589
|
+
const message = createBaseClientConfigureSession();
|
|
4590
|
+
message.sampleRate = object.sampleRate ?? 0;
|
|
4591
|
+
message.bitrate = object.bitrate ?? 0;
|
|
4592
|
+
message.audioFormat = object.audioFormat ?? 0;
|
|
4593
|
+
message.transportCompression = object.transportCompression ?? 0;
|
|
4594
|
+
return message;
|
|
4595
|
+
}
|
|
4596
|
+
};
|
|
4597
|
+
function createBaseServerConfirmSession() {
|
|
4598
|
+
return { connectionId: "" };
|
|
4599
|
+
}
|
|
4600
|
+
const ServerConfirmSession = {
|
|
4601
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4602
|
+
if (message.connectionId !== "") {
|
|
4603
|
+
writer.uint32(10).string(message.connectionId);
|
|
4604
|
+
}
|
|
4605
|
+
return writer;
|
|
4606
|
+
},
|
|
4607
|
+
decode(input, length) {
|
|
4608
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4609
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
4610
|
+
const message = createBaseServerConfirmSession();
|
|
4611
|
+
while (reader.pos < end) {
|
|
4612
|
+
const tag = reader.uint32();
|
|
4613
|
+
switch (tag >>> 3) {
|
|
4614
|
+
case 1: {
|
|
4615
|
+
if (tag !== 10) {
|
|
4616
|
+
break;
|
|
4617
|
+
}
|
|
4618
|
+
message.connectionId = reader.string();
|
|
4619
|
+
continue;
|
|
4620
|
+
}
|
|
4621
|
+
}
|
|
4622
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4623
|
+
break;
|
|
4624
|
+
}
|
|
4625
|
+
reader.skip(tag & 7);
|
|
4626
|
+
}
|
|
4627
|
+
return message;
|
|
4628
|
+
},
|
|
4629
|
+
fromJSON(object) {
|
|
4630
|
+
return { connectionId: isSet(object.connectionId) ? globalThis.String(object.connectionId) : "" };
|
|
4631
|
+
},
|
|
4632
|
+
toJSON(message) {
|
|
4633
|
+
const obj = {};
|
|
4634
|
+
if (message.connectionId !== "") {
|
|
4635
|
+
obj.connectionId = message.connectionId;
|
|
4636
|
+
}
|
|
4637
|
+
return obj;
|
|
4638
|
+
},
|
|
4639
|
+
create(base) {
|
|
4640
|
+
return ServerConfirmSession.fromPartial(base ?? {});
|
|
4641
|
+
},
|
|
4642
|
+
fromPartial(object) {
|
|
4643
|
+
const message = createBaseServerConfirmSession();
|
|
4644
|
+
message.connectionId = object.connectionId ?? "";
|
|
4645
|
+
return message;
|
|
4646
|
+
}
|
|
4647
|
+
};
|
|
4648
|
+
function createBaseClientAudioInput() {
|
|
4649
|
+
return { reqId: "", end: false, audio: new Uint8Array(0) };
|
|
4650
|
+
}
|
|
4651
|
+
const ClientAudioInput = {
|
|
4652
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4653
|
+
if (message.reqId !== "") {
|
|
4654
|
+
writer.uint32(10).string(message.reqId);
|
|
4655
|
+
}
|
|
4656
|
+
if (message.end !== false) {
|
|
4657
|
+
writer.uint32(16).bool(message.end);
|
|
4658
|
+
}
|
|
4659
|
+
if (message.audio.length !== 0) {
|
|
4660
|
+
writer.uint32(26).bytes(message.audio);
|
|
4661
|
+
}
|
|
4662
|
+
return writer;
|
|
4663
|
+
},
|
|
4664
|
+
decode(input, length) {
|
|
4665
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4666
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
4667
|
+
const message = createBaseClientAudioInput();
|
|
4668
|
+
while (reader.pos < end) {
|
|
4669
|
+
const tag = reader.uint32();
|
|
4670
|
+
switch (tag >>> 3) {
|
|
4671
|
+
case 1: {
|
|
4672
|
+
if (tag !== 10) {
|
|
4673
|
+
break;
|
|
4674
|
+
}
|
|
4675
|
+
message.reqId = reader.string();
|
|
4676
|
+
continue;
|
|
4677
|
+
}
|
|
4678
|
+
case 2: {
|
|
4679
|
+
if (tag !== 16) {
|
|
4680
|
+
break;
|
|
4681
|
+
}
|
|
4682
|
+
message.end = reader.bool();
|
|
4683
|
+
continue;
|
|
4684
|
+
}
|
|
4685
|
+
case 3: {
|
|
4686
|
+
if (tag !== 26) {
|
|
4687
|
+
break;
|
|
4688
|
+
}
|
|
4689
|
+
message.audio = reader.bytes();
|
|
4690
|
+
continue;
|
|
4691
|
+
}
|
|
4692
|
+
}
|
|
4693
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4694
|
+
break;
|
|
4695
|
+
}
|
|
4696
|
+
reader.skip(tag & 7);
|
|
4697
|
+
}
|
|
4698
|
+
return message;
|
|
4699
|
+
},
|
|
4700
|
+
fromJSON(object) {
|
|
4701
|
+
return {
|
|
4702
|
+
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
4703
|
+
end: isSet(object.end) ? globalThis.Boolean(object.end) : false,
|
|
4704
|
+
audio: isSet(object.audio) ? bytesFromBase64(object.audio) : new Uint8Array(0)
|
|
4705
|
+
};
|
|
4706
|
+
},
|
|
4707
|
+
toJSON(message) {
|
|
4708
|
+
const obj = {};
|
|
4709
|
+
if (message.reqId !== "") {
|
|
4710
|
+
obj.reqId = message.reqId;
|
|
4711
|
+
}
|
|
4712
|
+
if (message.end !== false) {
|
|
4713
|
+
obj.end = message.end;
|
|
4714
|
+
}
|
|
4715
|
+
if (message.audio.length !== 0) {
|
|
4716
|
+
obj.audio = base64FromBytes(message.audio);
|
|
4717
|
+
}
|
|
4718
|
+
return obj;
|
|
4719
|
+
},
|
|
4720
|
+
create(base) {
|
|
4721
|
+
return ClientAudioInput.fromPartial(base ?? {});
|
|
4722
|
+
},
|
|
4723
|
+
fromPartial(object) {
|
|
4724
|
+
const message = createBaseClientAudioInput();
|
|
4725
|
+
message.reqId = object.reqId ?? "";
|
|
4726
|
+
message.end = object.end ?? false;
|
|
4727
|
+
message.audio = object.audio ?? new Uint8Array(0);
|
|
4728
|
+
return message;
|
|
4729
|
+
}
|
|
4730
|
+
};
|
|
4731
|
+
function createBaseServerError() {
|
|
4732
|
+
return { connectionId: "", reqId: "", code: 0, message: "" };
|
|
4733
|
+
}
|
|
4734
|
+
const ServerError = {
|
|
4735
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4736
|
+
if (message.connectionId !== "") {
|
|
4737
|
+
writer.uint32(10).string(message.connectionId);
|
|
4738
|
+
}
|
|
4739
|
+
if (message.reqId !== "") {
|
|
4740
|
+
writer.uint32(18).string(message.reqId);
|
|
4741
|
+
}
|
|
4742
|
+
if (message.code !== 0) {
|
|
4743
|
+
writer.uint32(24).int32(message.code);
|
|
4744
|
+
}
|
|
4745
|
+
if (message.message !== "") {
|
|
4746
|
+
writer.uint32(34).string(message.message);
|
|
4747
|
+
}
|
|
4748
|
+
return writer;
|
|
4749
|
+
},
|
|
4750
|
+
decode(input, length) {
|
|
4751
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4752
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
4753
|
+
const message = createBaseServerError();
|
|
4754
|
+
while (reader.pos < end) {
|
|
4755
|
+
const tag = reader.uint32();
|
|
4756
|
+
switch (tag >>> 3) {
|
|
4757
|
+
case 1: {
|
|
4758
|
+
if (tag !== 10) {
|
|
4759
|
+
break;
|
|
4760
|
+
}
|
|
4761
|
+
message.connectionId = reader.string();
|
|
4762
|
+
continue;
|
|
4763
|
+
}
|
|
4764
|
+
case 2: {
|
|
4765
|
+
if (tag !== 18) {
|
|
4766
|
+
break;
|
|
4767
|
+
}
|
|
4768
|
+
message.reqId = reader.string();
|
|
4769
|
+
continue;
|
|
4770
|
+
}
|
|
4771
|
+
case 3: {
|
|
4772
|
+
if (tag !== 24) {
|
|
4773
|
+
break;
|
|
4774
|
+
}
|
|
4775
|
+
message.code = reader.int32();
|
|
4776
|
+
continue;
|
|
4777
|
+
}
|
|
4778
|
+
case 4: {
|
|
4779
|
+
if (tag !== 34) {
|
|
4780
|
+
break;
|
|
4781
|
+
}
|
|
4782
|
+
message.message = reader.string();
|
|
4783
|
+
continue;
|
|
4784
|
+
}
|
|
4785
|
+
}
|
|
4786
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4787
|
+
break;
|
|
4788
|
+
}
|
|
4789
|
+
reader.skip(tag & 7);
|
|
4790
|
+
}
|
|
4791
|
+
return message;
|
|
4792
|
+
},
|
|
4793
|
+
fromJSON(object) {
|
|
4794
|
+
return {
|
|
4795
|
+
connectionId: isSet(object.connectionId) ? globalThis.String(object.connectionId) : "",
|
|
4796
|
+
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
4797
|
+
code: isSet(object.code) ? globalThis.Number(object.code) : 0,
|
|
4798
|
+
message: isSet(object.message) ? globalThis.String(object.message) : ""
|
|
4799
|
+
};
|
|
4800
|
+
},
|
|
4801
|
+
toJSON(message) {
|
|
4802
|
+
const obj = {};
|
|
4803
|
+
if (message.connectionId !== "") {
|
|
4804
|
+
obj.connectionId = message.connectionId;
|
|
4805
|
+
}
|
|
4806
|
+
if (message.reqId !== "") {
|
|
4807
|
+
obj.reqId = message.reqId;
|
|
4808
|
+
}
|
|
4809
|
+
if (message.code !== 0) {
|
|
4810
|
+
obj.code = Math.round(message.code);
|
|
4811
|
+
}
|
|
4812
|
+
if (message.message !== "") {
|
|
4813
|
+
obj.message = message.message;
|
|
4814
|
+
}
|
|
4815
|
+
return obj;
|
|
4816
|
+
},
|
|
4817
|
+
create(base) {
|
|
4818
|
+
return ServerError.fromPartial(base ?? {});
|
|
4819
|
+
},
|
|
4820
|
+
fromPartial(object) {
|
|
4821
|
+
const message = createBaseServerError();
|
|
4822
|
+
message.connectionId = object.connectionId ?? "";
|
|
4823
|
+
message.reqId = object.reqId ?? "";
|
|
4824
|
+
message.code = object.code ?? 0;
|
|
4825
|
+
message.message = object.message ?? "";
|
|
4826
|
+
return message;
|
|
4827
|
+
}
|
|
4828
|
+
};
|
|
4829
|
+
function createBaseFlame() {
|
|
4830
|
+
return { translation: [], rotation: [], neckPose: [], jawPose: [], eyePose: [], eyeLid: [], expression: [] };
|
|
4831
|
+
}
|
|
4832
|
+
const Flame = {
|
|
4833
|
+
encode(message, writer = new BinaryWriter()) {
|
|
4834
|
+
writer.uint32(10).fork();
|
|
4835
|
+
for (const v of message.translation) {
|
|
4836
|
+
writer.float(v);
|
|
4837
|
+
}
|
|
4838
|
+
writer.join();
|
|
4839
|
+
writer.uint32(18).fork();
|
|
4840
|
+
for (const v of message.rotation) {
|
|
4841
|
+
writer.float(v);
|
|
4842
|
+
}
|
|
4843
|
+
writer.join();
|
|
4844
|
+
writer.uint32(26).fork();
|
|
4845
|
+
for (const v of message.neckPose) {
|
|
4846
|
+
writer.float(v);
|
|
4847
|
+
}
|
|
4848
|
+
writer.join();
|
|
4849
|
+
writer.uint32(34).fork();
|
|
4850
|
+
for (const v of message.jawPose) {
|
|
4851
|
+
writer.float(v);
|
|
4852
|
+
}
|
|
4853
|
+
writer.join();
|
|
4854
|
+
writer.uint32(42).fork();
|
|
4855
|
+
for (const v of message.eyePose) {
|
|
4856
|
+
writer.float(v);
|
|
4857
|
+
}
|
|
4858
|
+
writer.join();
|
|
4859
|
+
writer.uint32(50).fork();
|
|
4860
|
+
for (const v of message.eyeLid) {
|
|
4861
|
+
writer.float(v);
|
|
4862
|
+
}
|
|
4863
|
+
writer.join();
|
|
4864
|
+
writer.uint32(58).fork();
|
|
4865
|
+
for (const v of message.expression) {
|
|
4866
|
+
writer.float(v);
|
|
4867
|
+
}
|
|
4868
|
+
writer.join();
|
|
4869
|
+
return writer;
|
|
4870
|
+
},
|
|
4871
|
+
decode(input, length) {
|
|
4872
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
4873
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
4874
|
+
const message = createBaseFlame();
|
|
4875
|
+
while (reader.pos < end) {
|
|
4876
|
+
const tag = reader.uint32();
|
|
4877
|
+
switch (tag >>> 3) {
|
|
4878
|
+
case 1: {
|
|
4879
|
+
if (tag === 13) {
|
|
4880
|
+
message.translation.push(reader.float());
|
|
4881
|
+
continue;
|
|
4882
|
+
}
|
|
4883
|
+
if (tag === 10) {
|
|
4884
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4885
|
+
while (reader.pos < end2) {
|
|
4886
|
+
message.translation.push(reader.float());
|
|
4887
|
+
}
|
|
4888
|
+
continue;
|
|
4889
|
+
}
|
|
4890
|
+
break;
|
|
4891
|
+
}
|
|
4892
|
+
case 2: {
|
|
4893
|
+
if (tag === 21) {
|
|
4894
|
+
message.rotation.push(reader.float());
|
|
4895
|
+
continue;
|
|
4896
|
+
}
|
|
4897
|
+
if (tag === 18) {
|
|
4898
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4899
|
+
while (reader.pos < end2) {
|
|
4900
|
+
message.rotation.push(reader.float());
|
|
4901
|
+
}
|
|
4902
|
+
continue;
|
|
4903
|
+
}
|
|
4904
|
+
break;
|
|
4905
|
+
}
|
|
4906
|
+
case 3: {
|
|
4907
|
+
if (tag === 29) {
|
|
4908
|
+
message.neckPose.push(reader.float());
|
|
4909
|
+
continue;
|
|
4910
|
+
}
|
|
4911
|
+
if (tag === 26) {
|
|
4912
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4913
|
+
while (reader.pos < end2) {
|
|
4914
|
+
message.neckPose.push(reader.float());
|
|
4915
|
+
}
|
|
4916
|
+
continue;
|
|
4917
|
+
}
|
|
4918
|
+
break;
|
|
4919
|
+
}
|
|
4920
|
+
case 4: {
|
|
4921
|
+
if (tag === 37) {
|
|
4922
|
+
message.jawPose.push(reader.float());
|
|
4923
|
+
continue;
|
|
4924
|
+
}
|
|
4925
|
+
if (tag === 34) {
|
|
4926
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4927
|
+
while (reader.pos < end2) {
|
|
4928
|
+
message.jawPose.push(reader.float());
|
|
4929
|
+
}
|
|
4930
|
+
continue;
|
|
4931
|
+
}
|
|
4932
|
+
break;
|
|
4933
|
+
}
|
|
4934
|
+
case 5: {
|
|
4935
|
+
if (tag === 45) {
|
|
4936
|
+
message.eyePose.push(reader.float());
|
|
4937
|
+
continue;
|
|
4938
|
+
}
|
|
4939
|
+
if (tag === 42) {
|
|
4940
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4941
|
+
while (reader.pos < end2) {
|
|
4942
|
+
message.eyePose.push(reader.float());
|
|
4943
|
+
}
|
|
4944
|
+
continue;
|
|
4945
|
+
}
|
|
4946
|
+
break;
|
|
4947
|
+
}
|
|
4948
|
+
case 6: {
|
|
4949
|
+
if (tag === 53) {
|
|
4950
|
+
message.eyeLid.push(reader.float());
|
|
4951
|
+
continue;
|
|
4952
|
+
}
|
|
4953
|
+
if (tag === 50) {
|
|
4954
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4955
|
+
while (reader.pos < end2) {
|
|
4956
|
+
message.eyeLid.push(reader.float());
|
|
4957
|
+
}
|
|
4958
|
+
continue;
|
|
4959
|
+
}
|
|
4960
|
+
break;
|
|
4961
|
+
}
|
|
4962
|
+
case 7: {
|
|
4963
|
+
if (tag === 61) {
|
|
4964
|
+
message.expression.push(reader.float());
|
|
4965
|
+
continue;
|
|
4966
|
+
}
|
|
4967
|
+
if (tag === 58) {
|
|
4968
|
+
const end2 = reader.uint32() + reader.pos;
|
|
4969
|
+
while (reader.pos < end2) {
|
|
4970
|
+
message.expression.push(reader.float());
|
|
4971
|
+
}
|
|
4972
|
+
continue;
|
|
4973
|
+
}
|
|
4974
|
+
break;
|
|
4975
|
+
}
|
|
4976
|
+
}
|
|
4977
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
4978
|
+
break;
|
|
4979
|
+
}
|
|
4980
|
+
reader.skip(tag & 7);
|
|
4981
|
+
}
|
|
4982
|
+
return message;
|
|
4983
|
+
},
|
|
4984
|
+
fromJSON(object) {
|
|
4985
|
+
return {
|
|
4986
|
+
translation: globalThis.Array.isArray(object == null ? void 0 : object.translation) ? object.translation.map((e) => globalThis.Number(e)) : [],
|
|
4987
|
+
rotation: globalThis.Array.isArray(object == null ? void 0 : object.rotation) ? object.rotation.map((e) => globalThis.Number(e)) : [],
|
|
4988
|
+
neckPose: globalThis.Array.isArray(object == null ? void 0 : object.neckPose) ? object.neckPose.map((e) => globalThis.Number(e)) : [],
|
|
4989
|
+
jawPose: globalThis.Array.isArray(object == null ? void 0 : object.jawPose) ? object.jawPose.map((e) => globalThis.Number(e)) : [],
|
|
4990
|
+
eyePose: globalThis.Array.isArray(object == null ? void 0 : object.eyePose) ? object.eyePose.map((e) => globalThis.Number(e)) : [],
|
|
4991
|
+
eyeLid: globalThis.Array.isArray(object == null ? void 0 : object.eyeLid) ? object.eyeLid.map((e) => globalThis.Number(e)) : [],
|
|
4992
|
+
expression: globalThis.Array.isArray(object == null ? void 0 : object.expression) ? object.expression.map((e) => globalThis.Number(e)) : []
|
|
4993
|
+
};
|
|
4994
|
+
},
|
|
4995
|
+
toJSON(message) {
|
|
4996
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
4997
|
+
const obj = {};
|
|
4998
|
+
if ((_a = message.translation) == null ? void 0 : _a.length) {
|
|
4999
|
+
obj.translation = message.translation;
|
|
5000
|
+
}
|
|
5001
|
+
if ((_b = message.rotation) == null ? void 0 : _b.length) {
|
|
5002
|
+
obj.rotation = message.rotation;
|
|
5003
|
+
}
|
|
5004
|
+
if ((_c = message.neckPose) == null ? void 0 : _c.length) {
|
|
5005
|
+
obj.neckPose = message.neckPose;
|
|
5006
|
+
}
|
|
5007
|
+
if ((_d = message.jawPose) == null ? void 0 : _d.length) {
|
|
5008
|
+
obj.jawPose = message.jawPose;
|
|
5009
|
+
}
|
|
5010
|
+
if ((_e = message.eyePose) == null ? void 0 : _e.length) {
|
|
5011
|
+
obj.eyePose = message.eyePose;
|
|
5012
|
+
}
|
|
5013
|
+
if ((_f = message.eyeLid) == null ? void 0 : _f.length) {
|
|
5014
|
+
obj.eyeLid = message.eyeLid;
|
|
5015
|
+
}
|
|
5016
|
+
if ((_g = message.expression) == null ? void 0 : _g.length) {
|
|
5017
|
+
obj.expression = message.expression;
|
|
5018
|
+
}
|
|
5019
|
+
return obj;
|
|
5020
|
+
},
|
|
5021
|
+
create(base) {
|
|
5022
|
+
return Flame.fromPartial(base ?? {});
|
|
5023
|
+
},
|
|
5024
|
+
fromPartial(object) {
|
|
5025
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
5026
|
+
const message = createBaseFlame();
|
|
5027
|
+
message.translation = ((_a = object.translation) == null ? void 0 : _a.map((e) => e)) || [];
|
|
5028
|
+
message.rotation = ((_b = object.rotation) == null ? void 0 : _b.map((e) => e)) || [];
|
|
5029
|
+
message.neckPose = ((_c = object.neckPose) == null ? void 0 : _c.map((e) => e)) || [];
|
|
5030
|
+
message.jawPose = ((_d = object.jawPose) == null ? void 0 : _d.map((e) => e)) || [];
|
|
5031
|
+
message.eyePose = ((_e = object.eyePose) == null ? void 0 : _e.map((e) => e)) || [];
|
|
5032
|
+
message.eyeLid = ((_f = object.eyeLid) == null ? void 0 : _f.map((e) => e)) || [];
|
|
5033
|
+
message.expression = ((_g = object.expression) == null ? void 0 : _g.map((e) => e)) || [];
|
|
5034
|
+
return message;
|
|
5035
|
+
}
|
|
5036
|
+
};
|
|
5037
|
+
function createBaseFlameAnimation() {
|
|
5038
|
+
return { keyframes: [] };
|
|
5039
|
+
}
|
|
5040
|
+
const FlameAnimation = {
|
|
5041
|
+
encode(message, writer = new BinaryWriter()) {
|
|
5042
|
+
for (const v of message.keyframes) {
|
|
5043
|
+
Flame.encode(v, writer.uint32(10).fork()).join();
|
|
5044
|
+
}
|
|
5045
|
+
return writer;
|
|
5046
|
+
},
|
|
5047
|
+
decode(input, length) {
|
|
5048
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
5049
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
5050
|
+
const message = createBaseFlameAnimation();
|
|
5051
|
+
while (reader.pos < end) {
|
|
5052
|
+
const tag = reader.uint32();
|
|
5053
|
+
switch (tag >>> 3) {
|
|
5054
|
+
case 1: {
|
|
5055
|
+
if (tag !== 10) {
|
|
5056
|
+
break;
|
|
5057
|
+
}
|
|
5058
|
+
message.keyframes.push(Flame.decode(reader, reader.uint32()));
|
|
5059
|
+
continue;
|
|
5060
|
+
}
|
|
5061
|
+
}
|
|
5062
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5063
|
+
break;
|
|
5064
|
+
}
|
|
5065
|
+
reader.skip(tag & 7);
|
|
5066
|
+
}
|
|
5067
|
+
return message;
|
|
5068
|
+
},
|
|
5069
|
+
fromJSON(object) {
|
|
5070
|
+
return {
|
|
5071
|
+
keyframes: globalThis.Array.isArray(object == null ? void 0 : object.keyframes) ? object.keyframes.map((e) => Flame.fromJSON(e)) : []
|
|
5072
|
+
};
|
|
5073
|
+
},
|
|
5074
|
+
toJSON(message) {
|
|
5075
|
+
var _a;
|
|
5076
|
+
const obj = {};
|
|
5077
|
+
if ((_a = message.keyframes) == null ? void 0 : _a.length) {
|
|
5078
|
+
obj.keyframes = message.keyframes.map((e) => Flame.toJSON(e));
|
|
5079
|
+
}
|
|
5080
|
+
return obj;
|
|
5081
|
+
},
|
|
5082
|
+
create(base) {
|
|
5083
|
+
return FlameAnimation.fromPartial(base ?? {});
|
|
5084
|
+
},
|
|
5085
|
+
fromPartial(object) {
|
|
5086
|
+
var _a;
|
|
5087
|
+
const message = createBaseFlameAnimation();
|
|
5088
|
+
message.keyframes = ((_a = object.keyframes) == null ? void 0 : _a.map((e) => Flame.fromPartial(e))) || [];
|
|
5089
|
+
return message;
|
|
5090
|
+
}
|
|
5091
|
+
};
|
|
5092
|
+
function createBaseServerResponseAnimation() {
|
|
5093
|
+
return { connectionId: "", reqId: "", end: false, animation: void 0 };
|
|
5094
|
+
}
|
|
5095
|
+
const ServerResponseAnimation = {
|
|
5096
|
+
encode(message, writer = new BinaryWriter()) {
|
|
5097
|
+
if (message.connectionId !== "") {
|
|
5098
|
+
writer.uint32(10).string(message.connectionId);
|
|
5099
|
+
}
|
|
5100
|
+
if (message.reqId !== "") {
|
|
5101
|
+
writer.uint32(18).string(message.reqId);
|
|
5102
|
+
}
|
|
5103
|
+
if (message.end !== false) {
|
|
5104
|
+
writer.uint32(24).bool(message.end);
|
|
5105
|
+
}
|
|
5106
|
+
if (message.animation !== void 0) {
|
|
5107
|
+
FlameAnimation.encode(message.animation, writer.uint32(34).fork()).join();
|
|
5108
|
+
}
|
|
5109
|
+
return writer;
|
|
5110
|
+
},
|
|
5111
|
+
decode(input, length) {
|
|
5112
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
5113
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
5114
|
+
const message = createBaseServerResponseAnimation();
|
|
5115
|
+
while (reader.pos < end) {
|
|
5116
|
+
const tag = reader.uint32();
|
|
5117
|
+
switch (tag >>> 3) {
|
|
5118
|
+
case 1: {
|
|
5119
|
+
if (tag !== 10) {
|
|
5120
|
+
break;
|
|
5121
|
+
}
|
|
5122
|
+
message.connectionId = reader.string();
|
|
5123
|
+
continue;
|
|
5124
|
+
}
|
|
5125
|
+
case 2: {
|
|
5126
|
+
if (tag !== 18) {
|
|
5127
|
+
break;
|
|
5128
|
+
}
|
|
5129
|
+
message.reqId = reader.string();
|
|
5130
|
+
continue;
|
|
5131
|
+
}
|
|
5132
|
+
case 3: {
|
|
5133
|
+
if (tag !== 24) {
|
|
5134
|
+
break;
|
|
5135
|
+
}
|
|
5136
|
+
message.end = reader.bool();
|
|
5137
|
+
continue;
|
|
5138
|
+
}
|
|
5139
|
+
case 4: {
|
|
5140
|
+
if (tag !== 34) {
|
|
5141
|
+
break;
|
|
5142
|
+
}
|
|
5143
|
+
message.animation = FlameAnimation.decode(reader, reader.uint32());
|
|
5144
|
+
continue;
|
|
5145
|
+
}
|
|
5146
|
+
}
|
|
5147
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5148
|
+
break;
|
|
5149
|
+
}
|
|
5150
|
+
reader.skip(tag & 7);
|
|
5151
|
+
}
|
|
5152
|
+
return message;
|
|
5153
|
+
},
|
|
5154
|
+
fromJSON(object) {
|
|
5155
|
+
return {
|
|
5156
|
+
connectionId: isSet(object.connectionId) ? globalThis.String(object.connectionId) : "",
|
|
5157
|
+
reqId: isSet(object.reqId) ? globalThis.String(object.reqId) : "",
|
|
5158
|
+
end: isSet(object.end) ? globalThis.Boolean(object.end) : false,
|
|
5159
|
+
animation: isSet(object.animation) ? FlameAnimation.fromJSON(object.animation) : void 0
|
|
5160
|
+
};
|
|
5161
|
+
},
|
|
5162
|
+
toJSON(message) {
|
|
5163
|
+
const obj = {};
|
|
5164
|
+
if (message.connectionId !== "") {
|
|
5165
|
+
obj.connectionId = message.connectionId;
|
|
5166
|
+
}
|
|
5167
|
+
if (message.reqId !== "") {
|
|
5168
|
+
obj.reqId = message.reqId;
|
|
5169
|
+
}
|
|
5170
|
+
if (message.end !== false) {
|
|
5171
|
+
obj.end = message.end;
|
|
5172
|
+
}
|
|
5173
|
+
if (message.animation !== void 0) {
|
|
5174
|
+
obj.animation = FlameAnimation.toJSON(message.animation);
|
|
5175
|
+
}
|
|
5176
|
+
return obj;
|
|
5177
|
+
},
|
|
5178
|
+
create(base) {
|
|
5179
|
+
return ServerResponseAnimation.fromPartial(base ?? {});
|
|
5180
|
+
},
|
|
5181
|
+
fromPartial(object) {
|
|
5182
|
+
const message = createBaseServerResponseAnimation();
|
|
5183
|
+
message.connectionId = object.connectionId ?? "";
|
|
5184
|
+
message.reqId = object.reqId ?? "";
|
|
5185
|
+
message.end = object.end ?? false;
|
|
5186
|
+
message.animation = object.animation !== void 0 && object.animation !== null ? FlameAnimation.fromPartial(object.animation) : void 0;
|
|
5187
|
+
return message;
|
|
5188
|
+
}
|
|
5189
|
+
};
|
|
5190
|
+
function createBaseMessage() {
|
|
5191
|
+
return {
|
|
5192
|
+
type: 0,
|
|
5193
|
+
clientConfigureSession: void 0,
|
|
5194
|
+
serverConfirmSession: void 0,
|
|
5195
|
+
clientAudioInput: void 0,
|
|
5196
|
+
serverError: void 0,
|
|
5197
|
+
serverResponseAnimation: void 0
|
|
5198
|
+
};
|
|
5199
|
+
}
|
|
5200
|
+
const Message = {
|
|
5201
|
+
encode(message, writer = new BinaryWriter()) {
|
|
5202
|
+
if (message.type !== 0) {
|
|
5203
|
+
writer.uint32(8).int32(message.type);
|
|
5204
|
+
}
|
|
5205
|
+
if (message.clientConfigureSession !== void 0) {
|
|
5206
|
+
ClientConfigureSession.encode(message.clientConfigureSession, writer.uint32(18).fork()).join();
|
|
5207
|
+
}
|
|
5208
|
+
if (message.serverConfirmSession !== void 0) {
|
|
5209
|
+
ServerConfirmSession.encode(message.serverConfirmSession, writer.uint32(26).fork()).join();
|
|
5210
|
+
}
|
|
5211
|
+
if (message.clientAudioInput !== void 0) {
|
|
5212
|
+
ClientAudioInput.encode(message.clientAudioInput, writer.uint32(34).fork()).join();
|
|
5213
|
+
}
|
|
5214
|
+
if (message.serverError !== void 0) {
|
|
5215
|
+
ServerError.encode(message.serverError, writer.uint32(42).fork()).join();
|
|
5216
|
+
}
|
|
5217
|
+
if (message.serverResponseAnimation !== void 0) {
|
|
5218
|
+
ServerResponseAnimation.encode(message.serverResponseAnimation, writer.uint32(50).fork()).join();
|
|
5219
|
+
}
|
|
5220
|
+
return writer;
|
|
5221
|
+
},
|
|
5222
|
+
decode(input, length) {
|
|
5223
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
5224
|
+
let end = length === void 0 ? reader.len : reader.pos + length;
|
|
5225
|
+
const message = createBaseMessage();
|
|
5226
|
+
while (reader.pos < end) {
|
|
5227
|
+
const tag = reader.uint32();
|
|
5228
|
+
switch (tag >>> 3) {
|
|
5229
|
+
case 1: {
|
|
5230
|
+
if (tag !== 8) {
|
|
5231
|
+
break;
|
|
5232
|
+
}
|
|
5233
|
+
message.type = reader.int32();
|
|
5234
|
+
continue;
|
|
5235
|
+
}
|
|
5236
|
+
case 2: {
|
|
5237
|
+
if (tag !== 18) {
|
|
5238
|
+
break;
|
|
5239
|
+
}
|
|
5240
|
+
message.clientConfigureSession = ClientConfigureSession.decode(reader, reader.uint32());
|
|
5241
|
+
continue;
|
|
5242
|
+
}
|
|
5243
|
+
case 3: {
|
|
5244
|
+
if (tag !== 26) {
|
|
5245
|
+
break;
|
|
5246
|
+
}
|
|
5247
|
+
message.serverConfirmSession = ServerConfirmSession.decode(reader, reader.uint32());
|
|
5248
|
+
continue;
|
|
5249
|
+
}
|
|
5250
|
+
case 4: {
|
|
5251
|
+
if (tag !== 34) {
|
|
5252
|
+
break;
|
|
5253
|
+
}
|
|
5254
|
+
message.clientAudioInput = ClientAudioInput.decode(reader, reader.uint32());
|
|
5255
|
+
continue;
|
|
5256
|
+
}
|
|
5257
|
+
case 5: {
|
|
5258
|
+
if (tag !== 42) {
|
|
5259
|
+
break;
|
|
5260
|
+
}
|
|
5261
|
+
message.serverError = ServerError.decode(reader, reader.uint32());
|
|
5262
|
+
continue;
|
|
5263
|
+
}
|
|
5264
|
+
case 6: {
|
|
5265
|
+
if (tag !== 50) {
|
|
5266
|
+
break;
|
|
5267
|
+
}
|
|
5268
|
+
message.serverResponseAnimation = ServerResponseAnimation.decode(reader, reader.uint32());
|
|
5269
|
+
continue;
|
|
5270
|
+
}
|
|
4286
5271
|
}
|
|
4287
|
-
|
|
4288
|
-
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
reason: errorMessage,
|
|
4292
|
-
stage: "sdk_init"
|
|
4293
|
-
});
|
|
4294
|
-
throw new Error(`SDK initialization failed: Template resources loading failed - ${errorMessage}`);
|
|
5272
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
5273
|
+
break;
|
|
5274
|
+
}
|
|
5275
|
+
reader.skip(tag & 7);
|
|
4295
5276
|
}
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4300
|
-
|
|
4301
|
-
|
|
4302
|
-
|
|
4303
|
-
|
|
4304
|
-
|
|
4305
|
-
|
|
4306
|
-
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
static get sessionToken() {
|
|
4313
|
-
return idManager.getSessionToken();
|
|
4314
|
-
}
|
|
4315
|
-
static get userId() {
|
|
4316
|
-
return idManager.getUserId();
|
|
4317
|
-
}
|
|
4318
|
-
static get version() {
|
|
4319
|
-
return this._version;
|
|
4320
|
-
}
|
|
4321
|
-
static getPlaybackMode() {
|
|
4322
|
-
var _a;
|
|
4323
|
-
return ((_a = this._configuration) == null ? void 0 : _a.drivingServiceMode) ?? DrivingServiceMode.sdk;
|
|
4324
|
-
}
|
|
4325
|
-
static getAvatarCore() {
|
|
4326
|
-
return this._avatarCore;
|
|
4327
|
-
}
|
|
4328
|
-
static cleanup() {
|
|
4329
|
-
if (!this._isInitialized) {
|
|
4330
|
-
return;
|
|
5277
|
+
return message;
|
|
5278
|
+
},
|
|
5279
|
+
fromJSON(object) {
|
|
5280
|
+
return {
|
|
5281
|
+
type: isSet(object.type) ? messageTypeFromJSON(object.type) : 0,
|
|
5282
|
+
clientConfigureSession: isSet(object.clientConfigureSession) ? ClientConfigureSession.fromJSON(object.clientConfigureSession) : void 0,
|
|
5283
|
+
serverConfirmSession: isSet(object.serverConfirmSession) ? ServerConfirmSession.fromJSON(object.serverConfirmSession) : void 0,
|
|
5284
|
+
clientAudioInput: isSet(object.clientAudioInput) ? ClientAudioInput.fromJSON(object.clientAudioInput) : void 0,
|
|
5285
|
+
serverError: isSet(object.serverError) ? ServerError.fromJSON(object.serverError) : void 0,
|
|
5286
|
+
serverResponseAnimation: isSet(object.serverResponseAnimation) ? ServerResponseAnimation.fromJSON(object.serverResponseAnimation) : void 0
|
|
5287
|
+
};
|
|
5288
|
+
},
|
|
5289
|
+
toJSON(message) {
|
|
5290
|
+
const obj = {};
|
|
5291
|
+
if (message.type !== 0) {
|
|
5292
|
+
obj.type = messageTypeToJSON(message.type);
|
|
4331
5293
|
}
|
|
4332
|
-
|
|
4333
|
-
|
|
4334
|
-
if (this._avatarCore) {
|
|
4335
|
-
this._avatarCore.release();
|
|
4336
|
-
this._avatarCore = null;
|
|
4337
|
-
}
|
|
4338
|
-
this._configuration = null;
|
|
4339
|
-
this._dynamicSdkConfig = null;
|
|
4340
|
-
this._isInitialized = false;
|
|
4341
|
-
idManager.clear();
|
|
4342
|
-
clearSdkConfigCache();
|
|
4343
|
-
cleanupCLS();
|
|
4344
|
-
logger.log("[AvatarSDK] Cleanup completed");
|
|
4345
|
-
} catch (error) {
|
|
4346
|
-
logger.error("Failed to cleanup AvatarSDK:", error instanceof Error ? error.message : String(error));
|
|
5294
|
+
if (message.clientConfigureSession !== void 0) {
|
|
5295
|
+
obj.clientConfigureSession = ClientConfigureSession.toJSON(message.clientConfigureSession);
|
|
4347
5296
|
}
|
|
4348
|
-
|
|
4349
|
-
|
|
4350
|
-
try {
|
|
4351
|
-
this._dynamicSdkConfig = await fetchSdkConfig(this._version);
|
|
4352
|
-
} catch (error) {
|
|
4353
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
4354
|
-
logger.warn("Failed to fetch SDK config from remote, using defaults:", message);
|
|
4355
|
-
logEvent("sdk_config", "warning", {
|
|
4356
|
-
reason: message
|
|
4357
|
-
});
|
|
5297
|
+
if (message.serverConfirmSession !== void 0) {
|
|
5298
|
+
obj.serverConfirmSession = ServerConfirmSession.toJSON(message.serverConfirmSession);
|
|
4358
5299
|
}
|
|
4359
|
-
|
|
4360
|
-
|
|
4361
|
-
if (!this._configuration) {
|
|
4362
|
-
throw new Error("AvatarSDK not initialized");
|
|
5300
|
+
if (message.clientAudioInput !== void 0) {
|
|
5301
|
+
obj.clientAudioInput = ClientAudioInput.toJSON(message.clientAudioInput);
|
|
4363
5302
|
}
|
|
4364
|
-
if (
|
|
4365
|
-
|
|
5303
|
+
if (message.serverError !== void 0) {
|
|
5304
|
+
obj.serverError = ServerError.toJSON(message.serverError);
|
|
4366
5305
|
}
|
|
4367
|
-
|
|
4368
|
-
|
|
4369
|
-
throw new Error(`No configuration found for environment: ${this._configuration.environment}`);
|
|
5306
|
+
if (message.serverResponseAnimation !== void 0) {
|
|
5307
|
+
obj.serverResponseAnimation = ServerResponseAnimation.toJSON(message.serverResponseAnimation);
|
|
4370
5308
|
}
|
|
4371
|
-
|
|
4372
|
-
|
|
4373
|
-
|
|
4374
|
-
|
|
4375
|
-
|
|
4376
|
-
|
|
5309
|
+
return obj;
|
|
5310
|
+
},
|
|
5311
|
+
create(base) {
|
|
5312
|
+
return Message.fromPartial(base ?? {});
|
|
5313
|
+
},
|
|
5314
|
+
fromPartial(object) {
|
|
5315
|
+
const message = createBaseMessage();
|
|
5316
|
+
message.type = object.type ?? 0;
|
|
5317
|
+
message.clientConfigureSession = object.clientConfigureSession !== void 0 && object.clientConfigureSession !== null ? ClientConfigureSession.fromPartial(object.clientConfigureSession) : void 0;
|
|
5318
|
+
message.serverConfirmSession = object.serverConfirmSession !== void 0 && object.serverConfirmSession !== null ? ServerConfirmSession.fromPartial(object.serverConfirmSession) : void 0;
|
|
5319
|
+
message.clientAudioInput = object.clientAudioInput !== void 0 && object.clientAudioInput !== null ? ClientAudioInput.fromPartial(object.clientAudioInput) : void 0;
|
|
5320
|
+
message.serverError = object.serverError !== void 0 && object.serverError !== null ? ServerError.fromPartial(object.serverError) : void 0;
|
|
5321
|
+
message.serverResponseAnimation = object.serverResponseAnimation !== void 0 && object.serverResponseAnimation !== null ? ServerResponseAnimation.fromPartial(object.serverResponseAnimation) : void 0;
|
|
5322
|
+
return message;
|
|
5323
|
+
}
|
|
5324
|
+
};
|
|
5325
|
+
function bytesFromBase64(b64) {
|
|
5326
|
+
const bin = globalThis.atob(b64);
|
|
5327
|
+
const arr = new Uint8Array(bin.length);
|
|
5328
|
+
for (let i = 0; i < bin.length; ++i) {
|
|
5329
|
+
arr[i] = bin.charCodeAt(i);
|
|
4377
5330
|
}
|
|
5331
|
+
return arr;
|
|
5332
|
+
}
|
|
5333
|
+
function base64FromBytes(arr) {
|
|
5334
|
+
const bin = [];
|
|
5335
|
+
arr.forEach((byte) => {
|
|
5336
|
+
bin.push(globalThis.String.fromCharCode(byte));
|
|
5337
|
+
});
|
|
5338
|
+
return globalThis.btoa(bin.join(""));
|
|
5339
|
+
}
|
|
5340
|
+
function isSet(value) {
|
|
5341
|
+
return value !== null && value !== void 0;
|
|
4378
5342
|
}
|
|
4379
|
-
__publicField(AvatarSDK, "_isInitialized", false);
|
|
4380
|
-
__publicField(AvatarSDK, "_configuration", null);
|
|
4381
|
-
__publicField(AvatarSDK, "_version", "1.0.0-beta.34");
|
|
4382
|
-
__publicField(AvatarSDK, "_avatarCore", null);
|
|
4383
|
-
__publicField(AvatarSDK, "_dynamicSdkConfig", null);
|
|
4384
5343
|
class EventEmitter {
|
|
4385
5344
|
constructor() {
|
|
4386
5345
|
__publicField(this, "events", /* @__PURE__ */ new Map());
|
|
@@ -4428,6 +5387,7 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4428
5387
|
__publicField(this, "isConnecting", false);
|
|
4429
5388
|
__publicField(this, "isManuallyDisconnected", false);
|
|
4430
5389
|
__publicField(this, "reconnectTimer", null);
|
|
5390
|
+
__publicField(this, "sessionConfigured", false);
|
|
4431
5391
|
this.wsUrl = options.wsUrl;
|
|
4432
5392
|
this.reconnectAttempts = options.reconnectAttempts ?? 5;
|
|
4433
5393
|
this.jwtToken = options.jwtToken;
|
|
@@ -4446,6 +5406,7 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4446
5406
|
try {
|
|
4447
5407
|
this.isConnecting = true;
|
|
4448
5408
|
this.currentCharacterId = characterId;
|
|
5409
|
+
this.sessionConfigured = false;
|
|
4449
5410
|
idManager.generateConnectionId();
|
|
4450
5411
|
const url = this.buildWebSocketUrl(characterId);
|
|
4451
5412
|
logger.log("[AnimationWebSocketClient] Connecting to:", url);
|
|
@@ -4473,6 +5434,7 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4473
5434
|
this.currentRetryCount = 0;
|
|
4474
5435
|
this.isConnecting = false;
|
|
4475
5436
|
this.isManuallyDisconnected = true;
|
|
5437
|
+
this.sessionConfigured = false;
|
|
4476
5438
|
if (this.reconnectTimer) {
|
|
4477
5439
|
clearTimeout(this.reconnectTimer);
|
|
4478
5440
|
this.reconnectTimer = null;
|
|
@@ -4484,6 +5446,10 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4484
5446
|
logger.error("[AnimationWebSocketClient] WebSocket not connected");
|
|
4485
5447
|
return false;
|
|
4486
5448
|
}
|
|
5449
|
+
if (!this.sessionConfigured) {
|
|
5450
|
+
logger.error("[AnimationWebSocketClient] Session not configured yet");
|
|
5451
|
+
return false;
|
|
5452
|
+
}
|
|
4487
5453
|
try {
|
|
4488
5454
|
const message = {
|
|
4489
5455
|
type: MessageType.MESSAGE_CLIENT_AUDIO_INPUT,
|
|
@@ -4501,11 +5467,10 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4501
5467
|
} catch (error) {
|
|
4502
5468
|
const message = error instanceof Error ? error.message : String(error);
|
|
4503
5469
|
logger.error("[AnimationWebSocketClient] Failed to send audio data:", message);
|
|
4504
|
-
logEvent("
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
reason: message
|
|
5470
|
+
logEvent("send_audio_failed", "error", {
|
|
5471
|
+
req_id: conversationId || "",
|
|
5472
|
+
con_id: idManager.getConnectionId() || "",
|
|
5473
|
+
description: message
|
|
4509
5474
|
});
|
|
4510
5475
|
this.emit("error", error);
|
|
4511
5476
|
return false;
|
|
@@ -4525,13 +5490,13 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4525
5490
|
url.searchParams.set("id", characterId);
|
|
4526
5491
|
const currentToken = AvatarSDK.sessionToken || this.jwtToken;
|
|
4527
5492
|
if (currentToken) {
|
|
4528
|
-
url.searchParams.set("
|
|
5493
|
+
url.searchParams.set("sessionKey", currentToken);
|
|
4529
5494
|
}
|
|
4530
5495
|
if (this.appId) {
|
|
4531
5496
|
url.searchParams.set("appId", this.appId);
|
|
4532
5497
|
}
|
|
4533
5498
|
if (this.clientId) {
|
|
4534
|
-
url.searchParams.set("
|
|
5499
|
+
url.searchParams.set("deviceId", this.clientId);
|
|
4535
5500
|
}
|
|
4536
5501
|
const connectionId = idManager.getConnectionId();
|
|
4537
5502
|
if (connectionId) {
|
|
@@ -4542,11 +5507,15 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4542
5507
|
connectWebSocket(url) {
|
|
4543
5508
|
return new Promise((resolve2, reject) => {
|
|
4544
5509
|
try {
|
|
5510
|
+
const urlForLog = this.sanitizeUrlForLog(url);
|
|
5511
|
+
logger.log(`[AnimationWebSocketClient] Connecting to WebSocket: ${urlForLog}`);
|
|
4545
5512
|
this.ws = new WebSocket(url);
|
|
4546
5513
|
this.ws.onopen = () => {
|
|
4547
5514
|
this.isConnecting = false;
|
|
4548
5515
|
this.currentRetryCount = 0;
|
|
4549
5516
|
this.isManuallyDisconnected = false;
|
|
5517
|
+
logger.log(`[AnimationWebSocketClient] WebSocket connected successfully`);
|
|
5518
|
+
this.configureSession();
|
|
4550
5519
|
this.emit("connected");
|
|
4551
5520
|
resolve2();
|
|
4552
5521
|
};
|
|
@@ -4568,19 +5537,77 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4568
5537
|
}
|
|
4569
5538
|
};
|
|
4570
5539
|
this.ws.onerror = (error) => {
|
|
4571
|
-
|
|
5540
|
+
var _a;
|
|
5541
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5542
|
+
const readyState = (_a = this.ws) == null ? void 0 : _a.readyState;
|
|
5543
|
+
const readyStateText = readyState === WebSocket.CONNECTING ? "CONNECTING" : readyState === WebSocket.OPEN ? "OPEN" : readyState === WebSocket.CLOSING ? "CLOSING" : readyState === WebSocket.CLOSED ? "CLOSED" : "UNKNOWN";
|
|
5544
|
+
const errorDetails = `ReadyState: ${readyState} (${readyStateText}), URL: ${urlForLog}, Error: ${errorMessage}`;
|
|
5545
|
+
logger.error("[AnimationWebSocketClient] WebSocket error:", errorDetails);
|
|
5546
|
+
if (readyState === WebSocket.CLOSED) {
|
|
5547
|
+
logger.warn("[AnimationWebSocketClient] Connection failed immediately. Possible causes:");
|
|
5548
|
+
logger.warn(" 1. Server may not support v2 protocol yet");
|
|
5549
|
+
logger.warn(" 2. Incorrect URL path or server configuration");
|
|
5550
|
+
logger.warn(" 3. Authentication or authorization issue");
|
|
5551
|
+
logger.warn(" 4. Network/firewall blocking the connection");
|
|
5552
|
+
logger.warn(` Please check browser Network tab for detailed error information`);
|
|
5553
|
+
}
|
|
4572
5554
|
logEvent("character_animation_service", "error", {
|
|
4573
5555
|
characterId: this.currentCharacterId,
|
|
4574
|
-
event: "websocket_error"
|
|
5556
|
+
event: "websocket_error",
|
|
5557
|
+
reason: `ReadyState: ${readyState} (${readyStateText}), URL: ${urlForLog}`
|
|
4575
5558
|
});
|
|
4576
|
-
this.emit("error", new Error(
|
|
5559
|
+
this.emit("error", new Error(`WebSocket error (readyState: ${readyState})`));
|
|
4577
5560
|
if (!this.isManuallyDisconnected && this.currentRetryCount < this.reconnectAttempts) {
|
|
4578
5561
|
this.scheduleReconnect();
|
|
4579
5562
|
}
|
|
4580
5563
|
};
|
|
4581
5564
|
this.ws.onclose = (event) => {
|
|
4582
|
-
|
|
5565
|
+
const closeDetails = {
|
|
5566
|
+
code: event.code,
|
|
5567
|
+
reason: event.reason || "(no reason)",
|
|
5568
|
+
wasClean: event.wasClean,
|
|
5569
|
+
url: urlForLog
|
|
5570
|
+
};
|
|
5571
|
+
logger.log("[AnimationWebSocketClient] WebSocket closed:", closeDetails);
|
|
4583
5572
|
this.emit("disconnected", event.reason || "Connection closed");
|
|
5573
|
+
this.sessionConfigured = false;
|
|
5574
|
+
let sdkErrorCode = null;
|
|
5575
|
+
const reason = event.reason || "";
|
|
5576
|
+
const reasonLower = reason.toLowerCase();
|
|
5577
|
+
if (event.code === 1008 || reasonLower.includes("401") || reasonLower.includes("unauth") || reasonLower.includes("expired") || reasonLower.includes("token expired")) {
|
|
5578
|
+
sdkErrorCode = ErrorCode.sessionTokenExpired;
|
|
5579
|
+
logEvent("session_token_expired", "warning", {
|
|
5580
|
+
con_id: idManager.getConnectionId() || "",
|
|
5581
|
+
description: reason || "Session token expired"
|
|
5582
|
+
});
|
|
5583
|
+
} else if (reasonLower.includes("400") || reasonLower.includes("invalid") || reasonLower.includes("bad request")) {
|
|
5584
|
+
sdkErrorCode = ErrorCode.sessionTokenInvalid;
|
|
5585
|
+
logEvent("session_token_invalid", "warning", {
|
|
5586
|
+
con_id: idManager.getConnectionId() || "",
|
|
5587
|
+
description: reason || "Session token invalid"
|
|
5588
|
+
});
|
|
5589
|
+
} else if (reasonLower.includes("404") || reasonLower.includes("notfound") || reasonLower.includes("not found")) {
|
|
5590
|
+
sdkErrorCode = ErrorCode.avatarIDUnrecognized;
|
|
5591
|
+
logEvent("avatar_id_unrecognized", "error", {
|
|
5592
|
+
avatar_id: this.currentCharacterId || "",
|
|
5593
|
+
description: reason || "Avatar ID unrecognized"
|
|
5594
|
+
});
|
|
5595
|
+
}
|
|
5596
|
+
if (sdkErrorCode) {
|
|
5597
|
+
const error = new SPAvatarError(
|
|
5598
|
+
reason || `WebSocket connection failed with code ${event.code}`,
|
|
5599
|
+
sdkErrorCode
|
|
5600
|
+
);
|
|
5601
|
+
this.emit("error", error);
|
|
5602
|
+
}
|
|
5603
|
+
if (event.code === 1006) {
|
|
5604
|
+
logger.warn("[AnimationWebSocketClient] Connection closed abnormally (1006) - possible causes: network issue, server rejection, or protocol mismatch");
|
|
5605
|
+
logEvent("character_animation_service", "warning", {
|
|
5606
|
+
characterId: this.currentCharacterId,
|
|
5607
|
+
event: "websocket_abnormal_close",
|
|
5608
|
+
reason: `Code: ${event.code}, URL: ${urlForLog}`
|
|
5609
|
+
});
|
|
5610
|
+
}
|
|
4584
5611
|
if (event.code === 1012) {
|
|
4585
5612
|
logEvent("service_restarted", "warning", {
|
|
4586
5613
|
con_id: idManager.getConnectionId() || "",
|
|
@@ -4593,21 +5620,83 @@ class AnimationWebSocketClient extends EventEmitter {
|
|
|
4593
5620
|
};
|
|
4594
5621
|
} catch (error) {
|
|
4595
5622
|
this.isConnecting = false;
|
|
5623
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
5624
|
+
logger.error("[AnimationWebSocketClient] Failed to create WebSocket:", errorMessage);
|
|
4596
5625
|
reject(error);
|
|
4597
5626
|
}
|
|
4598
5627
|
});
|
|
4599
5628
|
}
|
|
5629
|
+
sanitizeUrlForLog(url) {
|
|
5630
|
+
try {
|
|
5631
|
+
const urlObj = new URL(url);
|
|
5632
|
+
if (urlObj.searchParams.has("sessionKey")) {
|
|
5633
|
+
const sessionKey = urlObj.searchParams.get("sessionKey") || "";
|
|
5634
|
+
urlObj.searchParams.set("sessionKey", sessionKey.length > 10 ? `${sessionKey.substring(0, 10)}...` : "***");
|
|
5635
|
+
}
|
|
5636
|
+
if (urlObj.searchParams.has("token")) {
|
|
5637
|
+
const token = urlObj.searchParams.get("token") || "";
|
|
5638
|
+
urlObj.searchParams.set("token", token.length > 10 ? `${token.substring(0, 10)}...` : "***");
|
|
5639
|
+
}
|
|
5640
|
+
return urlObj.toString();
|
|
5641
|
+
} catch {
|
|
5642
|
+
return url.length > 100 ? `${url.substring(0, 100)}...` : url;
|
|
5643
|
+
}
|
|
5644
|
+
}
|
|
5645
|
+
configureSession() {
|
|
5646
|
+
if (!this.ws || this.ws.readyState !== WebSocket.OPEN) {
|
|
5647
|
+
logger.error("[AnimationWebSocketClient] Cannot configure session: WebSocket not open");
|
|
5648
|
+
return;
|
|
5649
|
+
}
|
|
5650
|
+
try {
|
|
5651
|
+
const audioFormatConfig = AvatarSDK.getAudioFormat();
|
|
5652
|
+
const message = {
|
|
5653
|
+
type: MessageType.MESSAGE_CLIENT_CONFIGURE_SESSION,
|
|
5654
|
+
clientConfigureSession: {
|
|
5655
|
+
sampleRate: audioFormatConfig.sampleRate,
|
|
5656
|
+
bitrate: 0,
|
|
5657
|
+
audioFormat: AudioFormat.AUDIO_FORMAT_PCM_S16LE,
|
|
5658
|
+
transportCompression: TransportCompression.TRANSPORT_COMPRESSION_NONE
|
|
5659
|
+
}
|
|
5660
|
+
};
|
|
5661
|
+
const writer = new BinaryWriter();
|
|
5662
|
+
Message.encode(message, writer);
|
|
5663
|
+
const bytes = writer.finish();
|
|
5664
|
+
this.ws.send(bytes);
|
|
5665
|
+
logger.log(`[AnimationWebSocketClient] Session configuration sent (sampleRate: ${audioFormatConfig.sampleRate})`);
|
|
5666
|
+
} catch (error) {
|
|
5667
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
5668
|
+
logger.error("[AnimationWebSocketClient] Failed to configure session:", message);
|
|
5669
|
+
logEvent("configure_session_failed", "error", {
|
|
5670
|
+
description: message
|
|
5671
|
+
});
|
|
5672
|
+
this.emit("error", error);
|
|
5673
|
+
}
|
|
5674
|
+
}
|
|
4600
5675
|
handleMessage(data) {
|
|
4601
5676
|
try {
|
|
4602
5677
|
const reader = new BinaryReader(new Uint8Array(data));
|
|
4603
5678
|
const message = Message.decode(reader);
|
|
4604
|
-
if (message.
|
|
4605
|
-
|
|
4606
|
-
|
|
5679
|
+
if (message.type === MessageType.MESSAGE_SERVER_CONFIRM_SESSION) {
|
|
5680
|
+
if (message.serverConfirmSession) {
|
|
5681
|
+
this.sessionConfigured = true;
|
|
5682
|
+
const connectionId = message.serverConfirmSession.connectionId;
|
|
5683
|
+
if (connectionId) {
|
|
5684
|
+
idManager.setConnectionId(connectionId);
|
|
5685
|
+
logger.log(`[AnimationWebSocketClient] Session confirmed, connection_id updated: ${connectionId}`);
|
|
5686
|
+
} else {
|
|
5687
|
+
logger.log("[AnimationWebSocketClient] Session confirmed by server");
|
|
5688
|
+
}
|
|
5689
|
+
this.emit("sessionConfirmed", connectionId);
|
|
5690
|
+
return;
|
|
5691
|
+
}
|
|
5692
|
+
}
|
|
5693
|
+
if (message.serverError) {
|
|
5694
|
+
logger.error(`[AnimationWebSocketClient] Server error: reqId=${message.serverError.reqId}, code=${message.serverError.code}, message=${message.serverError.message}`);
|
|
5695
|
+
this.emit("error", new Error(message.serverError.message || "Server error"));
|
|
4607
5696
|
return;
|
|
4608
5697
|
}
|
|
4609
|
-
if (message.type === MessageType.
|
|
4610
|
-
logger.warn("[AnimationWebSocketClient]
|
|
5698
|
+
if (message.type === MessageType.MESSAGE_SERVER_ERROR) {
|
|
5699
|
+
logger.warn("[AnimationWebSocketClient] MESSAGE_SERVER_ERROR received but no error field in message");
|
|
4611
5700
|
logEvent("character_animation_service", "warning", {
|
|
4612
5701
|
characterId: this.currentCharacterId,
|
|
4613
5702
|
event: "message_error_without_payload"
|
|
@@ -4644,7 +5733,6 @@ class NetworkLayer {
|
|
|
4644
5733
|
__publicField(this, "wsClient");
|
|
4645
5734
|
__publicField(this, "dataController");
|
|
4646
5735
|
__publicField(this, "currentConversationId", null);
|
|
4647
|
-
__publicField(this, "audioBytesPerSecond", APP_CONFIG.audio.sampleRate * 2);
|
|
4648
5736
|
__publicField(this, "audioMetrics", this.createAudioMetrics());
|
|
4649
5737
|
__publicField(this, "isFallbackMode", false);
|
|
4650
5738
|
__publicField(this, "isConnecting", false);
|
|
@@ -4659,6 +5747,10 @@ class NetworkLayer {
|
|
|
4659
5747
|
});
|
|
4660
5748
|
this.setupWebSocketListeners();
|
|
4661
5749
|
}
|
|
5750
|
+
getAudioBytesPerSecond() {
|
|
5751
|
+
const audioFormat = AvatarSDK.getAudioFormat();
|
|
5752
|
+
return audioFormat.sampleRate * 2;
|
|
5753
|
+
}
|
|
4662
5754
|
async connect(characterId) {
|
|
4663
5755
|
var _a, _b, _c, _d;
|
|
4664
5756
|
if (this.isConnecting) {
|
|
@@ -4733,7 +5825,7 @@ class NetworkLayer {
|
|
|
4733
5825
|
shouldReportMetrics = true;
|
|
4734
5826
|
}
|
|
4735
5827
|
metrics.accumulatedBytes += audioData.byteLength;
|
|
4736
|
-
const currentDuration = metrics.accumulatedBytes / this.
|
|
5828
|
+
const currentDuration = metrics.accumulatedBytes / this.getAudioBytesPerSecond();
|
|
4737
5829
|
if (currentDuration >= 2 && metrics.tap2Timestamp === 0) {
|
|
4738
5830
|
metrics.tap2Timestamp = Date.now();
|
|
4739
5831
|
metrics.cachedTap2Timestamp = String(metrics.tap2Timestamp);
|
|
@@ -4791,6 +5883,13 @@ class NetworkLayer {
|
|
|
4791
5883
|
}
|
|
4792
5884
|
setupWebSocketListeners() {
|
|
4793
5885
|
this.wsClient.removeAllListeners();
|
|
5886
|
+
this.wsClient.on("sessionConfirmed", (connectionId) => {
|
|
5887
|
+
if (connectionId) {
|
|
5888
|
+
logger.log(`[NetworkLayer] Session confirmed, connection_id: ${connectionId}, ready to send audio`);
|
|
5889
|
+
} else {
|
|
5890
|
+
logger.log("[NetworkLayer] Session confirmed, ready to send audio");
|
|
5891
|
+
}
|
|
5892
|
+
});
|
|
4794
5893
|
this.wsClient.on("connected", () => {
|
|
4795
5894
|
var _a, _b;
|
|
4796
5895
|
this.isFallbackMode = false;
|
|
@@ -4835,7 +5934,7 @@ class NetworkLayer {
|
|
|
4835
5934
|
case MessageType.MESSAGE_SERVER_RESPONSE_ANIMATION:
|
|
4836
5935
|
this.handleAnimationMessage(message);
|
|
4837
5936
|
break;
|
|
4838
|
-
case MessageType.
|
|
5937
|
+
case MessageType.MESSAGE_SERVER_ERROR:
|
|
4839
5938
|
this.handleErrorMessage(message);
|
|
4840
5939
|
break;
|
|
4841
5940
|
}
|
|
@@ -4899,42 +5998,43 @@ class NetworkLayer {
|
|
|
4899
5998
|
}
|
|
4900
5999
|
}
|
|
4901
6000
|
handleErrorMessage(message) {
|
|
4902
|
-
var _a, _b
|
|
4903
|
-
if (!message.
|
|
4904
|
-
logger.warn("[NetworkLayer]
|
|
4905
|
-
if (message.serverResponseAnimation) {
|
|
4906
|
-
logger.warn("[NetworkLayer] MESSAGE_ERROR contains animation data, treating as animation message");
|
|
4907
|
-
logEvent("character_manager", "warning", {
|
|
4908
|
-
characterId: this.dataController.getAvatarId(),
|
|
4909
|
-
event: "message_error_with_payload"
|
|
4910
|
-
});
|
|
4911
|
-
this.handleAnimationMessage(message);
|
|
4912
|
-
}
|
|
6001
|
+
var _a, _b;
|
|
6002
|
+
if (!message.serverError) {
|
|
6003
|
+
logger.warn("[NetworkLayer] MESSAGE_SERVER_ERROR received but message.serverError is empty");
|
|
4913
6004
|
return;
|
|
4914
6005
|
}
|
|
4915
|
-
const conversationId = message.
|
|
4916
|
-
logger.error(`[NetworkLayer] Server error: conversationId=${conversationId}, code=${message.
|
|
6006
|
+
const conversationId = message.serverError.reqId || this.currentConversationId || "";
|
|
6007
|
+
logger.error(`[NetworkLayer] Server error: conversationId=${conversationId}, code=${message.serverError.code}, message=${message.serverError.message}`);
|
|
4917
6008
|
logEvent("message_error", "error", {
|
|
4918
6009
|
req_id: conversationId,
|
|
4919
6010
|
con_id: idManager.getConnectionId() || "",
|
|
4920
|
-
description: message.
|
|
6011
|
+
description: message.serverError.message || `Server error: code=${message.serverError.code}`
|
|
4921
6012
|
});
|
|
4922
|
-
const
|
|
4923
|
-
|
|
4924
|
-
|
|
6013
|
+
const httpStatusCode = message.serverError.code;
|
|
6014
|
+
const errorCodeStr = (httpStatusCode == null ? void 0 : httpStatusCode.toString()) ?? "";
|
|
6015
|
+
let sdkErrorCode;
|
|
6016
|
+
let errorMessage = message.serverError.message || "Server error occurred";
|
|
6017
|
+
if (httpStatusCode === 401) {
|
|
6018
|
+
sdkErrorCode = ErrorCode.sessionTokenExpired;
|
|
6019
|
+
logEvent("session_token_expired", "warning", {
|
|
4925
6020
|
con_id: idManager.getConnectionId() || "",
|
|
4926
|
-
description:
|
|
6021
|
+
description: errorMessage
|
|
4927
6022
|
});
|
|
4928
|
-
}
|
|
4929
|
-
|
|
4930
|
-
logEvent("
|
|
6023
|
+
} else if (httpStatusCode === 400) {
|
|
6024
|
+
sdkErrorCode = ErrorCode.sessionTokenInvalid;
|
|
6025
|
+
logEvent("session_token_invalid", "warning", {
|
|
4931
6026
|
con_id: idManager.getConnectionId() || "",
|
|
4932
|
-
description:
|
|
6027
|
+
description: errorMessage
|
|
4933
6028
|
});
|
|
6029
|
+
} else if (httpStatusCode === 404) {
|
|
6030
|
+
sdkErrorCode = ErrorCode.avatarIDUnrecognized;
|
|
6031
|
+
errorMessage = errorMessage || "Avatar ID not recognized";
|
|
6032
|
+
} else {
|
|
6033
|
+
sdkErrorCode = errorCodeStr || "SERVER_ERROR";
|
|
4934
6034
|
}
|
|
4935
|
-
(
|
|
4936
|
-
|
|
4937
|
-
|
|
6035
|
+
(_b = (_a = this.dataController).onError) == null ? void 0 : _b.call(_a, new SPAvatarError(
|
|
6036
|
+
errorMessage,
|
|
6037
|
+
sdkErrorCode
|
|
4938
6038
|
));
|
|
4939
6039
|
if (this.currentConversationId && conversationId === this.currentConversationId) {
|
|
4940
6040
|
logger.warn("[NetworkLayer] Server error for current conversation - triggering audio-only mode via empty animation data");
|
|
@@ -5000,6 +6100,8 @@ class AvatarController {
|
|
|
5000
6100
|
__publicField(this, "keyframesOffset", 0);
|
|
5001
6101
|
__publicField(this, "MAX_KEYFRAMES", 5e3);
|
|
5002
6102
|
__publicField(this, "KEYFRAMES_CLEANUP_THRESHOLD", 3e3);
|
|
6103
|
+
__publicField(this, "lastSyncLogTime", 0);
|
|
6104
|
+
__publicField(this, "lastOutOfBoundsState", false);
|
|
5003
6105
|
__publicField(this, "isAudioOnlyMode", false);
|
|
5004
6106
|
__publicField(this, "hostModeMetrics", {
|
|
5005
6107
|
accumulatedBytes: 0,
|
|
@@ -5044,8 +6146,9 @@ class AvatarController {
|
|
|
5044
6146
|
case AvatarState.active:
|
|
5045
6147
|
return this.isPlaying ? ConversationState.playing : ConversationState.idle;
|
|
5046
6148
|
case AvatarState.playing:
|
|
5047
|
-
case AvatarState.paused:
|
|
5048
6149
|
return ConversationState.playing;
|
|
6150
|
+
case AvatarState.paused:
|
|
6151
|
+
return ConversationState.pausing;
|
|
5049
6152
|
default:
|
|
5050
6153
|
return ConversationState.idle;
|
|
5051
6154
|
}
|
|
@@ -5234,7 +6337,7 @@ class AvatarController {
|
|
|
5234
6337
|
}
|
|
5235
6338
|
try {
|
|
5236
6339
|
const reader = new BinaryReader(binaryData);
|
|
5237
|
-
const message = Message.decode(reader);
|
|
6340
|
+
const message = Message$1.decode(reader);
|
|
5238
6341
|
if ((_b = (_a = message.serverResponseAnimation) == null ? void 0 : _a.animation) == null ? void 0 : _b.keyframes) {
|
|
5239
6342
|
const chunkKeyframes = message.serverResponseAnimation.animation.keyframes;
|
|
5240
6343
|
allKeyframes.push(...chunkKeyframes);
|
|
@@ -5396,6 +6499,8 @@ class AvatarController {
|
|
|
5396
6499
|
this.lastRenderedFrameIndex = -1;
|
|
5397
6500
|
this.keyframesOffset = 0;
|
|
5398
6501
|
this.isAudioOnlyMode = false;
|
|
6502
|
+
this.lastSyncLogTime = 0;
|
|
6503
|
+
this.lastOutOfBoundsState = false;
|
|
5399
6504
|
if (this.playbackMode === DrivingServiceMode.host) {
|
|
5400
6505
|
this.hostModeMetrics = {
|
|
5401
6506
|
accumulatedBytes: 0,
|
|
@@ -5584,8 +6689,21 @@ class AvatarController {
|
|
|
5584
6689
|
if (arrayIndex < 0) {
|
|
5585
6690
|
arrayIndex = 0;
|
|
5586
6691
|
}
|
|
5587
|
-
|
|
6692
|
+
const isOutOfBounds = arrayIndex >= this.currentKeyframes.length;
|
|
6693
|
+
if (isOutOfBounds) {
|
|
5588
6694
|
arrayIndex = this.currentKeyframes.length - 1;
|
|
6695
|
+
const now = Date.now();
|
|
6696
|
+
const stateChanged = isOutOfBounds !== this.lastOutOfBoundsState;
|
|
6697
|
+
const timeSinceLastLog = now - this.lastSyncLogTime;
|
|
6698
|
+
if (stateChanged || timeSinceLastLog >= 1e3) {
|
|
6699
|
+
logger.warn(`[PlaybackLoop] Frame index out of bounds! audioTime: ${audioTime.toFixed(3)}s, frameIndex: ${frameIndex}, maxAvailable: ${this.currentKeyframes.length - 1 + this.keyframesOffset}, using last frame`);
|
|
6700
|
+
this.lastSyncLogTime = now;
|
|
6701
|
+
this.lastOutOfBoundsState = isOutOfBounds;
|
|
6702
|
+
}
|
|
6703
|
+
} else {
|
|
6704
|
+
if (isOutOfBounds !== this.lastOutOfBoundsState) {
|
|
6705
|
+
this.lastOutOfBoundsState = isOutOfBounds;
|
|
6706
|
+
}
|
|
5589
6707
|
}
|
|
5590
6708
|
if (frameIndex === this.lastRenderedFrameIndex) {
|
|
5591
6709
|
this.playbackLoopId = requestAnimationFrame(playLoop);
|
|
@@ -6095,18 +7213,32 @@ class AvatarDownloader {
|
|
|
6095
7213
|
body: options.body ? JSON.stringify(options.body) : void 0
|
|
6096
7214
|
});
|
|
6097
7215
|
if (!response.ok) {
|
|
6098
|
-
|
|
7216
|
+
let error;
|
|
7217
|
+
if (response.status === 401) {
|
|
7218
|
+
logEvent("session_token_expired", "warning", {
|
|
7219
|
+
con_id: idManager.getConnectionId() || "",
|
|
7220
|
+
description: `HTTP 401: ${response.statusText}`
|
|
7221
|
+
});
|
|
7222
|
+
error = new SPAvatarError(`HTTP 401: ${response.statusText}`, ErrorCode.sessionTokenExpired);
|
|
7223
|
+
} else if (response.status === 400) {
|
|
6099
7224
|
logEvent("session_token_invalid", "warning", {
|
|
6100
7225
|
con_id: idManager.getConnectionId() || "",
|
|
6101
7226
|
description: `HTTP 400: ${response.statusText}`
|
|
6102
7227
|
});
|
|
6103
|
-
|
|
6104
|
-
|
|
6105
|
-
|
|
6106
|
-
|
|
7228
|
+
error = new SPAvatarError(`HTTP 400: ${response.statusText}`, ErrorCode.sessionTokenInvalid);
|
|
7229
|
+
} else if (response.status === 404) {
|
|
7230
|
+
const urlMatch = url.match(/\/v2\/character\/([^/?]+)/);
|
|
7231
|
+
const extractedCharacterId = urlMatch ? urlMatch[1] : "unknown";
|
|
7232
|
+
const errorMessage = `HTTP 404: ${response.statusText}`;
|
|
7233
|
+
logEvent("avatar_id_unrecognized", "error", {
|
|
7234
|
+
avatar_id: extractedCharacterId,
|
|
7235
|
+
description: errorMessage
|
|
6107
7236
|
});
|
|
7237
|
+
error = new SPAvatarError(errorMessage, ErrorCode.avatarIDUnrecognized);
|
|
7238
|
+
} else {
|
|
7239
|
+
error = new Error(`HTTP ${response.status} ${response.statusText}`);
|
|
6108
7240
|
}
|
|
6109
|
-
throw
|
|
7241
|
+
throw error;
|
|
6110
7242
|
}
|
|
6111
7243
|
return response.json();
|
|
6112
7244
|
} catch (err) {
|
|
@@ -6118,14 +7250,27 @@ class AvatarDownloader {
|
|
|
6118
7250
|
}
|
|
6119
7251
|
async getCharacterById(characterId) {
|
|
6120
7252
|
var _a;
|
|
7253
|
+
const startTime = Date.now();
|
|
6121
7254
|
try {
|
|
6122
7255
|
const client = this.getSdkApiClient();
|
|
6123
7256
|
const response = await client.request(`/v2/character/${characterId}`, {
|
|
6124
7257
|
method: "GET"
|
|
6125
7258
|
});
|
|
7259
|
+
const duration = Date.now() - startTime;
|
|
7260
|
+
logEvent("fetch_avatar_metadata_measure", "info", {
|
|
7261
|
+
avatar_id: characterId,
|
|
7262
|
+
duration
|
|
7263
|
+
});
|
|
6126
7264
|
return response;
|
|
6127
7265
|
} catch (error) {
|
|
6128
7266
|
logger.errorWithError("Failed to fetch character:", error);
|
|
7267
|
+
if (error instanceof SPAvatarError) {
|
|
7268
|
+
logEvent("fetch_avatar_metadata_failed", "error", {
|
|
7269
|
+
avatar_id: characterId ?? "unknown",
|
|
7270
|
+
description: error.message
|
|
7271
|
+
});
|
|
7272
|
+
throw error;
|
|
7273
|
+
}
|
|
6129
7274
|
const errorMessage = error && typeof error === "object" && "message" in error ? String(error.message) : "Failed to fetch character";
|
|
6130
7275
|
const dataMessage = error && typeof error === "object" && "data" in error && typeof error.data === "object" && ((_a = error.data) == null ? void 0 : _a.message) ? String(error.data.message) : null;
|
|
6131
7276
|
logEvent("fetch_avatar_metadata_failed", "error", {
|
|
@@ -8444,10 +9589,17 @@ class AvatarView {
|
|
|
8444
9589
|
img.src = imageUrl;
|
|
8445
9590
|
}
|
|
8446
9591
|
}
|
|
8447
|
-
|
|
9592
|
+
get transform() {
|
|
9593
|
+
if (!this.renderSystem) {
|
|
9594
|
+
throw new Error("Render system not initialized");
|
|
9595
|
+
}
|
|
9596
|
+
return this.renderSystem.getTransform();
|
|
9597
|
+
}
|
|
9598
|
+
set transform(value) {
|
|
8448
9599
|
if (!this.renderSystem) {
|
|
8449
9600
|
throw new Error("Render system not initialized");
|
|
8450
9601
|
}
|
|
9602
|
+
const { x, y, scale } = value;
|
|
8451
9603
|
logger.log(`[AvatarView] Setting transform: x=${x}, y=${y}, scale=${scale}`);
|
|
8452
9604
|
this.renderSystem.setTransform(x, y, scale);
|
|
8453
9605
|
if (this.isInitialized && this.renderSystem) {
|