@memori.ai/memori-react 7.14.1 → 7.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.d.ts +17 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js +73 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.d.ts +17 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js +25 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js.map +1 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +5 -3
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +26 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +166 -0
- package/dist/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -0
- package/dist/components/MemoriWidget/MemoriWidget.js +24 -25
- package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/dist/components/layouts/FullPage.js +1 -1
- package/dist/components/layouts/FullPage.js.map +1 -1
- package/dist/components/layouts/website-assistant.css +2 -2
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.d.ts +17 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js +69 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.d.ts +17 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js +22 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js.map +1 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +5 -3
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.d.ts +26 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js +163 -0
- package/esm/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.js.map +1 -0
- package/esm/components/MemoriWidget/MemoriWidget.js +24 -25
- package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
- package/esm/components/layouts/FullPage.js +1 -1
- package/esm/components/layouts/FullPage.js.map +1 -1
- package/esm/components/layouts/website-assistant.css +2 -2
- package/package.json +1 -1
- package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +5 -4
- package/src/components/MemoriWidget/MemoriWidget.tsx +135 -49
- package/src/components/layouts/FullPage.tsx +1 -1
- package/src/components/layouts/website-assistant.css +2 -2
- package/src/index.stories.tsx +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
+
## [7.15.0](https://github.com/memori-ai/memori-react/compare/v7.14.2...v7.15.0) (2025-01-29)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* enhance avatar animations and add new story example ([a02564d](https://github.com/memori-ai/memori-react/commit/a02564df11cc1c2b71d6475ac772c1185007041d))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* improve avatar mesh detection for different avatar types ([442a6c5](https://github.com/memori-ai/memori-react/commit/442a6c52304d25f980c3c90e404e9a16856a605d))
|
|
14
|
+
|
|
15
|
+
## [7.14.2](https://github.com/memori-ai/memori-react/compare/v7.14.1...v7.14.2) (2025-01-22)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Features
|
|
19
|
+
|
|
20
|
+
* **style:** updated opacity for website assistant layout ([ee89183](https://github.com/memori-ai/memori-react/commit/ee891834d7e4f4646c7c8e8f7773d66026f10303))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Bug Fixes
|
|
24
|
+
|
|
25
|
+
* double translation of last message when reopening session ([4f356bc](https://github.com/memori-ai/memori-react/commit/4f356bc7ef17daacd31de250a2898d403076c682))
|
|
26
|
+
|
|
3
27
|
## [7.14.1](https://github.com/memori-ai/memori-react/compare/v7.14.0...v7.14.1) (2025-01-20)
|
|
4
28
|
|
|
5
29
|
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { SkinnedMesh } from 'three';
|
|
2
|
+
export declare class MorphTargetController {
|
|
3
|
+
private headMesh;
|
|
4
|
+
private currentEmotionValues;
|
|
5
|
+
private previousEmotionKeys;
|
|
6
|
+
constructor(headMesh: SkinnedMesh);
|
|
7
|
+
updateMorphTargets(currentTime: number, emotionMorphTargets: Record<string, number>, currentViseme: {
|
|
8
|
+
name: string;
|
|
9
|
+
weight: number;
|
|
10
|
+
} | null, eyeBlink: boolean, blinkState: {
|
|
11
|
+
isBlinking: boolean;
|
|
12
|
+
lastBlinkTime: number;
|
|
13
|
+
nextBlinkTime: number;
|
|
14
|
+
blinkStartTime: number;
|
|
15
|
+
}): void;
|
|
16
|
+
private calculateBlinkValue;
|
|
17
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MorphTargetController = void 0;
|
|
4
|
+
const three_1 = require("three");
|
|
5
|
+
const constants_1 = require("./constants");
|
|
6
|
+
class MorphTargetController {
|
|
7
|
+
constructor(headMesh) {
|
|
8
|
+
this.currentEmotionValues = {};
|
|
9
|
+
this.previousEmotionKeys = new Set();
|
|
10
|
+
this.headMesh = headMesh;
|
|
11
|
+
}
|
|
12
|
+
updateMorphTargets(currentTime, emotionMorphTargets, currentViseme, eyeBlink, blinkState) {
|
|
13
|
+
if (!this.headMesh.morphTargetDictionary ||
|
|
14
|
+
!this.headMesh.morphTargetInfluences) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const blinkValue = this.calculateBlinkValue(currentTime, blinkState, eyeBlink);
|
|
18
|
+
const currentEmotionKeys = new Set(Object.keys(emotionMorphTargets));
|
|
19
|
+
Object.entries(this.headMesh.morphTargetDictionary).forEach(([key, index]) => {
|
|
20
|
+
if (typeof index !== 'number')
|
|
21
|
+
return;
|
|
22
|
+
let targetValue = 0;
|
|
23
|
+
if (currentEmotionKeys.has(key)) {
|
|
24
|
+
const targetEmotionValue = emotionMorphTargets[key];
|
|
25
|
+
const currentEmotionValue = this.currentEmotionValues[key] || 0;
|
|
26
|
+
const newEmotionValue = three_1.MathUtils.lerp(currentEmotionValue, targetEmotionValue * 2.5, constants_1.EMOTION_SMOOTHING);
|
|
27
|
+
this.currentEmotionValues[key] = newEmotionValue;
|
|
28
|
+
targetValue += newEmotionValue;
|
|
29
|
+
}
|
|
30
|
+
if (currentViseme && key === currentViseme.name) {
|
|
31
|
+
targetValue += currentViseme.weight;
|
|
32
|
+
}
|
|
33
|
+
if (key === 'eyesClosed' && eyeBlink) {
|
|
34
|
+
targetValue += blinkValue;
|
|
35
|
+
}
|
|
36
|
+
targetValue = three_1.MathUtils.clamp(targetValue, 0, 1);
|
|
37
|
+
if (this.headMesh.morphTargetInfluences) {
|
|
38
|
+
this.headMesh.morphTargetInfluences[index] = three_1.MathUtils.lerp(this.headMesh.morphTargetInfluences[index] || 0, targetValue, constants_1.VISEME_SMOOTHING);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
this.previousEmotionKeys = currentEmotionKeys;
|
|
42
|
+
}
|
|
43
|
+
calculateBlinkValue(currentTime, blinkState, eyeBlink) {
|
|
44
|
+
if (!eyeBlink)
|
|
45
|
+
return 0;
|
|
46
|
+
let blinkValue = 0;
|
|
47
|
+
if (currentTime >= blinkState.nextBlinkTime && !blinkState.isBlinking) {
|
|
48
|
+
blinkState.isBlinking = true;
|
|
49
|
+
blinkState.blinkStartTime = currentTime;
|
|
50
|
+
blinkState.lastBlinkTime = currentTime;
|
|
51
|
+
blinkState.nextBlinkTime =
|
|
52
|
+
currentTime +
|
|
53
|
+
Math.random() * (constants_1.BLINK_CONFIG.maxInterval - constants_1.BLINK_CONFIG.minInterval) +
|
|
54
|
+
constants_1.BLINK_CONFIG.minInterval;
|
|
55
|
+
}
|
|
56
|
+
if (blinkState.isBlinking) {
|
|
57
|
+
const blinkProgress = (currentTime - blinkState.blinkStartTime) / constants_1.BLINK_CONFIG.blinkDuration;
|
|
58
|
+
if (blinkProgress <= 0.5) {
|
|
59
|
+
blinkValue = blinkProgress * 2;
|
|
60
|
+
}
|
|
61
|
+
else if (blinkProgress <= 1) {
|
|
62
|
+
blinkValue = 2 - blinkProgress * 2;
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
blinkState.isBlinking = false;
|
|
66
|
+
blinkValue = 0;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return blinkValue;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
exports.MorphTargetController = MorphTargetController;
|
|
73
|
+
//# sourceMappingURL=MorhTargetController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MorhTargetController.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/MorhTargetController.ts"],"names":[],"mappings":";;;AACA,iCAAkC;AAClC,2CAAgF;AAEhF,MAAa,qBAAqB;IAKhC,YAAY,QAAqB;QAHzB,yBAAoB,GAA2B,EAAE,CAAC;QAClD,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BAAM,IAAI,aAAa,IAAI,CAAC,EAAE;gBAC7B,UAAU,GAAG,CAAC,GAAG,aAAa,GAAG,CAAC,CAAC;aACpC;iBAAM;gBACL,UAAU,CAAC,UAAU,GAAG,KAAK,CAAC;gBAC9B,UAAU,GAAG,CAAC,CAAC;aAChB;SACF;QAED,OAAO,UAAU,CAAC;IACpB,CAAC;CACF;AAtHD,sDAsHC"}
|
package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Vector3, Euler } from 'three';
|
|
2
|
+
import { AnimationConfig } from './types';
|
|
3
|
+
export declare const AVATAR_POSITION: Vector3;
|
|
4
|
+
export declare const AVATAR_ROTATION: Euler;
|
|
5
|
+
export declare const AVATAR_POSITION_ZOOMED: Vector3;
|
|
6
|
+
export declare const ANIMATION_URLS: {
|
|
7
|
+
MALE: string;
|
|
8
|
+
FEMALE: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const BLINK_CONFIG: {
|
|
11
|
+
minInterval: number;
|
|
12
|
+
maxInterval: number;
|
|
13
|
+
blinkDuration: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const DEFAULT_CONFIG: AnimationConfig;
|
|
16
|
+
export declare const EMOTION_SMOOTHING = 0.3;
|
|
17
|
+
export declare const VISEME_SMOOTHING = 0.5;
|
package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VISEME_SMOOTHING = exports.EMOTION_SMOOTHING = exports.DEFAULT_CONFIG = exports.BLINK_CONFIG = exports.ANIMATION_URLS = exports.AVATAR_POSITION_ZOOMED = exports.AVATAR_ROTATION = exports.AVATAR_POSITION = void 0;
|
|
4
|
+
const three_1 = require("three");
|
|
5
|
+
exports.AVATAR_POSITION = new three_1.Vector3(0, -1, 0);
|
|
6
|
+
exports.AVATAR_ROTATION = new three_1.Euler(0.175, 0, 0);
|
|
7
|
+
exports.AVATAR_POSITION_ZOOMED = new three_1.Vector3(0, -1.45, 0);
|
|
8
|
+
exports.ANIMATION_URLS = {
|
|
9
|
+
MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
|
|
10
|
+
FEMALE: 'https://assets.memori.ai/api/v2/asset/2adc934b-24b2-45bd-94ad-ffec58d3cb32.glb',
|
|
11
|
+
};
|
|
12
|
+
exports.BLINK_CONFIG = {
|
|
13
|
+
minInterval: 1000,
|
|
14
|
+
maxInterval: 5000,
|
|
15
|
+
blinkDuration: 150,
|
|
16
|
+
};
|
|
17
|
+
exports.DEFAULT_CONFIG = {
|
|
18
|
+
fadeInDuration: 0.8,
|
|
19
|
+
fadeOutDuration: 0.8,
|
|
20
|
+
idleCount: 5,
|
|
21
|
+
timeScale: 1.0,
|
|
22
|
+
};
|
|
23
|
+
exports.EMOTION_SMOOTHING = 0.3;
|
|
24
|
+
exports.VISEME_SMOOTHING = 0.5;
|
|
25
|
+
//# sourceMappingURL=constants.js.map
|
package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/constants.ts"],"names":[],"mappings":";;;AAAA,iCAAuC;AAG1B,QAAA,eAAe,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AACxC,QAAA,eAAe,GAAG,IAAI,aAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AACzC,QAAA,sBAAsB,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAElD,QAAA,cAAc,GAAG;IAC5B,IAAI,EAAE,gFAAgF;IACtF,MAAM,EACJ,gFAAgF;CACnF,CAAC;AAEW,QAAA,YAAY,GAAG;IAC1B,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,GAAG;CACnB,CAAC;AAEW,QAAA,cAAc,GAAoB;IAC7C,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;IACpB,SAAS,EAAE,CAAC;IACZ,SAAS,EAAE,GAAG;CACf,CAAC;AAEW,QAAA,iBAAiB,GAAG,GAAG,CAAC;AACxB,QAAA,gBAAgB,GAAG,GAAG,CAAC"}
|
|
@@ -14,8 +14,10 @@ const constants_1 = require("../../constants");
|
|
|
14
14
|
function FullbodyAvatar({ url, sex, setIsRpm, currentBaseAction, timeScale, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, avatarHeight = 50, avatarDepth = 0, onCameraZChange, }) {
|
|
15
15
|
var _a;
|
|
16
16
|
const { scene } = (0, drei_1.useGLTF)(url);
|
|
17
|
-
const { animations } = (0, drei_1.useGLTF)(
|
|
18
|
-
const {
|
|
17
|
+
const { animations: baseAnimations } = (0, drei_1.useGLTF)(url);
|
|
18
|
+
const { animations: additionalAnimations } = (0, drei_1.useGLTF)(constants_1.ANIMATION_URLS[sex]);
|
|
19
|
+
const mergedAnimations = (0, react_1.useMemo)(() => [...baseAnimations, ...additionalAnimations], [baseAnimations, additionalAnimations]);
|
|
20
|
+
const { actions } = (0, drei_1.useAnimations)(mergedAnimations, scene);
|
|
19
21
|
const animationControllerRef = (0, react_1.useRef)();
|
|
20
22
|
const morphTargetControllerRef = (0, react_1.useRef)();
|
|
21
23
|
const positionControllerRef = (0, react_1.useRef)();
|
|
@@ -58,7 +60,7 @@ function FullbodyAvatar({ url, sex, setIsRpm, currentBaseAction, timeScale, eyeB
|
|
|
58
60
|
let foundMesh;
|
|
59
61
|
scene === null || scene === void 0 ? void 0 : scene.traverse((object) => {
|
|
60
62
|
if (object instanceof three_1.SkinnedMesh &&
|
|
61
|
-
(object.name === 'GBNL__Head' || object.name === 'Wolf3D_Avatar')) {
|
|
63
|
+
(object.name === 'GBNL__Head' || object.name === 'Wolf3D_Avatar' || object.name === 'Wolf3D_Avatar006_1')) {
|
|
62
64
|
if (object.name === 'GBNL__Head') {
|
|
63
65
|
setIsRpm(false);
|
|
64
66
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fullbodyAvatar.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx"],"names":[],"mappings":";;;;AAAA,iCAAmD;AACnD,iCAKe;AACf,4CAA2D;AAC3D,8CAA8C;AAC9C,mCAA8D;AAC9D,4EAAyE;AACzE,gFAA6E;AAC7E,sFAAmF;AACnF,+CAOyB;AAEzB,SAAgB,cAAc,CAAC,EAC7B,GAAG,EACH,GAAG,EACH,QAAQ,EACR,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,YAAY,GAAG,EAAE,EACjB,WAAW,GAAG,CAAC,EACf,eAAe,GACK;;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;IAC/B,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,cAAO,EAAC,0BAAc,CAAC,GAAG,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"fullbodyAvatar.js","sourceRoot":"","sources":["../../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx"],"names":[],"mappings":";;;;AAAA,iCAAmD;AACnD,iCAKe;AACf,4CAA2D;AAC3D,8CAA8C;AAC9C,mCAA8D;AAC9D,4EAAyE;AACzE,gFAA6E;AAC7E,sFAAmF;AACnF,+CAOyB;AAEzB,SAAgB,cAAc,CAAC,EA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K,EAAE,EAAE;;QACxB,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC;QAGnD,MAAA,sBAAsB,CAAC,OAAO,0CAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QAG9C,IAAI,wBAAwB,CAAC,OAAO,EAAE;YACpC,MAAM,aAAa,GAAG,mBAAmB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;YAC9D,wBAAwB,CAAC,OAAO,CAAC,kBAAkB,CACjD,WAAW,EACX,mBAAmB,EACnB,aAAa,EACb,QAAQ,IAAI,KAAK,EACjB,aAAa,CAAC,OAAO,CACtB,CAAC;SACH;QAGD,IAAI,KAAK,IAAI,qBAAqB,CAAC,OAAO,EAAE;YAC1C,MAAM,QAAQ,GAAG,qBAAqB,CAAC,OAAO,CAAC,WAAW,CAAC,6BAAiB,CAAC,CAAC;YAC9E,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SAC5B;IACH,CAAC,CAAC,CAAC;IAGH,MAAM,QAAQ,GAAG,CAAA,MAAA,qBAAqB,CAAC,OAAO,0CAAE,WAAW,EAAE,KAAI,2BAAe,CAAC;IAEjF,OAAO,CACL,kCACE,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,2BAAe,YAEzB,sCAAW,MAAM,EAAE,KAAK,GAAI,GACtB,CACT,CAAC;AACJ,CAAC;AA5LD,wCA4LC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
interface FullbodyAvatarProps {
|
|
2
|
+
url: string;
|
|
3
|
+
sex: 'MALE' | 'FEMALE';
|
|
4
|
+
onLoaded?: () => void;
|
|
5
|
+
currentBaseAction: {
|
|
6
|
+
action: string;
|
|
7
|
+
weight: number;
|
|
8
|
+
};
|
|
9
|
+
timeScale: number;
|
|
10
|
+
isZoomed?: boolean;
|
|
11
|
+
eyeBlink?: boolean;
|
|
12
|
+
stopProcessing: () => void;
|
|
13
|
+
resetVisemeQueue: () => void;
|
|
14
|
+
updateCurrentViseme: (currentTime: number) => {
|
|
15
|
+
name: string;
|
|
16
|
+
weight: number;
|
|
17
|
+
} | null;
|
|
18
|
+
smoothMorphTarget?: boolean;
|
|
19
|
+
morphTargetSmoothing?: number;
|
|
20
|
+
morphTargetInfluences: Record<string, number>;
|
|
21
|
+
setMorphTargetDictionary: (morphTargetDictionary: Record<string, number>) => void;
|
|
22
|
+
setMorphTargetInfluences: (morphTargetInfluences: Record<string, number>) => void;
|
|
23
|
+
emotionMorphTargets: Record<string, number>;
|
|
24
|
+
}
|
|
25
|
+
export default function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }: FullbodyAvatarProps): JSX.Element;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const three_1 = require("three");
|
|
6
|
+
const drei_1 = require("@react-three/drei");
|
|
7
|
+
const fiber_1 = require("@react-three/fiber");
|
|
8
|
+
const AVATAR_POSITION = new three_1.Vector3(0, -1, 0);
|
|
9
|
+
const AVATAR_ROTATION = new three_1.Euler(0.175, 0, 0);
|
|
10
|
+
const AVATAR_POSITION_ZOOMED = new three_1.Vector3(0, -1.45, 0);
|
|
11
|
+
const ANIMATION_URLS = {
|
|
12
|
+
MALE: 'https://assets.memori.ai/api/v2/asset/2c5e88a4-cf62-408b-9ef0-518b099dfcb2.glb',
|
|
13
|
+
FEMALE: 'https://assets.memori.ai/api/v2/asset/8d1a5853-f05a-4a34-9f99-6eff64986081.glb',
|
|
14
|
+
};
|
|
15
|
+
const BLINK_CONFIG = {
|
|
16
|
+
minInterval: 1000,
|
|
17
|
+
maxInterval: 5000,
|
|
18
|
+
blinkDuration: 150,
|
|
19
|
+
};
|
|
20
|
+
const EMOTION_SMOOTHING = 0.3;
|
|
21
|
+
const VISME_SMOOTHING = 0.5;
|
|
22
|
+
function FullbodyAvatar({ url, sex, currentBaseAction, timeScale, isZoomed, eyeBlink, updateCurrentViseme, setMorphTargetDictionary, setMorphTargetInfluences, emotionMorphTargets, }) {
|
|
23
|
+
const { scene } = (0, drei_1.useGLTF)(url);
|
|
24
|
+
const { animations } = (0, drei_1.useGLTF)(ANIMATION_URLS[sex]);
|
|
25
|
+
const { actions } = (0, drei_1.useAnimations)(animations, scene);
|
|
26
|
+
const mixerRef = (0, react_1.useRef)();
|
|
27
|
+
const headMeshRef = (0, react_1.useRef)();
|
|
28
|
+
const currentActionRef = (0, react_1.useRef)(null);
|
|
29
|
+
const isTransitioningToIdleRef = (0, react_1.useRef)(false);
|
|
30
|
+
const lastBlinkTimeRef = (0, react_1.useRef)(0);
|
|
31
|
+
const nextBlinkTimeRef = (0, react_1.useRef)(0);
|
|
32
|
+
const isBlinkingRef = (0, react_1.useRef)(false);
|
|
33
|
+
const blinkStartTimeRef = (0, react_1.useRef)(0);
|
|
34
|
+
const currentEmotionRef = (0, react_1.useRef)({});
|
|
35
|
+
const previousEmotionKeysRef = (0, react_1.useRef)(new Set());
|
|
36
|
+
const headMesh = (0, react_1.useMemo)(() => {
|
|
37
|
+
let foundMesh;
|
|
38
|
+
scene.traverse((object) => {
|
|
39
|
+
if (object instanceof three_1.SkinnedMesh &&
|
|
40
|
+
(object.name === 'GBNL__Head' || object.name === 'Wolf3D_Avatar')) {
|
|
41
|
+
foundMesh = object;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
return foundMesh;
|
|
45
|
+
}, [scene]);
|
|
46
|
+
(0, react_1.useEffect)(() => {
|
|
47
|
+
if (headMesh) {
|
|
48
|
+
headMeshRef.current = headMesh;
|
|
49
|
+
if (headMesh.morphTargetDictionary && headMesh.morphTargetInfluences) {
|
|
50
|
+
setMorphTargetDictionary(headMesh.morphTargetDictionary);
|
|
51
|
+
const initialInfluences = Object.keys(headMesh.morphTargetDictionary).reduce((acc, key) => ({ ...acc, [key]: 0 }), {});
|
|
52
|
+
setMorphTargetInfluences(initialInfluences);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
mixerRef.current = new three_1.AnimationMixer(scene);
|
|
56
|
+
}, [headMesh, scene, setMorphTargetDictionary, setMorphTargetInfluences]);
|
|
57
|
+
const handleAnimationChange = (0, react_1.useCallback)(() => {
|
|
58
|
+
if (!actions || !currentBaseAction.action)
|
|
59
|
+
return;
|
|
60
|
+
const newAction = actions[currentBaseAction.action];
|
|
61
|
+
if (!newAction) {
|
|
62
|
+
console.warn(`Animation "${currentBaseAction.action}" not found in actions.`);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
const fadeOutDuration = 0.8;
|
|
66
|
+
const fadeInDuration = 0.8;
|
|
67
|
+
if (currentActionRef.current) {
|
|
68
|
+
currentActionRef.current.fadeOut(fadeOutDuration);
|
|
69
|
+
}
|
|
70
|
+
newAction.reset().fadeIn(fadeInDuration).play();
|
|
71
|
+
currentActionRef.current = newAction;
|
|
72
|
+
newAction.timeScale = timeScale;
|
|
73
|
+
if (currentBaseAction.action.startsWith('Gioia') ||
|
|
74
|
+
currentBaseAction.action.startsWith('Rabbia') ||
|
|
75
|
+
currentBaseAction.action.startsWith('Sorpresa') ||
|
|
76
|
+
currentBaseAction.action.startsWith('Timore') ||
|
|
77
|
+
currentBaseAction.action.startsWith('Tristezza')) {
|
|
78
|
+
newAction.setLoop(three_1.LoopOnce, 1);
|
|
79
|
+
newAction.clampWhenFinished = true;
|
|
80
|
+
isTransitioningToIdleRef.current = true;
|
|
81
|
+
}
|
|
82
|
+
}, [actions, currentBaseAction, timeScale]);
|
|
83
|
+
(0, react_1.useEffect)(() => {
|
|
84
|
+
handleAnimationChange();
|
|
85
|
+
}, [handleAnimationChange]);
|
|
86
|
+
const updateFrame = (0, react_1.useCallback)((currentTime) => {
|
|
87
|
+
var _a;
|
|
88
|
+
if (!headMeshRef.current ||
|
|
89
|
+
!headMeshRef.current.morphTargetDictionary ||
|
|
90
|
+
!headMeshRef.current.morphTargetInfluences)
|
|
91
|
+
return;
|
|
92
|
+
let blinkValue = 0;
|
|
93
|
+
if (eyeBlink) {
|
|
94
|
+
if (currentTime >= nextBlinkTimeRef.current && !isBlinkingRef.current) {
|
|
95
|
+
isBlinkingRef.current = true;
|
|
96
|
+
blinkStartTimeRef.current = currentTime;
|
|
97
|
+
lastBlinkTimeRef.current = currentTime;
|
|
98
|
+
nextBlinkTimeRef.current =
|
|
99
|
+
currentTime +
|
|
100
|
+
Math.random() *
|
|
101
|
+
(BLINK_CONFIG.maxInterval - BLINK_CONFIG.minInterval) +
|
|
102
|
+
BLINK_CONFIG.minInterval;
|
|
103
|
+
}
|
|
104
|
+
if (isBlinkingRef.current) {
|
|
105
|
+
const blinkProgress = (currentTime - blinkStartTimeRef.current) /
|
|
106
|
+
BLINK_CONFIG.blinkDuration;
|
|
107
|
+
if (blinkProgress <= 0.5) {
|
|
108
|
+
blinkValue = blinkProgress * 2;
|
|
109
|
+
}
|
|
110
|
+
else if (blinkProgress <= 1) {
|
|
111
|
+
blinkValue = 2 - blinkProgress * 2;
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
isBlinkingRef.current = false;
|
|
115
|
+
blinkValue = 0;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
const currentViseme = updateCurrentViseme(currentTime / 1000);
|
|
120
|
+
const currentEmotionKeys = new Set(Object.keys(emotionMorphTargets));
|
|
121
|
+
Object.entries(headMeshRef.current.morphTargetDictionary).forEach(([key, index]) => {
|
|
122
|
+
if (typeof index === 'number') {
|
|
123
|
+
let targetValue = 0;
|
|
124
|
+
if (currentEmotionKeys.has(key)) {
|
|
125
|
+
const targetEmotionValue = emotionMorphTargets[key];
|
|
126
|
+
const currentEmotionValue = currentEmotionRef.current[key] || 0;
|
|
127
|
+
const newEmotionValue = three_1.MathUtils.lerp(currentEmotionValue, targetEmotionValue * 2.5, EMOTION_SMOOTHING);
|
|
128
|
+
currentEmotionRef.current[key] = newEmotionValue;
|
|
129
|
+
targetValue += newEmotionValue;
|
|
130
|
+
}
|
|
131
|
+
if (currentViseme && key === currentViseme.name) {
|
|
132
|
+
targetValue += currentViseme.weight;
|
|
133
|
+
}
|
|
134
|
+
if (key === 'eyesClosed' && eyeBlink) {
|
|
135
|
+
targetValue += blinkValue;
|
|
136
|
+
}
|
|
137
|
+
targetValue = three_1.MathUtils.clamp(targetValue, 0, 1);
|
|
138
|
+
if (headMeshRef.current &&
|
|
139
|
+
headMeshRef.current.morphTargetInfluences) {
|
|
140
|
+
headMeshRef.current.morphTargetInfluences[index] = three_1.MathUtils.lerp(headMeshRef.current.morphTargetInfluences[index], targetValue, VISME_SMOOTHING);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
previousEmotionKeysRef.current = currentEmotionKeys;
|
|
145
|
+
if (isTransitioningToIdleRef.current && currentActionRef.current) {
|
|
146
|
+
if (currentActionRef.current.time >=
|
|
147
|
+
currentActionRef.current.getClip().duration) {
|
|
148
|
+
const idleNumber = Math.floor(Math.random() * 5) + 1;
|
|
149
|
+
const idleAction = actions[`Idle${idleNumber === 3 ? 4 : idleNumber}`];
|
|
150
|
+
if (idleAction) {
|
|
151
|
+
currentActionRef.current.fadeOut(0.5);
|
|
152
|
+
idleAction.reset().fadeIn(0.5).play();
|
|
153
|
+
currentActionRef.current = idleAction;
|
|
154
|
+
isTransitioningToIdleRef.current = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
(_a = mixerRef.current) === null || _a === void 0 ? void 0 : _a.update(0.01);
|
|
159
|
+
}, [actions, emotionMorphTargets, eyeBlink, updateCurrentViseme]);
|
|
160
|
+
(0, fiber_1.useFrame)(state => {
|
|
161
|
+
updateFrame(state.clock.elapsedTime * 1000);
|
|
162
|
+
});
|
|
163
|
+
return ((0, jsx_runtime_1.jsx)("group", { position: isZoomed ? AVATAR_POSITION_ZOOMED : AVATAR_POSITION, rotation: AVATAR_ROTATION, children: (0, jsx_runtime_1.jsx)("primitive", { object: scene }) }));
|
|
164
|
+
}
|
|
165
|
+
exports.default = FullbodyAvatar;
|
|
166
|
+
//# sourceMappingURL=fullbodyAvatar.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fullbodyAvatar.js","sourceRoot":"","sources":["../../../../../../src/components/Avatar/AvatarView/AvatarComponent/components/fullbodyAvatar.tsx"],"names":[],"mappings":";;;AAAA,iCAAuE;AACvE,iCASe;AACf,4CAA2D;AAC3D,8CAAwD;AA8BxD,MAAM,eAAe,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAC9C,MAAM,eAAe,GAAG,IAAI,aAAK,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;AAC/C,MAAM,sBAAsB,GAAG,IAAI,eAAO,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;AAExD,MAAM,cAAc,GAAG;IACrB,IAAI,EAAE,gFAAgF;IACtF,MAAM,EACJ,gFAAgF;CACnF,CAAC;AAEF,MAAM,YAAY,GAAG;IACnB,WAAW,EAAE,IAAI;IACjB,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,GAAG;CACnB,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B,SAAwB,cAAc,CAAC,EACrC,GAAG,EACH,GAAG,EACH,iBAAiB,EACjB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,GACC;IACpB,MAAM,EAAE,KAAK,EAAE,GAAG,IAAA,cAAO,EAAC,GAAG,CAAC,CAAC;IAC/B,MAA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CAAC,CAAC;oBACtC,UAAU,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;oBACtC,gBAAgB,CAAC,OAAO,GAAG,UAAU,CAAC;oBACtC,wBAAwB,CAAC,OAAO,GAAG,KAAK,CAAC;iBAC1C;aACF;SACF;QAED,MAAA,QAAQ,CAAC,OAAO,0CAAE,MAAM,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC,EACD,CAAC,OAAO,EAAE,mBAAmB,EAAE,QAAQ,EAAE,mBAAmB,CAAC,CAC9D,CAAC;IAEF,IAAA,gBAAQ,EAAC,KAAK,CAAC,EAAE;QACf,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,OAAO,CACL,kCACE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,eAAe,EAC7D,QAAQ,EAAE,eAAe,YAEzB,sCAAW,MAAM,EAAE,KAAK,GAAI,GACtB,CACT,CAAC;AACJ,CAAC;AA3ND,iCA2NC"}
|
|
@@ -437,14 +437,15 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
437
437
|
setMemoriTyping(false);
|
|
438
438
|
}
|
|
439
439
|
};
|
|
440
|
-
const translateDialogState = async (state, userLang, msg) => {
|
|
440
|
+
const translateDialogState = async (state, userLang, msg, avoidPushingMessage = false) => {
|
|
441
441
|
var _a, _b, _c;
|
|
442
442
|
const emission = (_a = state === null || state === void 0 ? void 0 : state.emission) !== null && _a !== void 0 ? _a : currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.emission;
|
|
443
443
|
let translatedState = { ...state };
|
|
444
444
|
let translatedMsg = null;
|
|
445
445
|
if (!emission ||
|
|
446
446
|
language.toUpperCase() === userLang.toUpperCase() ||
|
|
447
|
-
!isMultilanguageEnabled
|
|
447
|
+
!isMultilanguageEnabled ||
|
|
448
|
+
avoidPushingMessage) {
|
|
448
449
|
translatedState = { ...state, emission };
|
|
449
450
|
if (emission) {
|
|
450
451
|
translatedMsg = {
|
|
@@ -490,7 +491,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
490
491
|
hints: (_c = state.hints) !== null && _c !== void 0 ? _c : (state.state === 'G1' ? currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.hints : []),
|
|
491
492
|
};
|
|
492
493
|
}
|
|
493
|
-
if (t.text.length > 0)
|
|
494
|
+
if (t.text.length > 0) {
|
|
494
495
|
translatedMsg = {
|
|
495
496
|
text: emission,
|
|
496
497
|
translatedText: t.text,
|
|
@@ -508,9 +509,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
508
509
|
tag: state.currentTag,
|
|
509
510
|
memoryTags: state.memoryTags,
|
|
510
511
|
};
|
|
512
|
+
}
|
|
511
513
|
}
|
|
512
514
|
catch (error) {
|
|
513
|
-
console.error(error);
|
|
515
|
+
console.error('[TRANSLATE] Error during translation:', error);
|
|
514
516
|
translatedState = { ...state, emission };
|
|
515
517
|
translatedMsg = {
|
|
516
518
|
text: emission,
|
|
@@ -530,7 +532,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
530
532
|
}
|
|
531
533
|
}
|
|
532
534
|
setCurrentDialogState(translatedState);
|
|
533
|
-
if (translatedMsg) {
|
|
535
|
+
if (!avoidPushingMessage && translatedMsg) {
|
|
534
536
|
pushMessage(translatedMsg);
|
|
535
537
|
}
|
|
536
538
|
return translatedState;
|
|
@@ -670,9 +672,10 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
670
672
|
referral = (() => {
|
|
671
673
|
return window.location.href;
|
|
672
674
|
})();
|
|
675
|
+
console.log('[REOPEN_SESSION] Got referral:', referral);
|
|
673
676
|
}
|
|
674
677
|
catch (err) {
|
|
675
|
-
console.debug(err);
|
|
678
|
+
console.debug('[REOPEN_SESSION] Error getting referral:', err);
|
|
676
679
|
}
|
|
677
680
|
const { sessionID, currentState, ...response } = await initSession({
|
|
678
681
|
memoriID: (_a = memori.engineMemoriID) !== null && _a !== void 0 ? _a : '',
|
|
@@ -735,10 +738,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
735
738
|
});
|
|
736
739
|
}
|
|
737
740
|
}
|
|
738
|
-
if (position)
|
|
741
|
+
if (position) {
|
|
739
742
|
applyPosition(position, sessionID);
|
|
740
|
-
|
|
743
|
+
}
|
|
744
|
+
if (memori.needsDateTime) {
|
|
741
745
|
sendDateChangedEvent({ sessionID: sessionID, state: currentState });
|
|
746
|
+
}
|
|
742
747
|
setLoading(false);
|
|
743
748
|
return {
|
|
744
749
|
dialogState: currentState,
|
|
@@ -746,22 +751,23 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
746
751
|
};
|
|
747
752
|
}
|
|
748
753
|
else if (response === null || response === void 0 ? void 0 : response.resultMessage.startsWith('This Memori is aged restricted')) {
|
|
749
|
-
console.error(response);
|
|
754
|
+
console.error('[REOPEN_SESSION] Age restriction error:', response);
|
|
750
755
|
react_hot_toast_1.default.error(t('underageTwinSession', { age: minAge }));
|
|
751
756
|
setGotErrorInOpening(true);
|
|
752
757
|
}
|
|
753
758
|
else if ((response === null || response === void 0 ? void 0 : response.resultCode) === 403) {
|
|
759
|
+
console.error('[REOPEN_SESSION] Authentication error');
|
|
754
760
|
setMemoriPwd(undefined);
|
|
755
761
|
setAuthModalState('password');
|
|
756
762
|
}
|
|
757
763
|
else {
|
|
758
|
-
console.error(response);
|
|
764
|
+
console.error('[REOPEN_SESSION] Other error:', response);
|
|
759
765
|
react_hot_toast_1.default.error(t((0, error_1.getErrori18nKey)(response.resultCode)));
|
|
760
766
|
setGotErrorInOpening(true);
|
|
761
767
|
}
|
|
762
768
|
}
|
|
763
769
|
catch (err) {
|
|
764
|
-
console.error(err);
|
|
770
|
+
console.error('[REOPEN_SESSION] Caught error:', err);
|
|
765
771
|
}
|
|
766
772
|
setLoading(false);
|
|
767
773
|
return null;
|
|
@@ -1654,14 +1660,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1654
1660
|
const sessionID = (session === null || session === void 0 ? void 0 : session.sessionID) || sessionId;
|
|
1655
1661
|
const dialogState = (session === null || session === void 0 ? void 0 : session.dialogState) || currentDialogState;
|
|
1656
1662
|
setClickedStart(true);
|
|
1663
|
+
let translatedMessages = [];
|
|
1657
1664
|
let memoriAudioElement = document.getElementById('memori-audio');
|
|
1658
1665
|
let isSafari = window.navigator.userAgent.includes('Safari') &&
|
|
1659
1666
|
!window.navigator.userAgent.includes('Chrome');
|
|
1660
1667
|
if (memoriAudioElement && isSafari) {
|
|
1661
1668
|
memoriAudioElement.muted = false;
|
|
1662
|
-
memoriAudioElement.play().catch((e) => {
|
|
1663
|
-
console.warn('error playing intro audio', e);
|
|
1664
|
-
});
|
|
1665
1669
|
}
|
|
1666
1670
|
let storageBirthDate = (0, configuration_1.getLocalConfig)('birthDate', undefined);
|
|
1667
1671
|
let birth = birthDate || storageBirthDate || undefined;
|
|
@@ -1722,7 +1726,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1722
1726
|
else if (initialSessionID) {
|
|
1723
1727
|
const { currentState, ...response } = await getSession(sessionID);
|
|
1724
1728
|
if (response.resultCode !== 0 || !currentState) {
|
|
1725
|
-
console.debug('session expired, opening new session');
|
|
1726
1729
|
setGotErrorInOpening(true);
|
|
1727
1730
|
setSessionId(undefined);
|
|
1728
1731
|
setClickedStart(false);
|
|
@@ -1737,7 +1740,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1737
1740
|
if (personification &&
|
|
1738
1741
|
(currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== personification.tag) {
|
|
1739
1742
|
try {
|
|
1740
|
-
console.debug('change tag #3');
|
|
1741
1743
|
await changeTag(memori.engineMemoriID, sessionID, '-');
|
|
1742
1744
|
const session = await changeTag(memori.engineMemoriID, sessionID, personification.tag, personification.pin);
|
|
1743
1745
|
if (session && session.resultCode === 0) {
|
|
@@ -1753,12 +1755,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1753
1755
|
});
|
|
1754
1756
|
}
|
|
1755
1757
|
else {
|
|
1756
|
-
console.error('
|
|
1758
|
+
console.error('[CLICK_START] Session error:', session);
|
|
1757
1759
|
throw new Error('No session');
|
|
1758
1760
|
}
|
|
1759
1761
|
}
|
|
1760
1762
|
catch (e) {
|
|
1761
|
-
console.error('
|
|
1763
|
+
console.error('[CLICK_START] Error changing tag:', e);
|
|
1762
1764
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, personification.tag, personification.pin, {
|
|
1763
1765
|
PATHNAME: (_h = window.location.pathname) === null || _h === void 0 ? void 0 : _h.toUpperCase(),
|
|
1764
1766
|
ROUTE: ((_l = (_k = (_j = window.location.pathname) === null || _j === void 0 ? void 0 : _j.split('/')) === null || _k === void 0 ? void 0 : _k.pop()) === null || _l === void 0 ? void 0 : _l.toUpperCase()) ||
|
|
@@ -1774,7 +1776,6 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1774
1776
|
(currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== constants_1.anonTag &&
|
|
1775
1777
|
(currentDialogState === null || currentDialogState === void 0 ? void 0 : currentDialogState.currentTag) !== '-') {
|
|
1776
1778
|
try {
|
|
1777
|
-
console.debug('change tag #6');
|
|
1778
1779
|
await changeTag(memori.engineMemoriID, sessionID, '-');
|
|
1779
1780
|
const session = await changeTag(memori.engineMemoriID, sessionID, constants_1.anonTag);
|
|
1780
1781
|
if (session && session.resultCode === 0) {
|
|
@@ -1790,12 +1791,12 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1790
1791
|
});
|
|
1791
1792
|
}
|
|
1792
1793
|
else {
|
|
1793
|
-
console.error('
|
|
1794
|
+
console.error('[CLICK_START] Session error:', session);
|
|
1794
1795
|
throw new Error('No session');
|
|
1795
1796
|
}
|
|
1796
1797
|
}
|
|
1797
1798
|
catch (e) {
|
|
1798
|
-
console.error('
|
|
1799
|
+
console.error('[CLICK_START] Error changing tag:', e);
|
|
1799
1800
|
reopenSession(true, memori === null || memori === void 0 ? void 0 : memori.secretToken, undefined, undefined, undefined, {
|
|
1800
1801
|
PATHNAME: (_m = window.location.pathname) === null || _m === void 0 ? void 0 : _m.toUpperCase(),
|
|
1801
1802
|
ROUTE: ((_q = (_p = (_o = window.location.pathname) === null || _o === void 0 ? void 0 : _o.split('/')) === null || _p === void 0 ? void 0 : _p.pop()) === null || _q === void 0 ? void 0 : _q.toUpperCase()) ||
|
|
@@ -1823,7 +1824,7 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1823
1824
|
initial: i === 0,
|
|
1824
1825
|
});
|
|
1825
1826
|
});
|
|
1826
|
-
|
|
1827
|
+
translatedMessages = messages;
|
|
1827
1828
|
if (language.toUpperCase() !== userLang.toUpperCase() &&
|
|
1828
1829
|
isMultilanguageEnabled) {
|
|
1829
1830
|
try {
|
|
@@ -1834,15 +1835,13 @@ const MemoriWidget = ({ memori, memoriConfigs, ownerUserID, ownerUserName, tenan
|
|
|
1834
1835
|
})));
|
|
1835
1836
|
}
|
|
1836
1837
|
catch (e) {
|
|
1837
|
-
console.log('Error translating messages', e);
|
|
1838
1838
|
}
|
|
1839
1839
|
}
|
|
1840
1840
|
setHistory(translatedMessages);
|
|
1841
1841
|
}
|
|
1842
1842
|
catch (e) {
|
|
1843
|
-
console.log('Error retrieving chat logs', e);
|
|
1844
1843
|
}
|
|
1845
|
-
translateDialogState(currentState, userLang)
|
|
1844
|
+
translateDialogState(currentState, userLang, undefined, true)
|
|
1846
1845
|
.then(ts => {
|
|
1847
1846
|
let text = ts.translatedEmission || ts.emission;
|
|
1848
1847
|
if (text) {
|