@kyrven/react-pdf-viewer 0.4.0-beta.1 → 0.4.0-beta.3

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 CHANGED
@@ -1,23 +1,85 @@
1
- # Visor PDF para React
1
+ # Kyrven React PDF Viewer
2
2
 
3
- Beta para aplicaciones React con Vite. El motor Hayro se ejecuta en un worker WebAssembly en el navegador. Vite incluye automáticamente ambos archivos en el despliegue.
3
+ A React component for viewing PDFs in the browser. Hayro parses and rasterizes pages in a web worker using a precompiled Rust/WebAssembly engine. Local documents are processed in the browser.
4
+
5
+ ## Install and render a PDF
6
+
7
+ In a React application using Vite, install the beta from npm:
4
8
 
5
9
  ```sh
6
10
  npm install @kyrven/react-pdf-viewer@beta
7
11
  ```
8
12
 
13
+ Place a PDF at `public/invoice.pdf`, then render the component:
14
+
9
15
  ```tsx
10
16
  import { PdfViewer } from '@kyrven/react-pdf-viewer'
11
17
 
12
- export default function Factura() {
13
- return <PdfViewer src="/facturas/ejemplo.pdf" options={{ height: '75vh' }} />
18
+ export default function Invoice() {
19
+ return <PdfViewer src="/invoice.pdf" options={{ height: '75vh' }} />
14
20
  }
15
21
  ```
16
22
 
17
- `src` admite una URL, un File, un Blob o un Uint8Array. Las URLs externas requieren que el servidor PDF permita CORS. El componente cancela la descarga cuando cambia el documento o se desmonta. La descarga tiene un plazo de 60 segundos y comprueba los bytes durante la lectura. Los límites predeterminados son 64 MiB y 2.000 páginas. Usa `options.maxFileBytes` o `options.maxPages` para reducirlos.
23
+ Vite packages the worker and WASM automatically. Use a modern browser with module workers, WebAssembly SIMD and Canvas 2D. Serve the worker and WASM from the application origin and configure the server to serve WASM as `application/wasm`.
24
+
25
+ ## Component API
26
+
27
+ `src` accepts a URL string, URL object, File, Blob or Uint8Array. Cross-origin PDF servers must allow CORS. Changing the source or unmounting the component cancels an active download. Downloads have a 60-second deadline and enforce the configured byte limit while reading.
28
+
29
+ | Option | Purpose |
30
+ | --- | --- |
31
+ | `layout` | Initial reading mode, either `continuous` (default) or `single`. |
32
+ | `initialZoom` | Initial zoom factor, from 0.25 to 3. |
33
+ | `height` | Viewport height as a CSS length or a number of pixels. |
34
+ | `toolbar` | Visible controls. Choose from `page`, `zoom` and `settings`. |
35
+ | `maxCachedPages` | Maximum number of cached canvases, from 1 to 6. |
36
+ | `maxFileBytes`, `maxPages` | Reduce the default limits of 64 MiB and 2,000 pages per document. |
37
+
38
+ Pass these fields in the `options` prop. The component also accepts `onLoad(pageCount)`, `onPageChange(page)` and `onError(error)`. It displays rasterized pages with zoom and navigation. Text selection, search and interactive forms are outside the current feature set.
39
+
40
+ ## Other bundlers
41
+
42
+ Import the component from `@kyrven/react-pdf-viewer/static` and run `npx hayro-pdf-assets public/hayro` during deployment. To use a different public directory, pass the target path to the command and its URL to the component as `assetsUrl`.
43
+
44
+ ## Develop and package
45
+
46
+ Use Node.js 22.13 or later. From the project root:
47
+
48
+ ```sh
49
+ npm ci
50
+ npm run build
51
+ npm pack
52
+ ```
53
+
54
+ The React component and its TypeScript adapter live in `src/viewer/`. The Rust adapter is in `engine/src/lib.rs`, the pinned Hayro dependency is in `engine/Cargo.toml`, and the worker is in `engine/web/pdf.worker.mjs`. The npm build copies the checked-in binary from `engine/prebuilt/hayro.wasm` into the generated `dist-lib/engine/` directory. Contributors working only on React do not need a Rust toolchain.
55
+
56
+ After changing Rust code or dependencies, install the WebAssembly target, rebuild the binary and regenerate the npm package:
57
+
58
+ ```sh
59
+ rustup target add wasm32-unknown-unknown
60
+ npm run build:engine
61
+ npm pack
62
+ ```
63
+
64
+ Commit the regenerated binary alongside its source changes. Review the dependency inventory and third-party notices when updating Cargo.lock.
18
65
 
