@memori.ai/memori-react 7.19.1 → 7.21.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.
Files changed (145) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/components/Avatar/Avatar.js +3 -3
  3. package/dist/components/Avatar/Avatar.js.map +1 -1
  4. package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.d.ts +3 -2
  5. package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js +13 -6
  6. package/dist/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js.map +1 -1
  7. package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +14 -18
  8. package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +19 -77
  9. package/dist/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
  10. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +17 -2
  11. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +95 -70
  12. package/dist/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  13. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.d.ts +65 -0
  14. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js +747 -0
  15. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js.map +1 -0
  16. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.d.ts +9 -2
  17. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +60 -2
  18. package/dist/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
  19. package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
  20. package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +5 -11
  21. package/dist/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
  22. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +13 -52
  23. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js +68 -70
  24. package/dist/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
  25. package/dist/components/Avatar/AvatarView/index.d.ts +1 -1
  26. package/dist/components/Avatar/AvatarView/index.js +2 -2
  27. package/dist/components/Avatar/AvatarView/index.js.map +1 -1
  28. package/dist/components/Chat/Chat.js +2 -2
  29. package/dist/components/Chat/Chat.js.map +1 -1
  30. package/dist/components/ChatBubble/ChatBubble.js +12 -9
  31. package/dist/components/ChatBubble/ChatBubble.js.map +1 -1
  32. package/dist/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
  33. package/dist/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  34. package/dist/components/LoginDrawer/LoginDrawer.js +6 -6
  35. package/dist/components/LoginDrawer/LoginDrawer.js.map +1 -1
  36. package/dist/components/MemoriWidget/MemoriWidget.js +143 -64
  37. package/dist/components/MemoriWidget/MemoriWidget.js.map +1 -1
  38. package/dist/components/SignupForm/SignupForm.js +4 -4
  39. package/dist/components/SignupForm/SignupForm.js.map +1 -1
  40. package/dist/components/StartPanel/StartPanel.js +5 -5
  41. package/dist/components/StartPanel/StartPanel.js.map +1 -1
  42. package/dist/components/UploadButton/UploadButton.js +2 -2
  43. package/dist/components/UploadButton/UploadButton.js.map +1 -1
  44. package/dist/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
  45. package/dist/components/WhyThisAnswer/WhyThisAnswer.js +2 -1
  46. package/dist/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  47. package/dist/context/visemeContext.js +0 -39
  48. package/dist/context/visemeContext.js.map +1 -1
  49. package/dist/index.js +4 -3
  50. package/dist/index.js.map +1 -1
  51. package/dist/locales/de.json +1 -0
  52. package/dist/locales/en.json +1 -0
  53. package/dist/locales/es.json +1 -0
  54. package/dist/locales/fr.json +1 -0
  55. package/dist/locales/it.json +1 -0
  56. package/esm/components/Avatar/Avatar.js +3 -3
  57. package/esm/components/Avatar/Avatar.js.map +1 -1
  58. package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.d.ts +3 -2
  59. package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js +13 -6
  60. package/esm/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.js.map +1 -1
  61. package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.d.ts +14 -18
  62. package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js +20 -78
  63. package/esm/components/Avatar/AvatarView/AvatarComponent/avatarComponent.js.map +1 -1
  64. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.d.ts +17 -2
  65. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js +99 -74
  66. package/esm/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.js.map +1 -1
  67. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.d.ts +65 -0
  68. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js +743 -0
  69. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.js.map +1 -0
  70. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.d.ts +9 -2
  71. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js +61 -3
  72. package/esm/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.js.map +1 -1
  73. package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.d.ts +3 -4
  74. package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js +5 -11
  75. package/esm/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.js.map +1 -1
  76. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.d.ts +13 -52
  77. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js +67 -69
  78. package/esm/components/Avatar/AvatarView/AvatarComponent/constants.js.map +1 -1
  79. package/esm/components/Avatar/AvatarView/index.d.ts +1 -1
  80. package/esm/components/Avatar/AvatarView/index.js +2 -2
  81. package/esm/components/Avatar/AvatarView/index.js.map +1 -1
  82. package/esm/components/Chat/Chat.js +2 -2
  83. package/esm/components/Chat/Chat.js.map +1 -1
  84. package/esm/components/ChatBubble/ChatBubble.js +12 -9
  85. package/esm/components/ChatBubble/ChatBubble.js.map +1 -1
  86. package/esm/components/ExpertsDrawer/ExpertsDrawer.js +1 -1
  87. package/esm/components/ExpertsDrawer/ExpertsDrawer.js.map +1 -1
  88. package/esm/components/LoginDrawer/LoginDrawer.js +6 -6
  89. package/esm/components/LoginDrawer/LoginDrawer.js.map +1 -1
  90. package/esm/components/MemoriWidget/MemoriWidget.js +143 -64
  91. package/esm/components/MemoriWidget/MemoriWidget.js.map +1 -1
  92. package/esm/components/SignupForm/SignupForm.js +4 -4
  93. package/esm/components/SignupForm/SignupForm.js.map +1 -1
  94. package/esm/components/StartPanel/StartPanel.js +5 -5
  95. package/esm/components/StartPanel/StartPanel.js.map +1 -1
  96. package/esm/components/UploadButton/UploadButton.js +2 -2
  97. package/esm/components/UploadButton/UploadButton.js.map +1 -1
  98. package/esm/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
  99. package/esm/components/WhyThisAnswer/WhyThisAnswer.js +2 -1
  100. package/esm/components/WhyThisAnswer/WhyThisAnswer.js.map +1 -1
  101. package/esm/context/visemeContext.js +0 -39
  102. package/esm/context/visemeContext.js.map +1 -1
  103. package/esm/index.js +4 -3
  104. package/esm/index.js.map +1 -1
  105. package/esm/locales/de.json +1 -0
  106. package/esm/locales/en.json +1 -0
  107. package/esm/locales/es.json +1 -0
  108. package/esm/locales/fr.json +1 -0
  109. package/esm/locales/it.json +1 -0
  110. package/package.json +2 -2
  111. package/src/components/Avatar/Avatar.tsx +3 -3
  112. package/src/components/Avatar/AvatarView/AvatarComponent/Shadow/DynamicShadow.tsx +15 -8
  113. package/src/components/Avatar/AvatarView/AvatarComponent/avatarComponent.tsx +64 -219
  114. package/src/components/Avatar/AvatarView/AvatarComponent/components/FullbodyAvatar/fullbodyAvatar.tsx +221 -124
  115. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AvatarAnimator.ts +1250 -0
  116. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/MorphTargetController.ts +164 -8
  117. package/src/components/Avatar/AvatarView/AvatarComponent/components/halfbodyAvatar.tsx +19 -17
  118. package/src/components/Avatar/AvatarView/AvatarComponent/constants.ts +80 -79
  119. package/src/components/Avatar/AvatarView/index.tsx +1 -7
  120. package/src/components/Chat/Chat.tsx +2 -2
  121. package/src/components/ChatBubble/ChatBubble.tsx +37 -26
  122. package/src/components/ExpertsDrawer/ExpertsDrawer.tsx +1 -1
  123. package/src/components/LoginDrawer/LoginDrawer.tsx +6 -6
  124. package/src/components/MemoriWidget/MemoriWidget.tsx +184 -78
  125. package/src/components/SignupForm/SignupForm.tsx +5 -5
  126. package/src/components/StartPanel/StartPanel.tsx +5 -5
  127. package/src/components/UploadButton/UploadButton.tsx +4 -4
  128. package/src/components/UploadButton/__snapshots__/UploadButton.test.tsx.snap +1 -1
  129. package/src/components/WhyThisAnswer/WhyThisAnswer.css +43 -0
  130. package/src/components/WhyThisAnswer/WhyThisAnswer.stories.tsx +44 -3
  131. package/src/components/WhyThisAnswer/WhyThisAnswer.test.tsx +128 -8
  132. package/src/components/WhyThisAnswer/WhyThisAnswer.tsx +28 -3
  133. package/src/components/WhyThisAnswer/__snapshots__/WhyThisAnswer.test.tsx.snap +15 -1
  134. package/src/components/layouts/layouts.stories.tsx +0 -8
  135. package/src/context/visemeContext.tsx +40 -41
  136. package/src/index.stories.tsx +63 -65
  137. package/src/index.tsx +5 -3
  138. package/src/locales/de.json +1 -0
  139. package/src/locales/en.json +1 -0
  140. package/src/locales/es.json +1 -0
  141. package/src/locales/fr.json +1 -0
  142. package/src/locales/it.json +1 -0
  143. package/src/mocks/data.ts +3 -9
  144. package/src/components/Avatar/AvatarView/AvatarComponent/components/controllers/AnimationController.ts +0 -308
  145. package/src/helpers/tenant.ts +0 -47
