@sawport/peers-caller 0.0.0 → 0.0.1

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.
Files changed (2) hide show
  1. package/README.md +182 -57
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -680,103 +680,228 @@ yarn type-check # Check TypeScript types without building
680
680
 
681
681
  This project uses **Vitest** for testing with comprehensive coverage reporting and WebRTC API mocking.
682
682
 
683
- This project uses Vitest for testing with comprehensive coverage reporting.
683
+ ### Testing
684
+
685
+ This project uses **Vitest** for testing with comprehensive coverage reporting and WebRTC API mocking.
686
+
687
+ #### Test Environment
688
+
689
+ The test setup includes:
690
+ - **WebRTC API Mocks**: RTCPeerConnection, MediaDevices, getUserMedia
691
+ - **Socket.IO Mocking**: Complete WebSocket simulation
692
+ - **jsdom Environment**: DOM testing capabilities
693
+ - **TypeScript Support**: Full type checking in tests
694
+ - **Coverage Reporting**: Detailed coverage analysis
684
695
 
685
696
  #### Running Tests
686
697
 
687
698
  ```bash
688
- # Run tests once
699
+ # Run all tests once
689
700
  yarn test
690
701
 
691
- # Run tests in watch mode (for development)
702
+ # Watch mode for development
692
703
  yarn test:watch
693
704
 
694
- # Run tests with coverage report
705
+ # Generate coverage report
695
706
  yarn test:coverage
696
707
 
697
- # Open Vitest UI
708
+ # Interactive test UI
698
709
  yarn test:ui
699
710
  ```
700
711
 
701
- #### Test Structure
702
-
703
- - `__tests__/` - Integration and setup tests
704
- - `src/**/*.test.ts` - Unit tests alongside source code
705
- - `src/test-utils.ts` - Shared test utilities and mocks
706
-
707
712
  #### Writing Tests
708
713
 