19
- Configura `layout` (continuous o single), `toolbar` (page, zoom, settings), `initialZoom`, `height` y `maxCachedPages` en options. Usa `onLoad`, `onPageChange` y `onError` como propiedades del componente. El visor rasteriza páginas y permite navegar y ampliar. Requiere un navegador moderno con workers de módulo, WASM SIMD y Canvas 2D. Sirve el WASM como application/wasm desde el origen de la app.
66
+ ## License
67
+
68
+ The project is distributed under the [MIT License](LICENSE). Third-party licenses and attributions are included in [THIRD-PARTY](THIRD-PARTY/).
69
+
70
+ ## Publish a release to npm
71
+
72
+ Run the following commands from a clean, up-to-date main branch after committing and testing your changes. If the Rust engine changed, first rebuild it with `npm run build:engine` and include the updated WASM in your commit.
73
+
74
+ ```sh
75
+ npm ci
76
+ npm run build
77
+ npm version prerelease --preid=beta
78
+ npm publish --access public --tag beta
79
+ git push origin main --follow-tags
80
+ npm view @kyrven/react-pdf-viewer@beta version
81
+ ```
20
82
 
21
- Para empaquetadores sin soporte de importaciones de recursos de Vite, importa desde `@kyrven/react-pdf-viewer/static` y ejecuta `npx hayro-pdf-assets public/hayro` al desplegar. La propiedad assetsUrl permite indicar una base distinta de /hayro/.
83
+ From 0.4.0-beta.1, this creates version 0.4.0-beta.2 and its Git tag. Complete the npm authentication prompt when publishing. The registry can take a few minutes to make the new version available. Verify it in a separate React application with `npm install @kyrven/react-pdf-viewer@beta`.
22
84
 
23
- El paquete incluye el WASM precompilado y los avisos de las dependencias en THIRD-PARTY. Para mantener el proyecto, ejecuta npm ci y npm pack. Si cambian el código Rust o Cargo.lock, regenera el binario con npm run build:engine y revisa las atribuciones antes de empaquetar.
85
+ For the first stable release in this series, use `npm version 0.4.0` and `npm publish --access public --tag latest`, then push the release commit and tag. Choose patch, minor or major for subsequent stable releases according to the changes.
@@ -1,4 +1,4 @@
1
- hayro-poc-engine v0.1.0 (C:\Users\geosc\Documents\Codex\2026-11-20\pdf-engine-rust\outputs\hayro-poc\engine)
1
+ hayro-poc-engine v0.1.0 (engine/)
2
2
  hayro v0.9.0
3
3
  ab_glyph_rasterizer v0.1.10
4
4
  bytemuck v1.25.2
package/dist-lib/index.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { PdfViewer as Viewer } from './PdfViewer.js';
4
- const workerUrl = new URL('@kyrven/react-pdf-viewer/pdf.worker.mjs?no-inline', import.meta.url).href;
5
- const wasmUrl = new URL('@kyrven/react-pdf-viewer/hayro.wasm', import.meta.url).href;
4
+ // The private alias lets Vite externalize the worker during dependency optimization.
5
+ import workerUrl from '#hayro-worker.txt?url&no-inline';
6
+ import wasmUrl from './engine/hayro.wasm?url&no-inline';
6
7
  const engine = { workerUrl, wasmUrl };
7
8
  export function PdfViewer(props) {
8
9
  return _jsx(Viewer, { ...props, engine: engine });
package/package.json CHANGED
@@ -1,11 +1,14 @@
1
1
  {
2
2
  "name": "@kyrven/react-pdf-viewer",
3
- "version": "0.4.0-beta.1",
4
- "description": "Visor React de PDF con Hayro y WebAssembly",
3
+ "version": "0.4.0-beta.3",
4
+ "description": "React PDF viewer powered by Hayro, a Rust rendering engine compiled to WebAssembly.",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": ">=22.13.0"
8
8
  },
9
+ "imports": {
10
+ "#hayro-worker.txt": "./dist-lib/engine/pdf.worker.mjs"
11
+ },
9
12
  "exports": {
10
13
  ".": {
11
14
  "types": "./dist-lib/index.d.ts",
@@ -47,5 +50,13 @@
47
50
  "react": "19.3.1",
48
51
  "typescript": "~5.9.3"
49
52
  },
50
- "license": "MIT"
53
+ "license": "MIT",
54
+ "repository": {
55
+ "type": "git",
56
+ "url": "git+https://github.com/OscarGE11/kyrven-react-pdf-viewer.git"
57
+ },
58
+ "bugs": {
59
+ "url": "https://github.com/OscarGE11/kyrven-react-pdf-viewer/issues"
60
+ },
61
+ "homepage": "https://github.com/OscarGE11/kyrven-react-pdf-viewer#readme"
51
62
  }