src/: Core library (e.g.,processor.js,transform.js,versions.js,v2/,v3/,calculator/). Entry point:src/index.js(types intypes/).tests/: Jest tests (*.test.js) organized by version (tests/v2,tests/v3) with fixtures intests/fixtures/.scripts/: Helper scripts (notablyscripts/test.jswhich runs Jest in watch mode locally).examples/: Sample integrations, e.g.,examples/tiny-iiif/.
npm install: Install dependencies (installs optionalsharp).npm test: Run Jest (watches locally; CI disables watch).npm test:coverage: Generate coverage report incoverage/.npm run lint: Lintsrc/**/*.jswith ESLint (Standard config).npm run lint:fix: Auto-fix lint issues where possible.npm run clean: Removenode_modules/,vendor/, andcoverage/.
- Style: JavaScript (ES2022), 2-space indent, semicolons, Standard-based rules (
.eslintrc). Preferconst, novar, enforce object spacing, warn on high complexity. - Files: Lowercase filenames with dashes or simple names (e.g.,
processor.js,index.js); tests end with.test.js. - Imports/Exports: CommonJS (
require,module.exports). Keep functions small; aim under 30 lines where practical (rule-enforced warning).
- Framework: Jest; place tests under
tests/mirroringsrc/structure; name files*.test.js. - Running: Use
npm testfor watch;npm test:coveragebefore pushing. - Expectations: Maintain or improve coverage; include tests for new features and bug fixes; avoid network or external I/O—use fixtures/mocks. Debug test runs with
DEBUG=iiif-processor:*.
- Commits: Short, imperative subjects (e.g., "Constrain region to image bounds", "Increase precision of scale factor calculation"). Group related changes.
- PRs: Provide a clear description, link issues, include tests, update README/types if APIs change, and ensure
npm run lintandnpm testpass. FollowCONTRIBUTING.mdand the Samvera Code of Conduct.
- Image engine:
sharpis an optional dependency but required at runtime for processing; ensure compatible Node LTS and native deps. - Debugging:
DEBUG=iiif-processor:*(oriiif-processor:main,iiif-processor:transform) enables verbose logs. Local S3 examples may useprocess.env.tiffBucket.