mirror of
https://github.com/xtr-dev/rondevu-client.git
synced 2025-12-10 10:53:24 +00:00
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:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@xtr-dev/rondevu-client",
|
||||
"version": "0.1.2",
|
||||
"version": "0.2.1",
|
||||
"description": "TypeScript client for Rondevu peer signaling and discovery server",
|
||||
"type": "module",
|
||||
"main": "dist/index.js",
|
||||
@@ -8,8 +8,7 @@
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"typecheck": "tsc --noEmit",
|
||||
"prepublishOnly": "npm run build",
|
||||
"publish": "npm publish"
|
||||
"prepublishOnly": "npm run build"
|
||||
},
|
||||
"keywords": [
|
||||
"webrtc",
|
||||
|
||||
@@ -16,14 +16,14 @@ import {
|
||||
} 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 fetchImpl: typeof fetch;
|
||||
|
||||
/**
|
||||
* Creates a new Rondevu client instance
|
||||
* Creates a new Rondevu API client instance
|
||||
* @param options - Client configuration options
|
||||
*/
|
||||
constructor(options: RondevuClientOptions) {
|
||||
@@ -70,8 +70,8 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const { version } = await client.getVersion();
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
* const { version } = await api.getVersion();
|
||||
* console.log('Server version:', version);
|
||||
* ```
|
||||
*/
|
||||
@@ -90,8 +90,8 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const { topics, pagination } = await client.listTopics();
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
* const { topics, pagination } = await api.listTopics();
|
||||
* console.log(`Found ${topics.length} topics`);
|
||||
* ```
|
||||
*/
|
||||
@@ -113,8 +113,8 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const { sessions } = await client.listSessions('my-room');
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
* const { sessions } = await api.listSessions('my-room');
|
||||
* const otherPeers = sessions.filter(s => s.peerId !== myPeerId);
|
||||
* ```
|
||||
*/
|
||||
@@ -133,8 +133,8 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const { code } = await client.createOffer('my-room', {
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
* const { code } = await api.createOffer('my-room', {
|
||||
* peerId: 'peer-123',
|
||||
* offer: signalingData
|
||||
* });
|
||||
@@ -162,17 +162,17 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
*
|
||||
* // Send answer
|
||||
* await client.sendAnswer({
|
||||
* await api.sendAnswer({
|
||||
* code: sessionCode,
|
||||
* answer: answerData,
|
||||
* side: 'answerer'
|
||||
* });
|
||||
*
|
||||
* // Send candidate
|
||||
* await client.sendAnswer({
|
||||
* await api.sendAnswer({
|
||||
* code: sessionCode,
|
||||
* candidate: candidateData,
|
||||
* side: 'offerer'
|
||||
@@ -195,16 +195,16 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
*
|
||||
* // Offerer polls for answer
|
||||
* const offererData = await client.poll(sessionCode, 'offerer');
|
||||
* const offererData = await api.poll(sessionCode, 'offerer');
|
||||
* if (offererData.answer) {
|
||||
* console.log('Received answer:', offererData.answer);
|
||||
* }
|
||||
*
|
||||
* // Answerer polls for offer
|
||||
* const answererData = await client.poll(sessionCode, 'answerer');
|
||||
* const answererData = await api.poll(sessionCode, 'answerer');
|
||||
* console.log('Received offer:', answererData.offer);
|
||||
* ```
|
||||
*/
|
||||
@@ -226,8 +226,8 @@ export class RondevuClient {
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const client = new RondevuClient({ baseUrl: 'https://example.com' });
|
||||
* const health = await client.health();
|
||||
* const api = new RondevuAPI({ baseUrl: 'https://example.com' });
|
||||
* const health = await api.health();
|
||||
* console.log('Server status:', health.status);
|
||||
* ```
|
||||
*/
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { EventEmitter } from './event-emitter';
|
||||
import { RondevuClient } from './client';
|
||||
import { RondevuAPI } from './client';
|
||||
import { RondevuConnectionParams } from './types';
|
||||
|
||||
/**
|
||||
@@ -12,7 +12,7 @@ export class RondevuConnection extends EventEmitter {
|
||||
readonly remotePeerId: string;
|
||||
|
||||
private pc: RTCPeerConnection;
|
||||
private client: RondevuClient;
|
||||
private client: RondevuAPI;
|
||||
private localPeerId: string;
|
||||
private dataChannels: Map<string, RTCDataChannel>;
|
||||
private pollingInterval?: ReturnType<typeof setInterval>;
|
||||
@@ -22,7 +22,7 @@ export class RondevuConnection extends EventEmitter {
|
||||
private isPolling: boolean = false;
|
||||
private isClosed: boolean = false;
|
||||
|
||||
constructor(params: RondevuConnectionParams, client: RondevuClient) {
|
||||
constructor(params: RondevuConnectionParams, client: RondevuAPI) {
|
||||
super();
|
||||
this.id = params.id;
|
||||
this.topic = params.topic;
|
||||
|
||||
@@ -9,8 +9,8 @@ export { Rondevu } from './rondevu';
|
||||
// Export connection class
|
||||
export { RondevuConnection } from './connection';
|
||||
|
||||
// Export low-level signaling client (for advanced usage)
|
||||
export { RondevuClient } from './client';
|
||||
// Export low-level signaling API (for advanced usage)
|
||||
export { RondevuAPI } from './client';
|
||||
|
||||
// Export all types
|
||||
export type {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { RondevuClient } from './client';
|
||||
import { RondevuAPI } from './client';
|
||||
import { RondevuConnection } from './connection';
|
||||
import { RondevuOptions, JoinOptions, RondevuConnectionParams } from './types';
|
||||
|
||||
@@ -7,8 +7,8 @@ import { RondevuOptions, JoinOptions, RondevuConnectionParams } from './types';
|
||||
*/
|
||||
export class Rondevu {
|
||||
readonly peerId: string;
|
||||
readonly api: RondevuAPI;
|
||||
|
||||
private client: RondevuClient;
|
||||
private baseUrl: string;
|
||||
private fetchImpl?: typeof fetch;
|
||||
private rtcConfig?: RTCConfiguration;
|
||||
@@ -23,7 +23,7 @@ export class Rondevu {
|
||||
this.baseUrl = options.baseUrl || 'https://rondevu.xtrdev.workers.dev';
|
||||
this.fetchImpl = options.fetch;
|
||||
|
||||
this.client = new RondevuClient({
|
||||
this.api = new RondevuAPI({
|
||||
baseUrl: this.baseUrl,
|
||||
fetch: options.fetch,
|
||||
});
|
||||
@@ -70,7 +70,7 @@ export class Rondevu {
|
||||
await this.waitForIceGathering(pc);
|
||||
|
||||
// Create session on server with custom code
|
||||
await this.client.createOffer(topic, {
|
||||
await this.api.createOffer(topic, {
|
||||
peerId: this.peerId,
|
||||
offer: pc.localDescription!.sdp,
|
||||
code: id,
|
||||
@@ -88,7 +88,7 @@ export class Rondevu {
|
||||
connectionTimeout: this.connectionTimeout,
|
||||
};
|
||||
|
||||
const connection = new RondevuConnection(connectionParams, this.client);
|
||||
const connection = new RondevuConnection(connectionParams, this.api);
|
||||
|
||||
// Start polling for answer
|
||||
connection.startPolling();
|
||||
@@ -103,7 +103,7 @@ export class Rondevu {
|
||||
*/
|
||||
async connect(id: string): Promise<RondevuConnection> {
|
||||
// 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) {
|
||||
throw new Error(`Connection ${id} not found or expired`);
|
||||
@@ -126,7 +126,7 @@ export class Rondevu {
|
||||
await this.waitForIceGathering(pc);
|
||||
|
||||
// Send answer to server
|
||||
await this.client.sendAnswer({
|
||||
await this.api.sendAnswer({
|
||||
code: id,
|
||||
answer: pc.localDescription!.sdp,
|
||||
side: 'answerer',
|
||||
@@ -144,7 +144,7 @@ export class Rondevu {
|
||||
connectionTimeout: this.connectionTimeout,
|
||||
};
|
||||
|
||||
const connection = new RondevuConnection(connectionParams, this.client);
|
||||
const connection = new RondevuConnection(connectionParams, this.api);
|
||||
|
||||
// Start polling for ICE candidates
|
||||
connection.startPolling();
|
||||
@@ -160,7 +160,7 @@ export class Rondevu {
|
||||
*/
|
||||
async join(topic: string, options?: JoinOptions): Promise<RondevuConnection> {
|
||||
// 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)
|
||||
let availableSessions = sessions.filter(
|
||||
@@ -243,7 +243,7 @@ export class Rondevu {
|
||||
*/
|
||||
private async findSessionByIdWithClient(
|
||||
id: string,
|
||||
client: RondevuClient
|
||||
client: RondevuAPI
|
||||
): Promise<{
|
||||
code: string;
|
||||
peerId: string;
|
||||
|
||||
Reference in New Issue
Block a user