@mulingai-npm/redis 3.37.0 → 3.38.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.
@@ -37,9 +37,10 @@ export declare class ChunkSequencerManager {
37
37
  private waitingRoomKey;
38
38
  /**
39
39
  * Get the next expected chunk number for a room/language
40
- * Returns 1 if not initialized yet (first chunk)
40
+ * If not initialized, uses fallbackChunk (defaults to the incoming chunk number).
41
+ * This handles sessions where chunk numbers don't start at 1 (they increment globally).
41
42
  */
42
- getExpectedChunk(roomId: string, language: string): Promise<number>;
43
+ getExpectedChunk(roomId: string, language: string, fallbackChunk?: number): Promise<number>;
43
44
  /**
44
45
  * Set the expected chunk number
45
46
  */
@@ -28,16 +28,17 @@ class ChunkSequencerManager {
28
28
  }
29
29
  /**
30
30
  * Get the next expected chunk number for a room/language
31
- * Returns 1 if not initialized yet (first chunk)
31
+ * If not initialized, uses fallbackChunk (defaults to the incoming chunk number).
32
+ * This handles sessions where chunk numbers don't start at 1 (they increment globally).
32
33
  */
33
- async getExpectedChunk(roomId, language) {
34
+ async getExpectedChunk(roomId, language, fallbackChunk) {
34
35
  const key = this.expectedChunkKey(roomId, language);
35
36
  const value = await this.redisClient.get(key);
36
37
  if (!value) {
37
- // Initialize to 1 for first chunk
38
- await this.redisClient.set(key, '1');
38
+ const initial = fallbackChunk !== null && fallbackChunk !== void 0 ? fallbackChunk : 1;
39
+ await this.redisClient.set(key, initial.toString());
39
40
  await this.redisClient.expire(key, 3600); // 1 hour TTL
40
- return 1;
41
+ return initial;
41
42
  }
42
43
  return parseInt(value, 10);
43
44
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "3.37.0",
3
+ "version": "3.38.0",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {