Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: ci

on:
push:
pull_request:

permissions:
contents: read

jobs:
test-lint-build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 20
cache: pnpm

- name: Install
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Test
run: pnpm test

- name: Build
run: pnpm build
163 changes: 163 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
name: release

on:
workflow_dispatch:
inputs:
tag:
description: 'SemVer tag to release (e.g., v1.2.3 or v1.2.3-rc.1)'
required: true
type: string

permissions:
contents: write

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout tag
uses: actions/checkout@v6
with:
fetch-depth: 0
ref: ${{ inputs.tag }}

- name: Verify tag exists
run: git rev-parse -q --verify "refs/tags/${{ inputs.tag }}"

- name: Setup pnpm
uses: pnpm/action-setup@v4

- name: Setup Node
uses: actions/setup-node@v5
with:
node-version: 20
cache: pnpm

- name: Install
run: pnpm install --frozen-lockfile

- name: Lint
run: pnpm lint

- name: Test
run: pnpm test

- name: Build
run: pnpm build

- name: Build example site
run: BASE_PATH="/${{ github.event.repository.name }}/" pnpm build:example

- name: Package dist
run: tar -czf "dist-${{ inputs.tag }}.tgz" dist

- name: Compute release metadata
id: meta
run: |
tag="${{ inputs.tag }}"
version="${tag#v}"
prerelease=false
npm_tag=latest
if [[ "$tag" == *-* ]]; then
prerelease=true
npm_tag=next
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "prerelease=$prerelease" >> "$GITHUB_OUTPUT"
echo "npm_tag=$npm_tag" >> "$GITHUB_OUTPUT"

- name: Verify package version matches tag
run: |
pkg_version="$(node -p "require('./package.json').version")"
if [[ "$pkg_version" != "${{ steps.meta.outputs.version }}" ]]; then
echo "Tag ${{ inputs.tag }} does not match package.json version $pkg_version" >&2
exit 1
fi

- name: Configure npm auth
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish to npm
run: pnpm publish --access public --no-git-checks --tag "${{ steps.meta.outputs.npm_tag }}"

- name: Generate release notes
id: notes
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const { owner, repo } = context.repo;
const tag = process.env.TAG;
const target = process.env.DEFAULT_BRANCH;
const response = await github.rest.repos.generateReleaseNotes({
owner,
repo,
tag_name: tag,
target_commitish: target,
});
const body = response.data.body || '';
const file = 'release-notes.md';
fs.writeFileSync(file, body);
env:
TAG: ${{ inputs.tag }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}

- name: Create GitHub Release
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const path = require('path');
const { owner, repo } = context.repo;
const tag = process.env.TAG;
const prerelease = process.env.PRERELEASE === 'true';
const makeLatest = prerelease ? 'false' : 'true';
const body = fs.readFileSync('release-notes.md', 'utf8');

const release = await github.rest.repos.createRelease({
owner,
repo,
tag_name: tag,
name: tag,
prerelease,
make_latest: makeLatest,
body,
});

const filePath = `dist-${tag}.tgz`;
const fileName = path.basename(filePath);
const fileData = fs.readFileSync(filePath);
const fileStat = fs.statSync(filePath);

await github.rest.repos.uploadReleaseAsset({
owner,
repo,
release_id: release.data.id,
name: fileName,
data: fileData,
headers: {
'content-type': 'application/gzip',
'content-length': fileStat.size,
},
});
env:
TAG: ${{ inputs.tag }}
PRERELEASE: ${{ steps.meta.outputs.prerelease }}

- name: Deploy GitHub Pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAG: ${{ inputs.tag }}
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git checkout --orphan gh-pages
git rm -rf .
cp -R apps/example/dist/* .
touch .nojekyll
git add .
git commit -m "docs: deploy gh-pages for ${TAG}"
git push -f origin gh-pages
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ build/Release
# Dependency directories
node_modules/
jspm_packages/
.pnpm-store/

# TypeScript v1 declaration files
typings/
Expand All @@ -61,9 +62,12 @@ typings/
.next

dist
examples/dist
.vite
.tsdown-cache

.DS_STORE

.rpt2_cache

.vscode
.vscode
36 changes: 0 additions & 36 deletions .travis.yml

This file was deleted.

37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Changelog

## v1.0.0-rc.1 - 2026-01-24

### Breaking changes
- Requires Node.js 20+ and React 18 peer dependencies.
- `PdfMultiViewer` now lazy-loads PDFs by default; set `lazyLoad={false}` to preload all documents.
- The package now ships `dist/react-pdfjs-multi.css` and `dist/pdf.worker.min.mjs`; update your CSS import and pdf.js worker setup accordingly.
- Removed the custom-event polyfill; legacy browsers may need their own polyfill.

### Added
- `icons` prop for `PdfMultiViewer` and `PdfRenderer` to override control icons/texture via CSS variables.
- `workerSrc` prop for `PdfMultiViewer` to provide a custom pdf.js worker URL.
- `initialLoadIndex` to prefetch a specific PDF when lazy-loading.
- A Vite-based example app under `apps/example` with new dev/build scripts.

### Updated
- Modernized build/test toolchain (tsdown, Vitest, Biome) and package exports (ESM/CJS via `exports`).
- Upgraded pdf.js to v5 and aligned the renderer integration with the ESM build.

## Unreleased (compared to main)

### Breaking changes
- Requires Node.js 20+ and React 18 peer dependencies.
- `PdfMultiViewer` now lazy-loads PDFs by default; set `lazyLoad={false}` to preload all documents.
- The package now ships `dist/react-pdfjs-multi.css` and `dist/pdf.worker.min.mjs`; update your CSS import and pdf.js worker setup accordingly.
- Removed the custom-event polyfill; legacy browsers may need their own polyfill.

### Added
- `icons` prop for `PdfMultiViewer` and `PdfRenderer` to override control icons/texture via CSS variables.
- `workerSrc` prop for `PdfMultiViewer` to provide a custom pdf.js worker URL.
- `initialLoadIndex` to prefetch a specific PDF when lazy-loading.
- A Vite-based example app under `apps/example` with new dev/build scripts.

### Updated
- Modernized build/test toolchain (tsdown, Vitest, Biome) and package exports (ESM/CJS via `exports`).
- Upgraded pdf.js to v5 and aligned the renderer integration with the ESM build.
Loading