@embedpdf/models 1.0.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 CloudPDF, Ji Chang
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,67 @@
1
+ <div align="center">
2
+ <a href="https://www.embedpdf.com">
3
+ <img alt="EmbedPDF logo" src="https://www.embedpdf.com/logo-192.png" height="96">
4
+ </a>
5
+ <h1>EmbedPDF</h1>
6
+
7
+ <a href="https://www.npmjs.com/package/@embedpdf/models"><img alt="NPM version" src="https://img.shields.io/npm/v/@embedpdf/models.svg?style=for-the-badge&labelColor=000000"></a> <a href="https://github.com/embedpdf/embed-pdf-viewer/blob/main/packages/models/LICENSE"><img alt="License" src="https://img.shields.io/npm/l/@embedpdf/models.svg?style=for-the-badge&labelColor=000000"></a> <a href="https://github.com/embedpdf/embed-pdf-viewer/discussions"><img alt="Join the community on GitHub" src="https://img.shields.io/badge/Join%20the%20community-blueviolet.svg?style=for-the-badge&labelColor=000000"></a>
8
+
9
+ </div>
10
+
11
+ # @embedpdf/models
12
+
13
+ Centralised **type definitions & helper utilities** shared by every EmbedPDF runtime and UI package. Keep your codebase error‑free with a single source of truth for documents, pages, annotations, geometry, async tasks, permissions, and more.
14
+
15
+ ## Documentation
16
+
17
+ Full reference & examples live at:
18
+
19
+ **[Official Documentation](https://www.embedpdf.com/docs)**
20
+
21
+ ## Why `@embedpdf/models`?
22
+
23
+ - **Single source of truth** – all packages agree on data shapes (e.g. `PdfDocumentObject`, `PdfAnnotationObject`).
24
+ - **Strong typing** – exhaustive enums, discriminated unions, generics; a huge boost to DX.
25
+ - **Zero runtime cost** – pure type exports & tiny helper functions, fully tree‑shakable.
26
+
27
+ ## Features
28
+
29
+ - Geometry helpers (`transformRect`, `rotateRect`, `boundingRect`, …)
30
+ - Logger with pluggable transports & log‑level filtering
31
+ - Promise‑like **Task** abstraction (cancellable / abortable)
32
+ - Rich PDF domain model: documents, pages, bookmarks, annotations, form fields, permissions, search
33
+ - Utility helpers (`unionFlags`, `PdfTaskHelper`, …)
34
+
35
+ ## Installation
36
+
37
+ ```bash
38
+ npm install @embedpdf/models
39
+ ```
40
+
41
+ ## Basic Usage
42
+
43
+ ```typescript
44
+ import { Rect, transformRect, Rotation } from '@embedpdf/models';
45
+
46
+ const pageSize = { width: 612, height: 792 }; // Letter size
47
+ const annotation: Rect = {
48
+ origin: { x: 100, y: 150 },
49
+ size: { width: 200, height: 50 },
50
+ };
51
+
52
+ // Rotate 90° and scale by 1.5×
53
+ const transformed = transformRect(pageSize, annotation, Rotation.Degree90, 1.5);
54
+ console.log(transformed);
55
+ ```
56
+
57
+ ## Learn More
58
+
59
+ Check the docs for deep dives into:
60
+
61
+ - **Geometry API** – positions, quads, rectangles
62
+ - **Task abstraction** – cancellable async workflows
63
+ - **Complete Type Reference** – every interface & enum used across the stack
64
+
65
+ ## License
66
+
67
+ MIT – see the [LICENSE](https://github.com/embedpdf/embed-pdf-viewer/blob/main/packages/models/LICENSE) file.