@xtr-dev/rondevu-client 0.21.10 → 0.21.11

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.
@@ -20,6 +20,7 @@ export interface DiscoverRequest {
20
20
  }
21
21
  export interface CountOffersByTagsRequest {
22
22
  tags: string[];
23
+ unique?: boolean;
23
24
  }
24
25
  export interface CountOffersByTagsResponse {
25
26
  counts: Record<string, number>;
@@ -136,8 +137,8 @@ export declare class RondevuAPI {
136
137
  /**
137
138
  * Count available offers by tags
138
139
  * Returns the count of available (unanswered, non-expired) offers for each tag
139
- * @param request - Request with tags to count
140
- * @returns Object mapping each tag to its offer count
140
+ * @param request - Request with tags to count and optional unique flag
141
+ * @returns Object mapping each tag to its count
141
142
  */
142
143
  countOffersByTags(request: CountOffersByTagsRequest): Promise<CountOffersByTagsResponse>;
143
144
  /**
@@ -214,14 +214,15 @@ export class RondevuAPI {
214
214
  /**
215
215
  * Count available offers by tags
216
216
  * Returns the count of available (unanswered, non-expired) offers for each tag
217
- * @param request - Request with tags to count
218
- * @returns Object mapping each tag to its offer count
217
+ * @param request - Request with tags to count and optional unique flag
218
+ * @returns Object mapping each tag to its count
219
219
  */
220
220
  async countOffersByTags(request) {
221
221
  const rpcRequest = {
222
222
  method: 'countOffersByTags',
223
223
  params: {
224
224
  tags: request.tags,
225
+ ...(request.unique !== undefined && { unique: request.unique }),
225
226
  },
226
227
  };
227
228
  const authHeaders = await this.generateAuthHeaders(rpcRequest);
@@ -123,6 +123,9 @@ export class RondevuConnection extends EventEmitter {
123
123
  if (this.state === ConnectionState.SIGNALING) {
124
124
  this.transitionTo(ConnectionState.CHECKING, 'ICE checking started');
125
125
  }
126
+ // ICE is progressing - clear the connection timeout to give ICE time to complete
127
+ // The timeout was for signaling, ICE checking shows progress is being made
128
+ this.clearConnectionTimeout();
126
129
  // Note: ICE candidate polling is handled by PollingManager
127
130
  // Candidates are received via handleRemoteIceCandidates()
128
131
  break;
@@ -6,7 +6,7 @@
6
6
  * Advanced options use sensible defaults.
7
7
  */
8
8
  export interface ConnectionOptions {
9
- /** Maximum time to wait for connection (ms). Default: 10000 */
9
+ /** Maximum time to wait for connection (ms). Default: 30000 */
10
10
  timeout?: number;
11
11
  /** Enable automatic reconnection on failures. Default: true */
12
12
  reconnect?: boolean;
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const DEFAULT_CONNECTION_CONFIG = {
5
5
  // Timeouts
6
- connectionTimeout: 10000, // 10 seconds
6
+ connectionTimeout: 30000, // 30 seconds (should be less than server offer TTL)
7
7
  iceGatheringTimeout: 10000, // 10 seconds
8
8
  // Reconnection
9
9
  reconnectEnabled: true,
@@ -30,6 +30,7 @@ export class PollingManager extends EventEmitter {
30
30
  this.debug('Already running');
31
31
  return;
32
32
  }
33
+ console.log('[PollingManager] Starting polling manager');
33
34
  this.debug('Starting polling manager');
34
35
  this.running = true;
35
36
  // Poll immediately
@@ -74,6 +75,11 @@ export class PollingManager extends EventEmitter {
74
75
  return;
75
76
  try {
76
77
  const result = await this.api.poll(this.lastPollTimestamp);
78
+ // Log poll results for debugging (only when there are results)
79
+ const iceCount = Object.values(result.iceCandidates).reduce((sum, candidates) => sum + candidates.length, 0);
80
+ if (result.answers.length > 0 || iceCount > 0) {
81
+ console.log(`[PollingManager] Poll: ${result.answers.length} answers, ${iceCount} ICE (since: ${this.lastPollTimestamp})`);
82
+ }
77
83
  // Emit answer events
78
84
  for (const answer of result.answers) {
79
85
  this.debug(`Poll: answer for ${answer.offerId}`);
@@ -260,15 +260,19 @@ export declare class Rondevu extends EventEmitter {
260
260
  * Returns the count of available (unanswered, non-expired) offers for each tag
261
261
  *
262
262
  * @param tags - Tags to count offers for
263
- * @returns Object mapping each tag to its offer count
263
+ * @param unique - If true, count unique public keys instead of total offers
264
+ * @returns Object mapping each tag to its count
264
265
  *
265
266
  * @example
266
267
  * ```typescript
267
268
  * const counts = await rondevu.countOffersByTags(['chat', 'video'])
268
269
  * console.log(counts.counts) // { chat: 5, video: 3 }
270
+ *
271
+ * // Count unique peers instead of total offers
272
+ * const uniquePeers = await rondevu.countOffersByTags(['chat'], true)
269
273
  * ```
270
274
  */
271
- countOffersByTags(tags: string[]): Promise<{
275
+ countOffersByTags(tags: string[], unique?: boolean): Promise<{
272
276
  counts: Record<string, number>;
273
277
  }>;
274
278
  /**
@@ -451,16 +451,20 @@ export class Rondevu extends EventEmitter {
451
451
  * Returns the count of available (unanswered, non-expired) offers for each tag
452
452
  *
453
453
  * @param tags - Tags to count offers for
454
- * @returns Object mapping each tag to its offer count
454
+ * @param unique - If true, count unique public keys instead of total offers
455
+ * @returns Object mapping each tag to its count
455
456
  *
456
457
  * @example
457
458
  * ```typescript
458
459
  * const counts = await rondevu.countOffersByTags(['chat', 'video'])
459
460
  * console.log(counts.counts) // { chat: 5, video: 3 }
461
+ *
462
+ * // Count unique peers instead of total offers
463
+ * const uniquePeers = await rondevu.countOffersByTags(['chat'], true)
460
464
  * ```
461
465
  */
462
- async countOffersByTags(tags) {
463
- return await this.api.countOffersByTags({ tags });
466
+ async countOffersByTags(tags, unique) {
467
+ return await this.api.countOffersByTags({ tags, unique });
464
468
  }
465
469
  // ============================================
466
470
  // WebRTC Signaling
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xtr-dev/rondevu-client",
3
- "version": "0.21.10",
3
+ "version": "0.21.11",
4
4
  "description": "TypeScript client for Rondevu with durable WebRTC connections, automatic reconnection, and message queuing",
5
5
  "type": "module",
6
6
  "main": "dist/core/index.js",