@zerohive/hive-viewer 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +62 -0
- package/dist/index.cjs +897 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +859 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +43 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# @zerohive/hive-viewer
|
|
2
|
+
|
|
3
|
+
A self-hostable, browser-first document viewer/editor for React and Next.js.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @zerohive/hive-viewer
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Import styles once in your app:
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import '@zerohive/hive-viewer/styles.css';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Usage
|
|
18
|
+
|
|
19
|
+
```tsx
|
|
20
|
+
import { DocumentViewer } from '@zerohive/hive-viewer';
|
|
21
|
+
|
|
22
|
+
export default function Page() {
|
|
23
|
+
return (
|
|
24
|
+
<DocumentViewer
|
|
25
|
+
mode="edit"
|
|
26
|
+
fileUrl="https://example.com/my.pdf"
|
|
27
|
+
fileName="my.pdf"
|
|
28
|
+
fileType="pdf"
|
|
29
|
+
allowSigning
|
|
30
|
+
onSignRequest={async () => ({
|
|
31
|
+
signatureImageUrl: 'https://.../sig.png',
|
|
32
|
+
signedBy: 'Jane Doe',
|
|
33
|
+
dateSigned: new Date().toISOString(),
|
|
34
|
+
comment: 'Approved'
|
|
35
|
+
})}
|
|
36
|
+
onSave={(b64, meta) => { /* persist */ }}
|
|
37
|
+
/>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Signing Workflow (decoupled)
|
|
43
|
+
|
|
44
|
+
- If `allowSigning={true}`, the toolbar shows **Sign Document**.
|
|
45
|
+
- Clicking it calls `onSignRequest()` (parent handles biometric/e-signature/KYC/etc.).
|
|
46
|
+
- The returned `Signature` is immediately displayed:
|
|
47
|
+
- `view/edit`: signatures appear in the right signature panel and can be **placed** onto the page by clicking **Place signature**.
|
|
48
|
+
- `create`: signatures are appended to the end of the document (no right panel).
|
|
49
|
+
|
|
50
|
+
## Progressive loading and caching
|
|
51
|
+
|
|
52
|
+
- `fileUrl` loading uses streaming where available (`fetch` + `ReadableStream`).
|
|
53
|
+
- For PDFs, `pdfjs` is configured with `rangeChunkSize` so rendering can start before the full file downloads.
|
|
54
|
+
- In `fileUrl` mode, the package caches the ArrayBuffer in-memory during the session to avoid re-fetching when switching layouts/modes.
|
|
55
|
+
|
|
56
|
+
## Security
|
|
57
|
+
|
|
58
|
+
- Markdown/HTML content is sanitized via DOMPurify before rendering.
|
|
59
|
+
|
|
60
|
+
## Props
|
|
61
|
+
|
|
62
|
+
See `src/types.ts` for full types.
|