@cvfile/viewer-web 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/LICENSE +190 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +581 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for describing the origin of the Work and
|
|
141
|
+
reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Support. While redistributing the Work or
|
|
166
|
+
Derivative Works thereof, You may choose to offer, and charge a
|
|
167
|
+
fee for, acceptance of support, warranty, indemnity, or other
|
|
168
|
+
liability obligations and/or rights consistent with this License.
|
|
169
|
+
However, in accepting such obligations, You may act only on Your
|
|
170
|
+
own behalf and on Your sole responsibility, not on behalf of any
|
|
171
|
+
other Contributor, and only if You agree to indemnify, defend,
|
|
172
|
+
and hold each Contributor harmless for any liability incurred by,
|
|
173
|
+
or claims asserted against, such Contributor by reason of your
|
|
174
|
+
accepting any such warranty or support.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 The cvfile.org authors
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement, TemplateResult } from 'lit';
|
|
3
|
+
|
|
4
|
+
type Tab = 'pdf' | 'md' | 'html';
|
|
5
|
+
type Theme = 'auto' | 'light' | 'dark';
|
|
6
|
+
type ChangedKeys = Map<PropertyKey, unknown>;
|
|
7
|
+
declare class CvEmbed extends LitElement {
|
|
8
|
+
static styles: lit.CSSResult;
|
|
9
|
+
src: string;
|
|
10
|
+
view: Tab | 'auto';
|
|
11
|
+
language: string;
|
|
12
|
+
tabBar: boolean;
|
|
13
|
+
theme: Theme;
|
|
14
|
+
private file;
|
|
15
|
+
private error;
|
|
16
|
+
private activeTab;
|
|
17
|
+
private loading;
|
|
18
|
+
private pdfPage;
|
|
19
|
+
private pdfPageCount;
|
|
20
|
+
private pdfModulePromise;
|
|
21
|
+
connectedCallback(): Promise<void>;
|
|
22
|
+
willUpdate(changed: ChangedKeys): void;
|
|
23
|
+
updated(changed: ChangedKeys): void;
|
|
24
|
+
loadFromBytes(bytes: Uint8Array): Promise<void>;
|
|
25
|
+
/** Public API: re-attempt the last load (used by error retry button). */
|
|
26
|
+
retry(): Promise<void>;
|
|
27
|
+
private loadFromSrc;
|
|
28
|
+
private processBytes;
|
|
29
|
+
private pickInitialTab;
|
|
30
|
+
private renderPdf;
|
|
31
|
+
private switchTab;
|
|
32
|
+
/** Keyboard navigation per WAI-ARIA tablist authoring practices. */
|
|
33
|
+
private handleTabKeydown;
|
|
34
|
+
render(): TemplateResult;
|
|
35
|
+
private renderMd;
|
|
36
|
+
}
|
|
37
|
+
declare global {
|
|
38
|
+
interface HTMLElementTagNameMap {
|
|
39
|
+
'cv-embed': CvEmbed;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export { CvEmbed };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,581 @@
|
|
|
1
|
+
import * as pdfjsLib from 'pdfjs-dist';
|
|
2
|
+
import workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
|
|
3
|
+
import { LitElement, css, html } from 'lit';
|
|
4
|
+
import { property, state } from 'lit/decorators.js';
|
|
5
|
+
import { extract } from '@cvfile/sdk';
|
|
6
|
+
import DOMPurify from 'dompurify';
|
|
7
|
+
import { marked } from 'marked';
|
|
8
|
+
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name in all)
|
|
16
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
19
|
+
var result = void 0 ;
|
|
20
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
+
if (decorator = decorators[i])
|
|
22
|
+
result = (decorator(target, key, result) ) || result;
|
|
23
|
+
if (result) __defProp(target, key, result);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
// src/render-pdf.ts
|
|
28
|
+
var render_pdf_exports = {};
|
|
29
|
+
__export(render_pdf_exports, {
|
|
30
|
+
renderPdfPage: () => renderPdfPage
|
|
31
|
+
});
|
|
32
|
+
function ensureWorker() {
|
|
33
|
+
if (workerConfigured) return;
|
|
34
|
+
pdfjsLib.GlobalWorkerOptions.workerSrc = workerUrl;
|
|
35
|
+
workerConfigured = true;
|
|
36
|
+
}
|
|
37
|
+
async function renderPdfPage(bytes, pageNumber, canvas) {
|
|
38
|
+
ensureWorker();
|
|
39
|
+
const view = new Uint8Array(bytes.byteLength);
|
|
40
|
+
view.set(bytes);
|
|
41
|
+
const loadingTask = pdfjsLib.getDocument({ data: view });
|
|
42
|
+
const pdf = await loadingTask.promise;
|
|
43
|
+
const page = await pdf.getPage(pageNumber);
|
|
44
|
+
const dpr = window.devicePixelRatio || 1;
|
|
45
|
+
const baseViewport = page.getViewport({ scale: 1 });
|
|
46
|
+
const containerWidth = canvas.parentElement?.clientWidth ?? baseViewport.width;
|
|
47
|
+
const targetWidth = Math.min(containerWidth - 32, 900);
|
|
48
|
+
const scale = targetWidth / baseViewport.width * dpr;
|
|
49
|
+
const viewport = page.getViewport({ scale });
|
|
50
|
+
canvas.width = Math.floor(viewport.width);
|
|
51
|
+
canvas.height = Math.floor(viewport.height);
|
|
52
|
+
canvas.style.width = `${Math.floor(viewport.width / dpr)}px`;
|
|
53
|
+
canvas.style.height = `${Math.floor(viewport.height / dpr)}px`;
|
|
54
|
+
const ctx = canvas.getContext("2d");
|
|
55
|
+
if (!ctx) {
|
|
56
|
+
throw new Error("Could not acquire 2D canvas context");
|
|
57
|
+
}
|
|
58
|
+
await page.render({ canvasContext: ctx, viewport }).promise;
|
|
59
|
+
return { numPages: pdf.numPages };
|
|
60
|
+
}
|
|
61
|
+
var workerConfigured;
|
|
62
|
+
var init_render_pdf = __esm({
|
|
63
|
+
"src/render-pdf.ts"() {
|
|
64
|
+
workerConfigured = false;
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
function renderMarkdown(source) {
|
|
68
|
+
const raw = marked.parse(source, { async: false });
|
|
69
|
+
return DOMPurify.sanitize(raw, {
|
|
70
|
+
USE_PROFILES: { html: true },
|
|
71
|
+
FORBID_TAGS: ["script", "style", "iframe", "object", "embed"],
|
|
72
|
+
FORBID_ATTR: ["onerror", "onload", "onclick", "onmouseover"]
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// src/cv-embed.ts
|
|
77
|
+
var CvEmbed = class extends LitElement {
|
|
78
|
+
constructor() {
|
|
79
|
+
super(...arguments);
|
|
80
|
+
this.src = "";
|
|
81
|
+
this.view = "auto";
|
|
82
|
+
this.language = "";
|
|
83
|
+
this.tabBar = true;
|
|
84
|
+
this.theme = "auto";
|
|
85
|
+
this.file = null;
|
|
86
|
+
this.error = null;
|
|
87
|
+
this.activeTab = "pdf";
|
|
88
|
+
this.loading = true;
|
|
89
|
+
this.pdfPage = 1;
|
|
90
|
+
this.pdfPageCount = 1;
|
|
91
|
+
this.pdfModulePromise = null;
|
|
92
|
+
}
|
|
93
|
+
static {
|
|
94
|
+
this.styles = css`
|
|
95
|
+
:host {
|
|
96
|
+
--cv-color: #111;
|
|
97
|
+
--cv-bg: #fafaf9;
|
|
98
|
+
--cv-border: #e5e5e3;
|
|
99
|
+
--cv-toolbar-bg: #ffffff;
|
|
100
|
+
--cv-stage-bg: #f4f4f2;
|
|
101
|
+
--cv-meta: #6b7280;
|
|
102
|
+
--cv-tab-hover: rgba(0, 0, 0, 0.04);
|
|
103
|
+
--cv-tab-active: rgba(0, 0, 0, 0.08);
|
|
104
|
+
--cv-card-bg: #ffffff;
|
|
105
|
+
--cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
|
|
106
|
+
--cv-focus-ring: #4f46e5;
|
|
107
|
+
--cv-error: #b91c1c;
|
|
108
|
+
--cv-error-bg: #fef2f2;
|
|
109
|
+
|
|
110
|
+
display: block;
|
|
111
|
+
font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
|
|
112
|
+
color: var(--cv-color);
|
|
113
|
+
background: var(--cv-bg);
|
|
114
|
+
border: 1px solid var(--cv-border);
|
|
115
|
+
border-radius: 12px;
|
|
116
|
+
overflow: hidden;
|
|
117
|
+
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
|
|
118
|
+
width: 100%;
|
|
119
|
+
min-height: 480px;
|
|
120
|
+
contain: paint;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
:host([theme='dark']),
|
|
124
|
+
:host([theme='auto']) {
|
|
125
|
+
color-scheme: light dark;
|
|
126
|
+
}
|
|
127
|
+
:host([theme='dark']) {
|
|
128
|
+
--cv-color: #f3f4f6;
|
|
129
|
+
--cv-bg: #0b0b0d;
|
|
130
|
+
--cv-border: #2a2a2e;
|
|
131
|
+
--cv-toolbar-bg: #15151a;
|
|
132
|
+
--cv-stage-bg: #0f0f12;
|
|
133
|
+
--cv-meta: #9ca3af;
|
|
134
|
+
--cv-tab-hover: rgba(255, 255, 255, 0.05);
|
|
135
|
+
--cv-tab-active: rgba(255, 255, 255, 0.10);
|
|
136
|
+
--cv-card-bg: #15151a;
|
|
137
|
+
--cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
|
|
138
|
+
--cv-error-bg: #2a1414;
|
|
139
|
+
}
|
|
140
|
+
@media (prefers-color-scheme: dark) {
|
|
141
|
+
:host([theme='auto']) {
|
|
142
|
+
--cv-color: #f3f4f6;
|
|
143
|
+
--cv-bg: #0b0b0d;
|
|
144
|
+
--cv-border: #2a2a2e;
|
|
145
|
+
--cv-toolbar-bg: #15151a;
|
|
146
|
+
--cv-stage-bg: #0f0f12;
|
|
147
|
+
--cv-meta: #9ca3af;
|
|
148
|
+
--cv-tab-hover: rgba(255, 255, 255, 0.05);
|
|
149
|
+
--cv-tab-active: rgba(255, 255, 255, 0.10);
|
|
150
|
+
--cv-card-bg: #15151a;
|
|
151
|
+
--cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
|
|
152
|
+
--cv-error-bg: #2a1414;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
.toolbar {
|
|
157
|
+
display: flex;
|
|
158
|
+
align-items: center;
|
|
159
|
+
gap: 0.25rem;
|
|
160
|
+
padding: 0.5rem 0.75rem;
|
|
161
|
+
border-bottom: 1px solid var(--cv-border);
|
|
162
|
+
background: var(--cv-toolbar-bg);
|
|
163
|
+
flex-wrap: wrap;
|
|
164
|
+
}
|
|
165
|
+
.tab {
|
|
166
|
+
appearance: none;
|
|
167
|
+
border: 0;
|
|
168
|
+
background: transparent;
|
|
169
|
+
padding: 0.4rem 0.8rem;
|
|
170
|
+
border-radius: 6px;
|
|
171
|
+
font: inherit;
|
|
172
|
+
color: inherit;
|
|
173
|
+
cursor: pointer;
|
|
174
|
+
opacity: 0.6;
|
|
175
|
+
transition: background 120ms, opacity 120ms;
|
|
176
|
+
}
|
|
177
|
+
.tab:hover:not([disabled]) { background: var(--cv-tab-hover); opacity: 0.95; }
|
|
178
|
+
.tab[aria-selected='true'] {
|
|
179
|
+
background: var(--cv-tab-active);
|
|
180
|
+
opacity: 1;
|
|
181
|
+
font-weight: 600;
|
|
182
|
+
}
|
|
183
|
+
.tab[disabled] { opacity: 0.3; cursor: not-allowed; }
|
|
184
|
+
.tab:focus-visible {
|
|
185
|
+
outline: 2px solid var(--cv-focus-ring);
|
|
186
|
+
outline-offset: 2px;
|
|
187
|
+
}
|
|
188
|
+
.meta {
|
|
189
|
+
margin-left: auto;
|
|
190
|
+
font-size: 0.8rem;
|
|
191
|
+
color: var(--cv-meta);
|
|
192
|
+
display: flex;
|
|
193
|
+
gap: 0.75rem;
|
|
194
|
+
flex-wrap: wrap;
|
|
195
|
+
}
|
|
196
|
+
.meta code { font: inherit; opacity: 0.85; }
|
|
197
|
+
.stage {
|
|
198
|
+
position: relative;
|
|
199
|
+
min-height: 420px;
|
|
200
|
+
max-height: var(--cv-max-height, 80vh);
|
|
201
|
+
overflow: auto;
|
|
202
|
+
padding: 0;
|
|
203
|
+
background: var(--cv-stage-bg);
|
|
204
|
+
}
|
|
205
|
+
.pdf-canvas {
|
|
206
|
+
display: block;
|
|
207
|
+
margin: 1rem auto;
|
|
208
|
+
box-shadow: var(--cv-card-shadow);
|
|
209
|
+
background: #fff;
|
|
210
|
+
max-width: 100%;
|
|
211
|
+
}
|
|
212
|
+
.pager {
|
|
213
|
+
display: flex;
|
|
214
|
+
justify-content: center;
|
|
215
|
+
align-items: center;
|
|
216
|
+
gap: 0.5rem;
|
|
217
|
+
padding: 0.5rem;
|
|
218
|
+
background: var(--cv-toolbar-bg);
|
|
219
|
+
border-top: 1px solid var(--cv-border);
|
|
220
|
+
font-size: 0.85rem;
|
|
221
|
+
}
|
|
222
|
+
.pager button {
|
|
223
|
+
appearance: none;
|
|
224
|
+
border: 1px solid var(--cv-border);
|
|
225
|
+
background: var(--cv-card-bg);
|
|
226
|
+
color: inherit;
|
|
227
|
+
padding: 0.25rem 0.6rem;
|
|
228
|
+
border-radius: 6px;
|
|
229
|
+
cursor: pointer;
|
|
230
|
+
font: inherit;
|
|
231
|
+
}
|
|
232
|
+
.pager button:focus-visible {
|
|
233
|
+
outline: 2px solid var(--cv-focus-ring);
|
|
234
|
+
outline-offset: 2px;
|
|
235
|
+
}
|
|
236
|
+
.pager button[disabled] { opacity: 0.4; cursor: not-allowed; }
|
|
237
|
+
.md, .html {
|
|
238
|
+
padding: 1.5rem 2rem;
|
|
239
|
+
background: var(--cv-card-bg);
|
|
240
|
+
max-width: 760px;
|
|
241
|
+
margin: 1rem auto;
|
|
242
|
+
box-shadow: var(--cv-card-shadow);
|
|
243
|
+
border-radius: 8px;
|
|
244
|
+
line-height: 1.6;
|
|
245
|
+
}
|
|
246
|
+
.html iframe {
|
|
247
|
+
width: 100%;
|
|
248
|
+
min-height: 420px;
|
|
249
|
+
border: 0;
|
|
250
|
+
background: #fff;
|
|
251
|
+
border-radius: 4px;
|
|
252
|
+
}
|
|
253
|
+
.md :first-child { margin-top: 0; }
|
|
254
|
+
.md h1 { font-size: 1.75rem; }
|
|
255
|
+
.md h2 { font-size: 1.25rem; border-bottom: 1px solid var(--cv-border); padding-bottom: 0.25rem; margin-top: 1.5rem; }
|
|
256
|
+
.md ul { padding-left: 1.25rem; }
|
|
257
|
+
.md a { color: var(--cv-focus-ring); }
|
|
258
|
+
|
|
259
|
+
.skeleton {
|
|
260
|
+
display: flex;
|
|
261
|
+
flex-direction: column;
|
|
262
|
+
gap: 1rem;
|
|
263
|
+
padding: 1.5rem 2rem;
|
|
264
|
+
max-width: 760px;
|
|
265
|
+
margin: 1rem auto;
|
|
266
|
+
}
|
|
267
|
+
.skeleton .bar {
|
|
268
|
+
height: 1rem;
|
|
269
|
+
background: linear-gradient(90deg, var(--cv-tab-hover) 0%, var(--cv-tab-active) 50%, var(--cv-tab-hover) 100%);
|
|
270
|
+
background-size: 200% 100%;
|
|
271
|
+
border-radius: 4px;
|
|
272
|
+
animation: shimmer 1.4s infinite;
|
|
273
|
+
}
|
|
274
|
+
.skeleton .bar.short { width: 40%; }
|
|
275
|
+
.skeleton .bar.medium { width: 70%; }
|
|
276
|
+
@keyframes shimmer {
|
|
277
|
+
0% { background-position: 200% 0; }
|
|
278
|
+
100% { background-position: -200% 0; }
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.empty {
|
|
282
|
+
padding: 2rem;
|
|
283
|
+
text-align: center;
|
|
284
|
+
color: var(--cv-meta);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
.err {
|
|
288
|
+
margin: 1rem;
|
|
289
|
+
padding: 1.5rem;
|
|
290
|
+
background: var(--cv-error-bg);
|
|
291
|
+
color: var(--cv-error);
|
|
292
|
+
border-radius: 8px;
|
|
293
|
+
border: 1px solid var(--cv-error);
|
|
294
|
+
}
|
|
295
|
+
.err button {
|
|
296
|
+
margin-top: 0.75rem;
|
|
297
|
+
appearance: none;
|
|
298
|
+
border: 1px solid var(--cv-error);
|
|
299
|
+
background: transparent;
|
|
300
|
+
color: var(--cv-error);
|
|
301
|
+
padding: 0.4rem 0.9rem;
|
|
302
|
+
border-radius: 6px;
|
|
303
|
+
cursor: pointer;
|
|
304
|
+
font: inherit;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/* Compact mode for narrow viewports */
|
|
308
|
+
@media (max-width: 480px) {
|
|
309
|
+
.toolbar { padding: 0.4rem 0.5rem; }
|
|
310
|
+
.tab { padding: 0.35rem 0.6rem; font-size: 0.9rem; }
|
|
311
|
+
.meta { width: 100%; margin-left: 0; padding-top: 0.25rem; font-size: 0.75rem; }
|
|
312
|
+
.md, .html { padding: 1rem 1.25rem; margin: 0.5rem; }
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/* Honour user motion preferences. */
|
|
316
|
+
@media (prefers-reduced-motion: reduce) {
|
|
317
|
+
.skeleton .bar { animation: none; }
|
|
318
|
+
.tab { transition: none; }
|
|
319
|
+
}
|
|
320
|
+
`;
|
|
321
|
+
}
|
|
322
|
+
async connectedCallback() {
|
|
323
|
+
super.connectedCallback();
|
|
324
|
+
if (this.src) {
|
|
325
|
+
await this.loadFromSrc();
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
willUpdate(changed) {
|
|
329
|
+
if (changed.has("src") && this.src) {
|
|
330
|
+
void this.loadFromSrc();
|
|
331
|
+
}
|
|
332
|
+
if (changed.has("view") && this.view !== "auto" && this.file) {
|
|
333
|
+
this.activeTab = this.view;
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
updated(changed) {
|
|
337
|
+
if (changed.has("activeTab") || changed.has("file") || changed.has("pdfPage")) {
|
|
338
|
+
if (this.activeTab === "pdf" && this.file) {
|
|
339
|
+
void this.renderPdf();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
loadFromBytes(bytes) {
|
|
344
|
+
return this.processBytes(bytes);
|
|
345
|
+
}
|
|
346
|
+
/** Public API: re-attempt the last load (used by error retry button). */
|
|
347
|
+
async retry() {
|
|
348
|
+
this.error = null;
|
|
349
|
+
if (this.src) {
|
|
350
|
+
await this.loadFromSrc();
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
async loadFromSrc() {
|
|
354
|
+
this.loading = true;
|
|
355
|
+
this.error = null;
|
|
356
|
+
this.file = null;
|
|
357
|
+
try {
|
|
358
|
+
const res = await fetch(this.src);
|
|
359
|
+
if (!res.ok) {
|
|
360
|
+
throw new Error(`Fetch failed: ${res.status} ${res.statusText}`);
|
|
361
|
+
}
|
|
362
|
+
const buf = new Uint8Array(await res.arrayBuffer());
|
|
363
|
+
await this.processBytes(buf);
|
|
364
|
+
} catch (err) {
|
|
365
|
+
this.error = err.message;
|
|
366
|
+
this.loading = false;
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
async processBytes(bytes) {
|
|
370
|
+
this.loading = true;
|
|
371
|
+
try {
|
|
372
|
+
const file = await extract(bytes);
|
|
373
|
+
this.file = file;
|
|
374
|
+
this.activeTab = this.pickInitialTab(file);
|
|
375
|
+
this.loading = false;
|
|
376
|
+
} catch (err) {
|
|
377
|
+
this.error = err.message;
|
|
378
|
+
this.loading = false;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
pickInitialTab(file) {
|
|
382
|
+
if (this.view !== "auto") return this.view;
|
|
383
|
+
return "pdf";
|
|
384
|
+
}
|
|
385
|
+
async renderPdf() {
|
|
386
|
+
if (!this.file) return;
|
|
387
|
+
const canvas = this.renderRoot.querySelector(".pdf-canvas");
|
|
388
|
+
if (!canvas) return;
|
|
389
|
+
if (!this.pdfModulePromise) {
|
|
390
|
+
this.pdfModulePromise = Promise.resolve().then(() => (init_render_pdf(), render_pdf_exports));
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
const mod = await this.pdfModulePromise;
|
|
394
|
+
const { numPages } = await mod.renderPdfPage(this.file.bytes, this.pdfPage, canvas);
|
|
395
|
+
if (numPages !== this.pdfPageCount) {
|
|
396
|
+
this.pdfPageCount = numPages;
|
|
397
|
+
}
|
|
398
|
+
} catch (err) {
|
|
399
|
+
this.error = `PDF render failed: ${err.message}`;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
switchTab(tab, available) {
|
|
403
|
+
if (!available[tab]) return;
|
|
404
|
+
this.activeTab = tab;
|
|
405
|
+
}
|
|
406
|
+
/** Keyboard navigation per WAI-ARIA tablist authoring practices. */
|
|
407
|
+
handleTabKeydown(event, available) {
|
|
408
|
+
const order = ["pdf", "md", "html"].filter((t) => available[t]);
|
|
409
|
+
const idx = order.indexOf(this.activeTab);
|
|
410
|
+
let next = null;
|
|
411
|
+
switch (event.key) {
|
|
412
|
+
case "ArrowRight":
|
|
413
|
+
case "ArrowDown":
|
|
414
|
+
next = order[(idx + 1) % order.length] ?? null;
|
|
415
|
+
break;
|
|
416
|
+
case "ArrowLeft":
|
|
417
|
+
case "ArrowUp":
|
|
418
|
+
next = order[(idx - 1 + order.length) % order.length] ?? null;
|
|
419
|
+
break;
|
|
420
|
+
case "Home":
|
|
421
|
+
next = order[0] ?? null;
|
|
422
|
+
break;
|
|
423
|
+
case "End":
|
|
424
|
+
next = order[order.length - 1] ?? null;
|
|
425
|
+
break;
|
|
426
|
+
}
|
|
427
|
+
if (next) {
|
|
428
|
+
event.preventDefault();
|
|
429
|
+
this.switchTab(next, available);
|
|
430
|
+
requestAnimationFrame(() => {
|
|
431
|
+
const button = this.renderRoot.querySelector(`button[data-tab="${next}"]`);
|
|
432
|
+
button?.focus();
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
render() {
|
|
437
|
+
if (this.error) {
|
|
438
|
+
return html`<div class="err" role="alert">
|
|
439
|
+
<strong>Could not load .cv</strong>
|
|
440
|
+
<div>${this.error}</div>
|
|
441
|
+
${this.src ? html`<button type="button" @click=${() => void this.retry()}>Retry</button>` : null}
|
|
442
|
+
<slot name="error"></slot>
|
|
443
|
+
</div>`;
|
|
444
|
+
}
|
|
445
|
+
if (this.loading || !this.file) {
|
|
446
|
+
return html`<div class="empty" aria-busy="true" aria-live="polite">
|
|
447
|
+
<div class="skeleton" part="skeleton">
|
|
448
|
+
<div class="bar short"></div>
|
|
449
|
+
<div class="bar"></div>
|
|
450
|
+
<div class="bar medium"></div>
|
|
451
|
+
<div class="bar"></div>
|
|
452
|
+
<div class="bar short"></div>
|
|
453
|
+
</div>
|
|
454
|
+
</div>`;
|
|
455
|
+
}
|
|
456
|
+
const file = this.file;
|
|
457
|
+
const md = file.payloads.find((p) => p.mimeType === "text/markdown");
|
|
458
|
+
const htmlPayload = file.payloads.find((p) => p.mimeType === "text/html");
|
|
459
|
+
const available = {
|
|
460
|
+
pdf: true,
|
|
461
|
+
md: !!md,
|
|
462
|
+
html: !!htmlPayload
|
|
463
|
+
};
|
|
464
|
+
const panelId = "cv-embed-panel";
|
|
465
|
+
return html`
|
|
466
|
+
${this.tabBar ? html`<div
|
|
467
|
+
class="toolbar"
|
|
468
|
+
role="tablist"
|
|
469
|
+
aria-label="Document representations"
|
|
470
|
+
part="toolbar"
|
|
471
|
+
@keydown=${(e) => this.handleTabKeydown(e, available)}
|
|
472
|
+
>
|
|
473
|
+
${["pdf", "md", "html"].map((t) => {
|
|
474
|
+
const enabled = available[t];
|
|
475
|
+
const selected = this.activeTab === t;
|
|
476
|
+
const labels = { pdf: "PDF", md: "Markdown", html: "HTML" };
|
|
477
|
+
return html`<button
|
|
478
|
+
class="tab"
|
|
479
|
+
data-tab=${t}
|
|
480
|
+
role="tab"
|
|
481
|
+
part="tab tab-${t}${selected ? " tab-active" : ""}"
|
|
482
|
+
aria-selected=${selected}
|
|
483
|
+
aria-controls=${panelId}
|
|
484
|
+
tabindex=${selected ? 0 : -1}
|
|
485
|
+
?disabled=${!enabled}
|
|
486
|
+
@click=${() => this.switchTab(t, available)}
|
|
487
|
+
>
|
|
488
|
+
${labels[t]}
|
|
489
|
+
</button>`;
|
|
490
|
+
})}
|
|
491
|
+
<div class="meta" part="meta">
|
|
492
|
+
<span><code>cv:${file.metadata.version}</code></span>
|
|
493
|
+
<span>${file.metadata.primaryLanguage}</span>
|
|
494
|
+
<span>${file.payloads.length} payload${file.payloads.length === 1 ? "" : "s"}</span>
|
|
495
|
+
</div>
|
|
496
|
+
</div>` : null}
|
|
497
|
+
<div
|
|
498
|
+
id=${panelId}
|
|
499
|
+
class="stage"
|
|
500
|
+
role="tabpanel"
|
|
501
|
+
part="stage"
|
|
502
|
+
aria-label="${this.activeTab.toUpperCase()} representation"
|
|
503
|
+
>
|
|
504
|
+
${this.activeTab === "pdf" ? html`<canvas class="pdf-canvas" part="pdf-canvas" aria-label="PDF preview"></canvas>` : this.activeTab === "md" && md ? html`<div class="md" part="md">${this.renderMd(md.text())}</div>` : this.activeTab === "html" && htmlPayload ? html`<div class="html" part="html">
|
|
505
|
+
<iframe sandbox="" srcdoc=${htmlPayload.text()} title="HTML rendering"></iframe>
|
|
506
|
+
</div>` : html`<div class="empty">No payload available for this view.</div>`}
|
|
507
|
+
</div>
|
|
508
|
+
${this.activeTab === "pdf" && this.pdfPageCount > 1 ? html`<div class="pager" part="pager">
|
|
509
|
+
<button
|
|
510
|
+
type="button"
|
|
511
|
+
?disabled=${this.pdfPage <= 1}
|
|
512
|
+
aria-label="Previous page"
|
|
513
|
+
@click=${() => {
|
|
514
|
+
this.pdfPage = Math.max(1, this.pdfPage - 1);
|
|
515
|
+
}}
|
|
516
|
+
>
|
|
517
|
+
← Prev
|
|
518
|
+
</button>
|
|
519
|
+
<span aria-live="polite">Page ${this.pdfPage} of ${this.pdfPageCount}</span>
|
|
520
|
+
<button
|
|
521
|
+
type="button"
|
|
522
|
+
?disabled=${this.pdfPage >= this.pdfPageCount}
|
|
523
|
+
aria-label="Next page"
|
|
524
|
+
@click=${() => {
|
|
525
|
+
this.pdfPage = Math.min(this.pdfPageCount, this.pdfPage + 1);
|
|
526
|
+
}}
|
|
527
|
+
>
|
|
528
|
+
Next →
|
|
529
|
+
</button>
|
|
530
|
+
</div>` : null}
|
|
531
|
+
`;
|
|
532
|
+
}
|
|
533
|
+
renderMd(source) {
|
|
534
|
+
const safeHtml = renderMarkdown(source);
|
|
535
|
+
const tmpl = document.createElement("template");
|
|
536
|
+
tmpl.innerHTML = safeHtml;
|
|
537
|
+
return html`${tmpl.content.cloneNode(true)}`;
|
|
538
|
+
}
|
|
539
|
+
};
|
|
540
|
+
__decorateClass([
|
|
541
|
+
property({ type: String })
|
|
542
|
+
], CvEmbed.prototype, "src");
|
|
543
|
+
__decorateClass([
|
|
544
|
+
property({ type: String })
|
|
545
|
+
], CvEmbed.prototype, "view");
|
|
546
|
+
__decorateClass([
|
|
547
|
+
property({ type: String, attribute: "language" })
|
|
548
|
+
], CvEmbed.prototype, "language");
|
|
549
|
+
__decorateClass([
|
|
550
|
+
property({ type: Boolean, attribute: "tab-bar" })
|
|
551
|
+
], CvEmbed.prototype, "tabBar");
|
|
552
|
+
__decorateClass([
|
|
553
|
+
property({ type: String, reflect: true })
|
|
554
|
+
], CvEmbed.prototype, "theme");
|
|
555
|
+
__decorateClass([
|
|
556
|
+
state()
|
|
557
|
+
], CvEmbed.prototype, "file");
|
|
558
|
+
__decorateClass([
|
|
559
|
+
state()
|
|
560
|
+
], CvEmbed.prototype, "error");
|
|
561
|
+
__decorateClass([
|
|
562
|
+
state()
|
|
563
|
+
], CvEmbed.prototype, "activeTab");
|
|
564
|
+
__decorateClass([
|
|
565
|
+
state()
|
|
566
|
+
], CvEmbed.prototype, "loading");
|
|
567
|
+
__decorateClass([
|
|
568
|
+
state()
|
|
569
|
+
], CvEmbed.prototype, "pdfPage");
|
|
570
|
+
__decorateClass([
|
|
571
|
+
state()
|
|
572
|
+
], CvEmbed.prototype, "pdfPageCount");
|
|
573
|
+
|
|
574
|
+
// src/index.ts
|
|
575
|
+
if (typeof window !== "undefined" && !customElements.get("cv-embed")) {
|
|
576
|
+
customElements.define("cv-embed", CvEmbed);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export { CvEmbed };
|
|
580
|
+
//# sourceMappingURL=index.js.map
|
|
581
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/render-pdf.ts","../src/render-markdown.ts","../src/cv-embed.ts","../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,kBAAA,GAAA,EAAA;AAAA,QAAA,CA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A,CAAA;AAAA,EAAhB,KAAA;AAAM,CAAA,EA9OI,OAAA,CA8OM,SAAA,EAAA,SAAA,CAAA;AACA,eAAA,CAAA;AAAA,EAAhB,KAAA;AAAM,CAAA,EA/OI,OAAA,CA+OM,SAAA,EAAA,SAAA,CAAA;AACA,eAAA,CAAA;AAAA,EAAhB,KAAA;AAAM,CAAA,EAhPI,OAAA,CAgPM,SAAA,EAAA,cAAA,CAAA;;;ACzPnB,IAAI,OAAO,MAAA,KAAW,WAAA,IAAe,CAAC,cAAA,CAAe,GAAA,CAAI,UAAU,CAAA,EAAG;AACpE,EAAA,cAAA,CAAe,MAAA,CAAO,YAAY,OAAO,CAAA;AAC3C","file":"index.js","sourcesContent":["import * as pdfjsLib from 'pdfjs-dist';\nimport workerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';\n\nlet workerConfigured = false;\n\nfunction ensureWorker(): void {\n if (workerConfigured) return;\n pdfjsLib.GlobalWorkerOptions.workerSrc = workerUrl;\n workerConfigured = true;\n}\n\nexport interface RenderResult {\n numPages: number;\n}\n\nexport async function renderPdfPage(\n bytes: Uint8Array,\n pageNumber: number,\n canvas: HTMLCanvasElement,\n): Promise<RenderResult> {\n ensureWorker();\n const view = new Uint8Array(bytes.byteLength);\n view.set(bytes);\n const loadingTask = pdfjsLib.getDocument({ data: view });\n const pdf = await loadingTask.promise;\n const page = await pdf.getPage(pageNumber);\n\n const dpr = window.devicePixelRatio || 1;\n const baseViewport = page.getViewport({ scale: 1 });\n const containerWidth = canvas.parentElement?.clientWidth ?? baseViewport.width;\n const targetWidth = Math.min(containerWidth - 32, 900);\n const scale = (targetWidth / baseViewport.width) * dpr;\n const viewport = page.getViewport({ scale });\n\n canvas.width = Math.floor(viewport.width);\n canvas.height = Math.floor(viewport.height);\n canvas.style.width = `${Math.floor(viewport.width / dpr)}px`;\n canvas.style.height = `${Math.floor(viewport.height / dpr)}px`;\n\n const ctx = canvas.getContext('2d');\n if (!ctx) {\n throw new Error('Could not acquire 2D canvas context');\n }\n await page.render({ canvasContext: ctx, viewport }).promise;\n return { numPages: pdf.numPages };\n}\n","import DOMPurify from 'dompurify';\nimport { marked } from 'marked';\n\nexport function renderMarkdown(source: string): string {\n const raw = marked.parse(source, { async: false }) as string;\n return DOMPurify.sanitize(raw, {\n USE_PROFILES: { html: true },\n FORBID_TAGS: ['script', 'style', 'iframe', 'object', 'embed'],\n FORBID_ATTR: ['onerror', 'onload', 'onclick', 'onmouseover'],\n });\n}\n","import { LitElement, css, html, type TemplateResult } from 'lit';\nimport { property, state } from 'lit/decorators.js';\nimport { extract } from '@cvfile/sdk';\nimport type { CvFile } from '@cvfile/sdk';\nimport { renderMarkdown } from './render-markdown.js';\nimport { renderPdfPage } from './render-pdf.js';\n\ntype Tab = 'pdf' | 'md' | 'html';\ntype Theme = 'auto' | 'light' | 'dark';\ntype ChangedKeys = Map<PropertyKey, unknown>;\n\nexport class CvEmbed extends LitElement {\n static override styles = css`\n :host {\n --cv-color: #111;\n --cv-bg: #fafaf9;\n --cv-border: #e5e5e3;\n --cv-toolbar-bg: #ffffff;\n --cv-stage-bg: #f4f4f2;\n --cv-meta: #6b7280;\n --cv-tab-hover: rgba(0, 0, 0, 0.04);\n --cv-tab-active: rgba(0, 0, 0, 0.08);\n --cv-card-bg: #ffffff;\n --cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);\n --cv-focus-ring: #4f46e5;\n --cv-error: #b91c1c;\n --cv-error-bg: #fef2f2;\n\n display: block;\n font-family: ui-sans-serif, system-ui, -apple-system, \"Segoe UI\", sans-serif;\n color: var(--cv-color);\n background: var(--cv-bg);\n border: 1px solid var(--cv-border);\n border-radius: 12px;\n overflow: hidden;\n box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);\n width: 100%;\n min-height: 480px;\n contain: paint;\n }\n\n :host([theme='dark']),\n :host([theme='auto']) {\n color-scheme: light dark;\n }\n :host([theme='dark']) {\n --cv-color: #f3f4f6;\n --cv-bg: #0b0b0d;\n --cv-border: #2a2a2e;\n --cv-toolbar-bg: #15151a;\n --cv-stage-bg: #0f0f12;\n --cv-meta: #9ca3af;\n --cv-tab-hover: rgba(255, 255, 255, 0.05);\n --cv-tab-active: rgba(255, 255, 255, 0.10);\n --cv-card-bg: #15151a;\n --cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);\n --cv-error-bg: #2a1414;\n }\n @media (prefers-color-scheme: dark) {\n :host([theme='auto']) {\n --cv-color: #f3f4f6;\n --cv-bg: #0b0b0d;\n --cv-border: #2a2a2e;\n --cv-toolbar-bg: #15151a;\n --cv-stage-bg: #0f0f12;\n --cv-meta: #9ca3af;\n --cv-tab-hover: rgba(255, 255, 255, 0.05);\n --cv-tab-active: rgba(255, 255, 255, 0.10);\n --cv-card-bg: #15151a;\n --cv-card-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);\n --cv-error-bg: #2a1414;\n }\n }\n\n .toolbar {\n display: flex;\n align-items: center;\n gap: 0.25rem;\n padding: 0.5rem 0.75rem;\n border-bottom: 1px solid var(--cv-border);\n background: var(--cv-toolbar-bg);\n flex-wrap: wrap;\n }\n .tab {\n appearance: none;\n border: 0;\n background: transparent;\n padding: 0.4rem 0.8rem;\n border-radius: 6px;\n font: inherit;\n color: inherit;\n cursor: pointer;\n opacity: 0.6;\n transition: background 120ms, opacity 120ms;\n }\n .tab:hover:not([disabled]) { background: var(--cv-tab-hover); opacity: 0.95; }\n .tab[aria-selected='true'] {\n background: var(--cv-tab-active);\n opacity: 1;\n font-weight: 600;\n }\n .tab[disabled] { opacity: 0.3; cursor: not-allowed; }\n .tab:focus-visible {\n outline: 2px solid var(--cv-focus-ring);\n outline-offset: 2px;\n }\n .meta {\n margin-left: auto;\n font-size: 0.8rem;\n color: var(--cv-meta);\n display: flex;\n gap: 0.75rem;\n flex-wrap: wrap;\n }\n .meta code { font: inherit; opacity: 0.85; }\n .stage {\n position: relative;\n min-height: 420px;\n max-height: var(--cv-max-height, 80vh);\n overflow: auto;\n padding: 0;\n background: var(--cv-stage-bg);\n }\n .pdf-canvas {\n display: block;\n margin: 1rem auto;\n box-shadow: var(--cv-card-shadow);\n background: #fff;\n max-width: 100%;\n }\n .pager {\n display: flex;\n justify-content: center;\n align-items: center;\n gap: 0.5rem;\n padding: 0.5rem;\n background: var(--cv-toolbar-bg);\n border-top: 1px solid var(--cv-border);\n font-size: 0.85rem;\n }\n .pager button {\n appearance: none;\n border: 1px solid var(--cv-border);\n background: var(--cv-card-bg);\n color: inherit;\n padding: 0.25rem 0.6rem;\n border-radius: 6px;\n cursor: pointer;\n font: inherit;\n }\n .pager button:focus-visible {\n outline: 2px solid var(--cv-focus-ring);\n outline-offset: 2px;\n }\n .pager button[disabled] { opacity: 0.4; cursor: not-allowed; }\n .md, .html {\n padding: 1.5rem 2rem;\n background: var(--cv-card-bg);\n max-width: 760px;\n margin: 1rem auto;\n box-shadow: var(--cv-card-shadow);\n border-radius: 8px;\n line-height: 1.6;\n }\n .html iframe {\n width: 100%;\n min-height: 420px;\n border: 0;\n background: #fff;\n border-radius: 4px;\n }\n .md :first-child { margin-top: 0; }\n .md h1 { font-size: 1.75rem; }\n .md h2 { font-size: 1.25rem; border-bottom: 1px solid var(--cv-border); padding-bottom: 0.25rem; margin-top: 1.5rem; }\n .md ul { padding-left: 1.25rem; }\n .md a { color: var(--cv-focus-ring); }\n\n .skeleton {\n display: flex;\n flex-direction: column;\n gap: 1rem;\n padding: 1.5rem 2rem;\n max-width: 760px;\n margin: 1rem auto;\n }\n .skeleton .bar {\n height: 1rem;\n background: linear-gradient(90deg, var(--cv-tab-hover) 0%, var(--cv-tab-active) 50%, var(--cv-tab-hover) 100%);\n background-size: 200% 100%;\n border-radius: 4px;\n animation: shimmer 1.4s infinite;\n }\n .skeleton .bar.short { width: 40%; }\n .skeleton .bar.medium { width: 70%; }\n @keyframes shimmer {\n 0% { background-position: 200% 0; }\n 100% { background-position: -200% 0; }\n }\n\n .empty {\n padding: 2rem;\n text-align: center;\n color: var(--cv-meta);\n }\n\n .err {\n margin: 1rem;\n padding: 1.5rem;\n background: var(--cv-error-bg);\n color: var(--cv-error);\n border-radius: 8px;\n border: 1px solid var(--cv-error);\n }\n .err button {\n margin-top: 0.75rem;\n appearance: none;\n border: 1px solid var(--cv-error);\n background: transparent;\n color: var(--cv-error);\n padding: 0.4rem 0.9rem;\n border-radius: 6px;\n cursor: pointer;\n font: inherit;\n }\n\n /* Compact mode for narrow viewports */\n @media (max-width: 480px) {\n .toolbar { padding: 0.4rem 0.5rem; }\n .tab { padding: 0.35rem 0.6rem; font-size: 0.9rem; }\n .meta { width: 100%; margin-left: 0; padding-top: 0.25rem; font-size: 0.75rem; }\n .md, .html { padding: 1rem 1.25rem; margin: 0.5rem; }\n }\n\n /* Honour user motion preferences. */\n @media (prefers-reduced-motion: reduce) {\n .skeleton .bar { animation: none; }\n .tab { transition: none; }\n }\n `;\n\n @property({ type: String }) src = '';\n @property({ type: String }) view: Tab | 'auto' = 'auto';\n @property({ type: String, attribute: 'language' }) language = '';\n @property({ type: Boolean, attribute: 'tab-bar' }) tabBar = true;\n @property({ type: String, reflect: true }) theme: Theme = 'auto';\n\n @state() private file: CvFile | null = null;\n @state() private error: string | null = null;\n @state() private activeTab: Tab = 'pdf';\n @state() private loading = true;\n @state() private pdfPage = 1;\n @state() private pdfPageCount = 1;\n\n private pdfModulePromise: Promise<typeof import('./render-pdf.js')> | null = null;\n\n override async connectedCallback(): Promise<void> {\n super.connectedCallback();\n if (this.src) {\n await this.loadFromSrc();\n }\n }\n\n override willUpdate(changed: ChangedKeys): void {\n if (changed.has('src') && this.src) {\n void this.loadFromSrc();\n }\n if (changed.has('view') && this.view !== 'auto' && this.file) {\n this.activeTab = this.view;\n }\n }\n\n override updated(changed: ChangedKeys): void {\n if (changed.has('activeTab') || changed.has('file') || changed.has('pdfPage')) {\n if (this.activeTab === 'pdf' && this.file) {\n void this.renderPdf();\n }\n }\n }\n\n loadFromBytes(bytes: Uint8Array): Promise<void> {\n return this.processBytes(bytes);\n }\n\n /** Public API: re-attempt the last load (used by error retry button). */\n async retry(): Promise<void> {\n this.error = null;\n if (this.src) {\n await this.loadFromSrc();\n }\n }\n\n private async loadFromSrc(): Promise<void> {\n this.loading = true;\n this.error = null;\n this.file = null;\n try {\n const res = await fetch(this.src);\n if (!res.ok) {\n throw new Error(`Fetch failed: ${res.status} ${res.statusText}`);\n }\n const buf = new Uint8Array(await res.arrayBuffer());\n await this.processBytes(buf);\n } catch (err) {\n this.error = (err as Error).message;\n this.loading = false;\n }\n }\n\n private async processBytes(bytes: Uint8Array): Promise<void> {\n this.loading = true;\n try {\n const file = await extract(bytes);\n this.file = file;\n this.activeTab = this.pickInitialTab(file);\n this.loading = false;\n } catch (err) {\n this.error = (err as Error).message;\n this.loading = false;\n }\n }\n\n private pickInitialTab(file: CvFile): Tab {\n if (this.view !== 'auto') return this.view;\n void file;\n return 'pdf';\n }\n\n private async renderPdf(): Promise<void> {\n if (!this.file) return;\n const canvas = this.renderRoot.querySelector<HTMLCanvasElement>('.pdf-canvas');\n if (!canvas) return;\n if (!this.pdfModulePromise) {\n this.pdfModulePromise = import('./render-pdf.js');\n }\n try {\n const mod = await this.pdfModulePromise;\n const { numPages } = await mod.renderPdfPage(this.file.bytes, this.pdfPage, canvas);\n if (numPages !== this.pdfPageCount) {\n this.pdfPageCount = numPages;\n }\n } catch (err) {\n this.error = `PDF render failed: ${(err as Error).message}`;\n }\n }\n\n private switchTab(tab: Tab, available: Record<Tab, boolean>): void {\n if (!available[tab]) return;\n this.activeTab = tab;\n }\n\n /** Keyboard navigation per WAI-ARIA tablist authoring practices. */\n private handleTabKeydown(event: KeyboardEvent, available: Record<Tab, boolean>): void {\n const order: Tab[] = (['pdf', 'md', 'html'] as Tab[]).filter((t) => available[t]);\n const idx = order.indexOf(this.activeTab);\n let next: Tab | null = null;\n switch (event.key) {\n case 'ArrowRight':\n case 'ArrowDown':\n next = order[(idx + 1) % order.length] ?? null;\n break;\n case 'ArrowLeft':\n case 'ArrowUp':\n next = order[(idx - 1 + order.length) % order.length] ?? null;\n break;\n case 'Home':\n next = order[0] ?? null;\n break;\n case 'End':\n next = order[order.length - 1] ?? null;\n break;\n }\n if (next) {\n event.preventDefault();\n this.switchTab(next, available);\n requestAnimationFrame(() => {\n const button = this.renderRoot.querySelector<HTMLButtonElement>(`button[data-tab=\"${next}\"]`);\n button?.focus();\n });\n }\n }\n\n override render(): TemplateResult {\n if (this.error) {\n return html`<div class=\"err\" role=\"alert\">\n <strong>Could not load .cv</strong>\n <div>${this.error}</div>\n ${this.src\n ? html`<button type=\"button\" @click=${() => void this.retry()}>Retry</button>`\n : null}\n <slot name=\"error\"></slot>\n </div>`;\n }\n if (this.loading || !this.file) {\n return html`<div class=\"empty\" aria-busy=\"true\" aria-live=\"polite\">\n <div class=\"skeleton\" part=\"skeleton\">\n <div class=\"bar short\"></div>\n <div class=\"bar\"></div>\n <div class=\"bar medium\"></div>\n <div class=\"bar\"></div>\n <div class=\"bar short\"></div>\n </div>\n </div>`;\n }\n\n const file = this.file;\n const md = file.payloads.find((p) => p.mimeType === 'text/markdown');\n const htmlPayload = file.payloads.find((p) => p.mimeType === 'text/html');\n const available: Record<Tab, boolean> = {\n pdf: true,\n md: !!md,\n html: !!htmlPayload,\n };\n const panelId = 'cv-embed-panel';\n\n return html`\n ${this.tabBar\n ? html`<div\n class=\"toolbar\"\n role=\"tablist\"\n aria-label=\"Document representations\"\n part=\"toolbar\"\n @keydown=${(e: KeyboardEvent) => this.handleTabKeydown(e, available)}\n >\n ${(['pdf', 'md', 'html'] as Tab[]).map((t) => {\n const enabled = available[t];\n const selected = this.activeTab === t;\n const labels: Record<Tab, string> = { pdf: 'PDF', md: 'Markdown', html: 'HTML' };\n return html`<button\n class=\"tab\"\n data-tab=${t}\n role=\"tab\"\n part=\"tab tab-${t}${selected ? ' tab-active' : ''}\"\n aria-selected=${selected}\n aria-controls=${panelId}\n tabindex=${selected ? 0 : -1}\n ?disabled=${!enabled}\n @click=${() => this.switchTab(t, available)}\n >\n ${labels[t]}\n </button>`;\n })}\n <div class=\"meta\" part=\"meta\">\n <span><code>cv:${file.metadata.version}</code></span>\n <span>${file.metadata.primaryLanguage}</span>\n <span>${file.payloads.length} payload${file.payloads.length === 1 ? '' : 's'}</span>\n </div>\n </div>`\n : null}\n <div\n id=${panelId}\n class=\"stage\"\n role=\"tabpanel\"\n part=\"stage\"\n aria-label=\"${this.activeTab.toUpperCase()} representation\"\n >\n ${this.activeTab === 'pdf'\n ? html`<canvas class=\"pdf-canvas\" part=\"pdf-canvas\" aria-label=\"PDF preview\"></canvas>`\n : this.activeTab === 'md' && md\n ? html`<div class=\"md\" part=\"md\">${this.renderMd(md.text())}</div>`\n : this.activeTab === 'html' && htmlPayload\n ? html`<div class=\"html\" part=\"html\">\n <iframe sandbox=\"\" srcdoc=${htmlPayload.text()} title=\"HTML rendering\"></iframe>\n </div>`\n : html`<div class=\"empty\">No payload available for this view.</div>`}\n </div>\n ${this.activeTab === 'pdf' && this.pdfPageCount > 1\n ? html`<div class=\"pager\" part=\"pager\">\n <button\n type=\"button\"\n ?disabled=${this.pdfPage <= 1}\n aria-label=\"Previous page\"\n @click=${() => {\n this.pdfPage = Math.max(1, this.pdfPage - 1);\n }}\n >\n ← Prev\n </button>\n <span aria-live=\"polite\">Page ${this.pdfPage} of ${this.pdfPageCount}</span>\n <button\n type=\"button\"\n ?disabled=${this.pdfPage >= this.pdfPageCount}\n aria-label=\"Next page\"\n @click=${() => {\n this.pdfPage = Math.min(this.pdfPageCount, this.pdfPage + 1);\n }}\n >\n Next →\n </button>\n </div>`\n : null}\n `;\n }\n\n private renderMd(source: string): TemplateResult {\n const safeHtml = renderMarkdown(source);\n const tmpl = document.createElement('template');\n tmpl.innerHTML = safeHtml;\n return html`${tmpl.content.cloneNode(true)}`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'cv-embed': CvEmbed;\n }\n}\n\nexport { renderPdfPage };\n","import { CvEmbed } from './cv-embed.js';\n\nif (typeof window !== 'undefined' && !customElements.get('cv-embed')) {\n customElements.define('cv-embed', CvEmbed);\n}\n\nexport { CvEmbed };\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@cvfile/viewer-web",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "<cv-embed> web component and standalone viewer for the .cv open file format.",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"homepage": "https://cvfile.org",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/cvfile/cv",
|
|
10
|
+
"directory": "packages/viewer-web"
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"main": "./dist/index.js",
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist",
|
|
23
|
+
"README.md",
|
|
24
|
+
"LICENSE"
|
|
25
|
+
],
|
|
26
|
+
"sideEffects": [
|
|
27
|
+
"./dist/index.js",
|
|
28
|
+
"./src/index.ts"
|
|
29
|
+
],
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"lit": "^3.2.0",
|
|
32
|
+
"marked": "^14.1.0",
|
|
33
|
+
"dompurify": "^3.2.0",
|
|
34
|
+
"pdfjs-dist": "^4.7.76",
|
|
35
|
+
"@cvfile/sdk": "0.1.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/dompurify": "^3.0.5",
|
|
39
|
+
"tsup": "^8.3.0",
|
|
40
|
+
"typescript": "^5.6.0",
|
|
41
|
+
"vite": "^5.4.0"
|
|
42
|
+
},
|
|
43
|
+
"scripts": {
|
|
44
|
+
"build": "tsup",
|
|
45
|
+
"dev": "vite",
|
|
46
|
+
"preview": "vite preview",
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
48
|
+
}
|
|
49
|
+
}
|