Skip to content

Commit

Permalink
Merge pull request #2 from run-llama/feat/llama-pdf-viewer
Browse files Browse the repository at this point in the history
feat: llama pdf viewer
  • Loading branch information
marcusschiesser authored May 13, 2024
2 parents 9f95019 + 1e32cca commit 6ee68bb
Show file tree
Hide file tree
Showing 185 changed files with 4,246 additions and 46,488 deletions.
1 change: 1 addition & 0 deletions packages/react-pdf/.eslintignore → .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
node_modules
sample
14 changes: 14 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"extends": "wojtekmaj/react",
"rules": {
"@typescript-eslint/consistent-type-definitions": "off",
"@typescript-eslint/no-use-before-define": "off",
"react-hooks/exhaustive-deps": "off",
"no-console": "off",
"@typescript-eslint/ban-ts-comment": "off",
"react/jsx-no-leaked-render": "off",
"jsx-a11y/click-events-have-key-events": "off",
"jsx-a11y/no-static-element-interactions": "off",
"react/no-array-index-key": "off"
}
}
2 changes: 0 additions & 2 deletions .gitattributes

This file was deleted.

2 changes: 0 additions & 2 deletions .github/FUNDING.yml

This file was deleted.

65 changes: 0 additions & 65 deletions .github/ISSUE_TEMPLATE/Bug_report.yml

This file was deleted.

38 changes: 0 additions & 38 deletions .github/ISSUE_TEMPLATE/Feature_request.yml

This file was deleted.

5 changes: 0 additions & 5 deletions .github/ISSUE_TEMPLATE/config.yml

This file was deleted.

45 changes: 1 addition & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
react: [18, 19]
react: [18]

steps:
- name: Checkout
Expand Down Expand Up @@ -122,46 +122,3 @@ jobs:

- name: Run formatting
run: yarn format

unit:
name: Unit tests (React ${{ matrix.react }})
runs-on: ubuntu-latest
strategy:
matrix:
react: [18, 19]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Cache Yarn cache
uses: actions/cache@v4
env:
cache-name: yarn-cache
with:
path: ~/.yarn/berry/cache
key: ${{ runner.os }}-${{ env.cache-name }}-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-${{ env.cache-name }}
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Enable Corepack
run: corepack enable

- name: Install dependencies
run: yarn --immutable

- name: Override React version
if: ${{ matrix.react == 19 }}
run: |
npm pkg set resolutions.'@types/react'='npm:types-react@beta'
npm pkg set resolutions.'@types/react-dom'='npm:types-react-dom@beta'
yarn config set enableImmutableInstalls false
yarn up react@beta react-dom@beta
- name: Run tests (React ${{ matrix.react }})
run: yarn unit
25 changes: 0 additions & 25 deletions .github/workflows/close-stale-issues.yml

This file was deleted.

2 changes: 0 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,11 @@ jobs:
- name: Publish with latest tag
if: github.event.release.prelease == false
run: npm publish package.tgz --tag latest --provenance
working-directory: packages/react-pdf
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Publish with next tag
if: github.event.release.prelease == true
run: npm publish package.tgz --tag next --provenance
working-directory: packages/react-pdf
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ yarn-error.log
**/.env
**/.env.*
!**/.env.example

# sample app
sample/*
*.tgz
3 changes: 0 additions & 3 deletions .lintstagedrc.json

This file was deleted.

5 changes: 0 additions & 5 deletions .mailmap

This file was deleted.

1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.cache
.yarn
yarnrc.yml
dist
9 changes: 0 additions & 9 deletions .yarn/plugins/@yarnpkg/plugin-nolyfill.cjs

This file was deleted.

10 changes: 0 additions & 10 deletions .yarnrc.yml

This file was deleted.

21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

1 change: 0 additions & 1 deletion README.md

This file was deleted.

59 changes: 59 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
React PDF viewer for LLM applications

## Installation

```bash
npm install @llamaindex/pdf-viewer
```

## Usage

```jsx
import React from 'react';

import { PDFViewer, PdfFocusProvider } from '@llamaindex/pdf-viewer';

const file = {
id: 'sample-document',
url: 'https://d687lz8k56fia.cloudfront.net/sec-edgar-filings/0001045810/10-Q/0001045810-22-000147/filing-details.pdf',
};

function App() {
return (
<div className="AppContainer">
<PdfFocusProvider>
<PDFViewer file={file} />
</PdfFocusProvider>
</div>
);
}
```

## Custom Styles

```jsx
<PdfFocusProvider>
<PDFViewer containerClassName="your-container-class-name" file={file} />
</PdfFocusProvider>
```

## Multiple PDF Files

```jsx
<PdfFocusProvider>
<div className="your-layout-class-name">
<PDFViewer file={file1} />
<PDFViewer file={file2} />
<PDFViewer file={file3} />
</div>
</PdfFocusProvider>
```

## Dependencies

- react-pdf
- @wojtekmaj/react-hooks
- react-window
- react-intersection-observer
- lodash
- fuse.js
27 changes: 0 additions & 27 deletions __mocks__/_failing_page.ts

This file was deleted.

Loading

0 comments on commit 6ee68bb

Please sign in to comment.