Reorganize src/ directory into feature/domain-based structure

Restructure flat src/ directory (17 files) into organized folders:

Structure:
- src/core/ - Main API (rondevu.ts, offer-pool.ts, types.ts, index.ts)
- src/connections/ - WebRTC connections (base.ts, offerer.ts, answerer.ts, config.ts, events.ts)
- src/api/ - HTTP layer (client.ts, batcher.ts)
- src/crypto/ - Crypto adapters (adapter.ts, node.ts, web.ts)
- src/utils/ - Utilities (async-lock.ts, exponential-backoff.ts, message-buffer.ts)

Changes:
- Move all 17 files to appropriate feature folders
- Update all import paths to reflect new structure
- Update package.json main/types to point to dist/core/index.js
- Preserve git history with git mv

Benefits:
- Clear separation of concerns
- Easier navigation and maintenance
- Better scalability for future features
- Logical grouping of related files

🤖 Generated with Claude Code
This commit is contained in:
2025-12-16 22:51:23 +01:00
parent 121a4d490a
commit 3e55166cea
18 changed files with 47 additions and 47 deletions

View File

@@ -3,8 +3,8 @@
"version": "0.20.0", "version": "0.20.0",
"description": "TypeScript client for Rondevu with durable WebRTC connections, automatic reconnection, and message queuing", "description": "TypeScript client for Rondevu with durable WebRTC connections, automatic reconnection, and message queuing",
"type": "module", "type": "module",
"main": "dist/index.js", "main": "dist/core/index.js",
"types": "dist/index.d.ts", "types": "dist/core/index.d.ts",
"scripts": { "scripts": {
"build": "tsc", "build": "tsc",
"typecheck": "tsc --noEmit", "typecheck": "tsc --noEmit",

View File

@@ -2,12 +2,12 @@
* Rondevu API Client - RPC interface * Rondevu API Client - RPC interface
*/ */
import { CryptoAdapter, Keypair } from './crypto-adapter.js' import { CryptoAdapter, Keypair } from '../crypto/adapter.js'
import { WebCryptoAdapter } from './web-crypto-adapter.js' import { WebCryptoAdapter } from '../crypto/web.js'
import { RpcBatcher, BatcherOptions } from './rpc-batcher.js' import { RpcBatcher, BatcherOptions } from './batcher.js'
export type { Keypair } from './crypto-adapter.js' export type { Keypair } from '../crypto/adapter.js'
export type { BatcherOptions } from './rpc-batcher.js' export type { BatcherOptions } from './batcher.js'
export interface OfferRequest { export interface OfferRequest {
sdp: string sdp: string

View File

@@ -2,10 +2,10 @@
* Answerer-side WebRTC connection with answer creation and offer processing * Answerer-side WebRTC connection with answer creation and offer processing
*/ */
import { RondevuConnection } from './connection.js' import { RondevuConnection } from './base.js'
import { ConnectionState } from './connection-events.js' import { ConnectionState } from './events.js'
import { RondevuAPI } from './api.js' import { RondevuAPI } from '../api/client.js'
import { ConnectionConfig } from './connection-config.js' import { ConnectionConfig } from './config.js'
export interface AnswererOptions { export interface AnswererOptions {
api: RondevuAPI api: RondevuAPI

View File

@@ -3,16 +3,16 @@
*/ */
import { EventEmitter } from 'eventemitter3' import { EventEmitter } from 'eventemitter3'
import { ConnectionConfig, mergeConnectionConfig } from './connection-config.js' import { ConnectionConfig, mergeConnectionConfig } from './config.js'
import { import {
ConnectionState, ConnectionState,
ConnectionEventMap, ConnectionEventMap,
ConnectionEventName, ConnectionEventName,
ConnectionEventArgs, ConnectionEventArgs,
BufferedMessage, BufferedMessage,
} from './connection-events.js' } from './events.js'
import { ExponentialBackoff } from './exponential-backoff.js' import { ExponentialBackoff } from '../utils/exponential-backoff.js'
import { MessageBuffer } from './message-buffer.js' import { MessageBuffer } from '../utils/message-buffer.js'
/** /**
* Abstract base class for WebRTC connections with durability features * Abstract base class for WebRTC connections with durability features

View File

@@ -2,11 +2,11 @@
* Offerer-side WebRTC connection with offer creation and answer processing * Offerer-side WebRTC connection with offer creation and answer processing
*/ */
import { RondevuConnection } from './connection.js' import { RondevuConnection } from './base.js'
import { ConnectionState } from './connection-events.js' import { ConnectionState } from './events.js'
import { RondevuAPI } from './api.js' import { RondevuAPI } from '../api/client.js'
import { ConnectionConfig } from './connection-config.js' import { ConnectionConfig } from './config.js'
import { AsyncLock } from './async-lock.js' import { AsyncLock } from '../utils/async-lock.js'
export interface OffererOptions { export interface OffererOptions {
api: RondevuAPI api: RondevuAPI

View File

@@ -4,21 +4,21 @@
*/ */
export { Rondevu, RondevuError, NetworkError, ValidationError, ConnectionError } from './rondevu.js' export { Rondevu, RondevuError, NetworkError, ValidationError, ConnectionError } from './rondevu.js'
export { RondevuAPI } from './api.js' export { RondevuAPI } from '../api/client.js'
export { RpcBatcher } from './rpc-batcher.js' export { RpcBatcher } from '../api/batcher.js'
// Export connection classes // Export connection classes
export { RondevuConnection } from './connection.js' export { RondevuConnection } from '../connections/base.js'
export { OffererConnection } from './offerer-connection.js' export { OffererConnection } from '../connections/offerer.js'
export { AnswererConnection } from './answerer-connection.js' export { AnswererConnection } from '../connections/answerer.js'
// Export utilities // Export utilities
export { ExponentialBackoff } from './exponential-backoff.js' export { ExponentialBackoff } from '../utils/exponential-backoff.js'
export { MessageBuffer } from './message-buffer.js' export { MessageBuffer } from '../utils/message-buffer.js'
// Export crypto adapters // Export crypto adapters
export { WebCryptoAdapter } from './web-crypto-adapter.js' export { WebCryptoAdapter } from '../crypto/web.js'
export { NodeCryptoAdapter } from './node-crypto-adapter.js' export { NodeCryptoAdapter } from '../crypto/node.js'
// Export types // Export types
export type { export type {
@@ -33,7 +33,7 @@ export type {
Service, Service,
ServiceOffer, ServiceOffer,
IceCandidate, IceCandidate,
} from './api.js' } from '../api/client.js'
export type { export type {
RondevuOptions, RondevuOptions,
@@ -48,12 +48,12 @@ export type {
PaginatedServiceResult PaginatedServiceResult
} from './rondevu.js' } from './rondevu.js'
export type { CryptoAdapter } from './crypto-adapter.js' export type { CryptoAdapter } from '../crypto/adapter.js'
// Export connection types // Export connection types
export type { export type {
ConnectionConfig, ConnectionConfig,
} from './connection-config.js' } from '../connections/config.js'
export type { export type {
ConnectionState, ConnectionState,
@@ -63,13 +63,13 @@ export type {
ConnectionEventMap, ConnectionEventMap,
ConnectionEventName, ConnectionEventName,
ConnectionEventArgs, ConnectionEventArgs,
} from './connection-events.js' } from '../connections/events.js'
export type { export type {
OffererOptions, OffererOptions,
} from './offerer-connection.js' } from '../connections/offerer.js'
export type { export type {
AnswererOptions, AnswererOptions,
} from './answerer-connection.js' } from '../connections/answerer.js'

View File

@@ -1,8 +1,8 @@
import { EventEmitter } from 'eventemitter3' import { EventEmitter } from 'eventemitter3'
import { RondevuAPI } from './api.js' import { RondevuAPI } from '../api/client.js'
import { OffererConnection } from './offerer-connection.js' import { OffererConnection } from '../connections/offerer.js'
import { ConnectionConfig } from './connection-config.js' import { ConnectionConfig } from '../connections/config.js'
import { AsyncLock } from './async-lock.js' import { AsyncLock } from '../utils/async-lock.js'
export type OfferFactory = (pc: RTCPeerConnection) => Promise<{ export type OfferFactory = (pc: RTCPeerConnection) => Promise<{
dc?: RTCDataChannel dc?: RTCDataChannel

View File

@@ -1,9 +1,9 @@
import { RondevuAPI, Keypair, IceCandidate, BatcherOptions } from './api.js' import { RondevuAPI, Keypair, IceCandidate, BatcherOptions } from '../api/client.js'
import { CryptoAdapter } from './crypto-adapter.js' import { CryptoAdapter } from '../crypto/adapter.js'
import { EventEmitter } from 'eventemitter3' import { EventEmitter } from 'eventemitter3'
import { OffererConnection } from './offerer-connection.js' import { OffererConnection } from '../connections/offerer.js'
import { AnswererConnection } from './answerer-connection.js' import { AnswererConnection } from '../connections/answerer.js'
import { ConnectionConfig } from './connection-config.js' import { ConnectionConfig } from '../connections/config.js'
import { OfferPool } from './offer-pool.js' import { OfferPool } from './offer-pool.js'
// ICE server preset names // ICE server preset names

View File

@@ -4,7 +4,7 @@
*/ */
import * as ed25519 from '@noble/ed25519' 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 * Node.js Crypto implementation using Node.js built-in APIs

View File

@@ -3,7 +3,7 @@
*/ */
import * as ed25519 from '@noble/ed25519' 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+) // Set SHA-512 hash function for ed25519 (required in @noble/ed25519 v3+)
ed25519.hashes.sha512Async = async (message: Uint8Array) => { ed25519.hashes.sha512Async = async (message: Uint8Array) => {

View File

@@ -2,7 +2,7 @@
* Message buffering system for storing messages during disconnections * Message buffering system for storing messages during disconnections
*/ */
import { BufferedMessage } from './connection-events.js' import { BufferedMessage } from '../connections/events.js'
export interface MessageBufferConfig { export interface MessageBufferConfig {
maxSize: number // Maximum number of messages to buffer maxSize: number // Maximum number of messages to buffer