@@ -46,6 +46,7 @@
46
46
  "generatedByAI": "Von KI generierte Antworten können gelegentlich falsche Informationen generieren",
47
47
  "whyThisAnswer": "Warum diese Antwort?",
48
48
  "whyThisAnswerHelper": "Diese Antwort wurde automatisch von einer künstlichen Intelligenz auf Basis dieser verifizierten Inhalte generiert.",
49
+ "receiverLabel": "Zugewiesen an",
49
50
  "completionsEnabled": "Fortschrittliche KI kann mit automatisch generierten Antworten reagieren, die manchmal falsche Informationen enthalten können",
50
51
  "completionProviderDown": "Dieser Zwilling ist mit einer generativen KI von integriert {{provider}}, aber es ist derzeit nicht verfügbar. ",
51
52
  "completionProviderFallbackName": "ein externer Anbieter",
@@ -46,6 +46,7 @@
46
46
  "generatedByAI": "Answer generated by AI, may occasionally generate incorrect informations",
47
47
  "whyThisAnswer": "Why this answer?",
48
48
  "whyThisAnswerHelper": "This answer was generated automatically by an artificial intelligence based on these verified contents.",
49
+ "receiverLabel": "Assigned to",
49
50
  "completionsEnabled": "Advanced AI, can respond with automatically generated answers that may sometimes contain incorrect information",
