Rename RondevuClient to RondevuAPI and integrate into Rondevu class

- Renamed RondevuClient class to RondevuAPI for clarity
- Integrated API as public property `api` on Rondevu class
- Updated all internal references from `client` to `api`
- Updated all example code in documentation
- Removed recursive publish script from package.json
- Bumped version to 0.2.1

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-12 21:51:11 +01:00
parent 35dc5aee36
commit a893c7d040
5 changed files with 36 additions and 37 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "@xtr-dev/rondevu-client", "name": "@xtr-dev/rondevu-client",
"version": "0.1.2", "version": "0.2.1",
"description": "TypeScript client for Rondevu peer signaling and discovery server", "description": "TypeScript client for Rondevu peer signaling and discovery server",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/index.js",
@@ -8,8 +8,7 @@
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",
"prepublishOnly": "npm run build", "prepublishOnly": "npm run build"
"publish": "npm publish"
}, },
"keywords": [ "keywords": [
"webrtc", "webrtc",

View File

@@ -16,14 +16,14 @@ import {
} from './types'; } from './types';
/** /**
* HTTP client for Rondevu peer signaling and discovery server * HTTP API client for Rondevu peer signaling and discovery server
*/ */
export class RondevuClient { export class RondevuAPI {
private readonly baseUrl: string; private readonly baseUrl: string;
private readonly fetchImpl: typeof fetch; private readonly fetchImpl: typeof fetch;
/** /**
* Creates a new Rondevu client instance * Creates a new Rondevu API client instance
* @param options - Client configuration options * @param options - Client configuration options
*/ */
constructor(options: RondevuClientOptions) { constructor(options: RondevuClientOptions) {
@@ -70,8 +70,8 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* const { version } = await client.getVersion(); * const { version } = await api.getVersion();
* console.log('Server version:', version); * console.log('Server version:', version);
* ``` * ```
*/ */
@@ -90,8 +90,8 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* const { topics, pagination } = await client.listTopics(); * const { topics, pagination } = await api.listTopics();
* console.log(`Found ${topics.length} topics`); * console.log(`Found ${topics.length} topics`);
* ``` * ```
*/ */
@@ -113,8 +113,8 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* const { sessions } = await client.listSessions('my-room'); * const { sessions } = await api.listSessions('my-room');
* const otherPeers = sessions.filter(s => s.peerId !== myPeerId); * const otherPeers = sessions.filter(s => s.peerId !== myPeerId);
* ``` * ```
*/ */
@@ -133,8 +133,8 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* const { code } = await client.createOffer('my-room', { * const { code } = await api.createOffer('my-room', {
* peerId: 'peer-123', * peerId: 'peer-123',
* offer: signalingData * offer: signalingData
* }); * });
@@ -162,17 +162,17 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* *
* // Send answer * // Send answer
* await client.sendAnswer({ * await api.sendAnswer({
* code: sessionCode, * code: sessionCode,
* answer: answerData, * answer: answerData,
* side: 'answerer' * side: 'answerer'
* }); * });
* *
* // Send candidate * // Send candidate
* await client.sendAnswer({ * await api.sendAnswer({
* code: sessionCode, * code: sessionCode,
* candidate: candidateData, * candidate: candidateData,
* side: 'offerer' * side: 'offerer'
@@ -195,16 +195,16 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* *
* // Offerer polls for answer * // Offerer polls for answer
* const offererData = await client.poll(sessionCode, 'offerer'); * const offererData = await api.poll(sessionCode, 'offerer');
* if (offererData.answer) { * if (offererData.answer) {
* console.log('Received answer:', offererData.answer); * console.log('Received answer:', offererData.answer);
* } * }
* *
* // Answerer polls for offer * // Answerer polls for offer
* const answererData = await client.poll(sessionCode, 'answerer'); * const answererData = await api.poll(sessionCode, 'answerer');
* console.log('Received offer:', answererData.offer); * console.log('Received offer:', answererData.offer);
* ``` * ```
*/ */
@@ -226,8 +226,8 @@ export class RondevuClient {
* *
* @example * @example
* ```typescript * ```typescript
* const client = new RondevuClient({ baseUrl: 'https://example.com' }); * const api = new RondevuAPI({ baseUrl: 'https://example.com' });
* const health = await client.health(); * const health = await api.health();
* console.log('Server status:', health.status); * console.log('Server status:', health.status);
* ``` * ```
*/ */

View File

@@ -1,5 +1,5 @@
import { EventEmitter } from './event-emitter'; import { EventEmitter } from './event-emitter';
import { RondevuClient } from './client'; import { RondevuAPI } from './client';
import { RondevuConnectionParams } from './types'; import { RondevuConnectionParams } from './types';
/** /**
@@ -12,7 +12,7 @@ export class RondevuConnection extends EventEmitter {
readonly remotePeerId: string; readonly remotePeerId: string;
private pc: RTCPeerConnection; private pc: RTCPeerConnection;
private client: RondevuClient; private client: RondevuAPI;
private localPeerId: string; private localPeerId: string;
private dataChannels: Map<string, RTCDataChannel>; private dataChannels: Map<string, RTCDataChannel>;
private pollingInterval?: ReturnType<typeof setInterval>; private pollingInterval?: ReturnType<typeof setInterval>;
@@ -22,7 +22,7 @@ export class RondevuConnection extends EventEmitter {
private isPolling: boolean = false; private isPolling: boolean = false;
private isClosed: boolean = false; private isClosed: boolean = false;
constructor(params: RondevuConnectionParams, client: RondevuClient) { constructor(params: RondevuConnectionParams, client: RondevuAPI) {
super(); super();
this.id = params.id; this.id = params.id;
this.topic = params.topic; this.topic = params.topic;

View File

@@ -9,8 +9,8 @@ export { Rondevu } from './rondevu';
// Export connection class // Export connection class
export { RondevuConnection } from './connection'; export { RondevuConnection } from './connection';
// Export low-level signaling client (for advanced usage) // Export low-level signaling API (for advanced usage)
export { RondevuClient } from './client'; export { RondevuAPI } from './client';
// Export all types // Export all types
export type { export type {

View File

@@ -1,4 +1,4 @@
import { RondevuClient } from './client'; import { RondevuAPI } from './client';
import { RondevuConnection } from './connection'; import { RondevuConnection } from './connection';
import { RondevuOptions, JoinOptions, RondevuConnectionParams } from './types'; import { RondevuOptions, JoinOptions, RondevuConnectionParams } from './types';
@@ -7,8 +7,8 @@ import { RondevuOptions, JoinOptions, RondevuConnectionParams } from './types';
*/ */
export class Rondevu { export class Rondevu {
readonly peerId: string; readonly peerId: string;
readonly api: RondevuAPI;
private client: RondevuClient;
private baseUrl: string; private baseUrl: string;
private fetchImpl?: typeof fetch; private fetchImpl?: typeof fetch;
private rtcConfig?: RTCConfiguration; private rtcConfig?: RTCConfiguration;
@@ -23,7 +23,7 @@ export class Rondevu {
this.baseUrl = options.baseUrl || 'https://rondevu.xtrdev.workers.dev'; this.baseUrl = options.baseUrl || 'https://rondevu.xtrdev.workers.dev';
this.fetchImpl = options.fetch; this.fetchImpl = options.fetch;
this.client = new RondevuClient({ this.api = new RondevuAPI({
baseUrl: this.baseUrl, baseUrl: this.baseUrl,
fetch: options.fetch, fetch: options.fetch,
}); });
@@ -70,7 +70,7 @@ export class Rondevu {
await this.waitForIceGathering(pc); await this.waitForIceGathering(pc);
// Create session on server with custom code // Create session on server with custom code
await this.client.createOffer(topic, { await this.api.createOffer(topic, {
peerId: this.peerId, peerId: this.peerId,
offer: pc.localDescription!.sdp, offer: pc.localDescription!.sdp,
code: id, code: id,
@@ -88,7 +88,7 @@ export class Rondevu {
connectionTimeout: this.connectionTimeout, connectionTimeout: this.connectionTimeout,
}; };
const connection = new RondevuConnection(connectionParams, this.client); const connection = new RondevuConnection(connectionParams, this.api);
// Start polling for answer // Start polling for answer
connection.startPolling(); connection.startPolling();
@@ -103,7 +103,7 @@ export class Rondevu {
*/ */
async connect(id: string): Promise<RondevuConnection> { async connect(id: string): Promise<RondevuConnection> {
// Poll server to get session by ID // Poll server to get session by ID
const sessionData = await this.findSessionByIdWithClient(id, this.client); const sessionData = await this.findSessionByIdWithClient(id, this.api);
if (!sessionData) { if (!sessionData) {
throw new Error(`Connection ${id} not found or expired`); throw new Error(`Connection ${id} not found or expired`);
@@ -126,7 +126,7 @@ export class Rondevu {
await this.waitForIceGathering(pc); await this.waitForIceGathering(pc);
// Send answer to server // Send answer to server
await this.client.sendAnswer({ await this.api.sendAnswer({
code: id, code: id,
answer: pc.localDescription!.sdp, answer: pc.localDescription!.sdp,
side: 'answerer', side: 'answerer',
@@ -144,7 +144,7 @@ export class Rondevu {
connectionTimeout: this.connectionTimeout, connectionTimeout: this.connectionTimeout,
}; };
const connection = new RondevuConnection(connectionParams, this.client); const connection = new RondevuConnection(connectionParams, this.api);
// Start polling for ICE candidates // Start polling for ICE candidates
connection.startPolling(); connection.startPolling();
@@ -160,7 +160,7 @@ export class Rondevu {
*/ */
async join(topic: string, options?: JoinOptions): Promise<RondevuConnection> { async join(topic: string, options?: JoinOptions): Promise<RondevuConnection> {
// List sessions in topic // List sessions in topic
const { sessions } = await this.client.listSessions(topic); const { sessions } = await this.api.listSessions(topic);
// Filter out self (sessions with our peer ID) // Filter out self (sessions with our peer ID)
let availableSessions = sessions.filter( let availableSessions = sessions.filter(
@@ -243,7 +243,7 @@ export class Rondevu {
*/ */
private async findSessionByIdWithClient( private async findSessionByIdWithClient(
id: string, id: string,
client: RondevuClient client: RondevuAPI
): Promise<{ ): Promise<{
code: string; code: string;
peerId: string; peerId: string;