Thank you for your interest in contributing to the LiveTemplate client library!
- Node.js 18.x or higher
- npm 9.x or higher
- Git
# Clone the repository
git clone https://github.com/livetemplate/client.git
cd client
# Install dependencies
npm install
# Install git hooks
./scripts/install-hooks.sh
# Run tests
npm test
# Build
npm run buildgit checkout -b feature/your-feature-name
# or
git checkout -b fix/your-bug-fix- Write code following existing patterns
- Add tests for new functionality
- Update documentation as needed
- Ensure all tests pass
# Run all tests
npm test
# Run specific test file
npm test -- focus-manager
# Run with coverage
npm test -- --coverage
# Build to verify no errors
npm run buildThe repository has a pre-commit hook that will:
- Run linter (if configured)
- Run all tests
- Build the project
Commits must pass all checks before they can be committed.
git add .
git commit -m "feat: add new feature"We follow Conventional Commits:
feat:New featurefix:Bug fixdocs:Documentation changestest:Adding or updating testsrefactor:Code refactoringperf:Performance improvementschore:Build process or tooling changes
Examples:
feat: add keyboard navigation support
fix: prevent focus loss during updates
docs: update API documentation
test: add tests for modal manager
git push origin feature/your-feature-nameThen create a Pull Request on GitHub.
- Use TypeScript for all code
- Provide type definitions
- Avoid
anytypes when possible - Document public APIs with JSDoc comments
- Classes: PascalCase (
LiveTemplateClient,FocusManager) - Functions: camelCase (
sendEvent,morphTree) - Constants: UPPER_SNAKE_CASE (
MAX_RETRIES,DEFAULT_TIMEOUT) - Private members: prefix with underscore (
_internalState)
- One class/component per file
- Group related functionality in directories
- Export from index files when appropriate
describe("ComponentName", () => {
describe("method", () => {
it("should do something specific", () => {
// Arrange
const component = new Component();
// Act
const result = component.method();
// Assert
expect(result).toBe(expected);
});
});
});- Aim for >80% code coverage
- Test happy paths and error cases
- Test edge cases and boundary conditions
- Mock external dependencies
# All tests
npm test
# Watch mode (for development)
npm test -- --watch
# With coverage
npm test -- --coverage
# Specific file
npm test -- event-delegation.test.tsAdd to dom/ directory:
// dom/my-feature.ts
export class MyFeature {
constructor(private element: HTMLElement) {}
public doSomething(): void {
// Implementation
}
}Add to state/ directory for features that manage application state.
Add to transport/ directory for network-related features.
If the feature should be part of the main client API, update livetemplate-client.ts:
import { MyFeature } from "./dom/my-feature";
export class LiveTemplateClient {
private myFeature: MyFeature;
constructor(options: LiveTemplateClientOptions) {
// ...
this.myFeature = new MyFeature(this.targetElement);
}
}The client follows the core library's major.minor version:
- Patch versions: Independent, for client-specific bug fixes
- Minor versions: Match core library minor version
- Major versions: Match core library major version
Before releasing:
- Ensure version matches core library's major.minor
- Update CHANGELOG.md
- Run
./scripts/release.sh
Releases are automated via scripts/release.sh:
# Dry run (no changes)
./scripts/release.sh --dry-run
# Actual release
./scripts/release.shThe script will:
- Validate version against core library
- Update VERSION and package.json
- Generate CHANGELOG.md
- Run tests and build
- Commit and tag
- Publish to npm
- Create GitHub release
If the LiveTemplate protocol changes (tree format, WebSocket messages, etc.):
- Check with core library team for compatibility
- Update client to handle new format
- Maintain backward compatibility when possible
- Document breaking changes in CHANGELOG
- Coordinate release with core library
Update for:
- New features
- API changes
- Configuration options
- Examples
- Document public APIs with JSDoc
- Explain complex logic inline
- Keep comments up-to-date
Add examples for new features in:
- README.md Quick Start section
- Inline code comments
- Test files (as usage examples)
- Questions: GitHub Discussions
- Bugs: GitHub Issues
- Core Library: LiveTemplate Repo
- Be respectful and inclusive
- Welcome newcomers
- Focus on constructive feedback
- Collaborate openly
By contributing, you agree that your contributions will be licensed under the MIT License.