@rimori/client 2.5.28-next.0 → 2.5.28-next.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import { ThirdPartyModule, TOptions } from 'i18next';
1
+ import { ThirdPartyModule, i18n as i18nType } from 'i18next';
2
2
  import { AIModule } from '../plugin/module/AIModule';
3
3
  /**
4
4
  * Translator class for handling internationalization
@@ -32,7 +32,7 @@ export declare class Translator {
32
32
  * @param options - Translation options
33
33
  * @returns Translated string
34
34
  */
35
- t(key: string, options?: TOptions): string;
35
+ t(...args: Parameters<i18nType['t']>): string;
36
36
  /**
37
37
  * Get current language
38
38
  */
@@ -48,7 +48,7 @@ export class Translator {
48
48
  },
49
49
  },
50
50
  debug: false,
51
- // showSupportNotice: false, // TODO enable with next version of i18next
51
+ showSupportNotice: false,
52
52
  parseMissingKeyHandler: (key, defaultValue) => {
53
53
  if (!key.trim())
54
54
  return '';
@@ -130,11 +130,11 @@ export class Translator {
130
130
  * @param options - Translation options
131
131
  * @returns Translated string
132
132
  */
133
- t(key, options) {
133
+ t(...args) {
134
134
  if (!this.i18n) {
135
135
  throw new Error('Translator is not initialized');
136
136
  }
137
- return this.i18n.t(key, options);
137
+ return this.i18n.t(...args);
138
138
  }
139
139
  /**
140
140
  * Get current language
@@ -13,6 +13,8 @@ export declare class ChunkedAudioPlayer {
13
13
  private startedPlaying;
14
14
  private onEndOfSpeech;
15
15
  private readonly backgroundNoiseLevel;
16
+ private currentSource;
17
+ private stopped;
16
18
  constructor();
17
19
  private init;
18
20
  setOnLoudnessChange(callback: (value: number) => void): void;
@@ -20,6 +20,8 @@ export class ChunkedAudioPlayer {
20
20
  this.startedPlaying = false;
21
21
  this.onEndOfSpeech = () => { };
22
22
  this.backgroundNoiseLevel = 30; // Background noise level that should be treated as baseline (0)
23
+ this.currentSource = null;
24
+ this.stopped = false;
23
25
  this.init();
24
26
  }
25
27
  init() {
@@ -37,12 +39,10 @@ export class ChunkedAudioPlayer {
37
39
  }
38
40
  addChunk(chunk, position) {
39
41
  return __awaiter(this, void 0, void 0, function* () {
42
+ if (this.stopped)
43
+ return;
40
44
  console.log('Adding chunk', position, chunk);
41
45
  this.chunkQueue[position] = chunk;
42
- // console.log("received chunk", {
43
- // chunkQueue: this.chunkQueue.length,
44
- // isPlaying: this.isPlaying,
45
- // })
46
46
  if (position === 0 && !this.startedPlaying) {
47
47
  this.startedPlaying = true;
48
48
  this.playChunks();
@@ -50,25 +50,27 @@ export class ChunkedAudioPlayer {
50
50
  });
51
51
  }
52
52
  playChunks() {
53
- // console.log({ isPlaying: this.isPlaying });
54
- if (this.isPlaying)
53
+ if (this.isPlaying || this.stopped)
55
54
  return;
56
55
  if (!this.chunkQueue[this.currentIndex]) {
57
56
  // wait until the correct chunk arrives
58
57
  setTimeout(() => this.playChunks(), 10);
58
+ return;
59
59
  }
60
60
  this.isPlaying = true;
61
61
  this.playChunk(this.chunkQueue[this.currentIndex]).then(() => {
62
62
  this.isPlaying = false;
63
+ if (this.stopped)
64
+ return;
63
65
  this.currentIndex++;
64
66
  if (this.chunkQueue[this.currentIndex]) {
65
67
  this.shouldMonitorLoudness = true;
66
68
  this.playChunks();
67
69
  }
68
70
  else {
69
- // console.log('Playback finished', { currentIndex: this.currentIndex, chunkQueue: this.chunkQueue });
70
71
  setTimeout(() => {
71
- // console.log('Check again if really playback finished', { currentIndex: this.currentIndex, chunkQueue: this.chunkQueue });
72
+ if (this.stopped)
73
+ return;
72
74
  if (this.chunkQueue.length > this.currentIndex) {
73
75
  this.playChunks();
74
76
  }
@@ -81,8 +83,17 @@ export class ChunkedAudioPlayer {
81
83
  });
82
84
  }
83
85
  stopPlayback() {
84
- // console.log('Stopping playback');
85
- // Implement logic to stop the current playback
86
+ this.stopped = true;
87
+ // Stop the currently playing audio source node
88
+ if (this.currentSource) {
89
+ try {
90
+ this.currentSource.stop();
91
+ }
92
+ catch (_a) {
93
+ // already stopped
94
+ }
95
+ this.currentSource = null;
96
+ }
86
97
  this.isPlaying = false;
87
98
  this.chunkQueue = [];
88
99
  this.startedPlaying = false;
@@ -100,14 +111,17 @@ export class ChunkedAudioPlayer {
100
111
  }
101
112
  }
102
113
  playChunk(chunk) {
103
- // console.log({queue: this.chunkQueue})
104
- if (!chunk) {
114
+ if (!chunk || this.stopped) {
105
115
  return Promise.resolve();
106
116
  }
107
- // console.log('Playing chunk', chunk);
108
117
  return new Promise((resolve) => {
109
118
  const source = this.audioContext.createBufferSource();
119
+ this.currentSource = source;
110
120
  this.audioContext.decodeAudioData(chunk.slice(0)).then((audioBuffer) => {
121
+ if (this.stopped) {
122
+ resolve();
123
+ return;
124
+ }
111
125
  source.buffer = audioBuffer;
112
126
  // Create a GainNode for volume control
113
127
  const gainNode = this.audioContext.createGain();
@@ -117,10 +131,11 @@ export class ChunkedAudioPlayer {
117
131
  gainNode.connect(this.analyser);
118
132
  this.analyser.connect(this.audioContext.destination);
119
133
  source.start(0);
120
- // console.log('Playing chunk', this.currentIndex);
121
134
  gainNode.gain.value = this.volume;
122
135
  source.onended = () => {
123
- // console.log('Chunk ended');
136
+ if (this.currentSource === source) {
137
+ this.currentSource = null;
138
+ }
124
139
  resolve();
125
140
  };
126
141
  // Start monitoring loudness only once
@@ -190,11 +205,10 @@ export class ChunkedAudioPlayer {
190
205
  this.handle = requestAnimationFrame(() => this.monitorLoudness());
191
206
  }
192
207
  reset() {
193
- // console.log('Resetting player');
194
208
  this.stopPlayback();
209
+ this.stopped = false;
195
210
  this.currentIndex = 0;
196
211
  this.shouldMonitorLoudness = true;
197
- //reset to the beginning when the class gets initialized
198
212
  this.isMonitoring = false;
199
213
  this.isPlaying = false;
200
214
  this.init();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rimori/client",
3
- "version": "2.5.28-next.0",
3
+ "version": "2.5.28-next.2",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {
@@ -36,9 +36,9 @@
36
36
  "format": "prettier --write ."
37
37
  },
38
38
  "dependencies": {
39
- "@supabase/postgrest-js": "^2.98.0",
39
+ "@supabase/postgrest-js": "^2.100.1",
40
40
  "dotenv": "^16.5.0",
41
- "i18next": "^25.8.15"
41
+ "i18next": "^25.10.10"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@eslint/js": "^9.37.0",