50
51
  "completionProviderDown": "This agent is integrated with a generative AI from {{provider}}, but it is currently unavailable. Try again later.",
51
52
  "completionProviderFallbackName": "an external provider",
@@ -46,6 +46,7 @@
46
46
  "generatedByAI": "La respuesta generada por IA, ocasionalmente puede generar información incorrecta",
47
47
  "whyThisAnswer": "¿Por qué esta respuesta?",
48
48
  "whyThisAnswerHelper": "Esta respuesta fue generada automáticamente por una inteligencia artificial basada en estos contenidos verificados.",
49
+ "receiverLabel": "Asignado a",
49
50
  "completionsEnabled": "La IA avanzada puede responder con respuestas generadas automáticamente que a veces pueden contener información incorrecta.",
50
51
  "completionProviderDown": "Este Agent está integrado con una IA generativa de {{provider}}, pero actualmente no está disponible. ",
51
52
  "completionProviderFallbackName": "un proveedor externo",
@@ -46,6 +46,7 @@
46
46
  "generatedByAI": "Réponse générée par l'IA, peut occasionnellement générer des informations incorrectes",
47
47
  "whyThisAnswer": "Pourquoi cette réponse ?",
48
48
  "whyThisAnswerHelper": "Cette réponse a été générée automatiquement par une intelligence artificielle basée sur ces contenus vérifiés.",
49
+ "receiverLabel": "Assigné à",
49
50
  "completionsEnabled": "L'IA avancée peut répondre avec des réponses générées automatiquement qui peuvent parfois contenir des informations incorrectes",
50
51
  "completionProviderDown": "Ce Agent est intégré à une IA générative de {{provider}}, mais il est actuellement indisponible. ",
51
52
  "completionProviderFallbackName": "un prestataire externe",
@@ -46,6 +46,7 @@
46
46
  "generatedByAI": "Risposta generata da IA, può talvolta generare informazioni non corrette",
47
47
  "whyThisAnswer": "Perché questa risposta?",
48
48
  "whyThisAnswerHelper": "Questa risposta è stata generata automaticamente da un'intelligenza artificiale sulla base di questi contenuti verificati.",
49
+ "receiverLabel": "Assegnato a",
49
50
  "completionsEnabled": "IA evoluta, può rispondere con risposte generate automaticamente che talvolta potrebbero contenere informazioni non corrette",
50
51
  "completionProviderDown": "Questo agente è integrato con una IA generativa di {{provider}}, ma al momento non è disponibile. Riprova più tardi.",
51
52
  "completionProviderFallbackName": "un provider esterno",
