diff --git a/package.json b/package.json index 8fda9e8..007b227 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "0.20.0", "description": "TypeScript client for Rondevu with durable WebRTC connections, automatic reconnection, and message queuing", "type": "module", - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "dist/core/index.js", + "types": "dist/core/index.d.ts", "scripts": { "build": "tsc", "typecheck": "tsc --noEmit", diff --git a/src/rpc-batcher.ts b/src/api/batcher.ts similarity index 100% rename from src/rpc-batcher.ts rename to src/api/batcher.ts diff --git a/src/api.ts b/src/api/client.ts similarity index 97% rename from src/api.ts rename to src/api/client.ts index 8029d48..c80fcce 100644 --- a/src/api.ts +++ b/src/api/client.ts @@ -2,12 +2,12 @@ * Rondevu API Client - RPC interface */ -import { CryptoAdapter, Keypair } from './crypto-adapter.js' -import { WebCryptoAdapter } from './web-crypto-adapter.js' -import { RpcBatcher, BatcherOptions } from './rpc-batcher.js' +import { CryptoAdapter, Keypair } from '../crypto/adapter.js' +import { WebCryptoAdapter } from '../crypto/web.js' +import { RpcBatcher, BatcherOptions } from './batcher.js' -export type { Keypair } from './crypto-adapter.js' -export type { BatcherOptions } from './rpc-batcher.js' +export type { Keypair } from '../crypto/adapter.js' +export type { BatcherOptions } from './batcher.js' export interface OfferRequest { sdp: string diff --git a/src/answerer-connection.ts b/src/connections/answerer.ts similarity index 95% rename from src/answerer-connection.ts rename to src/connections/answerer.ts index ab6b926..98204b3 100644 --- a/src/answerer-connection.ts +++ b/src/connections/answerer.ts @@ -2,10 +2,10 @@ * Answerer-side WebRTC connection with answer creation and offer processing */ -import { RondevuConnection } from './connection.js' -import { ConnectionState } from './connection-events.js' -import { RondevuAPI } from './api.js' -import { ConnectionConfig } from './connection-config.js' +import { RondevuConnection } from './base.js' +import { ConnectionState } from './events.js' +import { RondevuAPI } from '../api/client.js' +import { ConnectionConfig } from './config.js' export interface AnswererOptions { api: RondevuAPI diff --git a/src/connection.ts b/src/connections/base.ts similarity index 98% rename from src/connection.ts rename to src/connections/base.ts index c6972de..3d0c309 100644 --- a/src/connection.ts +++ b/src/connections/base.ts @@ -3,16 +3,16 @@ */ import { EventEmitter } from 'eventemitter3' -import { ConnectionConfig, mergeConnectionConfig } from './connection-config.js' +import { ConnectionConfig, mergeConnectionConfig } from './config.js' import { ConnectionState, ConnectionEventMap, ConnectionEventName, ConnectionEventArgs, BufferedMessage, -} from './connection-events.js' -import { ExponentialBackoff } from './exponential-backoff.js' -import { MessageBuffer } from './message-buffer.js' +} from './events.js' +import { ExponentialBackoff } from '../utils/exponential-backoff.js' +import { MessageBuffer } from '../utils/message-buffer.js' /** * Abstract base class for WebRTC connections with durability features diff --git a/src/connection-config.ts b/src/connections/config.ts similarity index 100% rename from src/connection-config.ts rename to src/connections/config.ts diff --git a/src/connection-events.ts b/src/connections/events.ts similarity index 100% rename from src/connection-events.ts rename to src/connections/events.ts diff --git a/src/offerer-connection.ts b/src/connections/offerer.ts similarity index 97% rename from src/offerer-connection.ts rename to src/connections/offerer.ts index 99cd9d8..554c208 100644 --- a/src/offerer-connection.ts +++ b/src/connections/offerer.ts @@ -2,11 +2,11 @@ * Offerer-side WebRTC connection with offer creation and answer processing */ -import { RondevuConnection } from './connection.js' -import { ConnectionState } from './connection-events.js' -import { RondevuAPI } from './api.js' -import { ConnectionConfig } from './connection-config.js' -import { AsyncLock } from './async-lock.js' +import { RondevuConnection } from './base.js' +import { ConnectionState } from './events.js' +import { RondevuAPI } from '../api/client.js' +import { ConnectionConfig } from './config.js' +import { AsyncLock } from '../utils/async-lock.js' export interface OffererOptions { api: RondevuAPI diff --git a/src/index.ts b/src/core/index.ts similarity index 57% rename from src/index.ts rename to src/core/index.ts index cefc1ee..8a8c93d 100644 --- a/src/index.ts +++ b/src/core/index.ts @@ -4,21 +4,21 @@ */ export { Rondevu, RondevuError, NetworkError, ValidationError, ConnectionError } from './rondevu.js' -export { RondevuAPI } from './api.js' -export { RpcBatcher } from './rpc-batcher.js' +export { RondevuAPI } from '../api/client.js' +export { RpcBatcher } from '../api/batcher.js' // Export connection classes -export { RondevuConnection } from './connection.js' -export { OffererConnection } from './offerer-connection.js' -export { AnswererConnection } from './answerer-connection.js' +export { RondevuConnection } from '../connections/base.js' +export { OffererConnection } from '../connections/offerer.js' +export { AnswererConnection } from '../connections/answerer.js' // Export utilities -export { ExponentialBackoff } from './exponential-backoff.js' -export { MessageBuffer } from './message-buffer.js' +export { ExponentialBackoff } from '../utils/exponential-backoff.js' +export { MessageBuffer } from '../utils/message-buffer.js' // Export crypto adapters -export { WebCryptoAdapter } from './web-crypto-adapter.js' -export { NodeCryptoAdapter } from './node-crypto-adapter.js' +export { WebCryptoAdapter } from '../crypto/web.js' +export { NodeCryptoAdapter } from '../crypto/node.js' // Export types export type { @@ -33,7 +33,7 @@ export type { Service, ServiceOffer, IceCandidate, -} from './api.js' +} from '../api/client.js' export type { RondevuOptions, @@ -48,12 +48,12 @@ export type { PaginatedServiceResult } from './rondevu.js' -export type { CryptoAdapter } from './crypto-adapter.js' +export type { CryptoAdapter } from '../crypto/adapter.js' // Export connection types export type { ConnectionConfig, -} from './connection-config.js' +} from '../connections/config.js' export type { ConnectionState, @@ -63,13 +63,13 @@ export type { ConnectionEventMap, ConnectionEventName, ConnectionEventArgs, -} from './connection-events.js' +} from '../connections/events.js' export type { OffererOptions, -} from './offerer-connection.js' +} from '../connections/offerer.js' export type { AnswererOptions, -} from './answerer-connection.js' +} from '../connections/answerer.js' diff --git a/src/offer-pool.ts b/src/core/offer-pool.ts similarity index 98% rename from src/offer-pool.ts rename to src/core/offer-pool.ts index 8f03a2e..e5ca4e5 100644 --- a/src/offer-pool.ts +++ b/src/core/offer-pool.ts @@ -1,8 +1,8 @@ import { EventEmitter } from 'eventemitter3' -import { RondevuAPI } from './api.js' -import { OffererConnection } from './offerer-connection.js' -import { ConnectionConfig } from './connection-config.js' -import { AsyncLock } from './async-lock.js' +import { RondevuAPI } from '../api/client.js' +import { OffererConnection } from '../connections/offerer.js' +import { ConnectionConfig } from '../connections/config.js' +import { AsyncLock } from '../utils/async-lock.js' export type OfferFactory = (pc: RTCPeerConnection) => Promise<{ dc?: RTCDataChannel diff --git a/src/rondevu.ts b/src/core/rondevu.ts similarity index 99% rename from src/rondevu.ts rename to src/core/rondevu.ts index 0836302..93614d2 100644 --- a/src/rondevu.ts +++ b/src/core/rondevu.ts @@ -1,9 +1,9 @@ -import { RondevuAPI, Keypair, IceCandidate, BatcherOptions } from './api.js' -import { CryptoAdapter } from './crypto-adapter.js' +import { RondevuAPI, Keypair, IceCandidate, BatcherOptions } from '../api/client.js' +import { CryptoAdapter } from '../crypto/adapter.js' import { EventEmitter } from 'eventemitter3' -import { OffererConnection } from './offerer-connection.js' -import { AnswererConnection } from './answerer-connection.js' -import { ConnectionConfig } from './connection-config.js' +import { OffererConnection } from '../connections/offerer.js' +import { AnswererConnection } from '../connections/answerer.js' +import { ConnectionConfig } from '../connections/config.js' import { OfferPool } from './offer-pool.js' // ICE server preset names diff --git a/src/types.ts b/src/core/types.ts similarity index 100% rename from src/types.ts rename to src/core/types.ts diff --git a/src/crypto-adapter.ts b/src/crypto/adapter.ts similarity index 100% rename from src/crypto-adapter.ts rename to src/crypto/adapter.ts diff --git a/src/node-crypto-adapter.ts b/src/crypto/node.ts similarity index 98% rename from src/node-crypto-adapter.ts rename to src/crypto/node.ts index 2bf9d73..f8e1106 100644 --- a/src/node-crypto-adapter.ts +++ b/src/crypto/node.ts @@ -4,7 +4,7 @@ */ import * as ed25519 from '@noble/ed25519' -import { CryptoAdapter, Keypair } from './crypto-adapter.js' +import { CryptoAdapter, Keypair } from './adapter.js' /** * Node.js Crypto implementation using Node.js built-in APIs diff --git a/src/web-crypto-adapter.ts b/src/crypto/web.ts similarity index 97% rename from src/web-crypto-adapter.ts rename to src/crypto/web.ts index aa8175b..6992a63 100644 --- a/src/web-crypto-adapter.ts +++ b/src/crypto/web.ts @@ -3,7 +3,7 @@ */ import * as ed25519 from '@noble/ed25519' -import { CryptoAdapter, Keypair } from './crypto-adapter.js' +import { CryptoAdapter, Keypair } from './adapter.js' // Set SHA-512 hash function for ed25519 (required in @noble/ed25519 v3+) ed25519.hashes.sha512Async = async (message: Uint8Array) => { diff --git a/src/async-lock.ts b/src/utils/async-lock.ts similarity index 100% rename from src/async-lock.ts rename to src/utils/async-lock.ts diff --git a/src/exponential-backoff.ts b/src/utils/exponential-backoff.ts similarity index 100% rename from src/exponential-backoff.ts rename to src/utils/exponential-backoff.ts diff --git a/src/message-buffer.ts b/src/utils/message-buffer.ts similarity index 98% rename from src/message-buffer.ts rename to src/utils/message-buffer.ts index bb8bfd5..72d6b45 100644 --- a/src/message-buffer.ts +++ b/src/utils/message-buffer.ts @@ -2,7 +2,7 @@ * Message buffering system for storing messages during disconnections */ -import { BufferedMessage } from './connection-events.js' +import { BufferedMessage } from '../connections/events.js' export interface MessageBufferConfig { maxSize: number // Maximum number of messages to buffer