Thank you for your interest in contributing to ng2-pdfjs-viewer! This document provides guidelines and information for contributors.
- π Bug Reports: Use GitHub Issues with the "bug" label
- π‘ Feature Requests: Use GitHub Discussions for feature ideas
- π Documentation: Help improve our docs and examples
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Run the test suite (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Node.js 18.0+
- Angular CLI 20.0+
- Git
# Clone the repository
git clone https://github.com/intbot/ng2-pdfjs-viewer.git
cd ng2-pdfjs-viewer
# Install dependencies
npm install
# Install playground dependencies
cd playground
npm install
cd ..Important: Due to Angular's build cache, you may need to clear the cache before running the app:
# Clear Angular cache (Windows PowerShell)
Remove-Item -Recurse -Force "playground\.angular"
# Or manually delete the .angular folder in playground directory# Build the library
npm run build
# Run the sample app
npm run start
# Run the complete test workflow (build β publish β update β install β run)
./test.bat
# Run tests
npm test
# Lint code
npm run lint
# Format code
npm run formatThe project uses a comprehensive test workflow via test.bat:
- Build the library
- Publish to local npm registry
- Link the build into the playground (yalc)
- Install dependencies
- Run the playground
This ensures you're testing the actual built library, not just the source code.
# Run unit tests
npm test
# Run e2e tests
npm run e2e
# Run tests with coverage
npm run test:coverage- Use TypeScript strict mode
- Follow Angular style guide
- Use meaningful variable and function names
- Add JSDoc comments for public APIs
- Use semantic HTML elements
- Follow Angular template best practices
- Use Angular Material components when possible
- Use CSS custom properties for theming
- Follow BEM methodology for class naming
- Use responsive design principles
- Avoid
!importantunless necessary
- Use conventional commit messages
- Keep commits focused and atomic
- Write descriptive commit messages
ng2-pdfjs-viewer/
βββ lib/ # Library source code
β βββ src/ # TypeScript source
β β βββ ng2-pdfjs-viewer.component.ts
β β βββ interfaces/
β β βββ managers/
β β βββ utils/
β βββ pdfjs/ # PDF.js integration
β β βββ web/
β β βββ postmessage-wrapper.js
β βββ dist/ # Built library
βββ playground/ # Demo app β feature explorer (Angular 22)
β βββ src/app/
β βββ shell/ # App shell + command palette
β βββ pages/ # One page per feature
β βββ core/ # Feature registry + services
βββ README.md # Main documentation
βββ CHANGELOG.md # Version history
βββ CONTRIBUTING.md # This file
- ng2-pdfjs-viewer.component.ts: Main Angular component
- postmessage-wrapper.js: PDF.js integration layer
- ActionQueueManager.ts: Action dispatching system
- PropertyTransformers.ts: Data transformation utilities
- Test all public methods and properties
- Test error conditions and edge cases
- Mock external dependencies
- Aim for 80%+ code coverage
- Test component integration with PDF.js
- Test event handling and communication
- Test different PDF sources (URL, Blob, Uint8Array)
- Test complete user workflows
- Test on different browsers
- Test responsive behavior
- Add JSDoc comments for all public APIs
- Include usage examples in comments
- Document complex algorithms and logic
- Update feature lists when adding new features
- Add usage examples for new functionality
- Update installation and setup instructions
- Document all input properties
- Document all output events
- Document all public methods
- Include type information
Docs and README copy should read like a maintainer wrote them β concrete and specific. CI
enforces a house style on every PR: check-docs-voice.mjs scans the Markdown/MDX a PR adds and the
PR's own title and body, and blocks filler and marketing-speak. A pre-commit hook runs the same check locally so
you catch it before pushing β enable it once per clone:
git config core.hooksPath .githooksIt runs node scripts/check-docs-voice.mjs --staged on staged Markdown/MDX. The rules:
- Lead with a concrete fact, number, or behavior, not an adjective.
- Cut filler superlatives (
seamless,effortless,blazing-fast,cutting-edge,world-class). Brand words (comprehensive,feature-rich,AI-enabled,mobile-first) are fine to use. - Keep a real voice: name trade-offs, state honest limits, write in first person where it fits.
- Vary sentence length and structure; don't repeat an identical title-then-one-sentence shape.
- Skip generic openers like
Welcome to the β¦orIn this guide we'll. Keep the code examples.
Run it on specific files anytime: node scripts/check-docs-voice.mjs README.md docs-website/docs/intro.md.
- Use semantic versioning (MAJOR.MINOR.PATCH)
- Update version in
lib/package.json - Update CHANGELOG.md with new features
- Create git tag for release
Publishing is automated: pushing a v* tag triggers .github/workflows/main.yml,
which builds lib/ and publishes to npm using trusted publishing (OIDC) with a
provenance attestation β no long-lived npm token is stored in the repo.
# Cut a release (from lib/) β builds, commits, tags, and pushes the tag
cd lib
npm version patch # or minor / majorFor a local dry run you can still npm run build && npm run package in lib/ to produce
the tarball without publishing.
Before the OIDC publish works, the ng2-pdfjs-viewer package must trust this repo's workflow:
- On npmjs.com β the
ng2-pdfjs-viewerpackage β Settings β Trusted Publisher. - Add a GitHub Actions publisher: organization
intbot, repositoryng2-pdfjs-viewer, workflow filenamemain.yml. - Once configured, the legacy
NPM_TOKENrepository secret can be deleted.
Provenance is generated automatically because this is a public repository.
This repo ships only the lib/ package β it has zero runtime dependencies. The playground and
demo app (playground/) and the docs site (docs-website/)
are not published.
To keep the repository's security signal honest, Dependabot alerts for those non-shipped
projects are auto-dismissed by a repository-level auto-triage rule that matches their manifest
paths. This is configured once in Settings β Code security β Dependabot β Auto-triage rules
(action: auto-dismiss; manifest path: playground/**, docs-website/**);
the built-in "dismiss low-impact dev-scoped" preset is also enabled. Dependabot version-update
PRs are scoped to /lib and the GitHub Actions workflows via .github/dependabot.yml. See
SECURITY.md for the rationale.
When reporting bugs, please include:
-
Environment Information
- Angular version
- Node.js version
- Browser and version
- Operating system
-
Reproduction Steps
- Clear steps to reproduce the issue
- Expected behavior
- Actual behavior
-
Code Example
- Minimal code that reproduces the issue
- Error messages or console output
-
Additional Context
- Screenshots if applicable
- Related issues or discussions
When requesting features, please include:
-
Use Case
- Why is this feature needed?
- How would it be used?
-
Proposed Solution
- How should it work?
- Any design considerations?
-
Alternatives
- Have you considered other approaches?
- Any workarounds currently available?
## Description
Brief description of changes
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Breaking change
- [ ] Documentation update
## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
## Checklist
- [ ] Code follows style guidelines
- [ ] Self-review completed
- [ ] Documentation updated
- [ ] No breaking changes (or documented)- π¬ Discussions: GitHub Discussions
- π§ Email: codehippie1@gmail.com
- π Issues: GitHub Issues
By contributing to ng2-pdfjs-viewer, you agree that your contributions will be licensed under the Apache License 2.0.
Thank you for contributing to ng2-pdfjs-viewer! π