package/src/mocks/data.ts CHANGED
@@ -15,16 +15,12 @@ import {
15
15
  export const sessionID = '131165be-9d1a-42fb-a3ce-e8f86d40c88f';
16
16
 
17
17
  export const tenant: Tenant = {
18
+ tenantID: '96caa4b4-31a4-48e5-8163-dec61869a2a7',
19
+ name: 'www.aisuru.com',
20
+ description: 'AIsuru',
18
21
  adminCount: 3,
19
- config: {
20
- name: 'AIsuru',
21
- requirePosition: false,
22
- showNewUser: true,
23
- },
24
22
  creationTimestamp: '2023-05-31T14:32:48.885287Z',
25
- description: 'AIsuru',
26
23
  disableRegistration: false,
27
- id: 'www.aisuru.com',
28
24
  lastChangeTimestamp: '2023-05-31T14:32:48.885287Z',
29
25
  logoURL: 'https://aisuru.com/images/aisuru/logo.png',
30
26
  maxAdmins: 0,
@@ -37,10 +33,8 @@ export const tenant: Tenant = {
37
33
  maxTotalMemori: 0,
38
34
  maxUsers: 0,
39
35
  memoriCount: 0,
40
- name: 'www.aisuru.com',
41
36
  nonFreeSessionCost: 0.02,
42
37
  paying: true,
43
- tenantID: '96caa4b4-31a4-48e5-8163-dec61869a2a7',
44
38
  theme: 'aisuru',
45
39
  userCount: 0,
46
40
  };
@@ -1,308 +0,0 @@
1
- import { AnimationState, AnimationConfig } from '../FullbodyAvatar/types';
2
- import { AnimationAction, AnimationMixer, LoopOnce } from 'three';
3
- import { DEFAULT_CONFIG, MAX_IDLE_LOOPS_DEFAULT } from '../../constants';
4
-
5
- /**
6
- * Controller class for managing avatar animations and transitions between states
7
- */
8
- export class AnimationController {
9
- // Current animation state (LOADING, EMOTION, IDLE)
10
- private currentState: AnimationState = AnimationState.LOADING;
11
- // Currently playing animation action
12
- private currentAction: AnimationAction | null = null;
13
- // Three.js animation mixer
14
- private mixer: AnimationMixer;
15
- // Map of available animation actions
16
- private actions: Record<string, AnimationAction>;
17
- // Animation configuration settings
18
- private config: AnimationConfig;
19
- // Index of last played idle animation
20
- private lastIdleIndex: number = -1;
21
- // Flag to prevent overlapping transitions
22
- private isTransitioning: boolean = false;
23
- // Counter for number of times current idle has looped
24
- private currentIdleLoopCount: number = 0;
25
- // Maximum number of idle loops before forcing change
26
- private readonly MAX_IDLE_LOOPS = MAX_IDLE_LOOPS_DEFAULT;
27
- // Timestamp of last animation frame
28
- private lastAnimationTime: number = 0;
29
- // Flag to check if chat has already started
30
- private isChatAlreadyStarted: boolean = false;
31
- // Sequence of animations
32
- private sequence: string[] | null = null;
33
- // Index of current animation in sequence
34
- private sequenceIndex: number = 0;
35
-
36
- constructor(
37
- mixer: AnimationMixer,
38
- actions: Record<string, AnimationAction>,
39
- config: AnimationConfig = DEFAULT_CONFIG
40
- ) {
41
- // console.log('Initializing AnimationController');
42
- this.mixer = mixer;
43
- this.actions = actions;
44
- this.config = config;
45
- }
46
-
47
- /**
48
- * Checks if current idle animation has completed a loop
49
- */
50
- private checkForLoop() {
51
- if (!this.currentAction || this.currentState !== AnimationState.IDLE)
52
- return;
53
-
54
- const clip = this.currentAction.getClip();
55
- const currentTime = this.currentAction.time;
56
-
57
- // If the current time is less than the last time we recorded,
58
- // it means the animation has looped
59
- if (currentTime < this.lastAnimationTime) {
60
- this.currentIdleLoopCount++;
61
- // console.log(
62
- // `[AnimationController] Loop detected! Count: ${this.currentIdleLoopCount}`
63
- // );
64
-
65
- // Force idle change after MAX_IDLE_LOOPS
66
- if (this.currentIdleLoopCount >= this.MAX_IDLE_LOOPS) {
67
- this.forceIdleChange();
68
- }
69
- }
70
-
71
- this.lastAnimationTime = currentTime;
72
- }
73
-
74
- /**
75
- * Forces transition to a new idle animation
76
- */
77
- private forceIdleChange() {
78
- this.currentIdleLoopCount = 0;
79
- this.lastAnimationTime = 0;
80
- this.transitionTo(AnimationState.IDLE);
81
- }
82
-
83
- /**
84
- * Selects next random idle animation that differs from last played
85
- */
86
- private getNextIdleAnimation(): AnimationAction {
87
- let nextIndex;
88
- do {
89
- nextIndex = Math.floor(Math.random() * this.config.idleCount) + 1;
90
- } while (nextIndex === this.lastIdleIndex);
91
-
92
- // console.log(
93
- // '[AnimationController] isChatAlreadyStarted',
94
- // this.isChatAlreadyStarted
95
- // );
96
-
97
- if (this.isChatAlreadyStarted && nextIndex === 3) {
98
- // If chat has already started and the last idle was Idle4, use Idle3 instead
99
- nextIndex = this.lastIdleIndex !== 4 ? 4 : 2;
100
- }
101
-
102
- // console.log(
103
- // `[AnimationController] Selected idle animation: Idle${nextIndex}`
104
- // );
105
- this.lastIdleIndex = nextIndex;
106
- const idleAction = this.actions[`Idle${nextIndex}`];
107
-
108
- if (!idleAction) {
109
- throw new Error(`Idle animation ${nextIndex} not found`);
110
- }
111
-
112
- return idleAction;
113
- }
114
-
115
- /**
116
- * Plays a sequence of animations
117
- */
118
- playSequence(sequenceString: string) {
119
- const animations = sequenceString.split('->').map(anim => anim.trim());
120
- console.log('[AnimationController] playSequence:', animations);
121
-
122
- this.sequence = animations;
123
- this.sequenceIndex = 0;
124
-
125
- const firstAnim = this.parseAnimationName(animations[0]);
126
- this.transitionTo(AnimationState.EMOTION, firstAnim);
127
- }
128
-
129
- // Animation Name Parsing
130
- private parseAnimationName(animation: string): string {
131
- const randomMatch = animation.match(/(\w+)\[(\d+),(\d+)\]/);
132
- if (randomMatch) {
133
- const [_, base, min, max] = randomMatch;
134
- const random =
135
- Math.floor(Math.random() * (Number(max) - Number(min) + 1)) +
136
- Number(min);
137
- return `${base}${random}`;
138
- }
139
- return animation;
140
- }
141
-
142
- /**
143
- * Transitions to a new animation state
144
- */
145
- transitionTo(state: AnimationState, emotionName?: string) {
146
- if (this.isTransitioning) {
147
- // console.log(
148
- // '[AnimationController] Transition already in progress, skipping'
149
- // );
150
- return;
151
- }
152
-
153
- // console.log(
154
- // `[AnimationController] Transitioning to ${state}${
155
- // emotionName ? ` (${emotionName})` : ''
156
- // }`
157
- // );
158
- this.isTransitioning = true;
159
-
160
- try {
161
- let nextAction: AnimationAction | null = null;
162
-
163
- // Select the next action based on the current state
164
- switch (state) {
165
- case AnimationState.LOADING:
166
- nextAction = this.actions[emotionName || 'Loading1'];
167
- this.currentIdleLoopCount = 0;
168
- this.lastAnimationTime = 0;
169
- break;
170
- case AnimationState.EMOTION:
171
- nextAction = this.actions[emotionName || 'Timore1'];
172
- this.currentIdleLoopCount = 0;
173
- this.lastAnimationTime = 0;
174
- break;
175
- case AnimationState.IDLE:
176
- nextAction = this.getNextIdleAnimation();
177
- // Only reset loop count if we're coming from a different idle animation
178
- if (this.currentState !== AnimationState.IDLE) {
179
- this.currentIdleLoopCount = 0;
180
- this.lastAnimationTime = 0;
181
- }
182
- break;
183
- }
184
-
185
- if (!nextAction) {
186
- throw new Error(`No animation found for state: ${state}`);
187
- }
188
-
189
- // Fade out current animation
190
- if (this.currentAction) {
191
- this.currentAction.fadeOut(this.config.fadeOutDuration);
192
- }
193
-
194
- // Setup next animation
195
- nextAction.reset().fadeIn(this.config.fadeInDuration).play();
196
-
197
- // Configure animation properties
198
- nextAction.timeScale = this.config.timeScale;
199
- if (state !== AnimationState.IDLE) {
200
- nextAction.setLoop(LoopOnce, 1);
201
- nextAction.clampWhenFinished = true;
202
- } else {
203
- nextAction.setLoop(Infinity, Infinity);
204
- }
205
-
206
- this.currentAction = nextAction;
207
- this.currentState = state;
208
- // console.log('[AnimationController] Transition completed successfully');
209
- } catch (error) {
210
- console.error(
211
- '[AnimationController] Error during animation transition:',
212
- error
213
- );
214
- if (state !== AnimationState.IDLE) {
215
- this.transitionTo(AnimationState.IDLE);
216
- }
217
- } finally {
218
- this.isTransitioning = false;
219
- }
220
- }
221
-
222
- /**
223
- * Updates animation state on each frame
224
- */
225
- update(delta: number) {
226
- if (!this.currentAction) return;
227
-
228
- // Check for loop completion in idle animations
229
- this.checkForLoop();
230
-
231
- // Sequence progression,
232
- // If sequence is playing, transition to the next animation in the sequence
233
- // If sequence is finished, transition to idle
234
- if (
235
- this.sequence &&
236
- this.currentState === AnimationState.EMOTION &&
237
- this.currentAction.time >= this.currentAction.getClip().duration * 0.9
238
- ) {
239
- this.sequenceIndex++;
240
-
241
- if (this.sequenceIndex < this.sequence.length) {
242
- const nextAnim = this.parseAnimationName(this.sequence[this.sequenceIndex]);
243
- this.transitionTo(AnimationState.EMOTION, nextAnim);
244
- } else {
245
- this.sequence = null;
246
- this.sequenceIndex = 0;
247
- this.transitionTo(AnimationState.IDLE);
248
- }
249
- }
250
-
251
- // Check if emotion/loading animation is finished
252
- if (
253
- this.currentState !== AnimationState.IDLE &&
254
- this.currentAction.time >= this.currentAction.getClip().duration * 0.9
255
- ) {
256
- // console.log(
257
- // '[AnimationController] Non-idle animation completed, transitioning to idle'
258
- // );
259
- this.transitionTo(AnimationState.IDLE);
260
- }
261
-
262
- this.mixer.update(delta);
263
- }
264
-
265
- /**
266
- * Returns current animation state
267
- */
268
- getCurrentState(): AnimationState {
269
- return this.currentState;
270
- }
271
-
272
- /**
273
- * Returns number of times current idle has looped
274
- */
275
- getLoopCount(): number {
276
- return this.currentIdleLoopCount;
277
- }
278
-
279
- /**
280
- * Updates animation playback speed
281
- */
282
- setTimeScale(timeScale: number) {
283
- // console.log(`[AnimationController] Setting time scale to ${timeScale}`);
284
- this.config.timeScale = timeScale;
285
- if (this.currentAction) {
286
- this.currentAction.timeScale = timeScale;
287
- }
288
- }
289
-
290
- updateIsChatAlreadyStarted(isChatAlreadyStarted: boolean) {
291
- this.isChatAlreadyStarted = isChatAlreadyStarted;
292
- }
293
-
294
- /**
295
- * Returns debug information about current animation state
296
- */
297
- getDebugInfo() {
298
- return {
299
- currentState: this.currentState,
300
- currentIdleIndex: this.lastIdleIndex,
301
- loopCount: this.currentIdleLoopCount,
302
- currentTime: this.currentAction?.time || 0,
303
- lastTime: this.lastAnimationTime,
304
- isTransitioning: this.isTransitioning,
305
- isChatAlreadyStarted: this.isChatAlreadyStarted,
306
- };
307
- }
308
- }
@@ -1,47 +0,0 @@
1
- import { Tenant } from '@memori.ai/memori-api-client/dist/types';
2
-
3
- const defaultTenant: Tenant = {
4
- id: 'aisuru.com',
5
- theme: 'aisuru',
6
- config: {
7
- name: 'Memori',
8
- showNewUser: false,
9
- requirePosition: false,
10
- },
11
- };
12
-
13
- export const getTenant = async (
14
- tenantID: string,
15
- baseURL?: string
16
- ): Promise<Tenant> => {
17
- const apiBaseUrl = baseURL
18
- ? new URL(
19
- `${
20
- baseURL.startsWith('http')
21
- ? ''
22
- : baseURL.includes('localhost')
23
- ? 'http://'
24
- : 'https://'
25
- }${baseURL}`
26
- ).origin
27
- : 'https://aisuru.com';
28
-
29
- try {
30
- const response = await fetch(`${apiBaseUrl}/api/tenant/${tenantID}`);
31
- const { tenant } = await response.json();
32
-
33
- if (!tenant) {
34
- return {
35
- ...defaultTenant,
36
- tenantID,
37
- };
38
- }
39
-
40
- return tenant;
41
- } catch (error) {
42
- return {
43
- ...defaultTenant,
44
- tenantID,
45
- };
46
- }
47
- };