genus-pdf-viewer 0.1.13 → 0.2.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 +96 -64
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/{workers → dist}/pdf.worker.min.mjs +0 -0
- package/dist/styles.css +132 -0
- package/dist/styles.d.ts +2 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +135 -0
- package/dist/styles.js.map +1 -0
- package/dist/types.d.ts +41 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/viewer.d.ts +27 -0
- package/dist/viewer.d.ts.map +1 -0
- package/dist/viewer.js +630 -0
- package/dist/viewer.js.map +1 -0
- package/package.json +51 -20
- package/fesm2022/genus-pdf-viewer.mjs +0 -1346
- package/fesm2022/genus-pdf-viewer.mjs.map +0 -1
- package/genus-pdf-viewer-0.1.13.tgz +0 -0
- package/index.d.ts +0 -119
- package/schematics/collection.json +0 -10
- package/schematics/ng-add/index.js +0 -171
- package/schematics/ng-add/schema.json +0 -27
package/README.md
CHANGED
|
@@ -1,96 +1,128 @@
|
|
|
1
|
-
#
|
|
1
|
+
# `genus-pdf-viewer`
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Framework-agnostic PDF viewer built on `pdfjs-dist` with a custom element and a small TypeScript API.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm
|
|
8
|
+
npm install genus-pdf-viewer
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
The package ships `pdf.worker.min.mjs` and resolves it automatically from the built package. Override `workerSrc` only if your app needs a custom asset location.
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## Breaking Change
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
ng add genus-pdf-viewer
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
`ng add` will:
|
|
20
|
-
- add `provideGenusPdfViewer()` to your app config when `app.config.ts` is found
|
|
21
|
-
- copy `pdf.worker.min.js` and `pdf.worker.min.mjs` to your app assets/public path
|
|
15
|
+
`0.2.0` replaces the older Angular-specific `0.1.x` package with a framework-agnostic runtime. If you still need the Angular library API from npm, stay on `0.1.13` or earlier.
|
|
22
16
|
|
|
23
|
-
|
|
24
|
-
- `--project <name>` target a specific Angular app in a workspace
|
|
25
|
-
- `--skipWorkerCopy` skip worker file copy
|
|
26
|
-
- `--overwriteWorker` replace existing worker file
|
|
27
|
-
|
|
28
|
-
## Worker setup (recommended: library provider)
|
|
29
|
-
|
|
30
|
-
Use the provider shipped by the library, which sets a sensible default and allows overrides.
|
|
17
|
+
## TypeScript Usage
|
|
31
18
|
|
|
32
19
|
```ts
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
20
|
+
import { createGenusPdfViewer } from "genus-pdf-viewer";
|
|
21
|
+
|
|
22
|
+
const root = document.getElementById("pdf-root");
|
|
23
|
+
|
|
24
|
+
if (root) {
|
|
25
|
+
const viewer = createGenusPdfViewer(root, {
|
|
26
|
+
src: "https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf",
|
|
27
|
+
title: "Example PDF",
|
|
28
|
+
fit: "width",
|
|
29
|
+
continuous: false,
|
|
30
|
+
showToolbar: true,
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
viewer.addEventListener("genus-ready", (event) => {
|
|
34
|
+
console.log("ready", event.detail.pageCount);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
47
37
|
```
|
|
48
38
|
|
|
49
|
-
|
|
50
|
-
- The package ships its own worker at `workers/pdf.worker.min.mjs` and uses it by default.
|
|
51
|
-
- The provider then falls back to in-package fake-worker bootstrap, and finally tries `/assets/pdf.worker.min.js` or `/assets/pdf.worker.min.mjs`.
|
|
52
|
-
- You can still override `workerSrc` if your app needs a custom location.
|
|
53
|
-
- Optional CMaps: copy `node_modules/pdfjs-dist/cmaps` to `src/assets/cmaps/` and set `cMapUrl`/`cMapPacked` if you enable text layer.
|
|
54
|
-
|
|
55
|
-
Manual alternative (not recommended): set `GlobalWorkerOptions.workerSrc` yourself at bootstrap.
|
|
39
|
+
## Custom Element
|
|
56
40
|
|
|
57
|
-
|
|
41
|
+
Register the element yourself when you want to use declarative markup without first calling `createGenusPdfViewer()`.
|
|
58
42
|
|
|
59
43
|
```ts
|
|
60
|
-
import {
|
|
44
|
+
import { defineGenusPdfViewerElement } from "genus-pdf-viewer";
|
|
45
|
+
|
|
46
|
+
defineGenusPdfViewerElement();
|
|
61
47
|
```
|
|
62
48
|
|
|
63
49
|
```html
|
|
64
50
|
<genus-pdf-viewer
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
51
|
+
src="https://mozilla.github.io/pdf.js/web/compressed.tracemonkey-pldi-09.pdf"
|
|
52
|
+
title="Example PDF"
|
|
53
|
+
page="1"
|
|
54
|
+
zoom="1"
|
|
55
|
+
fit="width"
|
|
56
|
+
continuous="false"
|
|
57
|
+
toolbar="true"
|
|
58
|
+
download="true"
|
|
59
|
+
></genus-pdf-viewer>
|
|
70
60
|
```
|
|
71
61
|
|
|
72
|
-
|
|
73
|
-
|
|
62
|
+
## API
|
|
63
|
+
|
|
64
|
+
`createGenusPdfViewer(container, config)` appends and returns a `GenusPdfViewerElement`.
|
|
65
|
+
|
|
66
|
+
Config fields:
|
|
67
|
+
|
|
68
|
+
- `src`: `string | URL | Uint8Array | Blob`
|
|
69
|
+
- `title?`: custom download and toolbar title
|
|
70
|
+
- `page?`, `zoom?`, `minZoom?`, `maxZoom?`, `zoomStep?`
|
|
71
|
+
- `fit?`: `"width" | "page" | "none"`
|
|
72
|
+
- `continuous?`, `showToolbar?`, `allowDownload?`
|
|
73
|
+
- `workerSrc?`: override the default worker URL
|
|
74
|
+
- `withCredentials?`, `httpHeaders?`: network request options for URL sources
|
|
75
|
+
|
|
76
|
+
Element methods:
|
|
74
77
|
|
|
75
|
-
|
|
78
|
+
- `configure(config)`
|
|
79
|
+
- `reload()`
|
|
80
|
+
- `goToPage(page)`
|
|
81
|
+
- `nextPage()`
|
|
82
|
+
- `prevPage()`
|
|
83
|
+
- `setZoom(zoom)`
|
|
84
|
+
- `zoomIn()`
|
|
85
|
+
- `zoomOut()`
|
|
86
|
+
- `download()`
|
|
87
|
+
- `destroy()`
|
|
76
88
|
|
|
77
|
-
|
|
78
|
-
- Continuous scrolling with width-fit for a doc-like reading experience.
|
|
79
|
-
- Toolbar: zoom in/out, page nav, Download, Print.
|
|
80
|
-
- Pan when zoomed: cursor changes to grab/grabbing; drag to scroll.
|
|
81
|
-
- Automatic iframe fallback when CORS/network blocks pdf.js byte access.
|
|
89
|
+
## Events
|
|
82
90
|
|
|
83
|
-
|
|
91
|
+
The viewer emits bubbling custom events:
|
|
92
|
+
|
|
93
|
+
- `genus-ready`
|
|
94
|
+
- `genus-pagechange`
|
|
95
|
+
- `genus-zoomchange`
|
|
96
|
+
- `genus-error`
|
|
97
|
+
|
|
98
|
+
## Package Exports
|
|
99
|
+
|
|
100
|
+
- `genus-pdf-viewer`: main TypeScript and custom-element API
|
|
101
|
+
- `genus-pdf-viewer/pdf.worker.min.mjs`: worker asset if you need to host it yourself
|
|
102
|
+
- `genus-pdf-viewer/styles.css`: packaged stylesheet export
|
|
103
|
+
|
|
104
|
+
## Demo
|
|
84
105
|
|
|
85
106
|
```bash
|
|
86
|
-
npm run
|
|
87
|
-
|
|
107
|
+
npm run build
|
|
108
|
+
npm run demo:serve
|
|
88
109
|
```
|
|
89
110
|
|
|
90
|
-
|
|
111
|
+
Open `http://127.0.0.1:4175/examples/`.
|
|
91
112
|
|
|
92
|
-
##
|
|
113
|
+
## Validate
|
|
93
114
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
115
|
+
```bash
|
|
116
|
+
npm run typecheck
|
|
117
|
+
npm run test
|
|
118
|
+
npm run build
|
|
119
|
+
npm pack --dry-run
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Publish
|
|
123
|
+
|
|
124
|
+
This repo is configured for the existing public npm package `genus-pdf-viewer`.
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
npm publish
|
|
128
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { createGenusPdfViewer, defineGenusPdfViewerElement, GenusPdfViewerElement, } from "./viewer.js";
|
|
2
|
+
export type { GenusPdfViewerConfig, GenusPdfViewerErrorEventDetail, GenusPdfViewerEventMap, GenusPdfViewerFit, GenusPdfViewerPageChangeEventDetail, GenusPdfViewerReadyEventDetail, GenusPdfViewerSource, GenusPdfViewerZoomChangeEventDetail, } from "./types.js";
|
|
3
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,YAAY,EACV,oBAAoB,EACpB,8BAA8B,EAC9B,sBAAsB,EACtB,iBAAiB,EACjB,mCAAmC,EACnC,8BAA8B,EAC9B,oBAAoB,EACpB,mCAAmC,GACpC,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GACtB,MAAM,aAAa,CAAC"}
|
|
File without changes
|
package/dist/styles.css
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
color: #0f172a;
|
|
4
|
+
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
* {
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.shell {
|
|
12
|
+
display: flex;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
gap: 12px;
|
|
15
|
+
width: 100%;
|
|
16
|
+
min-height: 320px;
|
|
17
|
+
background: #f8fafc;
|
|
18
|
+
border: 1px solid #dbe4ee;
|
|
19
|
+
border-radius: 18px;
|
|
20
|
+
overflow: hidden;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.toolbar {
|
|
24
|
+
display: flex;
|
|
25
|
+
align-items: center;
|
|
26
|
+
gap: 8px;
|
|
27
|
+
padding: 10px 12px;
|
|
28
|
+
background: rgba(255, 255, 255, 0.92);
|
|
29
|
+
border-bottom: 1px solid #dbe4ee;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.toolbar[hidden] {
|
|
33
|
+
display: none;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.title {
|
|
37
|
+
font-size: 14px;
|
|
38
|
+
font-weight: 700;
|
|
39
|
+
color: #334155;
|
|
40
|
+
margin-right: auto;
|
|
41
|
+
min-width: 0;
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
text-overflow: ellipsis;
|
|
44
|
+
white-space: nowrap;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
.toolbar button {
|
|
48
|
+
appearance: none;
|
|
49
|
+
border: 1px solid #cbd5e1;
|
|
50
|
+
background: #ffffff;
|
|
51
|
+
color: #0f172a;
|
|
52
|
+
border-radius: 999px;
|
|
53
|
+
min-width: 36px;
|
|
54
|
+
height: 36px;
|
|
55
|
+
padding: 0 12px;
|
|
56
|
+
font: inherit;
|
|
57
|
+
font-weight: 700;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.toolbar button:disabled {
|
|
62
|
+
opacity: 0.45;
|
|
63
|
+
cursor: not-allowed;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.toolbar button.primary {
|
|
67
|
+
background: #0f766e;
|
|
68
|
+
border-color: #0f766e;
|
|
69
|
+
color: #f8fafc;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.toolbar .value {
|
|
73
|
+
min-width: 56px;
|
|
74
|
+
text-align: center;
|
|
75
|
+
font-size: 13px;
|
|
76
|
+
color: #475569;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.stage {
|
|
80
|
+
position: relative;
|
|
81
|
+
min-height: 320px;
|
|
82
|
+
max-height: 80vh;
|
|
83
|
+
overflow: auto;
|
|
84
|
+
background:
|
|
85
|
+
radial-gradient(circle at top, rgba(15, 118, 110, 0.08), transparent 22%),
|
|
86
|
+
#eef2f7;
|
|
87
|
+
padding: 16px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.stage.single {
|
|
91
|
+
display: grid;
|
|
92
|
+
place-items: center;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.page-stack {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex-direction: column;
|
|
98
|
+
gap: 16px;
|
|
99
|
+
align-items: center;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.page {
|
|
103
|
+
background: #ffffff;
|
|
104
|
+
border-radius: 8px;
|
|
105
|
+
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
canvas {
|
|
109
|
+
display: block;
|
|
110
|
+
max-width: 100%;
|
|
111
|
+
height: auto;
|
|
112
|
+
border-radius: 8px;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.status {
|
|
116
|
+
position: absolute;
|
|
117
|
+
inset: 16px;
|
|
118
|
+
display: none;
|
|
119
|
+
align-items: center;
|
|
120
|
+
justify-content: center;
|
|
121
|
+
padding: 24px;
|
|
122
|
+
border-radius: 12px;
|
|
123
|
+
background: rgba(248, 250, 252, 0.92);
|
|
124
|
+
color: #475569;
|
|
125
|
+
text-align: center;
|
|
126
|
+
font-size: 14px;
|
|
127
|
+
line-height: 1.5;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.status.visible {
|
|
131
|
+
display: flex;
|
|
132
|
+
}
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const VIEWER_STYLES = "\n:host {\n display: block;\n color: #0f172a;\n font-family: \"Segoe UI\", \"Helvetica Neue\", Arial, sans-serif;\n}\n\n* {\n box-sizing: border-box;\n}\n\n.shell {\n display: flex;\n flex-direction: column;\n gap: 12px;\n width: 100%;\n min-height: 320px;\n background: #f8fafc;\n border: 1px solid #dbe4ee;\n border-radius: 18px;\n overflow: hidden;\n}\n\n.toolbar {\n display: flex;\n align-items: center;\n gap: 8px;\n padding: 10px 12px;\n background: rgba(255, 255, 255, 0.92);\n border-bottom: 1px solid #dbe4ee;\n}\n\n.toolbar[hidden] {\n display: none;\n}\n\n.title {\n font-size: 14px;\n font-weight: 700;\n color: #334155;\n margin-right: auto;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n\n.toolbar button {\n appearance: none;\n border: 1px solid #cbd5e1;\n background: #ffffff;\n color: #0f172a;\n border-radius: 999px;\n min-width: 36px;\n height: 36px;\n padding: 0 12px;\n font: inherit;\n font-weight: 700;\n cursor: pointer;\n}\n\n.toolbar button:disabled {\n opacity: 0.45;\n cursor: not-allowed;\n}\n\n.toolbar button.primary {\n background: #0f766e;\n border-color: #0f766e;\n color: #f8fafc;\n}\n\n.toolbar .value {\n min-width: 56px;\n text-align: center;\n font-size: 13px;\n color: #475569;\n}\n\n.stage {\n position: relative;\n min-height: 320px;\n max-height: 80vh;\n overflow: auto;\n background:\n radial-gradient(circle at top, rgba(15, 118, 110, 0.08), transparent 22%),\n #eef2f7;\n padding: 16px;\n}\n\n.stage.single {\n display: grid;\n place-items: center;\n}\n\n.page-stack {\n display: flex;\n flex-direction: column;\n gap: 16px;\n align-items: center;\n}\n\n.page {\n background: #ffffff;\n border-radius: 8px;\n box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);\n}\n\ncanvas {\n display: block;\n max-width: 100%;\n height: auto;\n border-radius: 8px;\n}\n\n.status {\n position: absolute;\n inset: 16px;\n display: none;\n align-items: center;\n justify-content: center;\n padding: 24px;\n border-radius: 12px;\n background: rgba(248, 250, 252, 0.92);\n color: #475569;\n text-align: center;\n font-size: 14px;\n line-height: 1.5;\n}\n\n.status.visible {\n display: flex;\n}\n";
|
|
2
|
+
//# sourceMappingURL=styles.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa,8sEAqIzB,CAAC"}
|
package/dist/styles.js
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
export const VIEWER_STYLES = `
|
|
2
|
+
:host {
|
|
3
|
+
display: block;
|
|
4
|
+
color: #0f172a;
|
|
5
|
+
font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
* {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.shell {
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-direction: column;
|
|
15
|
+
gap: 12px;
|
|
16
|
+
width: 100%;
|
|
17
|
+
min-height: 320px;
|
|
18
|
+
background: #f8fafc;
|
|
19
|
+
border: 1px solid #dbe4ee;
|
|
20
|
+
border-radius: 18px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.toolbar {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
gap: 8px;
|
|
28
|
+
padding: 10px 12px;
|
|
29
|
+
background: rgba(255, 255, 255, 0.92);
|
|
30
|
+
border-bottom: 1px solid #dbe4ee;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.toolbar[hidden] {
|
|
34
|
+
display: none;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.title {
|
|
38
|
+
font-size: 14px;
|
|
39
|
+
font-weight: 700;
|
|
40
|
+
color: #334155;
|
|
41
|
+
margin-right: auto;
|
|
42
|
+
min-width: 0;
|
|
43
|
+
overflow: hidden;
|
|
44
|
+
text-overflow: ellipsis;
|
|
45
|
+
white-space: nowrap;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.toolbar button {
|
|
49
|
+
appearance: none;
|
|
50
|
+
border: 1px solid #cbd5e1;
|
|
51
|
+
background: #ffffff;
|
|
52
|
+
color: #0f172a;
|
|
53
|
+
border-radius: 999px;
|
|
54
|
+
min-width: 36px;
|
|
55
|
+
height: 36px;
|
|
56
|
+
padding: 0 12px;
|
|
57
|
+
font: inherit;
|
|
58
|
+
font-weight: 700;
|
|
59
|
+
cursor: pointer;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.toolbar button:disabled {
|
|
63
|
+
opacity: 0.45;
|
|
64
|
+
cursor: not-allowed;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.toolbar button.primary {
|
|
68
|
+
background: #0f766e;
|
|
69
|
+
border-color: #0f766e;
|
|
70
|
+
color: #f8fafc;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.toolbar .value {
|
|
74
|
+
min-width: 56px;
|
|
75
|
+
text-align: center;
|
|
76
|
+
font-size: 13px;
|
|
77
|
+
color: #475569;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.stage {
|
|
81
|
+
position: relative;
|
|
82
|
+
min-height: 320px;
|
|
83
|
+
max-height: 80vh;
|
|
84
|
+
overflow: auto;
|
|
85
|
+
background:
|
|
86
|
+
radial-gradient(circle at top, rgba(15, 118, 110, 0.08), transparent 22%),
|
|
87
|
+
#eef2f7;
|
|
88
|
+
padding: 16px;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
.stage.single {
|
|
92
|
+
display: grid;
|
|
93
|
+
place-items: center;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.page-stack {
|
|
97
|
+
display: flex;
|
|
98
|
+
flex-direction: column;
|
|
99
|
+
gap: 16px;
|
|
100
|
+
align-items: center;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.page {
|
|
104
|
+
background: #ffffff;
|
|
105
|
+
border-radius: 8px;
|
|
106
|
+
box-shadow: 0 12px 30px rgba(15, 23, 42, 0.12);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
canvas {
|
|
110
|
+
display: block;
|
|
111
|
+
max-width: 100%;
|
|
112
|
+
height: auto;
|
|
113
|
+
border-radius: 8px;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.status {
|
|
117
|
+
position: absolute;
|
|
118
|
+
inset: 16px;
|
|
119
|
+
display: none;
|
|
120
|
+
align-items: center;
|
|
121
|
+
justify-content: center;
|
|
122
|
+
padding: 24px;
|
|
123
|
+
border-radius: 12px;
|
|
124
|
+
background: rgba(248, 250, 252, 0.92);
|
|
125
|
+
color: #475569;
|
|
126
|
+
text-align: center;
|
|
127
|
+
font-size: 14px;
|
|
128
|
+
line-height: 1.5;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.status.visible {
|
|
132
|
+
display: flex;
|
|
133
|
+
}
|
|
134
|
+
`;
|
|
135
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqI5B,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export type GenusPdfViewerFit = "width" | "page" | "none";
|
|
2
|
+
export type GenusPdfViewerSource = string | URL | Uint8Array | Blob;
|
|
3
|
+
export interface GenusPdfViewerConfig {
|
|
4
|
+
src: GenusPdfViewerSource;
|
|
5
|
+
title?: string;
|
|
6
|
+
page?: number;
|
|
7
|
+
zoom?: number;
|
|
8
|
+
minZoom?: number;
|
|
9
|
+
maxZoom?: number;
|
|
10
|
+
zoomStep?: number;
|
|
11
|
+
fit?: GenusPdfViewerFit;
|
|
12
|
+
continuous?: boolean;
|
|
13
|
+
showToolbar?: boolean;
|
|
14
|
+
allowDownload?: boolean;
|
|
15
|
+
workerSrc?: string;
|
|
16
|
+
withCredentials?: boolean;
|
|
17
|
+
httpHeaders?: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
export interface GenusPdfViewerReadyEventDetail {
|
|
20
|
+
page: number;
|
|
21
|
+
pageCount: number;
|
|
22
|
+
zoom: number;
|
|
23
|
+
}
|
|
24
|
+
export interface GenusPdfViewerPageChangeEventDetail {
|
|
25
|
+
page: number;
|
|
26
|
+
pageCount: number;
|
|
27
|
+
}
|
|
28
|
+
export interface GenusPdfViewerZoomChangeEventDetail {
|
|
29
|
+
zoom: number;
|
|
30
|
+
}
|
|
31
|
+
export interface GenusPdfViewerErrorEventDetail {
|
|
32
|
+
error: unknown;
|
|
33
|
+
message: string;
|
|
34
|
+
}
|
|
35
|
+
export interface GenusPdfViewerEventMap {
|
|
36
|
+
ready: GenusPdfViewerReadyEventDetail;
|
|
37
|
+
pagechange: GenusPdfViewerPageChangeEventDetail;
|
|
38
|
+
zoomchange: GenusPdfViewerZoomChangeEventDetail;
|
|
39
|
+
error: GenusPdfViewerErrorEventDetail;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,CAAC;AAE1D,MAAM,MAAM,oBAAoB,GAAG,MAAM,GAAG,GAAG,GAAG,UAAU,GAAG,IAAI,CAAC;AAEpE,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,oBAAoB,CAAC;IAC1B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,GAAG,CAAC,EAAE,iBAAiB,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,8BAA8B;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,mCAAmC;IAClD,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,8BAA8B;IAC7C,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,sBAAsB;IACrC,KAAK,EAAE,8BAA8B,CAAC;IACtC,UAAU,EAAE,mCAAmC,CAAC;IAChD,UAAU,EAAE,mCAAmC,CAAC;IAChD,KAAK,EAAE,8BAA8B,CAAC;CACvC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
package/dist/viewer.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { GenusPdfViewerConfig } from "./types.js";
|
|
2
|
+
export declare class GenusPdfViewerElement extends HTMLElement {
|
|
3
|
+
#private;
|
|
4
|
+
static get observedAttributes(): string[];
|
|
5
|
+
constructor();
|
|
6
|
+
connectedCallback(): void;
|
|
7
|
+
disconnectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(): void;
|
|
9
|
+
configure(config: GenusPdfViewerConfig): void;
|
|
10
|
+
reload(): Promise<void>;
|
|
11
|
+
goToPage(page: number): Promise<void>;
|
|
12
|
+
nextPage(): Promise<void>;
|
|
13
|
+
prevPage(): Promise<void>;
|
|
14
|
+
setZoom(zoom: number): Promise<void>;
|
|
15
|
+
zoomIn(): Promise<void>;
|
|
16
|
+
zoomOut(): Promise<void>;
|
|
17
|
+
download(): Promise<void>;
|
|
18
|
+
destroy(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLElementTagNameMap {
|
|
22
|
+
"genus-pdf-viewer": GenusPdfViewerElement;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export declare function defineGenusPdfViewerElement(tagName?: string): void;
|
|
26
|
+
export declare function createGenusPdfViewer(container: HTMLElement, config: GenusPdfViewerConfig): GenusPdfViewerElement;
|
|
27
|
+
//# sourceMappingURL=viewer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewer.d.ts","sourceRoot":"","sources":["../src/viewer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,oBAAoB,EAMrB,MAAM,YAAY,CAAC;AA2MpB,qBAAa,qBAAsB,SAAQ,WAAW;;IACpD,MAAM,KAAK,kBAAkB,IAAI,MAAM,EAAE,CAExC;;IA+HD,iBAAiB,IAAI,IAAI;IAkBzB,oBAAoB,IAAI,IAAI;IAK5B,wBAAwB,IAAI,IAAI;IAOhC,SAAS,CAAC,MAAM,EAAE,oBAAoB,GAAG,IAAI;IA+DvC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBrC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQzB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAQzB,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBpC,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAWvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAWxB,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IA8BzB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAgS/B;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,kBAAkB,EAAE,qBAAqB,CAAC;KAC3C;CACF;AAED,wBAAgB,2BAA2B,CAAC,OAAO,SAAuB,GAAG,IAAI,CAIhF;AAED,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,oBAAoB,GAC3B,qBAAqB,CAMvB"}
|