ndf-viewer 0.0.0-stage → 0.0.1-v22
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 +17 -0
- package/README.md +43 -2
- package/fesm2022/ndf-viewer-annotations-C64kCr4j.mjs +275 -0
- package/fesm2022/ndf-viewer-annotations-C64kCr4j.mjs.map +1 -0
- package/fesm2022/ndf-viewer-decode-pdf-stream-DG2KqsJx.mjs +57 -0
- package/fesm2022/ndf-viewer-decode-pdf-stream-DG2KqsJx.mjs.map +1 -0
- package/fesm2022/ndf-viewer-download-source-B5y7EqUy.mjs +43 -0
- package/fesm2022/ndf-viewer-download-source-B5y7EqUy.mjs.map +1 -0
- package/fesm2022/ndf-viewer-flate-decode-ChdaD2sc.mjs +113 -0
- package/fesm2022/ndf-viewer-flate-decode-ChdaD2sc.mjs.map +1 -0
- package/fesm2022/ndf-viewer-measure-BiOKPKKQ.mjs +950 -0
- package/fesm2022/ndf-viewer-measure-BiOKPKKQ.mjs.map +1 -0
- package/fesm2022/ndf-viewer-media-DTgGmgNr.mjs +1370 -0
- package/fesm2022/ndf-viewer-media-DTgGmgNr.mjs.map +1 -0
- package/fesm2022/ndf-viewer-parse-dictionary-DHCE78B1.mjs +809 -0
- package/fesm2022/ndf-viewer-parse-dictionary-DHCE78B1.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-annotation-editor-geometry-mJU9jc1H.mjs +602 -0
- package/fesm2022/ndf-viewer-pdf-annotation-editor-geometry-mJU9jc1H.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-annotation-fields-uMCZAu7j.mjs +134 -0
- package/fesm2022/ndf-viewer-pdf-annotation-fields-uMCZAu7j.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-annotation-layer-DXB8hJWY.mjs +7 -0
- package/fesm2022/ndf-viewer-pdf-annotation-layer-DXB8hJWY.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-annotation-notes-BbllOY07.mjs +407 -0
- package/fesm2022/ndf-viewer-pdf-annotation-notes-BbllOY07.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-annotation-permission-gate-BTbmVtRp.mjs +45 -0
- package/fesm2022/ndf-viewer-pdf-annotation-permission-gate-BTbmVtRp.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-attachment-bytes-tTGbGblI.mjs +100 -0
- package/fesm2022/ndf-viewer-pdf-attachment-bytes-tTGbGblI.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-layer-CWoFovJp.mjs +329 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-layer-CWoFovJp.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-layer.component-IYdU7h6Q.mjs +745 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-layer.component-IYdU7h6Q.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-measure-DGqwoCT1.mjs +464 -0
- package/fesm2022/ndf-viewer-pdf-content-edit-measure-DGqwoCT1.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-destination-DQ27cKFZ.mjs +58 -0
- package/fesm2022/ndf-viewer-pdf-destination-DQ27cKFZ.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-data-fggGiNqA.mjs +179 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-data-fggGiNqA.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-layer-BA4qbtst.mjs +98 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-layer-BA4qbtst.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-layer.component-DdJ8nZNp.mjs +460 -0
- package/fesm2022/ndf-viewer-pdf-form-builder-layer.component-DdJ8nZNp.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-field-B1YlIni9.mjs +27 -0
- package/fesm2022/ndf-viewer-pdf-form-field-B1YlIni9.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-layer.component-C43FyDz_.mjs +249 -0
- package/fesm2022/ndf-viewer-pdf-form-layer.component-C43FyDz_.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-live-data.component-C7wJmJ5W.mjs +141 -0
- package/fesm2022/ndf-viewer-pdf-form-live-data.component-C7wJmJ5W.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-parse-DyqtZmsP.mjs +257 -0
- package/fesm2022/ndf-viewer-pdf-form-parse-DyqtZmsP.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-form-state-DvshpK4K.mjs +110 -0
- package/fesm2022/ndf-viewer-pdf-form-state-DvshpK4K.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-image-export-ChWqD3XB.mjs +298 -0
- package/fesm2022/ndf-viewer-pdf-image-export-ChWqD3XB.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-locale-host.directive-BFTtbEG9.mjs +1457 -0
- package/fesm2022/ndf-viewer-pdf-locale-host.directive-BFTtbEG9.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-measurement-layer.component-C3NNuEiC.mjs +599 -0
- package/fesm2022/ndf-viewer-pdf-measurement-layer.component-C3NNuEiC.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-page-renderer-VfL-2HVT.mjs +8666 -0
- package/fesm2022/ndf-viewer-pdf-page-renderer-VfL-2HVT.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-page-text-index-BaGUtXrn.mjs +27 -0
- package/fesm2022/ndf-viewer-pdf-page-text-index-BaGUtXrn.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-pki-placement-HSM5aXpq.mjs +614 -0
- package/fesm2022/ndf-viewer-pdf-pki-placement-HSM5aXpq.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-pki-signature-layer.component-CjzjTCyc.mjs +292 -0
- package/fesm2022/ndf-viewer-pdf-pki-signature-layer.component-CjzjTCyc.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-rectangle-l_5j3nD1.mjs +21 -0
- package/fesm2022/ndf-viewer-pdf-rectangle-l_5j3nD1.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-redaction-layer-DNAAK91N.mjs +105 -0
- package/fesm2022/ndf-viewer-pdf-redaction-layer-DNAAK91N.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-redaction-layer.component-Blw76Qk3.mjs +354 -0
- package/fesm2022/ndf-viewer-pdf-redaction-layer.component-Blw76Qk3.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-redaction-pages-AVu0FeDY.mjs +66 -0
- package/fesm2022/ndf-viewer-pdf-redaction-pages-AVu0FeDY.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-redaction-types-LvGpxdjx.mjs +49 -0
- package/fesm2022/ndf-viewer-pdf-redaction-types-LvGpxdjx.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-save-O5Sx6FZ-.mjs +11053 -0
- package/fesm2022/ndf-viewer-pdf-save-O5Sx6FZ-.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-signature-geometry-bTN8Gf98.mjs +262 -0
- package/fesm2022/ndf-viewer-pdf-signature-geometry-bTN8Gf98.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-signature-layer.component-DddUDKbO.mjs +402 -0
- package/fesm2022/ndf-viewer-pdf-signature-layer.component-DddUDKbO.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-squiggly-path-BretQvO-.mjs +74 -0
- package/fesm2022/ndf-viewer-pdf-squiggly-path-BretQvO-.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-stamp-C_ofCFqd.mjs +337 -0
- package/fesm2022/ndf-viewer-pdf-stamp-C_ofCFqd.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-stamp-flatten-C2wyltOe.mjs +128 -0
- package/fesm2022/ndf-viewer-pdf-stamp-flatten-C2wyltOe.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-text-highlights-DXpzf7mP.mjs +57 -0
- package/fesm2022/ndf-viewer-pdf-text-highlights-DXpzf7mP.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-text-reading-order-Bgx7gAc6.mjs +760 -0
- package/fesm2022/ndf-viewer-pdf-text-reading-order-Bgx7gAc6.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-text-run-bounds-CoNAsfYp.mjs +160 -0
- package/fesm2022/ndf-viewer-pdf-text-run-bounds-CoNAsfYp.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-text-run-join-VErxmXy5.mjs +51 -0
- package/fesm2022/ndf-viewer-pdf-text-run-join-VErxmXy5.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-text-script-CTTxIV5p.mjs +39 -0
- package/fesm2022/ndf-viewer-pdf-text-script-CTTxIV5p.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-theme-host.directive-ABmy5Hiu.mjs +233 -0
- package/fesm2022/ndf-viewer-pdf-theme-host.directive-ABmy5Hiu.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-thumbnail-renderer-AghWc5bf.mjs +181 -0
- package/fesm2022/ndf-viewer-pdf-thumbnail-renderer-AghWc5bf.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-user-annotation-layer-C-7QeQ7F.mjs +1121 -0
- package/fesm2022/ndf-viewer-pdf-user-annotation-layer-C-7QeQ7F.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-video-layer.component-B8xXI-eP.mjs +247 -0
- package/fesm2022/ndf-viewer-pdf-video-layer.component-B8xXI-eP.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-viewport-BHLKUCIi.mjs +142 -0
- package/fesm2022/ndf-viewer-pdf-viewport-BHLKUCIi.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-viewport-renderer-B8eECSZ-.mjs +223 -0
- package/fesm2022/ndf-viewer-pdf-viewport-renderer-B8eECSZ-.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-watermark-layer.component-B3hiEaIk.mjs +640 -0
- package/fesm2022/ndf-viewer-pdf-watermark-layer.component-B3hiEaIk.mjs.map +1 -0
- package/fesm2022/ndf-viewer-pdf-xfa-layer.component-Da9MBdfd.mjs +188 -0
- package/fesm2022/ndf-viewer-pdf-xfa-layer.component-Da9MBdfd.mjs.map +1 -0
- package/fesm2022/ndf-viewer-resource-budgets-D4mBRfd_.mjs +67 -0
- package/fesm2022/ndf-viewer-resource-budgets-D4mBRfd_.mjs.map +1 -0
- package/fesm2022/ndf-viewer-sanitize-display-text-D8OZwBQl.mjs +36 -0
- package/fesm2022/ndf-viewer-sanitize-display-text-D8OZwBQl.mjs.map +1 -0
- package/fesm2022/ndf-viewer-video-viewport-CIqss_ww.mjs +130 -0
- package/fesm2022/ndf-viewer-video-viewport-CIqss_ww.mjs.map +1 -0
- package/fesm2022/ndf-viewer-xfa-DcqctqLC.mjs +379 -0
- package/fesm2022/ndf-viewer-xfa-DcqctqLC.mjs.map +1 -0
- package/fesm2022/ndf-viewer-xml-safe-CvfCSaEn.mjs +7 -0
- package/fesm2022/ndf-viewer-xml-safe-CvfCSaEn.mjs.map +1 -0
- package/fesm2022/ndf-viewer-zip-viewer-source-BN7o6oIi.mjs +291 -0
- package/fesm2022/ndf-viewer-zip-viewer-source-BN7o6oIi.mjs.map +1 -0
- package/fesm2022/ndf-viewer.mjs +64568 -0
- package/fesm2022/ndf-viewer.mjs.map +1 -0
- package/package.json +32 -3
- package/types/ndf-viewer.d.ts +17040 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
Copyright 2026 CompTechCo
|
|
6
|
+
|
|
7
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
+
you may not use this file except in compliance with the License.
|
|
9
|
+
You may obtain a copy of the License at
|
|
10
|
+
|
|
11
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
|
|
13
|
+
Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
See the License for the specific language governing permissions and
|
|
17
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,44 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ndf-viewer
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Angular standalone PDF viewer library with a from-scratch rendering engine (no PDF.js or iframe embed).
|
|
4
|
+
|
|
5
|
+
## Documentation
|
|
6
|
+
|
|
7
|
+
Full guides live in the workspace [`docs/`](../../docs/) folder:
|
|
8
|
+
|
|
9
|
+
- [Quick Start](../../docs/quick-start.md)
|
|
10
|
+
- [Components](../../docs/components.md)
|
|
11
|
+
- [API Reference](../../docs/api-reference.md)
|
|
12
|
+
- [Theming](../../docs/theming.md)
|
|
13
|
+
|
|
14
|
+
## Cursor / AI agent skills
|
|
15
|
+
|
|
16
|
+
Copy [`agent-skills/`](./agent-skills/) into a consuming app’s `.cursor/skills/` (and optional `cursor-rules/`) so Cursor agents can wire the library automatically. See [`agent-skills/README.md`](./agent-skills/README.md).
|
|
17
|
+
|
|
18
|
+
## Build
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
ng build ndf-viewer
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Output: `dist/ndf-viewer`
|
|
25
|
+
|
|
26
|
+
## Tests
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
ng test ndf-viewer
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Public API
|
|
33
|
+
|
|
34
|
+
All exports are defined in `src/public-api.ts`. Import from `ndf-viewer` after building or linking.
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import {
|
|
38
|
+
PdfViewerComponent,
|
|
39
|
+
PdfViewerNavigationComponent,
|
|
40
|
+
providePdfViewer,
|
|
41
|
+
providePdfViewerTheme,
|
|
42
|
+
loadPdfDocument,
|
|
43
|
+
} from 'ndf-viewer';
|
|
44
|
+
```
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
import { x as isViewableAnnotationSubtype, y as describeAnnotationSubtype } from "./ndf-viewer-pdf-annotation-notes-BbllOY07.mjs";
|
|
2
|
+
import "./ndf-viewer-pdf-annotation-fields-uMCZAu7j.mjs";
|
|
3
|
+
import { A as defaultColorForSubtype, _ as translateRectangle, h as translateInkList, j as defaultOpacityForSubtype, k as createUserAnnotation, l as rectangleFromGeometry, m as scaleInkListToRectangle } from "./ndf-viewer-pdf-annotation-editor-geometry-mJU9jc1H.mjs";
|
|
4
|
+
import { n as pdfRectangle } from "./ndf-viewer-pdf-rectangle-l_5j3nD1.mjs";
|
|
5
|
+
import "./ndf-viewer-pdf-annotation-layer-DXB8hJWY.mjs";
|
|
6
|
+
import "./ndf-viewer-pdf-user-annotation-layer-C-7QeQ7F.mjs";
|
|
7
|
+
import "./ndf-viewer-pdf-squiggly-path-BretQvO-.mjs";
|
|
8
|
+
function collectDocumentAnnotations(document) {
|
|
9
|
+
const entries = [];
|
|
10
|
+
document.pages.forEach((page, index) => {
|
|
11
|
+
const pageNumber = index + 1;
|
|
12
|
+
for (const annotation of page.annotations) {
|
|
13
|
+
if (!isViewableAnnotationSubtype(annotation.subtype)) continue;
|
|
14
|
+
entries.push({
|
|
15
|
+
pageNumber,
|
|
16
|
+
annotation,
|
|
17
|
+
label: describeAnnotationSubtype(annotation.subtype),
|
|
18
|
+
preview: buildAnnotationPreview(annotation)
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
return entries;
|
|
23
|
+
}
|
|
24
|
+
function collectPageAnnotations(document, pageNumber) {
|
|
25
|
+
return collectDocumentAnnotations(document).filter((entry) => entry.pageNumber === pageNumber);
|
|
26
|
+
}
|
|
27
|
+
function countViewableAnnotations(document) {
|
|
28
|
+
return document.pages.reduce((count, page) => count + page.annotations.filter((annotation) => isViewableAnnotationSubtype(annotation.subtype)).length, 0);
|
|
29
|
+
}
|
|
30
|
+
function buildAnnotationPreview(annotation) {
|
|
31
|
+
const text = annotation.contents?.trim() || annotation.title?.trim() || annotation.subject?.trim();
|
|
32
|
+
if (text) return text.length > 80 ? `${text.slice(0, 77)}…` : text;
|
|
33
|
+
if (annotation.stampName) return annotation.stampName;
|
|
34
|
+
if (annotation.inkList.length > 0) return `${annotation.inkList.length} stroke(s)`;
|
|
35
|
+
if (annotation.vertices.length > 0) return `${annotation.vertices.length} point(s)`;
|
|
36
|
+
if (annotation.quadPoints.length > 0) return `${annotation.quadPoints.length / 8} region(s)`;
|
|
37
|
+
return "No description";
|
|
38
|
+
}
|
|
39
|
+
const REVIEW_STATES = /* @__PURE__ */ new Set([
|
|
40
|
+
"Accepted",
|
|
41
|
+
"Rejected",
|
|
42
|
+
"Cancelled",
|
|
43
|
+
"Completed",
|
|
44
|
+
"None",
|
|
45
|
+
"Marked",
|
|
46
|
+
"Unmarked"
|
|
47
|
+
]);
|
|
48
|
+
function importDocumentAnnotationsAsUser(document) {
|
|
49
|
+
const pending = [];
|
|
50
|
+
const objectToId = /* @__PURE__ */ new Map();
|
|
51
|
+
document.pages.forEach((page, index) => {
|
|
52
|
+
const pageNumber = index + 1;
|
|
53
|
+
for (const annotation of page.annotations) {
|
|
54
|
+
if (!toUserSubtype(annotation.subtype)) continue;
|
|
55
|
+
if (annotation.subtype === "Popup") continue;
|
|
56
|
+
const id = annotation.name?.trim() || `pdf-annot-${annotation.objectNumber}-${annotation.generation}`;
|
|
57
|
+
objectToId.set(`${annotation.objectNumber}:${annotation.generation}`, id);
|
|
58
|
+
pending.push({
|
|
59
|
+
pageNumber,
|
|
60
|
+
annotation,
|
|
61
|
+
id
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const result = [];
|
|
66
|
+
for (const item of pending) {
|
|
67
|
+
const { annotation, pageNumber, id } = item;
|
|
68
|
+
const subtype = toUserSubtype(annotation.subtype);
|
|
69
|
+
const inReplyTo = resolveReplyParentId(annotation, objectToId);
|
|
70
|
+
const groupPrimaryId = annotation.replyType === "Group" && inReplyTo && !annotation.state ? inReplyTo : null;
|
|
71
|
+
const replyParentId = annotation.replyType === "Group" && !annotation.state ? null : inReplyTo;
|
|
72
|
+
const state = normalizeReviewState(annotation.state);
|
|
73
|
+
const stateModel = normalizeStateModel(annotation.stateModel, state);
|
|
74
|
+
const color = annotation.color ?? defaultColorForSubtype(subtype);
|
|
75
|
+
const opacity = annotation.opacity ?? defaultOpacityForSubtype(subtype);
|
|
76
|
+
const rect = annotation.rectangle;
|
|
77
|
+
result.push(createUserAnnotation({
|
|
78
|
+
id,
|
|
79
|
+
pageNumber,
|
|
80
|
+
subtype,
|
|
81
|
+
rectangle: pdfRectangle(rect.left, rect.bottom, rect.right, rect.top),
|
|
82
|
+
contents: annotation.contents ?? "",
|
|
83
|
+
color,
|
|
84
|
+
opacity,
|
|
85
|
+
rotation: 0,
|
|
86
|
+
inkList: annotation.inkList.map((stroke) => [...stroke]),
|
|
87
|
+
quadPoints: [...annotation.quadPoints],
|
|
88
|
+
vertices: annotation.vertices.flatMap((point) => [point.x, point.y]),
|
|
89
|
+
author: annotation.title ?? "",
|
|
90
|
+
inReplyTo: replyParentId,
|
|
91
|
+
groupPrimaryId,
|
|
92
|
+
annotationState: state,
|
|
93
|
+
stateModel,
|
|
94
|
+
stampName: annotation.stampName ?? "",
|
|
95
|
+
flags: annotation.flags ?? 0
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
return result;
|
|
99
|
+
}
|
|
100
|
+
function resolveReplyParentId(annotation, objectToId) {
|
|
101
|
+
const ref = annotation.inReplyToReference;
|
|
102
|
+
if (!ref) return null;
|
|
103
|
+
return objectToId.get(`${ref.objectNumber}:${ref.generation}`) ?? null;
|
|
104
|
+
}
|
|
105
|
+
function normalizeReviewState(state) {
|
|
106
|
+
if (!state || !REVIEW_STATES.has(state)) return "";
|
|
107
|
+
return state;
|
|
108
|
+
}
|
|
109
|
+
function normalizeStateModel(model, state) {
|
|
110
|
+
if (model === "Review" || model === "Marked") return model;
|
|
111
|
+
if (state === "Marked" || state === "Unmarked") return "Marked";
|
|
112
|
+
if (state) return "Review";
|
|
113
|
+
return "";
|
|
114
|
+
}
|
|
115
|
+
function toUserSubtype(subtype) {
|
|
116
|
+
switch (subtype) {
|
|
117
|
+
case "Highlight":
|
|
118
|
+
case "Underline":
|
|
119
|
+
case "StrikeOut":
|
|
120
|
+
case "Squiggly":
|
|
121
|
+
case "FreeText":
|
|
122
|
+
case "Text":
|
|
123
|
+
case "Square":
|
|
124
|
+
case "Circle":
|
|
125
|
+
case "Polygon":
|
|
126
|
+
case "Polyline":
|
|
127
|
+
case "Ink":
|
|
128
|
+
case "Stamp":
|
|
129
|
+
case "Caret":
|
|
130
|
+
case "Line": return subtype;
|
|
131
|
+
default: return null;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function quadPointsToRegions(quadPoints) {
|
|
135
|
+
const regions = [];
|
|
136
|
+
for (let index = 0; index + 7 < quadPoints.length; index += 8) {
|
|
137
|
+
const xs = [
|
|
138
|
+
quadPoints[index],
|
|
139
|
+
quadPoints[index + 2],
|
|
140
|
+
quadPoints[index + 4],
|
|
141
|
+
quadPoints[index + 6]
|
|
142
|
+
];
|
|
143
|
+
const ys = [
|
|
144
|
+
quadPoints[index + 1],
|
|
145
|
+
quadPoints[index + 3],
|
|
146
|
+
quadPoints[index + 5],
|
|
147
|
+
quadPoints[index + 7]
|
|
148
|
+
];
|
|
149
|
+
regions.push(pdfRectangle(Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)));
|
|
150
|
+
}
|
|
151
|
+
return regions;
|
|
152
|
+
}
|
|
153
|
+
function resolveAnnotationHighlightRegions(annotation) {
|
|
154
|
+
if (annotation.quadPoints.length >= 8) return quadPointsToRegions(annotation.quadPoints);
|
|
155
|
+
if (annotation.vertices.length >= 2) {
|
|
156
|
+
const xs = annotation.vertices.map((point) => point.x);
|
|
157
|
+
const ys = annotation.vertices.map((point) => point.y);
|
|
158
|
+
return [pdfRectangle(Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys))];
|
|
159
|
+
}
|
|
160
|
+
if (annotation.inkList.length > 0) {
|
|
161
|
+
const xs = [];
|
|
162
|
+
const ys = [];
|
|
163
|
+
for (const stroke of annotation.inkList) for (let index = 0; index + 1 < stroke.length; index += 2) {
|
|
164
|
+
xs.push(stroke[index]);
|
|
165
|
+
ys.push(stroke[index + 1]);
|
|
166
|
+
}
|
|
167
|
+
if (xs.length > 0) {
|
|
168
|
+
const padding = 4;
|
|
169
|
+
return [pdfRectangle(Math.min(...xs) - padding, Math.min(...ys) - padding, Math.max(...xs) + padding, Math.max(...ys) + padding)];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (annotation.subtype === "Text") {
|
|
173
|
+
const noteWidth = 16;
|
|
174
|
+
const noteHeight = 14;
|
|
175
|
+
const rect = annotation.rectangle;
|
|
176
|
+
return [pdfRectangle(rect.left, rect.top - noteHeight, rect.left + noteWidth, rect.top)];
|
|
177
|
+
}
|
|
178
|
+
return [annotation.rectangle];
|
|
179
|
+
}
|
|
180
|
+
function patchFromGeometryField(annotation, field, value) {
|
|
181
|
+
const rect = annotation.rectangle;
|
|
182
|
+
switch (field) {
|
|
183
|
+
case "left": {
|
|
184
|
+
const dx = value - rect.left;
|
|
185
|
+
return {
|
|
186
|
+
rectangle: translateRectangle(rect, dx, 0),
|
|
187
|
+
...annotation.inkList.length > 0 ? { inkList: translateInkList(annotation.inkList, dx, 0) } : {}
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
case "bottom": {
|
|
191
|
+
const dy = value - rect.bottom;
|
|
192
|
+
return {
|
|
193
|
+
rectangle: translateRectangle(rect, 0, dy),
|
|
194
|
+
...annotation.inkList.length > 0 ? { inkList: translateInkList(annotation.inkList, 0, dy) } : {}
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
case "width": return {
|
|
198
|
+
rectangle: resizeFromGeometry(rect, value, rect.height, "width"),
|
|
199
|
+
...annotation.inkList.length > 0 ? { inkList: scaleInkListToRectangle(annotation.inkList, rect, resizeFromGeometry(rect, value, rect.height, "width")) } : {}
|
|
200
|
+
};
|
|
201
|
+
case "height": return {
|
|
202
|
+
rectangle: resizeFromGeometry(rect, rect.width, value, "height"),
|
|
203
|
+
...annotation.inkList.length > 0 ? { inkList: scaleInkListToRectangle(annotation.inkList, rect, resizeFromGeometry(rect, rect.width, value, "height")) } : {}
|
|
204
|
+
};
|
|
205
|
+
case "rotation": return { rotation: value };
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
function resizeFromGeometry(rect, width, height, anchor) {
|
|
209
|
+
const nextWidth = anchor === "width" ? Math.max(8, width) : rect.width;
|
|
210
|
+
const nextHeight = anchor === "height" ? Math.max(8, height) : rect.height;
|
|
211
|
+
return rectangleFromGeometry(rect.left, rect.bottom, nextWidth, nextHeight);
|
|
212
|
+
}
|
|
213
|
+
const COMPACT_STYLE_PALETTE = [
|
|
214
|
+
"#E44234",
|
|
215
|
+
"#FF6E00",
|
|
216
|
+
"#FFC02A",
|
|
217
|
+
"#00A76C",
|
|
218
|
+
"#25C2C2",
|
|
219
|
+
"#2C5BFF",
|
|
220
|
+
"#7B2D8E"
|
|
221
|
+
];
|
|
222
|
+
const EXTENDED_STYLE_PALETTE = [
|
|
223
|
+
"#000000",
|
|
224
|
+
"#4A4A4A",
|
|
225
|
+
"#9C9C9C",
|
|
226
|
+
"#CDCDCD",
|
|
227
|
+
"#FFFFFF",
|
|
228
|
+
"#8B572A",
|
|
229
|
+
"#F8E9D2",
|
|
230
|
+
"#F4A4C0",
|
|
231
|
+
"#F5D565",
|
|
232
|
+
"#7ED321",
|
|
233
|
+
"#50E3C2",
|
|
234
|
+
"#4A90E2",
|
|
235
|
+
"#BD10E0"
|
|
236
|
+
];
|
|
237
|
+
[...COMPACT_STYLE_PALETTE, ...EXTENDED_STYLE_PALETTE];
|
|
238
|
+
const CUSTOM_STORAGE_KEY = "pdf-viewer.style-palette.custom";
|
|
239
|
+
function normalizeHexColor(value) {
|
|
240
|
+
const raw = value.trim();
|
|
241
|
+
const match = /^#?([0-9a-fA-F]{6})$/.exec(raw);
|
|
242
|
+
if (!match) return null;
|
|
243
|
+
return `#${match[1].toUpperCase()}`;
|
|
244
|
+
}
|
|
245
|
+
function loadCustomStyleColors() {
|
|
246
|
+
try {
|
|
247
|
+
const raw = localStorage.getItem(CUSTOM_STORAGE_KEY);
|
|
248
|
+
if (!raw) return [];
|
|
249
|
+
const parsed = JSON.parse(raw);
|
|
250
|
+
if (!Array.isArray(parsed)) return [];
|
|
251
|
+
return parsed.map((entry) => typeof entry === "string" ? normalizeHexColor(entry) : null).filter((entry) => entry != null);
|
|
252
|
+
} catch {
|
|
253
|
+
return [];
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
function saveCustomStyleColors(colors) {
|
|
257
|
+
try {
|
|
258
|
+
localStorage.setItem(CUSTOM_STORAGE_KEY, JSON.stringify([...colors]));
|
|
259
|
+
} catch {}
|
|
260
|
+
}
|
|
261
|
+
function mergeStylePalette(custom, expanded) {
|
|
262
|
+
const base = expanded ? [...COMPACT_STYLE_PALETTE, ...EXTENDED_STYLE_PALETTE] : [...COMPACT_STYLE_PALETTE];
|
|
263
|
+
const seen = /* @__PURE__ */ new Set();
|
|
264
|
+
const out = [];
|
|
265
|
+
for (const color of [...base, ...custom]) {
|
|
266
|
+
const hex = normalizeHexColor(color);
|
|
267
|
+
if (!hex || seen.has(hex)) continue;
|
|
268
|
+
seen.add(hex);
|
|
269
|
+
out.push(hex);
|
|
270
|
+
}
|
|
271
|
+
return out;
|
|
272
|
+
}
|
|
273
|
+
export { patchFromGeometryField as a, collectDocumentAnnotations as c, saveCustomStyleColors as i, collectPageAnnotations as l, mergeStylePalette as n, resolveAnnotationHighlightRegions as o, normalizeHexColor as r, importDocumentAnnotationsAsUser as s, loadCustomStyleColors as t, countViewableAnnotations as u };
|
|
274
|
+
|
|
275
|
+
//# sourceMappingURL=ndf-viewer-annotations-C64kCr4j.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndf-viewer-annotations-C64kCr4j.mjs","names":[],"sources":["../../../projects/ndf-viewer/src/core/annotations/pdf-annotation-collect.ts","../../../projects/ndf-viewer/src/core/annotations/pdf-annotation-import.ts","../../../projects/ndf-viewer/src/core/annotations/pdf-annotation-regions.ts","../../../projects/ndf-viewer/src/core/annotations/pdf-annotation-editor-properties.ts","../../../projects/ndf-viewer/src/core/annotations/pdf-annotation-style-palette.ts"],"sourcesContent":["import type { PdfDocument } from '../document/pdf-document';\nimport type { PdfAnnotation } from '../document/pdf-annotation';\nimport { describeAnnotationSubtype, isViewableAnnotationSubtype } from './pdf-annotation-types';\n\n/** Annotation entry with page context for UI lists. */\nexport interface PdfDocumentAnnotation {\n readonly pageNumber: number;\n readonly annotation: PdfAnnotation;\n readonly label: string;\n readonly preview: string;\n}\n\nexport function collectDocumentAnnotations(document: PdfDocument): PdfDocumentAnnotation[] {\n const entries: PdfDocumentAnnotation[] = [];\n\n document.pages.forEach((page, index) => {\n const pageNumber = index + 1;\n for (const annotation of page.annotations) {\n if (!isViewableAnnotationSubtype(annotation.subtype)) {\n continue;\n }\n entries.push({\n pageNumber,\n annotation,\n label: describeAnnotationSubtype(annotation.subtype),\n preview: buildAnnotationPreview(annotation),\n });\n }\n });\n\n return entries;\n}\n\nexport function collectPageAnnotations(\n document: PdfDocument,\n pageNumber: number,\n): PdfDocumentAnnotation[] {\n return collectDocumentAnnotations(document).filter((entry) => entry.pageNumber === pageNumber);\n}\n\nexport function countViewableAnnotations(document: PdfDocument): number {\n return document.pages.reduce(\n (count, page) =>\n count +\n page.annotations.filter((annotation) => isViewableAnnotationSubtype(annotation.subtype))\n .length,\n 0,\n );\n}\n\nfunction buildAnnotationPreview(annotation: PdfAnnotation): string {\n const text =\n annotation.contents?.trim() || annotation.title?.trim() || annotation.subject?.trim();\n if (text) {\n return text.length > 80 ? `${text.slice(0, 77)}…` : text;\n }\n if (annotation.stampName) {\n return annotation.stampName;\n }\n if (annotation.inkList.length > 0) {\n return `${annotation.inkList.length} stroke(s)`;\n }\n if (annotation.vertices.length > 0) {\n return `${annotation.vertices.length} point(s)`;\n }\n if (annotation.quadPoints.length > 0) {\n return `${annotation.quadPoints.length / 8} region(s)`;\n }\n return 'No description';\n}\n","import type { PdfDocument } from '../document/pdf-document';\nimport type { PdfAnnotation } from '../document/pdf-annotation';\nimport {\n createUserAnnotation,\n defaultColorForSubtype,\n defaultOpacityForSubtype,\n type PdfAnnotationReviewState,\n type PdfAnnotationStateModel,\n type PdfUserAnnotation,\n type PdfUserAnnotationSubtype,\n} from './pdf-user-annotation';\nimport { pdfRectangle } from '../document/pdf-rectangle';\n\nconst REVIEW_STATES = new Set<string>([\n 'Accepted',\n 'Rejected',\n 'Cancelled',\n 'Completed',\n 'None',\n 'Marked',\n 'Unmarked',\n]);\n\n/**\n * Import page annotations from a loaded PDF into editor annotations, preserving\n * reply threads (`/IRT`) and review status (`/State` / `/StateModel`).\n */\nexport function importDocumentAnnotationsAsUser(document: PdfDocument): PdfUserAnnotation[] {\n interface Pending {\n readonly pageNumber: number;\n readonly annotation: PdfAnnotation;\n readonly id: string;\n }\n\n const pending: Pending[] = [];\n const objectToId = new Map<string, string>();\n\n document.pages.forEach((page, index) => {\n const pageNumber = index + 1;\n for (const annotation of page.annotations) {\n const subtype = toUserSubtype(annotation.subtype);\n if (!subtype) {\n continue;\n }\n // Skip popup chrome annotations.\n if (annotation.subtype === 'Popup') {\n continue;\n }\n const id =\n annotation.name?.trim() || `pdf-annot-${annotation.objectNumber}-${annotation.generation}`;\n objectToId.set(`${annotation.objectNumber}:${annotation.generation}`, id);\n pending.push({ pageNumber, annotation, id });\n }\n });\n\n const result: PdfUserAnnotation[] = [];\n for (const item of pending) {\n const { annotation, pageNumber, id } = item;\n const subtype = toUserSubtype(annotation.subtype)!;\n const inReplyTo = resolveReplyParentId(annotation, objectToId);\n const groupPrimaryId =\n annotation.replyType === 'Group' && inReplyTo && !annotation.state ? inReplyTo : null;\n const replyParentId = annotation.replyType === 'Group' && !annotation.state ? null : inReplyTo;\n\n const state = normalizeReviewState(annotation.state);\n const stateModel = normalizeStateModel(annotation.stateModel, state);\n\n const color = annotation.color ?? defaultColorForSubtype(subtype);\n const opacity = annotation.opacity ?? defaultOpacityForSubtype(subtype);\n const rect = annotation.rectangle;\n\n result.push(\n createUserAnnotation({\n id,\n pageNumber,\n subtype,\n rectangle: pdfRectangle(rect.left, rect.bottom, rect.right, rect.top),\n contents: annotation.contents ?? '',\n color,\n opacity,\n rotation: 0,\n // PdfAnnotation already stores each stroke as a flat coordinate list.\n inkList: annotation.inkList.map((stroke) => [...stroke]),\n quadPoints: [...annotation.quadPoints],\n vertices: annotation.vertices.flatMap((point) => [point.x, point.y]),\n author: annotation.title ?? '',\n inReplyTo: replyParentId,\n groupPrimaryId,\n annotationState: state,\n stateModel,\n stampName: annotation.stampName ?? '',\n flags: annotation.flags ?? 0,\n }),\n );\n }\n\n return result;\n}\n\nfunction resolveReplyParentId(\n annotation: PdfAnnotation,\n objectToId: ReadonlyMap<string, string>,\n): string | null {\n const ref = annotation.inReplyToReference;\n if (!ref) {\n return null;\n }\n return objectToId.get(`${ref.objectNumber}:${ref.generation}`) ?? null;\n}\n\nfunction normalizeReviewState(state: string | undefined): PdfAnnotationReviewState {\n if (!state || !REVIEW_STATES.has(state)) {\n return '';\n }\n return state as PdfAnnotationReviewState;\n}\n\nfunction normalizeStateModel(\n model: string | undefined,\n state: PdfAnnotationReviewState,\n): PdfAnnotationStateModel {\n if (model === 'Review' || model === 'Marked') {\n return model;\n }\n if (state === 'Marked' || state === 'Unmarked') {\n return 'Marked';\n }\n if (state) {\n return 'Review';\n }\n return '';\n}\n\nfunction toUserSubtype(subtype: string): PdfUserAnnotationSubtype | null {\n switch (subtype) {\n case 'Highlight':\n case 'Underline':\n case 'StrikeOut':\n case 'Squiggly':\n case 'FreeText':\n case 'Text':\n case 'Square':\n case 'Circle':\n case 'Polygon':\n case 'Polyline':\n case 'Ink':\n case 'Stamp':\n case 'Caret':\n case 'Line':\n return subtype;\n default:\n return null;\n }\n}\n","import type { PdfAnnotation } from '../document/pdf-annotation';\nimport { pdfRectangle, type PdfRectangle } from '../document/pdf-rectangle';\n\n/** Converts flat /QuadPoints arrays into bounding rectangles. */\nexport function quadPointsToRegions(quadPoints: readonly number[]): PdfRectangle[] {\n const regions: PdfRectangle[] = [];\n\n for (let index = 0; index + 7 < quadPoints.length; index += 8) {\n const xs = [\n quadPoints[index]!,\n quadPoints[index + 2]!,\n quadPoints[index + 4]!,\n quadPoints[index + 6]!,\n ];\n const ys = [\n quadPoints[index + 1]!,\n quadPoints[index + 3]!,\n quadPoints[index + 5]!,\n quadPoints[index + 7]!,\n ];\n regions.push(pdfRectangle(Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys)));\n }\n\n return regions;\n}\n\n/** Resolves overlay rectangles used to focus/highlight a selected annotation. */\nexport function resolveAnnotationHighlightRegions(annotation: PdfAnnotation): PdfRectangle[] {\n if (annotation.quadPoints.length >= 8) {\n return quadPointsToRegions(annotation.quadPoints);\n }\n\n if (annotation.vertices.length >= 2) {\n const xs = annotation.vertices.map((point) => point.x);\n const ys = annotation.vertices.map((point) => point.y);\n return [pdfRectangle(Math.min(...xs), Math.min(...ys), Math.max(...xs), Math.max(...ys))];\n }\n\n if (annotation.inkList.length > 0) {\n const xs: number[] = [];\n const ys: number[] = [];\n for (const stroke of annotation.inkList) {\n for (let index = 0; index + 1 < stroke.length; index += 2) {\n xs.push(stroke[index]!);\n ys.push(stroke[index + 1]!);\n }\n }\n if (xs.length > 0) {\n const padding = 4;\n return [\n pdfRectangle(\n Math.min(...xs) - padding,\n Math.min(...ys) - padding,\n Math.max(...xs) + padding,\n Math.max(...ys) + padding,\n ),\n ];\n }\n }\n\n if (annotation.subtype === 'Text') {\n const noteWidth = 16;\n const noteHeight = 14;\n const rect = annotation.rectangle;\n return [pdfRectangle(rect.left, rect.top - noteHeight, rect.left + noteWidth, rect.top)];\n }\n\n return [annotation.rectangle];\n}\n","import type { PdfRectangle } from '../document/pdf-rectangle';\nimport type { PdfRgbColor } from './pdf-annotation-fields';\nimport {\n rectangleFromGeometry,\n scaleInkListToRectangle,\n translateInkList,\n translateRectangle,\n} from './pdf-annotation-editor-geometry';\nimport type { PdfUserAnnotation } from './pdf-user-annotation';\n\nexport type GeometryField = 'left' | 'bottom' | 'width' | 'height' | 'rotation';\n\nexport interface AnnotationPropertyPatch {\n readonly contents?: string;\n readonly color?: PdfRgbColor;\n readonly opacity?: number;\n readonly rotation?: number;\n readonly rectangle?: PdfRectangle;\n readonly inkList?: readonly number[][];\n}\n\n/** Builds an update patch from a geometry field change in the edit panel. */\nexport function patchFromGeometryField(\n annotation: PdfUserAnnotation,\n field: GeometryField,\n value: number,\n): AnnotationPropertyPatch {\n const rect = annotation.rectangle;\n switch (field) {\n case 'left': {\n const dx = value - rect.left;\n return {\n rectangle: translateRectangle(rect, dx, 0),\n ...(annotation.inkList.length > 0\n ? { inkList: translateInkList(annotation.inkList, dx, 0) }\n : {}),\n };\n }\n case 'bottom': {\n const dy = value - rect.bottom;\n return {\n rectangle: translateRectangle(rect, 0, dy),\n ...(annotation.inkList.length > 0\n ? { inkList: translateInkList(annotation.inkList, 0, dy) }\n : {}),\n };\n }\n case 'width':\n return {\n rectangle: resizeFromGeometry(rect, value, rect.height, 'width'),\n ...(annotation.inkList.length > 0\n ? {\n inkList: scaleInkListToRectangle(\n annotation.inkList,\n rect,\n resizeFromGeometry(rect, value, rect.height, 'width'),\n ),\n }\n : {}),\n };\n case 'height':\n return {\n rectangle: resizeFromGeometry(rect, rect.width, value, 'height'),\n ...(annotation.inkList.length > 0\n ? {\n inkList: scaleInkListToRectangle(\n annotation.inkList,\n rect,\n resizeFromGeometry(rect, rect.width, value, 'height'),\n ),\n }\n : {}),\n };\n case 'rotation':\n return { rotation: value };\n }\n}\n\nfunction resizeFromGeometry(\n rect: PdfRectangle,\n width: number,\n height: number,\n anchor: 'width' | 'height',\n): PdfRectangle {\n const nextWidth = anchor === 'width' ? Math.max(8, width) : rect.width;\n const nextHeight = anchor === 'height' ? Math.max(8, height) : rect.height;\n return rectangleFromGeometry(rect.left, rect.bottom, nextWidth, nextHeight);\n}\n","/** PDFTron collapsed palette: Red → Purple (7 swatches). */\nexport const COMPACT_STYLE_PALETTE: readonly string[] = [\n '#E44234',\n '#FF6E00',\n '#FFC02A',\n '#00A76C',\n '#25C2C2',\n '#2C5BFF',\n '#7B2D8E',\n];\n\n/** Extra swatches revealed by “Show More” (greys + earth tones). */\nexport const EXTENDED_STYLE_PALETTE: readonly string[] = [\n '#000000',\n '#4A4A4A',\n '#9C9C9C',\n '#CDCDCD',\n '#FFFFFF',\n '#8B572A',\n '#F8E9D2',\n '#F4A4C0',\n '#F5D565',\n '#7ED321',\n '#50E3C2',\n '#4A90E2',\n '#BD10E0',\n];\n\n/** @deprecated Use COMPACT_STYLE_PALETTE + EXTENDED_STYLE_PALETTE. */\nexport const DEFAULT_STYLE_PALETTE: readonly string[] = [\n ...COMPACT_STYLE_PALETTE,\n ...EXTENDED_STYLE_PALETTE,\n];\n\nconst CUSTOM_STORAGE_KEY = 'pdf-viewer.style-palette.custom';\n\nexport function normalizeHexColor(value: string): string | null {\n const raw = value.trim();\n const match = /^#?([0-9a-fA-F]{6})$/.exec(raw);\n if (!match) {\n return null;\n }\n return `#${match[1]!.toUpperCase()}`;\n}\n\nexport function loadCustomStyleColors(): string[] {\n try {\n const raw = localStorage.getItem(CUSTOM_STORAGE_KEY);\n if (!raw) {\n return [];\n }\n const parsed = JSON.parse(raw) as unknown;\n if (!Array.isArray(parsed)) {\n return [];\n }\n return parsed\n .map((entry) => (typeof entry === 'string' ? normalizeHexColor(entry) : null))\n .filter((entry): entry is string => entry != null);\n } catch {\n return [];\n }\n}\n\nexport function saveCustomStyleColors(colors: readonly string[]): void {\n try {\n localStorage.setItem(CUSTOM_STORAGE_KEY, JSON.stringify([...colors]));\n } catch {\n // Ignore quota / private-mode failures.\n }\n}\n\nexport function mergeStylePalette(custom: readonly string[], expanded: boolean): string[] {\n const base = expanded\n ? [...COMPACT_STYLE_PALETTE, ...EXTENDED_STYLE_PALETTE]\n : [...COMPACT_STYLE_PALETTE];\n const seen = new Set<string>();\n const out: string[] = [];\n for (const color of [...base, ...custom]) {\n const hex = normalizeHexColor(color);\n if (!hex || seen.has(hex)) {\n continue;\n }\n seen.add(hex);\n out.push(hex);\n }\n return out;\n}\n"],"mappings":";;;;;;;AAYA,SAAgB,2BAA2B,UAAqB;CAC9D,MAAM,UAAmC,CAAA;CAEzC,SAAS,MAAM,SAAS,MAAM,UAAS;EACrC,MAAM,aAAa,QAAQ;EAC3B,KAAK,MAAM,cAAc,KAAK,aAAa;GACzC,IAAI,CAAC,4BAA4B,WAAW,OAAO,GACjD;GAEF,QAAQ,KAAK;IACX;IACA;IACA,OAAO,0BAA0B,WAAW,OAAO;IACnD,SAAS,uBAAuB,UAAU;GAC3C,CAAA;EACH;CACF,CAAC;CAED,OAAO;AACT;AAEA,SAAgB,uBACd,UACA,YAAkB;CAElB,OAAO,2BAA2B,QAAQ,CAAC,CAAC,QAAQ,UAAU,MAAM,eAAe,UAAU;AAC/F;AAEA,SAAgB,yBAAyB,UAAqB;CAC5D,OAAO,SAAS,MAAM,QACnB,OAAO,SACN,QACA,KAAK,YAAY,QAAQ,eAAe,4BAA4B,WAAW,OAAO,CAAC,CAAC,CACrF,QACL,CAAC;AAEL;AAEA,SAAS,uBAAuB,YAAyB;CACvD,MAAM,OACJ,WAAW,UAAU,KAAI,KAAM,WAAW,OAAO,KAAI,KAAM,WAAW,SAAS,KAAI;CACrF,IAAI,MACF,OAAO,KAAK,SAAS,KAAK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BAAkB,QAA2B,UAAiB;CAC5E,MAAM,OAAO,WACT,CAAC,GAAG,uBAAuB,GAAG,sBAAsB,IACpD,CAAC,GAAG,qBAAqB;CAC7B,MAAM,uBAAO,IAAI,IAAG;CACpB,MAAM,MAAgB,CAAA;CACtB,KAAK,MAAM,SAAS,CAAC,GAAG,MAAM,GAAG,MAAM,GAAG;EACxC,MAAM,MAAM,kBAAkB,KAAK;EACnC,IAAI,CAAC,OAAO,KAAK,IAAI,GAAG,GACtB;EAEF,KAAK,IAAI,GAAG;EACZ,IAAI,KAAK,GAAG;CACd;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { a as assertFilterChainDepth, i as assertDecodedByteCount, o as PdfIoError, t as decodeFlate } from "./ndf-viewer-flate-decode-ChdaD2sc.mjs";
|
|
2
|
+
function decodeAscii85(data) {
|
|
3
|
+
const output = [];
|
|
4
|
+
let group = 0;
|
|
5
|
+
let count = 0;
|
|
6
|
+
for (const byte of data) {
|
|
7
|
+
if (byte === 126) break;
|
|
8
|
+
if (byte <= 32 || byte === 122) {
|
|
9
|
+
if (byte === 122 && count > 0) throw new PdfIoError("Invalid z inside ASCII85 group.");
|
|
10
|
+
if (byte === 122) output.push(0, 0, 0, 0);
|
|
11
|
+
continue;
|
|
12
|
+
}
|
|
13
|
+
if (byte < 33 || byte > 117) continue;
|
|
14
|
+
group = group * 85 + (byte - 33);
|
|
15
|
+
count += 1;
|
|
16
|
+
if (count === 5) {
|
|
17
|
+
output.push(group >>> 24 & 255, group >>> 16 & 255, group >>> 8 & 255, group & 255);
|
|
18
|
+
group = 0;
|
|
19
|
+
count = 0;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (count > 0) {
|
|
23
|
+
for (let padding = count; padding < 5; padding += 1) group = group * 85 + 84;
|
|
24
|
+
for (let emitted = 0; emitted < count - 1; emitted += 1) output.push(group >>> 24 - emitted * 8 & 255);
|
|
25
|
+
}
|
|
26
|
+
return new Uint8Array(output);
|
|
27
|
+
}
|
|
28
|
+
async function decodePdfStream(stream) {
|
|
29
|
+
const filter = stream.dictionary.entries.get("Filter");
|
|
30
|
+
if (!filter) return stream.data;
|
|
31
|
+
const filters = filter.type === "name" ? [filter.value] : readFilterArray(filter);
|
|
32
|
+
assertFilterChainDepth(filters.length);
|
|
33
|
+
let data = stream.data;
|
|
34
|
+
for (const name of filters) {
|
|
35
|
+
if (name === "ASCII85Decode") {
|
|
36
|
+
data = decodeAscii85(data);
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
if (name === "FlateDecode") {
|
|
40
|
+
data = await decodeFlate(data);
|
|
41
|
+
assertDecodedByteCount(data.length);
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
throw new PdfIoError(`Unsupported stream filter: ${name}`);
|
|
45
|
+
}
|
|
46
|
+
return data;
|
|
47
|
+
}
|
|
48
|
+
function readFilterArray(value) {
|
|
49
|
+
if (value.type !== "array") throw new PdfIoError("Invalid stream Filter entry.");
|
|
50
|
+
return value.items.map((item) => {
|
|
51
|
+
if (item.type !== "name") throw new PdfIoError("Stream Filter array must contain names.");
|
|
52
|
+
return item.value;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
export { decodePdfStream as t };
|
|
56
|
+
|
|
57
|
+
//# sourceMappingURL=ndf-viewer-decode-pdf-stream-DG2KqsJx.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndf-viewer-decode-pdf-stream-DG2KqsJx.mjs","names":[],"sources":["../../../projects/ndf-viewer/src/core/streams/ascii85-decode.ts","../../../projects/ndf-viewer/src/core/streams/decode-pdf-stream.ts"],"sourcesContent":["import { PdfIoError } from '../io/pdf-io-error';\n\n/** Decodes PDF ASCII85-encoded stream bytes. */\nexport function decodeAscii85(data: Uint8Array): Uint8Array {\n const output: number[] = [];\n let group = 0;\n let count = 0;\n\n for (const byte of data) {\n if (byte === 0x7e) {\n break;\n }\n if (byte <= 0x20 || byte === 0x7a) {\n if (byte === 0x7a && count > 0) {\n throw new PdfIoError('Invalid z inside ASCII85 group.');\n }\n if (byte === 0x7a) {\n output.push(0, 0, 0, 0);\n }\n continue;\n }\n if (byte < 0x21 || byte > 0x75) {\n continue;\n }\n\n group = group * 85 + (byte - 0x21);\n count += 1;\n if (count === 5) {\n output.push((group >>> 24) & 0xff, (group >>> 16) & 0xff, (group >>> 8) & 0xff, group & 0xff);\n group = 0;\n count = 0;\n }\n }\n\n if (count > 0) {\n for (let padding = count; padding < 5; padding += 1) {\n group = group * 85 + 84;\n }\n for (let emitted = 0; emitted < count - 1; emitted += 1) {\n output.push((group >>> (24 - emitted * 8)) & 0xff);\n }\n }\n\n return new Uint8Array(output);\n}\n","import type { PdfStream, PdfValue } from '../objects/pdf-value';\nimport { decodeAscii85 } from './ascii85-decode';\nimport { decodeFlate } from './flate-decode';\nimport { PdfIoError } from '../io/pdf-io-error';\nimport { assertDecodedByteCount, assertFilterChainDepth } from './stream-budgets';\n\n/** Decode a PDF stream object, applying supported filters. */\nexport async function decodePdfStream(stream: PdfStream): Promise<Uint8Array> {\n const filter = stream.dictionary.entries.get('Filter');\n if (!filter) {\n return stream.data;\n }\n\n const filters = filter.type === 'name' ? [filter.value] : readFilterArray(filter);\n assertFilterChainDepth(filters.length);\n let data = stream.data;\n\n for (const name of filters) {\n if (name === 'ASCII85Decode') {\n data = decodeAscii85(data);\n continue;\n }\n if (name === 'FlateDecode') {\n data = await decodeFlate(data);\n assertDecodedByteCount(data.length);\n continue;\n }\n throw new PdfIoError(`Unsupported stream filter: ${name}`);\n }\n\n return data;\n}\n\nfunction readFilterArray(value: PdfValue): string[] {\n if (value.type !== 'array') {\n throw new PdfIoError('Invalid stream Filter entry.');\n }\n\n return value.items.map((item) => {\n if (item.type !== 'name') {\n throw new PdfIoError('Stream Filter array must contain names.');\n }\n return item.value;\n });\n}\n"],"mappings":";AAGA,SAAgB,cAAc,MAAgB;CAC5C,MAAM,SAAmB,CAAA;CACz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A,SAAS,gBAAgB,OAAe;CACtC,IAAI,MAAM,SAAS,SACjB,MAAM,IAAI,WAAW,8BAA8B;CAGrD,OAAO,MAAM,MAAM,KAAK,SAAQ;EAC9B,IAAI,KAAK,SAAS,QAChB,MAAM,IAAI,WAAW,yCAAyC;EAEhE,OAAO,KAAK;CACd,CAAC;AACH"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function isPdfViewerDownloadSource(src) {
|
|
2
|
+
if (typeof src !== "object" || src === null) return false;
|
|
3
|
+
const candidate = src;
|
|
4
|
+
return candidate.kind === "download" && (candidate.bytes instanceof Uint8Array || candidate.blob instanceof Blob);
|
|
5
|
+
}
|
|
6
|
+
function createPdfViewerDownloadSource(options) {
|
|
7
|
+
const filenameHint = options.filenameHint;
|
|
8
|
+
return {
|
|
9
|
+
kind: "download",
|
|
10
|
+
bytes: options.bytes ?? /* @__PURE__ */ new Uint8Array(0),
|
|
11
|
+
blob: options.blob,
|
|
12
|
+
mimeType: options.mimeType,
|
|
13
|
+
filenameHint,
|
|
14
|
+
reason: options.reason,
|
|
15
|
+
reasonMessage: options.reasonMessage ?? defaultReasonMessage(options.reason, options.mimeType, filenameHint)
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function downloadBlobFromSource(source) {
|
|
19
|
+
const blob = source.blob ?? new Blob([source.bytes.slice()], { type: source.mimeType || "application/octet-stream" });
|
|
20
|
+
const url = URL.createObjectURL(blob);
|
|
21
|
+
const anchor = document.createElement("a");
|
|
22
|
+
anchor.href = url;
|
|
23
|
+
anchor.download = source.filenameHint?.trim() || "download.bin";
|
|
24
|
+
anchor.rel = "noopener";
|
|
25
|
+
document.body.appendChild(anchor);
|
|
26
|
+
anchor.click();
|
|
27
|
+
anchor.remove();
|
|
28
|
+
URL.revokeObjectURL(url);
|
|
29
|
+
}
|
|
30
|
+
function defaultReasonMessage(reason, mimeType, filenameHint) {
|
|
31
|
+
const label = filenameHint?.trim() || mimeType || "this file";
|
|
32
|
+
switch (reason) {
|
|
33
|
+
case "empty": return `“${label}” is empty, so preview is not available.`;
|
|
34
|
+
case "truncated": return `“${label}” looks truncated and could not be previewed.`;
|
|
35
|
+
case "corrupt": return `“${label}” appears corrupt and could not be previewed.`;
|
|
36
|
+
case "oversized": return `“${label}” is too large to preview safely.`;
|
|
37
|
+
case "unsupported": return `Preview is not available for “${label}”.`;
|
|
38
|
+
default: return `Could not decode “${label}” for preview.`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export { downloadBlobFromSource as n, isPdfViewerDownloadSource as r, createPdfViewerDownloadSource as t };
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=ndf-viewer-download-source-B5y7EqUy.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndf-viewer-download-source-B5y7EqUy.mjs","names":[],"sources":["../../../projects/ndf-viewer/src/core/open-format/download-source.ts"],"sourcesContent":["import type { PdfDownloadFallbackReason } from './open-format-types';\n\n/** Tagged viewer source for the shared download-fallback surface (not a PDF). */\nexport interface PdfViewerDownloadSource {\n readonly kind: 'download';\n readonly bytes: Uint8Array;\n /** When set, download uses the blob directly (avoids loading large files into memory). */\n readonly blob?: Blob;\n readonly mimeType: string;\n readonly filenameHint?: string;\n readonly reason: PdfDownloadFallbackReason;\n /** Human-readable reason shown in the panel. */\n readonly reasonMessage: string;\n}\n\nexport function isPdfViewerDownloadSource(src: unknown): src is PdfViewerDownloadSource {\n if (typeof src !== 'object' || src === null) {\n return false;\n }\n const candidate = src as PdfViewerDownloadSource;\n return (\n candidate.kind === 'download' &&\n (candidate.bytes instanceof Uint8Array || candidate.blob instanceof Blob)\n );\n}\n\nexport function createPdfViewerDownloadSource(options: {\n bytes?: Uint8Array;\n blob?: Blob;\n mimeType: string;\n filenameHint?: string;\n reason: PdfDownloadFallbackReason;\n reasonMessage?: string;\n}): PdfViewerDownloadSource {\n const filenameHint = options.filenameHint;\n const bytes = options.bytes ?? new Uint8Array(0);\n return {\n kind: 'download',\n bytes,\n blob: options.blob,\n mimeType: options.mimeType,\n filenameHint,\n reason: options.reason,\n reasonMessage:\n options.reasonMessage ?? defaultReasonMessage(options.reason, options.mimeType, filenameHint),\n };\n}\n\nexport function downloadBlobFromSource(source: PdfViewerDownloadSource): void {\n const blob =\n source.blob ??\n new Blob([source.bytes.slice()], { type: source.mimeType || 'application/octet-stream' });\n const url = URL.createObjectURL(blob);\n const anchor = document.createElement('a');\n anchor.href = url;\n anchor.download = source.filenameHint?.trim() || 'download.bin';\n anchor.rel = 'noopener';\n document.body.appendChild(anchor);\n anchor.click();\n anchor.remove();\n URL.revokeObjectURL(url);\n}\n\nfunction defaultReasonMessage(\n reason: PdfDownloadFallbackReason,\n mimeType: string,\n filenameHint?: string,\n): string {\n const label = filenameHint?.trim() || mimeType || 'this file';\n switch (reason) {\n case 'empty':\n return `“${label}” is empty, so preview is not available.`;\n case 'truncated':\n return `“${label}” looks truncated and could not be previewed.`;\n case 'corrupt':\n return `“${label}” appears corrupt and could not be previewed.`;\n case 'oversized':\n return `“${label}” is too large to preview safely.`;\n case 'unsupported':\n return `Preview is not available for “${label}”.`;\n case 'decode-failed':\n default:\n return `Could not decode “${label}” for preview.`;\n }\n}\n"],"mappings":"AAeA,SAAgB,0BAA0B,KAAY;CACpD,IAAI,OAAO,QAAQ,YAAY,QAAQ,MACrC,OAAO;CAET,MAAM,YAAY;CAClB,OACE,UAAU,SAAS,eAClB,UAAU,iBAAiB,cAAc,UAAU,gBAAgB;AAExE;AAEA,SAAgB,8BAA8B,SAO7C;CACC,MAAM,eAAe,QAAQ;CAE7B,OAAO;EACL,MAAM;EACN,OAHY,QAAQ,yBAAS,IAAI,WAAW,CAAC;EAI7C,MAAM,QAAQ;EACd,UAAU,QAAQ;EAClB;EACA,QAAQ,QAAQ;EAChB,eACE,QAAQ,iBAAiB,qBAAqB,QAAQ,QAAQ,QAAQ,UAAU,YAAY;CAC/F;AACH;AAEA,SAAgB,uBAAuB,QAA+B;CACpE,MAAM,OACJ,OAAO,QACP,IAAI,KAAK,CAAC,OAAO,MAAM,MAAK,CAAE,GAAG,EAAE,MAAM,OAAO,YAAY,2BAA0B,CAAE;CAC1F,MAAM,MAAM,IAAI,gBAAgB,IAAI;CACpC,MAAM,SAAS,SAAS,cAAc,GAAG;CACzC,OAAO,OAAO;CACd,OAAO,WAAW,OAAO,cAAc,KAAI,KAAM;CACjD,OAAO,MAAM;CACb,SAAS,KAAK,YAAY,MAAM;CAChC,OAAO,MAAK;CACZ,OAAO,OAAM;CACb,IAAI,gBAAgB,GAAG;AACzB;AAEA,SAAS,qBACP,QACA,UACA,cAAqB;CAErB,MAAM,QAAQ,cAAc,KAAI,KAAM,YAAY;CAClD,QAAQ,QAAR;EACE,KAAK,SACH,OAAO,IAAI,MAAK;EAClB,KAAK,aACH,OAAO,IAAI,MAAK;EAClB,KAAK,WACH,OAAO,IAAI,MAAK;EAClB,KAAK,aACH,OAAO,IAAI,MAAK;EAClB,KAAK,eACH,OAAO,iCAAiC,MAAK;EAE/C,SACE,OAAO,qBAAqB,MAAK;CACrC;AACF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
var PdfIoError = class extends Error {
|
|
2
|
+
constructor(message) {
|
|
3
|
+
super(message);
|
|
4
|
+
this.name = "PdfIoError";
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
var StreamExpansionError = class extends PdfIoError {
|
|
8
|
+
constructor(message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "StreamExpansionError";
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const MAX_DECODED_STREAM_BYTES = 268435456;
|
|
14
|
+
function assertFilterChainDepth(filterCount, max = 8) {
|
|
15
|
+
if (filterCount > max) throw new PdfIoError(`Stream filter chain exceeds the ${max} filter cap.`);
|
|
16
|
+
}
|
|
17
|
+
function assertDecodedByteCount(byteCount, max = MAX_DECODED_STREAM_BYTES) {
|
|
18
|
+
if (!Number.isFinite(byteCount) || byteCount < 0) throw new PdfIoError("Decoded stream size is not a finite number.");
|
|
19
|
+
if (byteCount > max) throw new StreamExpansionError(`Decoded stream exceeds the ${max} byte expansion cap.`);
|
|
20
|
+
}
|
|
21
|
+
async function decodeFlate(data, options = {}) {
|
|
22
|
+
return decodeFlateInternal(data, {
|
|
23
|
+
formats: ["deflate", "deflate-raw"],
|
|
24
|
+
candidates: buildFlateCandidates(data),
|
|
25
|
+
maxOutputBytes: options.maxOutputBytes ?? 268435456
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
async function decodeZipDeflate(data, options = {}) {
|
|
29
|
+
return decodeFlateInternal(data, {
|
|
30
|
+
formats: ["deflate-raw", "deflate"],
|
|
31
|
+
candidates: [data],
|
|
32
|
+
maxOutputBytes: options.maxOutputBytes ?? 268435456
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async function decodeFlateInternal(data, options) {
|
|
36
|
+
if (typeof DecompressionStream === "undefined") throw new PdfIoError("DecompressionStream is not available in this environment.");
|
|
37
|
+
let lastError;
|
|
38
|
+
for (const candidate of options.candidates) for (const format of options.formats) try {
|
|
39
|
+
return await decompress(candidate, format, options.maxOutputBytes);
|
|
40
|
+
} catch (error) {
|
|
41
|
+
if (isStreamExpansionError(error)) throw error;
|
|
42
|
+
lastError = error;
|
|
43
|
+
}
|
|
44
|
+
throw new PdfIoError(lastError instanceof Error ? `FlateDecode failed: ${lastError.message}` : "FlateDecode failed.");
|
|
45
|
+
}
|
|
46
|
+
function buildFlateCandidates(data) {
|
|
47
|
+
const candidates = [];
|
|
48
|
+
const seen = /* @__PURE__ */ new Set();
|
|
49
|
+
const add = (slice) => {
|
|
50
|
+
const key = `${slice.byteOffset}:${slice.byteLength}`;
|
|
51
|
+
if (slice.length === 0 || seen.has(key)) return;
|
|
52
|
+
seen.add(key);
|
|
53
|
+
candidates.push(slice);
|
|
54
|
+
};
|
|
55
|
+
add(data);
|
|
56
|
+
const zlibOffset = findZlibOffset(data);
|
|
57
|
+
if (zlibOffset > 0) add(data.subarray(zlibOffset));
|
|
58
|
+
for (let trim = 1; trim <= 64; trim += 1) add(data.subarray(0, data.length - trim));
|
|
59
|
+
return candidates;
|
|
60
|
+
}
|
|
61
|
+
function findZlibOffset(data) {
|
|
62
|
+
for (let index = 0; index + 1 < data.length; index += 1) {
|
|
63
|
+
if (data[index] !== 120) continue;
|
|
64
|
+
const flag = data[index + 1];
|
|
65
|
+
if (flag === 1 || flag === 94 || flag === 156 || flag === 218) return index;
|
|
66
|
+
}
|
|
67
|
+
return 0;
|
|
68
|
+
}
|
|
69
|
+
function isStreamExpansionError(error) {
|
|
70
|
+
return error instanceof StreamExpansionError || error instanceof Error && error.name === "StreamExpansionError";
|
|
71
|
+
}
|
|
72
|
+
async function decompress(data, format, maxOutputBytes) {
|
|
73
|
+
return decompressViaWritable(new Uint8Array(data), format, maxOutputBytes);
|
|
74
|
+
}
|
|
75
|
+
async function decompressViaWritable(data, format, maxOutputBytes) {
|
|
76
|
+
const ds = new DecompressionStream(format);
|
|
77
|
+
const writer = ds.writable.getWriter();
|
|
78
|
+
const reader = ds.readable.getReader();
|
|
79
|
+
writer.closed.catch(() => void 0);
|
|
80
|
+
reader.closed.catch(() => void 0);
|
|
81
|
+
const payload = new Uint8Array(data.byteLength);
|
|
82
|
+
payload.set(data);
|
|
83
|
+
const writeDone = writer.write(payload).then(() => writer.close()).catch(() => void 0);
|
|
84
|
+
try {
|
|
85
|
+
return await readStreamToBytes(reader, maxOutputBytes);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
await writer.abort().catch(() => void 0);
|
|
88
|
+
throw error;
|
|
89
|
+
} finally {
|
|
90
|
+
await writeDone;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function readStreamToBytes(reader, maxOutputBytes) {
|
|
94
|
+
const chunks = [];
|
|
95
|
+
let totalLength = 0;
|
|
96
|
+
while (true) {
|
|
97
|
+
const { done, value } = await reader.read();
|
|
98
|
+
if (done) break;
|
|
99
|
+
chunks.push(value);
|
|
100
|
+
totalLength += value.byteLength;
|
|
101
|
+
if (totalLength > maxOutputBytes) throw new StreamExpansionError(`Decoded stream exceeds the ${maxOutputBytes} byte expansion cap.`);
|
|
102
|
+
}
|
|
103
|
+
const output = new Uint8Array(totalLength);
|
|
104
|
+
let offset = 0;
|
|
105
|
+
for (const chunk of chunks) {
|
|
106
|
+
output.set(chunk, offset);
|
|
107
|
+
offset += chunk.byteLength;
|
|
108
|
+
}
|
|
109
|
+
return output;
|
|
110
|
+
}
|
|
111
|
+
export { assertFilterChainDepth as a, assertDecodedByteCount as i, decodeZipDeflate as n, PdfIoError as o, MAX_DECODED_STREAM_BYTES as r, decodeFlate as t };
|
|
112
|
+
|
|
113
|
+
//# sourceMappingURL=ndf-viewer-flate-decode-ChdaD2sc.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ndf-viewer-flate-decode-ChdaD2sc.mjs","names":[],"sources":["../../../projects/ndf-viewer/src/core/io/pdf-io-error.ts","../../../projects/ndf-viewer/src/core/streams/stream-budgets.ts","../../../projects/ndf-viewer/src/core/streams/flate-decode.ts"],"sourcesContent":["export class PdfIoError extends Error {\n constructor(message: string) {\n super(message);\n this.name = 'PdfIoError';\n }\n}\n","import { PdfIoError } from '../io/pdf-io-error';\n\nexport class StreamExpansionError extends PdfIoError {\n constructor(message: string) {\n super(message);\n this.name = 'StreamExpansionError';\n }\n}\n\n/** Maximum `/Filter` names applied to one stream (G1 filter-chain cap). */\nexport const MAX_PDF_FILTER_CHAIN = 8;\n\n/**\n * Maximum decoded stream size after any filter (G1 expansion-bomb cap).\n *\n * Sized so legitimate large content passes: a 4000 × 3000 RGB image is 36 MB\n * decoded, and DOCX/XLSX/PPTX parts and PDF attachments can be larger still.\n * Still bounded, so a true expansion bomb stops well before exhausting memory.\n */\nexport const MAX_DECODED_STREAM_BYTES = 256 * 1024 * 1024;\n\nexport interface StreamDecodeBudget {\n readonly maxOutputBytes?: number;\n}\n\nexport function assertFilterChainDepth(filterCount: number, max = MAX_PDF_FILTER_CHAIN): void {\n if (filterCount > max) {\n throw new PdfIoError(`Stream filter chain exceeds the ${max} filter cap.`);\n }\n}\n\nexport function assertDecodedByteCount(byteCount: number, max = MAX_DECODED_STREAM_BYTES): void {\n if (!Number.isFinite(byteCount) || byteCount < 0) {\n throw new PdfIoError('Decoded stream size is not a finite number.');\n }\n if (byteCount > max) {\n throw new StreamExpansionError(`Decoded stream exceeds the ${max} byte expansion cap.`);\n }\n}\n","import { PdfIoError } from '../io/pdf-io-error';\nimport {\n MAX_DECODED_STREAM_BYTES,\n StreamExpansionError,\n type StreamDecodeBudget,\n} from './stream-budgets';\n\n/** Decompress FlateDecode (zlib-wrapped or raw deflate) stream bytes. */\nexport async function decodeFlate(\n data: Uint8Array,\n options: StreamDecodeBudget = {},\n): Promise<Uint8Array> {\n return decodeFlateInternal(data, {\n formats: ['deflate', 'deflate-raw'],\n candidates: buildFlateCandidates(data),\n maxOutputBytes: options.maxOutputBytes ?? MAX_DECODED_STREAM_BYTES,\n });\n}\n\n/**\n * ZIP method 8 uses raw DEFLATE (no zlib wrapper). Prefer that first and skip\n * the PDF salvage trims that would needlessly retry dozens of slices.\n */\nexport async function decodeZipDeflate(\n data: Uint8Array,\n options: StreamDecodeBudget = {},\n): Promise<Uint8Array> {\n return decodeFlateInternal(data, {\n formats: ['deflate-raw', 'deflate'],\n candidates: [data],\n maxOutputBytes: options.maxOutputBytes ?? MAX_DECODED_STREAM_BYTES,\n });\n}\n\nasync function decodeFlateInternal(\n data: Uint8Array,\n options: {\n readonly formats: readonly DecompressionFormat[];\n readonly candidates: readonly Uint8Array[];\n readonly maxOutputBytes: number;\n },\n): Promise<Uint8Array> {\n if (typeof DecompressionStream === 'undefined') {\n throw new PdfIoError('DecompressionStream is not available in this environment.');\n }\n\n let lastError: unknown;\n\n for (const candidate of options.candidates) {\n for (const format of options.formats) {\n try {\n return await decompress(candidate, format, options.maxOutputBytes);\n } catch (error) {\n if (isStreamExpansionError(error)) {\n throw error;\n }\n lastError = error;\n }\n }\n }\n\n throw new PdfIoError(\n lastError instanceof Error ? `FlateDecode failed: ${lastError.message}` : 'FlateDecode failed.',\n );\n}\n\nfunction buildFlateCandidates(data: Uint8Array): Uint8Array[] {\n const candidates: Uint8Array[] = [];\n const seen = new Set<string>();\n const add = (slice: Uint8Array): void => {\n const key = `${slice.byteOffset}:${slice.byteLength}`;\n if (slice.length === 0 || seen.has(key)) {\n return;\n }\n seen.add(key);\n candidates.push(slice);\n };\n\n add(data);\n\n const zlibOffset = findZlibOffset(data);\n if (zlibOffset > 0) {\n add(data.subarray(zlibOffset));\n }\n\n for (let trim = 1; trim <= 64; trim += 1) {\n add(data.subarray(0, data.length - trim));\n }\n\n return candidates;\n}\n\nfunction findZlibOffset(data: Uint8Array): number {\n for (let index = 0; index + 1 < data.length; index += 1) {\n if (data[index] !== 0x78) {\n continue;\n }\n\n const flag = data[index + 1]!;\n if (flag === 0x01 || flag === 0x5e || flag === 0x9c || flag === 0xda) {\n return index;\n }\n }\n\n return 0;\n}\n\nfunction isStreamExpansionError(error: unknown): error is StreamExpansionError {\n return (\n error instanceof StreamExpansionError ||\n (error instanceof Error && error.name === 'StreamExpansionError')\n );\n}\n\nasync function decompress(\n data: Uint8Array,\n format: DecompressionFormat,\n maxOutputBytes: number,\n): Promise<Uint8Array> {\n const copy = new Uint8Array(data);\n return decompressViaWritable(copy, format, maxOutputBytes);\n}\n\nasync function decompressViaWritable(\n data: Uint8Array,\n format: DecompressionFormat,\n maxOutputBytes: number,\n): Promise<Uint8Array> {\n const ds = new DecompressionStream(format);\n const writer = ds.writable.getWriter();\n const reader = ds.readable.getReader();\n void writer.closed.catch(() => undefined);\n void reader.closed.catch(() => undefined);\n\n const payload = new Uint8Array(data.byteLength);\n payload.set(data);\n const writeDone = writer\n .write(payload as BufferSource)\n .then(() => writer.close())\n .catch(() => undefined);\n\n try {\n return await readStreamToBytes(reader, maxOutputBytes);\n } catch (error) {\n await writer.abort().catch(() => undefined);\n throw error;\n } finally {\n await writeDone;\n }\n}\n\nasync function readStreamToBytes(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n maxOutputBytes: number,\n): Promise<Uint8Array> {\n const chunks: Uint8Array[] = [];\n let totalLength = 0;\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n totalLength += value.byteLength;\n if (totalLength > maxOutputBytes) {\n // Leave the reader locked so the inflater is back-pressured instead of\n // racing an abort into Node's zlib adapter (unhandled rejection).\n throw new StreamExpansionError(\n `Decoded stream exceeds the ${maxOutputBytes} byte expansion cap.`,\n );\n }\n }\n\n const output = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n output.set(chunk, offset);\n offset += chunk.byteLength;\n }\n return output;\n}\n\ntype DecompressionFormat = 'deflate' | 'deflate-raw';\n"],"mappings":"AAAA,IAAa,aAAb,cAAgC,MAAK;CACnC,YAAY,SAAe;EACzB,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACD;ACHD,IAAa,uBAAb,cAA0C,WAAU;CAClD,YAAY,SAAe;EACzB,MAAM,OAAO;EACb,KAAK,OAAO;CACd;AACD;AAYD,MAAa,2BAA2B;AAMxC,SAAgB,uBAAuB,aAAqB,MAAA,GAA0B;CACpF,IAAI,cAAc,KAChB,MAAM,IAAI,WAAW,mCAAmC,IAAG,aAAc;AAE7E;AAEA,SAAgB,uBAAuB,WAAmB,MAAM,0BAAwB;CACtF,IAAI,CAAC,OAAO,SAAS,SAAS,KAAK,YAAY,GAC7C,MAAM,IAAI,WAAW,6CAA6C;CAEpE,IAAI,YAAY,KACd,MAAM,IAAI,qBAAqB,8BAA8B,IAAG,qBAAsB;AAE1F;AC9BA,eAAsB,YACpB,MACA,UAA8B,CAAA,GAAE;CAEhC,OAAO,oBAAoB,MAAM;EAC/B,SAAS,CAAC,WAAW,aAAa;EAClC,YAAY,qBAAqB,IAAI;EACrC,gBAAgB,QAAQ,kBAAA;CACzB,CAAA;AACH;AAM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