709
- The test environment includes:
710
-
711
- - **WebRTC API mocks** - RTCPeerConnection, MediaDevices, etc.
712
- - **External library mocks** - simple-peer, socket.io-client
713
- - **jsdom environment** - For DOM testing
714
- - **TypeScript support** - Full type checking in tests
714
+ ```typescript
715
+ import { describe, it, expect, vi } from 'vitest';
716
+ import { PeersCaller } from '../core/PeersCaller';
717
+ import { mockWebRTC } from '../test-utils';
715
718
 
716
- Example test:
719
+ describe('PeersCaller', () => {
720
+ beforeEach(() => {
721
+ mockWebRTC(); // Set up WebRTC mocks
722
+ });
717
723
 
718
- ```typescript
719
- import { describe, it, expect } from 'vitest';
720
- import { generatePeerId } from '../utils';
724
+ it('should initialize successfully', async () => {
725
+ const peersCaller = new PeersCaller({
726
+ conversationId: 'test-123',
727
+ userId: 'user-456',
728
+ token: 'fake-token',
729
+ socketUrl: 'http://localhost:3000'
730
+ });
721
731
 
722
- describe('generatePeerId', () => {
723
- it('should generate unique peer IDs', () => {
724
- const id1 = generatePeerId();
725
- const id2 = generatePeerId();
726
-
727
- expect(id1).not.toBe(id2);
728
- expect(id1).toMatch(/^peer_\d+_[a-z0-9]{1,9}$/);
732
+ await expect(peersCaller.initialize()).resolves.not.toThrow();
733
+ expect(peersCaller.getCallState().callStatus).toBe('idle');
729
734
  });
730
735
  });
731
736
  ```
732
737
 
733
738
  #### Coverage Thresholds
734
739
 
735
- The project maintains high test coverage standards:
736
-
737
740
  - **Branches**: 80%
738
741
  - **Functions**: 80%
739
742
  - **Lines**: 80%
740
743
  - **Statements**: 80%
741
744
 
742
- ### CI/CD
745
+ ### Project Structure
746
+
747
+ ```
748
+ src/
749
+ ├── core/ # Core classes and logic
750
+ │ ├── PeersCaller.ts # Main orchestrator
751
+ │ ├── CallSocket.ts # WebSocket signaling
752
+ │ ├── CallParticipant.ts # Participant management
753
+ │ ├── CallRecorder.ts # Recording functionality
754
+ │ └── ...
755
+ ├── store/ # Zustand state management
756
+ │ └── index.ts
757
+ ├── hooks/ # React hooks
758
+ │ └── index.ts
759
+ ├── types/ # TypeScript definitions
760
+ │ └── index.ts
761
+ ├── utils/ # Utility functions
762
+ │ └── index.ts
763
+ ├── test-utils.ts # Test utilities and mocks
764
+ └── index.ts # Main entry point
765
+ ```
766
+
767
+ ### Contributing Guidelines
768
+
769
+ 1. **Fork & Clone**: Fork the repository and clone your fork
770
+ 2. **Branch**: Create a feature branch (`git checkout -b feature/amazing-feature`)
771
+ 3. **Develop**: Make your changes following the coding standards
772
+ 4. **Test**: Write tests for new functionality and ensure all tests pass
773
+ 5. **Type Safety**: Maintain TypeScript strict mode compliance
774
+ 6. **Documentation**: Update documentation as needed
775
+ 7. **Commit**: Use conventional commit messages
776
+ 8. **PR**: Open a Pull Request with a clear description
777
+
778
+ ### Code Style Guidelines
779
+
780
+ - **TypeScript Strict Mode**: All code must pass strict type checking
781
+ - **ESLint + Prettier**: Follow the established code style
782
+ - **Functional Programming**: Prefer pure functions and immutability
783
+ - **Error Handling**: Always handle errors gracefully
784
+ - **Documentation**: Document public APIs and complex logic
785
+ - **Testing**: Write tests for all new functionality
786
+
787
+ ### Build & Distribution
788
+
789
+ The library is built using **Vite** and generates multiple output formats:
790
+
791
+ ```bash
792
+ dist/
793
+ ├── peers-caller.es.js # ES modules
794
+ ├── peers-caller.umd.js # UMD bundle
795
+ ├── index.d.ts # TypeScript declarations
796
+ └── style.css # Optional styles
797
+ ```
798
+
799
+ ### CI/CD Pipeline
743
800
 
744
801
  GitHub Actions automatically:
745
802
 
746
- - ✅ Runs tests on Node.js 18.x, 20.x, 22.x
747
- - ✅ Checks TypeScript compilation
748
- - ✅ Generates coverage reports
749
- - ✅ Builds the library
750
- - ✅ Uploads coverage to Codecov (optional)
803
+ - ✅ **Tests** on Node.js 18.x, 20.x, 22.x
804
+ - ✅ **Type Checking** with TypeScript
805
+ - ✅ **Linting** with ESLint
806
+ - ✅ **Coverage Reports** with Codecov
807
+ - ✅ **Build Validation** for all platforms
808
+ - 🚀 **Automated Publishing** to npm (on release)
809
+
810
+ ## 🤝 Contributing
811
+
812
+ We welcome contributions! Here's how you can help:
813
+
814
+ ### Areas for Contribution
815
+
816
+ - 🐛 **Bug Fixes**: Report and fix issues
817
+ - ✨ **Features**: Propose and implement new features
818
+ - 📚 **Documentation**: Improve docs and examples
819
+ - 🧪 **Testing**: Add more test cases and improve coverage
820
+ - 🔧 **Performance**: Optimize performance and bundle size
821
+ - 🎨 **UI/UX**: Improve React hooks and developer experience
822
+
823
+ ### Getting Started
824
+
825
+ 1. Check existing [issues](https://github.com/sawport/peers-caller/issues) and [pull requests](https://github.com/sawport/peers-caller/pulls)
826
+ 2. Open an issue to discuss major changes
827
+ 3. Follow the development setup instructions
828
+ 4. Make your changes and add tests
829
+ 5. Submit a pull request
830
+
831
+ ### Commit Convention
832
+
833
+ We use [Conventional Commits](https://www.conventionalcommits.org/):
834
+
835
+ ```bash
836
+ feat: add screen sharing support
837
+ fix: resolve peer connection race condition
838
+ docs: update API documentation
839
+ test: add integration tests for recording
840
+ refactor: simplify state management logic
841
+ ```
842
+
843
+ ## 📋 Roadmap
751
844
 
752
- ## API Reference
845
+ ### Current Version (v0.x)
753
846
 
754
- ### Utilities
847
+ - ✅ Basic peer-to-peer video calls
848
+ - ✅ Mesh architecture (up to 4 participants)
849
+ - ✅ Media controls (audio/video toggle)
850
+ - ✅ Screen sharing
851
+ - ✅ Call recording
852
+ - ✅ React hooks integration
853
+ - ✅ TypeScript support
755
854
 
756
- ### Store
855
+ ### Planned Features (v1.0)
757
856
 
857
+ - 🔄 **Improved Error Handling**: Better error recovery and user feedback
858
+ - 📊 **Call Analytics**: Bandwidth monitoring and quality metrics
859
+ - 🔊 **Audio Processing**: Noise suppression and echo cancellation
860
+ - 📱 **Mobile Optimization**: Better mobile device support
861
+ - 🌍 **Internationalization**: Multi-language support
862
+ - 🔌 **Plugin System**: Extensible architecture for custom features
758
863
 
759
- ### Types
864
+ ### Future Considerations
760
865
 
761
- ## Contributing
866
+ - **SFU Mode**: Support for Selective Forwarding Unit architecture
867
+ - **Chat Integration**: Text messaging during calls
868
+ - **Whiteboard**: Collaborative drawing and annotation
869
+ - **Virtual Backgrounds**: AI-powered background replacement
870
+ - **Call Waiting**: Queue management for busy participants
762
871
 
763
- 1. Fork the repository
764
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`)
765
- 3. Make your changes
766
- 4. Add tests for new functionality
767
- 5. Ensure tests pass (`yarn test`)
768
- 6. Commit your changes (`git commit -m 'Add amazing feature'`)
769
- 7. Push to the branch (`git push origin feature/amazing-feature`)
770
- 8. Open a Pull Request
872
+ ## 🔒 Security Considerations
771
873
 
772
- ### Development Guidelines
874
+ ### WebRTC Security
773
875
 
774
- - Write tests for all new functionality
775
- - Maintain TypeScript strict mode compliance
776
- - Follow the existing code style
777
- - Update documentation as needed
778
- - Ensure CI passes before submitting PR
876
+ - **DTLS Encryption**: All media streams are encrypted end-to-end
877
+ - **SRTP**: Secure Real-time Transport Protocol for media
878
+ - **ICE Candidates**: Secure NAT traversal with STUN/TURN servers
879
+ - **Origin Validation**: Server-side origin checking for WebSocket connections
779
880
 
780
- ## License
881
+ ### Authentication
781
882
 
782
- MIT License - see LICENSE file for details.
883
+ - **JWT Tokens**: Secure authentication with JSON Web Tokens
884
+ - **Token Expiration**: Implement proper token refresh mechanisms
885
+ - **User Validation**: Server-side user validation and authorization
886
+
887
+ ### Best Practices
888
+
889
+ - **HTTPS Only**: Always use HTTPS in production
890
+ - **CORS Configuration**: Properly configure Cross-Origin Resource Sharing
891
+ - **Input Validation**: Validate all user inputs and signaling data
892
+ - **Rate Limiting**: Implement rate limiting on signaling server
893
+ - **Audit Logging**: Log security-relevant events
894
+
895
+ ## 📄 License
896
+
897
+ MIT License - see [LICENSE](./LICENSE) file for details.
898
+
899
+ ---
900
+
901
+ <div align="center">
902
+
903
+ **Built with ❤️ by the [Sawport](https://github.com/sawport) team**
904
+
905
+ [🌟 Star on GitHub](https://github.com/sawport/peers-caller) • [🐛 Report Issues](https://github.com/sawport/peers-caller/issues) • [💬 Discussions](https://github.com/sawport/peers-caller/discussions)
906
+
907
+ </div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sawport/peers-caller",
3
- "version": "0.0.0",
3
+ "version": "0.0.1",
4
4
  "description": "WebRTC multi-peer video call library with mesh architecture supporting up to 4 participants",
5
5
  "type": "module",
6
6
  "main": "./dist/peers-caller.umd.js",