Skip to content

Commit 6bca1e1

Browse files
committed
feat(CLAUDE.md): Add
1 parent 58646fc commit 6bca1e1

File tree

1 file changed

+256
-0
lines changed

1 file changed

+256
-0
lines changed

CLAUDE.md

Lines changed: 256 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,256 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## lib-jitsi-meet Architecture
6+
7+
This is the JavaScript library for accessing Jitsi Meet server-side deployments. It provides WebRTC functionality, XMPP communication, and media handling for Jitsi Meet clients.
8+
9+
## Common Development Commands
10+
11+
### Build Commands
12+
```bash
13+
npm run build # Full build (webpack UMD bundle + TypeScript compilation)
14+
npm run build:webpack # Build UMD bundle only for browser <script> tags
15+
npm run build:webpack-dev # Development webpack bundle
16+
npm run build:tsc # TypeScript compilation only for ESM modules
17+
npm run watch # Development build with file watching
18+
```
19+
20+
### Development Commands
21+
22+
**Testing:**
23+
- `npm test` - Run all tests via Karma (single run)
24+
- `npm run test-watch` - Run tests in watch mode
25+
- Tests use Jasmine framework with Chrome headless browser
26+
27+
**Code Quality:**
28+
- `npm run lint` - ESLint + TypeScript type checking
29+
- `npm run lint-fix` - Auto-fix linting issues
30+
- `npm run type-check` - TypeScript type checking only
31+
32+
**Documentation:**
33+
- `npm run typedoc` - Generate TypeScript documentation
34+
35+
**Other:**
36+
- `npm run gen-types` - Generate TypeScript declaration file
37+
38+
### TypeScript Migration
39+
40+
New features should be implemented only with TypeScript. When modifying existing JavaScript files, consider converting to TypeScript. The codebase is actively migrating from JavaScript to TypeScript.
41+
42+
**TypeScript Conventions:**
43+
- 4-space indentation, LF line endings
44+
- TypeScript enums for constant groups
45+
- Interfaces for major components during transition
46+
- Use strict type checking and avoid `any`, `unknown` and `object` type
47+
- Strong type checking enabled in tsconfig.json
48+
49+
### Key Dependencies
50+
51+
**Core Libraries:**
52+
- `strophe.js` - XMPP client library (custom Jitsi fork)
53+
- `webrtc-adapter` - WebRTC compatibility shim
54+
- `sdp-transform` - SDP parsing and manipulation
55+
- `@jitsi/logger` - Logging framework
56+
- `@jitsi/js-utils` - Jitsi JavaScript utilities
57+
58+
**Development:**
59+
- Webpack for bundling (UMD and ES modules)
60+
- Karma + Jasmine for testing
61+
- ESLint with @jitsi/eslint-config
62+
- TypeScript compiler
63+
64+
### Configuration Files
65+
- `webpack.config.js` + `webpack-shared-config.js` - Webpack configuration for UMD builds
66+
- `tsconfig.json` - TypeScript configuration with ES2020 target
67+
- `karma.conf.js` - Test runner configuration
68+
- `.eslintrc.js` - ESLint with TypeScript support
69+
- `tools/gen-version.js` - Version generation script
70+
71+
### Testing Guidelines
72+
73+
- Tests located alongside source files with `.spec.ts` extension
74+
- Karma runs tests in Chrome headless browser
75+
- Tests include both TypeScript and JavaScript files during migration
76+
- Use Jasmine framework for assertions and test structure
77+
78+
## Code Architecture
79+
80+
### Core API Structure
81+
- **JitsiMeetJS.ts** - Main library entry point exposing the public API
82+
- **JitsiConnection.ts** - XMPP connection management and authentication
83+
- **JitsiConference.js** - Video conference session representation
84+
- **JitsiParticipant.ts** - Conference participant abstraction
85+
- **JitsiTrack/JitsiLocalTrack/JitsiRemoteTrack** - Media track management
86+
87+
### Module Organization
88+
89+
**RTC Module** (`/modules/RTC/`):
90+
- Core WebRTC functionality, track management, and screen sharing
91+
- **TraceablePeerConnection.js** - Enhanced PeerConnection with debugging
92+
- **RTCUtils.js** - Browser compatibility and WebRTC utilities
93+
94+
**XMPP Module** (`/modules/xmpp/`):
95+
- XMPP/Jingle protocol implementation for signaling
96+
- **ChatRoom.js** - Multi-user chat room with presence management
97+
- **JingleSessionPC.js** - Jingle protocol for media negotiation
98+
- **SignalingLayerImpl.js** - Abstraction layer for signaling
99+
- **Strophe plugins** - Protocol extensions (disco, ping, stream-management, etc.)
100+
101+
**E2EE Module** (`/modules/e2ee/`):
102+
- End-to-end encryption using insertable streams and SFrame
103+
- **Worker.js** - Web worker for E2EE processing (separate webpack entry)
104+
- **OlmAdapter.js** - Integration with Olm for key management
105+
106+
**Quality Control** (`/modules/qualitycontrol/`):
107+
- Video quality adaptation and codec selection
108+
- **ReceiveVideoController/SendVideoController** - Stream management
109+
110+
**Service Layer** (`/service/`):
111+
- Type-safe constants, events, and enums
112+
- Well-defined event system used throughout the library
113+
114+
### Build System Architecture
115+
- **Dual output**: UMD bundle (`dist/umd/`) and ESM modules (`dist/esm/`)
116+
- **Webpack configuration**: Shared config with separate UMD and E2EE worker builds
117+
- **TypeScript migration**: Gradual migration with both `.js` and `.ts` files coexisting
118+
- **Testing**: Karma + Jasmine with webpack preprocessing for both JS and TS files
119+
120+
### Key Design Patterns
121+
- **Event-driven architecture**: Extensive use of EventEmitter throughout all modules
122+
- **Protocol abstraction**: Clean separation between XMPP signaling and WebRTC media
123+
- **Modular design**: Self-contained modules with clear dependencies
124+
- **Browser compatibility**: webrtc-adapter integration and capability detection
125+
126+
### Development Notes
127+
- Tests are located alongside source files with `.spec.js/.spec.ts` extensions
128+
- TypeScript types are maintained in `/types` directory for gradual migration
129+
- Main library exposes both ESM (`JitsiMeetJS.js`) and UMD (`lib-jitsi-meet.min.js`) builds
130+
- E2EE worker is built as separate bundle for web worker usage
131+
- Maintain backward compatibility in public API
132+
133+
## Integration with jitsi-meet
134+
135+
### Dependency Management
136+
- **NOT published to npm** - Uses GitHub releases for distribution
137+
- Default jitsi-meet dependency: `"lib-jitsi-meet": "https://github.com/jitsi/lib-jitsi-meet/releases/download/v<version>+<commit-hash>/lib-jitsi-meet.tgz"`
138+
- Package artifacts generated with `npm pack` command
139+
140+
### Local Development Workflow
141+
1. **Using npm pack** (recommended):
142+
```bash
143+
# In lib-jitsi-meet directory
144+
npm pack
145+
# In jitsi-meet directory
146+
npm install file:///path/to/lib-jitsi-meet-<version>.tgz --force && make
147+
```
148+
149+
2. **Using npm link** (simpler but won't work for mobile builds):
150+
```bash
151+
# In lib-jitsi-meet directory
152+
npm link
153+
# In jitsi-meet directory
154+
npm link lib-jitsi-meet
155+
# Rebuild after changes
156+
cd node_modules/lib-jitsi-meet && npm run build
157+
```
158+
159+
3. **Unlinking when done**:
160+
```bash
161+
npm unlink lib-jitsi-meet
162+
npm install
163+
```
164+
165+
### Integration Commands
166+
- **Full rebuild**: `npm install lib-jitsi-meet --force && make`
167+
- **Library only**: `npm install lib-jitsi-meet --force && make deploy-lib-jitsi-meet`
168+
- **Development changes**: Rebuild with `npm run build` in lib-jitsi-meet
169+
170+
## Code Style and Conventions
171+
172+
### Commit Message Format
173+
Follow [Conventional Commits](https://www.conventionalcommits.org) with **mandatory module scopes**:
174+
```
175+
feat(RTC): add new WebRTC functionality
176+
fix(xmpp): resolve Jingle negotiation issue
177+
docs(JitsiConnection): update connection API documentation
178+
```
179+
180+
Module scope examples:
181+
- `RTC` - WebRTC functionality
182+
- `xmpp` - XMPP/Jingle signaling
183+
- `e2ee` - End-to-end encryption
184+
- `qualitycontrol` - Video quality management
185+
- `service` - Events, constants, and type definitions
186+
- `JitsiConnection`, `JitsiConference`, etc. - Main API classes
187+
188+
### Testing Requirements
189+
- Write tests for new functionality using Jasmine syntax
190+
- Place test files alongside source with `.spec.js/.spec.ts` extension
191+
- Test both success and error scenarios
192+
- Mock external dependencies (XMPP connections, WebRTC APIs)
193+
- Ensure tests work with both Karma test runner and direct Node.js execution
194+
195+
## Architecture Best Practices
196+
197+
### Event System
198+
- Use typed events from `/service/` directory
199+
- Follow EventEmitter pattern consistently
200+
- Document event parameters and timing in JSDoc comments
201+
- Emit events for all significant state changes
202+
203+
### Module Design
204+
- Keep modules self-contained with minimal cross-dependencies
205+
- Use clear interfaces between XMPP signaling and WebRTC media layers
206+
- Abstract protocol details behind higher-level APIs
207+
- Provide consistent error handling and reporting
208+
209+
### WebRTC Integration
210+
- Use TraceablePeerConnection for enhanced debugging
211+
- Handle browser compatibility through RTCUtils abstraction
212+
- Implement proper track lifecycle management
213+
214+
### XMPP Protocol Handling
215+
- Implement Strophe plugins for protocol extensions
216+
- Handle connection states and recovery scenarios
217+
- Support both BOSH and WebSocket transports
218+
- Maintain protocol compliance with XEP specifications
219+
220+
## Common Development Scenarios
221+
222+
### Adding New WebRTC Features
223+
1. Implement core functionality in `/modules/RTC/`
224+
2. Add XMPP signaling support in `/modules/xmpp/`
225+
3. Expose through main API classes (JitsiConference, JitsiConnection)
226+
4. Update TypeScript definitions
227+
5. Add comprehensive tests
228+
6. Document public API changes
229+
230+
### Protocol Extensions
231+
1. Create Strophe plugin in `/modules/xmpp/strophe.*.js`
232+
2. Integrate with existing signaling layer
233+
3. Add event definitions in `/service/`
234+
4. Test with both BOSH and WebSocket transports
235+
5. Ensure backward compatibility
236+
237+
### Quality Control Enhancements
238+
1. Modify controllers in `/modules/qualitycontrol/`
239+
2. Update codec preferences and constraints
240+
3. Test across different network conditions
241+
4. Verify mobile and desktop compatibility
242+
5. Monitor performance impact
243+
244+
## External Resources
245+
- [Jitsi Handbook](https://jitsi.github.io/handbook/) - Comprehensive documentation
246+
- [lib-jitsi-meet Development Guide](https://jitsi.github.io/handbook/docs/dev-guide/ljm)
247+
- [jitsi-meet Integration Guide](https://jitsi.github.io/handbook/docs/dev-guide/ljm)
248+
- [XMPP Protocol Specifications](https://xmpp.org/extensions/) - XEP documentation
249+
- [WebRTC API Reference](https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API) - Browser WebRTC APIs
250+
251+
### Code Style
252+
- Follow @jitsi/eslint-config rules
253+
- TypeScript member ordering enforced
254+
- Sort object keys in ascending order
255+
- 4-space indentation consistently
256+
- JSDoc comments required

0 commit comments

Comments
 (0)