teamsync-pdf-viewer 1.0.3 → 1.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/CHANGELOG.md +53 -0
- package/LICENSE +96 -1
- package/README.md +166 -165
- package/dist/src/annotations/types.d.ts +45 -0
- package/dist/src/components/AboutModal.d.ts +6 -0
- package/dist/src/components/AnnotationContextMenu.d.ts +17 -0
- package/dist/src/components/DocumentViewer.d.ts +47 -0
- package/dist/src/components/Header.d.ts +35 -0
- package/dist/src/components/InsertLinkModal.d.ts +10 -0
- package/dist/src/components/LeftSidebar.d.ts +10 -0
- package/dist/src/components/PageContextMenu.d.ts +20 -0
- package/dist/src/components/PageRenderer.d.ts +40 -0
- package/dist/src/components/SettingsModal.d.ts +8 -0
- package/dist/src/components/Sidebar.d.ts +18 -0
- package/dist/src/components/TeamSyncViewer.d.ts +35 -0
- package/dist/src/components/TextSelectionMenu.d.ts +18 -0
- package/dist/src/core/ViewerInstance.d.ts +92 -0
- package/dist/src/core/busContext.d.ts +3 -0
- package/dist/src/core/createWebViewer.d.ts +5 -0
- package/dist/src/core/eventBus.d.ts +25 -0
- package/dist/src/core/export.d.ts +20 -0
- package/dist/src/core/pdfAssets.d.ts +27 -0
- package/dist/src/core/types.d.ts +103 -0
- package/dist/src/hooks/usePdfSearch.d.ts +23 -0
- package/dist/src/hooks/useShortcuts.d.ts +13 -0
- package/dist/src/hooks/useViewerBus.d.ts +7 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/plugins/index.d.ts +1 -0
- package/dist/src/plugins/types.d.ts +26 -0
- package/dist/src/utils/findRegexRedactions.d.ts +6 -0
- package/dist/src/utils/rotationUtils.d.ts +32 -0
- package/dist/style.css +2 -0
- package/dist/teamsync-pdf-viewer.js +5086 -0
- package/dist/teamsync-pdf-viewer.js.map +1 -0
- package/package.json +48 -15
- package/dist/TeamSync.pdf +0 -0
- package/dist/ThirdPartyNotices.txt +0 -639
- package/dist/favicon.svg +0 -16
- package/dist/icons.svg +0 -24
- package/dist/index.d.ts +0 -1
- package/dist/teamsync-pdf-viewer.css +0 -2
- package/dist/teamsync-pdf-viewer.es.js +0 -51524
- package/dist/teamsync-pdf-viewer.umd.cjs +0 -327
- package/dist/webviewer.js +0 -92
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `teamsync-pdf-viewer` are documented here.
|
|
4
|
+
|
|
5
|
+
## [1.1.0] — 2026-08-31
|
|
6
|
+
|
|
7
|
+
### Breaking
|
|
8
|
+
- The npm entry point is now **side-effect free**: importing the package no longer touches `window`,
|
|
9
|
+
never auto-mounts a demo viewer into `#root`, and no longer installs the iframe `postMessage` bridge.
|
|
10
|
+
Those behaviours live in the demo/iframe application build only (`src/demo/main.tsx`,
|
|
11
|
+
`npm run build:app`, `public/webviewer.js`).
|
|
12
|
+
- `react`, `react-dom` and `pdfjs-dist` are **peer dependencies** (previously `react` was a hard
|
|
13
|
+
dependency, which could install a second React copy).
|
|
14
|
+
- The pdf.js **worker is no longer inlined** as a `data:` URL. Hosts must serve
|
|
15
|
+
`pdf.worker.min.mjs` (matching their installed `pdfjs-dist`) and call `configurePdfAssets({ workerSrc })`
|
|
16
|
+
or pass `assets={{ workerSrc }}` to `<TeamSyncViewer>`. This shrinks the bundle from 5.3 MB to
|
|
17
|
+
well under 1 MB and works under strict Content-Security-Policies.
|
|
18
|
+
- The UMD build was removed (`pdfjs-dist` v6 is ESM-only, so it never worked for real consumers).
|
|
19
|
+
Script-tag users are served by the iframe package.
|
|
20
|
+
- `DocumentViewer`, `Header`, `Sidebar` and `PageRenderer` are no longer exported — they are
|
|
21
|
+
internal components with unstable props. Use `<TeamSyncViewer>` / `createWebViewer()`.
|
|
22
|
+
- Library styles are scoped under `.tspdf-root`; the global `*`/`body` resets moved to the demo.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
- `<TeamSyncViewer>` — an embeddable, container-sized React component with a small, typed prop
|
|
26
|
+
surface (`fileUrl`, `readOnly`, `currentUser`, `assets`, `withCredentials`, `toolbar`, `sidebars`,
|
|
27
|
+
`initialScale: 'fit-width' | 'fit-page'`, `onReady`, `onDocumentLoaded`, `onDocumentLoadError(error, retry)`,
|
|
28
|
+
`onFirstPageRendered`, `onPasswordRequired`, `onPageChange`, `onAnnotationsChange`).
|
|
29
|
+
- `createWebViewer(options, element)` (the old `WebViewer()` remains as a deprecated alias) returning a
|
|
30
|
+
`WebViewerInstance` with `destroy()`, `loadDocument(url)`, typed `on()/off()` events
|
|
31
|
+
(`documentLoaded`, `documentLoadError`, `firstPageRendered`, `pageChanged`, `annotationsChanged`,
|
|
32
|
+
`toolChanged`, `destroy`), `getFileData()`, `getAnnotations()` and the legacy `UI`/`Core` facades.
|
|
33
|
+
- Per-instance event bus: several viewers can be mounted on one page without cross-talk; keyboard
|
|
34
|
+
shortcuts apply to the focused viewer only.
|
|
35
|
+
- `configurePdfAssets()` for worker / CMap / standard-font / wasm locations.
|
|
36
|
+
- Real TypeScript declarations (`dist/index.d.ts`), `teamsync-pdf-viewer/style.css`, `"use client"`
|
|
37
|
+
banner for React Server Components bundlers, `sideEffects` metadata, source maps.
|
|
38
|
+
- CI workflow (lint, typecheck, unit tests, library + demo builds, `publint` + `arethetypeswrong`
|
|
39
|
+
package guards) and a first vitest suite.
|
|
40
|
+
|
|
41
|
+
### Fixed
|
|
42
|
+
- `package.json` `types` condition ordering and the non-existent `dist/style.css` export.
|
|
43
|
+
- Export (`getFileData`) no longer issues a `HEAD` probe nor re-downloads the document; it uses the
|
|
44
|
+
bytes of the already-loaded document, so presigned/expiring URLs work.
|
|
45
|
+
- Pages with an intrinsic `/Rotate` render correctly; UI rotation now composes on top of it
|
|
46
|
+
(search highlights and redactions were previously misplaced on such pages).
|
|
47
|
+
- Hard-coded signer email removed from digital-signature placeholders (uses `currentUser.name`).
|
|
48
|
+
- Watermark text no longer defaults to `user@example.com - Confidential` in embedded usage.
|
|
49
|
+
- Loading errors (including password-protected documents) are surfaced instead of being logged only.
|
|
50
|
+
- Truncated `LICENSE` replaced with the full CPAL-1.0 text; stale docs and package name fixed.
|
|
51
|
+
|
|
52
|
+
## [1.0.4] — 2026-08-15
|
|
53
|
+
- Historical release (never published to npm; 1.0.3 is the last 1.0.x on the registry).
|
package/LICENSE
CHANGED
|
@@ -73,5 +73,100 @@ You must cause all Covered Code to which You contribute to contain a file docume
|
|
|
73
73
|
|
|
74
74
|
3.4 Intellectual Property Matters
|
|
75
75
|
|
|
76
|
-
(a) Third Party Claims. If Contributor has knowledge that a license under a third party’s intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled “LEGAL” which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the
|
|
76
|
+
(a) Third Party Claims. If Contributor has knowledge that a license under a third party’s intellectual property rights is required to exercise the rights granted by such Contributor under Sections 2.1 or 2.2, Contributor must include a text file with the Source Code distribution titled “LEGAL” which describes the claim and the party making the claim in sufficient detail that a recipient will know whom to contact. If Contributor obtains such knowledge after the Modification is made available as described in Section 3.2, Contributor shall promptly modify the LEGAL file in all copies Contributor makes available thereafter and shall take other steps (such as notifying appropriate mailing lists or newsgroups) reasonably calculated to inform those who received the Covered Code that new knowledge has been obtained.
|
|
77
77
|
|
|
78
|
+
(b) Contributor APIs. If Contributor’s Modifications include an application programming interface and Contributor has knowledge of patent licenses which are reasonably necessary to implement that API, Contributor must also include this information in the LEGAL file.
|
|
79
|
+
|
|
80
|
+
(c) Representations. Contributor represents that, except as disclosed pursuant to Section 3.4(a) above, Contributor believes that Contributor’s Modifications are Contributor’s original creation(s) and/or Contributor has sufficient rights to grant the rights conveyed by this License.
|
|
81
|
+
|
|
82
|
+
3.5 Required Notices.
|
|
83
|
+
You must duplicate the notice in Exhibit A in each file of the Source Code. If it is not possible to put such notice in a particular Source Code file due to its structure, then You must include such notice in a location (such as a relevant directory) where a user would be likely to look for such a notice. If You created one or more Modification(s) You may add your name as a Contributor to the notice described in Exhibit A. You must also duplicate this License in any documentation for the Source Code where You describe recipients’ rights or ownership rights relating to Covered Code. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Code. However, You may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear than any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer.
|
|
84
|
+
|
|
85
|
+
3.6 Distribution of Executable Versions.
|
|
86
|
+
You may distribute Covered Code in Executable form only if the requirements of Section 3.1-3.5 have been met for that Covered Code, and if You include a notice stating that the Source Code version of the Covered Code is available under the terms of this License, including a description of how and where You have fulfilled the obligations of Section 3.2. The notice must be conspicuously included in any notice in an Executable version, related documentation or collateral in which You describe recipients’ rights relating to the Covered Code. You may distribute the Executable version of Covered Code or ownership rights under a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable version does not attempt to limit or alter the recipient’s rights in the Source Code version from the rights set forth in this License. If You distribute the Executable version under a different license You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer, Original Developer or any Contributor. You hereby agree to indemnify the Initial Developer, Original Developer and every Contributor for any liability incurred by the Initial Developer, Original Developer or such Contributor as a result of any such terms You offer.
|
|
87
|
+
|
|
88
|
+
3.7 Larger Works.
|
|
89
|
+
You may create a Larger Work by combining Covered Code with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Code.
|
|
90
|
+
|
|
91
|
+
4. Inability to Comply Due to Statute or Regulation.
|
|
92
|
+
If it is impossible for You to comply with any of the terms of this License with respect to some or all of the Covered Code due to statute, judicial order, or regulation then You must: (a) comply with the terms of this License to the maximum extent possible; and (b) describe the limitations and the code they affect. Such description must be included in the LEGAL file described in Section 3.4 and must be included with all distributions of the Source Code. Except to the extent prohibited by statute or regulation, such description must be sufficiently detailed for a recipient of ordinary skill to be able to understand it.
|
|
93
|
+
|
|
94
|
+
5. Application of this License.
|
|
95
|
+
This License applies to code to which the Initial Developer has attached the notice in Exhibit A and to related Covered Code.
|
|
96
|
+
|
|
97
|
+
6. Versions of the License.
|
|
98
|
+
|
|
99
|
+
6.1 New Versions.
|
|
100
|
+
Socialtext, Inc. (“Socialtext”) may publish revised and/or new versions of the License from time to time. Each version will be given a distinguishing version number.
|
|
101
|
+
|
|
102
|
+
6.2 Effect of New Versions.
|
|
103
|
+
Once Covered Code has been published under a particular version of the License, You may always continue to use it under the terms of that version. You may also choose to use such Covered Code under the terms of any subsequent version of the License published by Socialtext. No one other than Socialtext has the right to modify the terms applicable to Covered Code created under this License.
|
|
104
|
+
|
|
105
|
+
6.3 Derivative Works.
|
|
106
|
+
If You create or use a modified version of this License (which you may only do in order to apply it to code which is not already Covered Code governed by this License), You must (a) rename Your license so that the phrases “Socialtext”, “CPAL” or any confusingly similar phrase do not appear in your license (except to note that your license differs from this License) and (b) otherwise make it clear that Your version of the license contains terms which differ from the CPAL. (Filling in the name of the Initial Developer, Original Developer, Original Code or Contributor in the notice described in Exhibit A shall not of themselves be deemed to be modifications of this License.)
|
|
107
|
+
|
|
108
|
+
7. DISCLAIMER OF WARRANTY.
|
|
109
|
+
COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER, ORIGINAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
|
|
110
|
+
|
|
111
|
+
8. TERMINATION.
|
|
112
|
+
|
|
113
|
+
8.1 This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. All sublicenses to the Covered Code which are properly granted shall survive any termination of this License. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive.
|
|
114
|
+
|
|
115
|
+
8.2 If You initiate litigation by asserting a patent infringement claim (excluding declatory judgment actions) against Initial Developer, Original Developer or a Contributor (the Initial Developer, Original Developer or Contributor against whom You file such action is referred to as “Participant”) alleging that:
|
|
116
|
+
|
|
117
|
+
(a) such Participant’s Contributor Version directly or indirectly infringes any patent, then any and all rights granted by such Participant to You under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively, unless if within 60 days after receipt of notice You either: (i) agree in writing to pay Participant a mutually agreeable reasonable royalty for Your past and future use of Modifications made by such Participant, or (ii) withdraw Your litigation claim with respect to the Contributor Version against such Participant. If within 60 days of notice, a reasonable royalty and payment arrangement are not mutually agreed upon in writing by the parties or the litigation claim is not withdrawn, the rights granted by Participant to You under Sections 2.1 and/or 2.2 automatically terminate at the expiration of the 60 day notice period specified above.
|
|
118
|
+
|
|
119
|
+
(b) any software, hardware, or device, other than such Participant’s Contributor Version, directly or indirectly infringes any patent, then any rights granted to You by such Participant under Sections 2.1(b) and 2.2(b) are revoked effective as of the date You first made, used, sold, distributed, or had made, Modifications made by that Participant.
|
|
120
|
+
|
|
121
|
+
8.3 If You assert a patent infringement claim against Participant alleging that such Participant’s Contributor Version directly or indirectly infringes any patent where such claim is resolved (such as by license or settlement) prior to the initiation of patent infringement litigation, then the reasonable value of the licenses granted by such Participant under Sections 2.1 or 2.2 shall be taken into account in determining the amount or value of any payment or license.
|
|
122
|
+
|
|
123
|
+
8.4 In the event of termination under Sections 8.1 or 8.2 above, all end user license agreements (excluding distributors and resellers) which have been validly granted by You or any distributor hereunder prior to termination shall survive termination.
|
|
124
|
+
|
|
125
|
+
9. LIMITATION OF LIABILITY.
|
|
126
|
+
UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ORIGINAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
|
|
127
|
+
|
|
128
|
+
10. U.S. GOVERNMENT END USERS.
|
|
129
|
+
The Covered Code is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” and “commercial computer software documentation,” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Code with only those rights set forth herein.
|
|
130
|
+
|
|
131
|
+
11. MISCELLANEOUS.
|
|
132
|
+
This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by California law provisions (except to the extent applicable law, if any, provides otherwise), excluding its conflict-of-law provisions. With respect to disputes in which at least one party is a citizen of, or an entity chartered or registered to do business in the United States of America, any litigation relating to this License shall be subject to the jurisdiction of the Federal Courts of the Northern District of California, with venue lying in Santa Clara County, California, with the losing party responsible for costs, including without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License.
|
|
133
|
+
|
|
134
|
+
12. RESPONSIBILITY FOR CLAIMS.
|
|
135
|
+
As between Initial Developer, Original Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer, Original Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability.
|
|
136
|
+
|
|
137
|
+
13. MULTIPLE-LICENSED CODE.
|
|
138
|
+
Initial Developer may designate portions of the Covered Code as Multiple-Licensed. Multiple-Licensed means that the Initial Developer permits you to utilize portions of the Covered Code under Your choice of the CPAL or the alternative licenses, if any, specified by the Initial Developer in the file described in Exhibit A.
|
|
139
|
+
|
|
140
|
+
14. ADDITIONAL TERM: ATTRIBUTION
|
|
141
|
+
|
|
142
|
+
(a) As a modest attribution to the organizer of the development of the Original Code (“Original Developer”), in the hope that its promotional value may help justify the time, money and effort invested in writing the Original Code, the Original Developer may include in Exhibit B (“Attribution Information”) a requirement that each time an Executable and Source Code or a Larger Work is launched or initially run (which includes initiating a session), a prominent display of the Original Developer’s Attribution Information (as defined below) must occur on the graphic user interface employed by the end user to access such Covered Code (which may include display on a splash screen), if any. The size of the graphic image should be consistent with the size of the other elements of the Attribution Information. If the access by the end user to the Executable and Source Code does not create a graphic user interface for access to the Covered Code, this obligation shall not apply. If the Original Code displays such Attribution Information in a particular form (such as in the form of a splash screen, notice at login, an “about” display, or dedicated attribution area on user interface screens), continued use of such form for that Attribution Information is one way of meeting this requirement for notice.
|
|
143
|
+
|
|
144
|
+
(b) Attribution information may only include a copyright notice, a brief phrase, graphic image and a URL (“Attribution Information”) and is subject to the Attribution Limits as defined below. For these purposes, prominent shall mean display for sufficient duration to give reasonable notice to the user of the identity of the Original Developer and that if You include Attribution Information or similar information for other parties, You must ensure that the Attribution Information for the Original Developer shall be no less prominent than such Attribution Information or similar information for the other party. For greater certainty, the Original Developer may choose to specify in Exhibit B below that the above attribution requirement only applies to an Executable and Source Code resulting from the Original Code or any Modification, but not a Larger Work. The intent is to provide for reasonably modest attribution, therefore the Original Developer cannot require that You display, at any time, more than the following information as Attribution Information: (a) a copyright notice including the name of the Original Developer; (b) a word or one phrase (not exceeding 10 words); (c) one graphic image provided by the Original Developer; and (d) a URL (collectively, the “Attribution Limits”).
|
|
145
|
+
|
|
146
|
+
(c) If Exhibit B does not include any Attribution Information, then there are no requirements for You to display any Attribution Information of the Original Developer.
|
|
147
|
+
|
|
148
|
+
(d) You acknowledge that all trademarks, service marks and/or trade names contained within the Attribution Information distributed with the Covered Code are the exclusive property of their owners and may only be used with the permission of their owners, or under circumstances otherwise permitted by law or as expressly set out in this License.
|
|
149
|
+
|
|
150
|
+
15. ADDITIONAL TERM: NETWORK USE.
|
|
151
|
+
The term “External Deployment” means the use, distribution, or communication of the Original Code or Modifications in any way such that the Original Code or Modifications may be used by anyone other than You, whether those works are distributed or communicated to those persons or made available as an application intended for use over a network. As an express condition for the grants of license hereunder, You must treat any External Deployment by You of the Original Code or Modifications as a distribution under section 3.1 and make Source Code available under Section 3.2.
|
|
152
|
+
|
|
153
|
+
EXHIBIT A. Common Public Attribution License Version 1.0.
|
|
154
|
+
|
|
155
|
+
“The contents of this file are subject to the Common Public Attribution License Version 1.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://opensource.org/license/cpal-1-0. The License is based on the Mozilla Public License Version 1.1 but Sections 14 and 15 have been added to cover use of software over a computer network and provide for limited attribution for the Original Developer. In addition, Exhibit A has been modified to be consistent with Exhibit B.
|
|
156
|
+
Software distributed under the License is distributed on an “AS IS” basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License.
|
|
157
|
+
The Original Code is TeamSync PDF Viewer.
|
|
158
|
+
The Original Developer is not the Initial Developer and is __________. If left blank, the Original Developer is the Initial Developer. (Left blank: the Original Developer is the Initial Developer.)
|
|
159
|
+
The Initial Developer of the Original Code is AngelBot Ai Pvt Ltd. All portions of the code written by AngelBot Ai Pvt Ltd are Copyright (c) 2026 AngelBot Ai Pvt Ltd. All Rights Reserved.
|
|
160
|
+
Contributor: as recorded in the repository history at https://github.com/angelbot-ai/TeamSync-PDF-Viewer.
|
|
161
|
+
Alternatively, the contents of this file may be used under the terms of the _____ license (the [___] License), in which case the provisions of [______] License are applicable instead of those above.
|
|
162
|
+
If you wish to allow use of your version of this file only under the terms of the [____] License and not to allow others to use your version of this file under the CPAL, indicate your decision by deleting the provisions above and replace them with the notice and other provisions required by the [___] License. If you do not delete the provisions above, a recipient may use your version of this file under either the CPAL or the [___] License.”
|
|
163
|
+
|
|
164
|
+
[NOTE: The text of this Exhibit A may differ slightly from the text of the notices in the Source Code files of the Original Code. You should use the text of this Exhibit A rather than the text found in the Original Code Source Code for Your Modifications.]
|
|
165
|
+
|
|
166
|
+
EXHIBIT B. Attribution Information
|
|
167
|
+
|
|
168
|
+
Attribution Copyright Notice: Copyright (c) 2026 AngelBot Ai Pvt Ltd. All Rights Reserved.
|
|
169
|
+
Attribution Phrase (not exceeding 10 words): Powered by TeamSync PDF Viewer
|
|
170
|
+
Attribution URL: https://pdfviewer.teamsync.com/
|
|
171
|
+
Graphic Image as provided in the Covered Code, if any: the TeamSync logo included in the Covered Code (public/favicon.svg), if any.
|
|
172
|
+
Display of Attribution Information is required in Larger Works which are defined in the CPAL as a work which combines Covered Code or portions thereof with code not governed by the terms of the CPAL.
|
package/README.md
CHANGED
|
@@ -1,233 +1,234 @@
|
|
|
1
1
|
# TeamSync PDF Viewer SDK
|
|
2
2
|
|
|
3
|
+
Client-side PDF viewing, annotation, search, redaction and watermarking for React — built on
|
|
4
|
+
[pdf.js](https://mozilla.github.io/pdf.js/) and [pdf-lib](https://pdf-lib.js.org/).
|
|
5
|
+
|
|
3
6
|
<div align="center">
|
|
4
7
|
|
|
5
8
|

|
|
6
9
|
|
|
7
|
-
### **100% Open Source. 100% Client-Side. Enterprise PDF Engine.**
|
|
8
|
-
|
|
9
10
|
[](LICENSE)
|
|
10
11
|
[](https://pdfviewer.teamsync.com/)
|
|
11
|
-
[](https://www.typescriptlang.org/)
|
|
15
|
-
|
|
16
|
-
*No paywalls. No vendor lock-in. No server dependencies.*
|
|
17
|
-
Try the **[Interactive Live Demo](https://pdfviewer.teamsync.com/)** or integrate the high-performance PDF Viewer SDK into your React applications.
|
|
12
|
+
[](https://www.npmjs.com/package/teamsync-pdf-viewer)
|
|
13
|
+
[](https://react.dev/)
|
|
14
|
+
[](https://www.typescriptlang.org/)
|
|
18
15
|
|
|
19
16
|
</div>
|
|
20
17
|
|
|
21
18
|
---
|
|
22
19
|
|
|
23
|
-
##
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
|
|
20
|
+
## Features
|
|
21
|
+
|
|
22
|
+
- **Viewing** — continuous or page-by-page scrolling, single / double / cover-facing layouts,
|
|
23
|
+
thumbnails panel, zoom 10 % – 6400 % with fit-to-width / fit-to-page, pinch and wheel zoom,
|
|
24
|
+
rotation, pan tool, high-DPI canvas rendering, progressive loading of linearized PDFs (HTTP Range).
|
|
25
|
+
- **Text** — real selectable text layer, client-side search with highlighting and a results panel.
|
|
26
|
+
- **Annotations** — highlighter, freehand ink, shapes (rectangle, ellipse, line, arrow), text,
|
|
27
|
+
sticky notes, callouts, hyperlinks (page-jump or URL), signature images, undo/redo, keyboard shortcuts.
|
|
28
|
+
- **Redaction** — manual and regex/PII-driven redactions, burned in on export by rasterizing the
|
|
29
|
+
affected pages so the underlying content is destroyed; redacted text is also stripped from the
|
|
30
|
+
text layer and search index.
|
|
31
|
+
- **Watermarks** — single or tiled forensic watermarks, rendered live and baked on export.
|
|
32
|
+
- **Export** — download the annotated / redacted / watermarked document; no server round-trip.
|
|
33
|
+
- **Embeddable** — `<TeamSyncViewer>` sizes to its container, several viewers can share a page,
|
|
34
|
+
keyboard shortcuts apply to the focused viewer only, and importing the package is side-effect free
|
|
35
|
+
(safe under SSR).
|
|
36
|
+
|
|
37
|
+
Not yet supported: printing (planned for 1.2), AcroForm filling, rendering of annotations already
|
|
38
|
+
embedded in the PDF, document outline/bookmarks, password prompts (password-protected files raise
|
|
39
|
+
`onPasswordRequired`).
|
|
31
40
|
|
|
32
41
|
---
|
|
33
42
|
|
|
34
|
-
##
|
|
35
|
-
|
|
36
|
-
Install the package into your React / TypeScript project:
|
|
43
|
+
## Installation
|
|
37
44
|
|
|
38
45
|
```bash
|
|
39
|
-
|
|
40
|
-
npm install teamsync-pdf-viewer
|
|
41
|
-
|
|
42
|
-
# Using yarn
|
|
43
|
-
yarn add teamsync-pdf-viewer
|
|
44
|
-
|
|
45
|
-
# Using pnpm
|
|
46
|
-
pnpm add teamsync-pdf-viewer
|
|
46
|
+
npm install teamsync-pdf-viewer pdfjs-dist
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
If installing from GitHub Packages registry:
|
|
49
|
+
`react`, `react-dom` (18 or 19) and `pdfjs-dist` (6.x) are **peer dependencies**. `pdf-lib` and
|
|
50
|
+
`lucide-react` are installed automatically.
|
|
52
51
|
|
|
53
|
-
|
|
54
|
-
```ini
|
|
55
|
-
@angelbot-ai:registry=https://npm.pkg.github.com
|
|
56
|
-
```
|
|
57
|
-
2. Install via npm:
|
|
58
|
-
```bash
|
|
59
|
-
npm install teamsync-pdf-viewer
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
---
|
|
52
|
+
### Serve the pdf.js assets
|
|
63
53
|
|
|
64
|
-
|
|
54
|
+
The library never bundles the pdf.js worker (bundling it produced a 5 MB package with a `data:`
|
|
55
|
+
URL worker that strict Content-Security-Policies reject). Serve the worker — and, for full font /
|
|
56
|
+
CJK / JPEG 2000 support, the CMaps, standard fonts and wasm decoders — from your own origin and tell
|
|
57
|
+
the viewer where they are.
|
|
65
58
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- 🏠 **[Wiki Home](docs/wiki/Home.md)**: Main documentation index & overview.
|
|
69
|
-
- 🚀 **[Getting Started Guide](docs/wiki/Getting-Started.md)**: Installation, CDN, and framework setups.
|
|
70
|
-
- ⚙️ **[API Reference & Options](docs/wiki/API-Reference-&-Options.md)**: Complete parameter list for `WebViewerOptions` & `SDKPermissions`.
|
|
71
|
-
- 🎨 **[Annotations & Markup Guide](docs/wiki/Annotations-&-Markup-Guide.md)**: Freehand drawing, vector shapes, callouts & links.
|
|
72
|
-
- 🛡️ **[Redactions & PII Sanitization Guide](docs/wiki/Redactions-&-PII-Sanitization.md)**: Binary redactions, regex PII scanning & discard options.
|
|
73
|
-
- 💧 **[Forensic Watermarking Guide](docs/wiki/Forensic-Watermarking.md)**: Dynamic single and tiled watermark setup.
|
|
74
|
-
- 🔌 **[Plugin Architecture Guide](docs/wiki/Plugin-Architecture.md)**: Writing custom extension plugins.
|
|
75
|
-
|
|
76
|
-
---
|
|
59
|
+
**Vite / Rollup**
|
|
77
60
|
|
|
78
|
-
|
|
61
|
+
```ts
|
|
62
|
+
import workerSrc from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
|
|
63
|
+
import { configurePdfAssets } from 'teamsync-pdf-viewer';
|
|
79
64
|
|
|
80
|
-
|
|
65
|
+
configurePdfAssets({ workerSrc });
|
|
66
|
+
```
|
|
81
67
|
|
|
82
|
-
|
|
83
|
-
- **Full Drawing Toolkit**: Freehand ink (`brush`), highlighters, geometric shapes (rectangles, ellipses), arrows, and lines.
|
|
84
|
-
- **Notes & Callouts**: Sticky notes, callout text boxes with directional arrows, and text annotations.
|
|
85
|
-
- **Interactive Hyperlinks**: Create internal page-jump links (`#page=N`) or external web URL links directly on document selections.
|
|
68
|
+
**Next.js (or any static host)** — copy the files at build time and reference them by URL:
|
|
86
69
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
70
|
+
```bash
|
|
71
|
+
# e.g. in a prebuild script
|
|
72
|
+
cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdfjs/
|
|
73
|
+
cp -r node_modules/pdfjs-dist/cmaps node_modules/pdfjs-dist/standard_fonts node_modules/pdfjs-dist/wasm public/pdfjs/
|
|
74
|
+
```
|
|
92
75
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
76
|
+
```ts
|
|
77
|
+
configurePdfAssets({
|
|
78
|
+
workerSrc: '/pdfjs/pdf.worker.min.mjs',
|
|
79
|
+
cMapUrl: '/pdfjs/cmaps/',
|
|
80
|
+
standardFontDataUrl: '/pdfjs/standard_fonts/',
|
|
81
|
+
wasmUrl: '/pdfjs/wasm/',
|
|
82
|
+
});
|
|
83
|
+
```
|
|
96
84
|
|
|
97
|
-
|
|
98
|
-
|
|
85
|
+
The worker **must** come from the same `pdfjs-dist` version the viewer runs against
|
|
86
|
+
(`import { pdfjsVersion } from 'teamsync-pdf-viewer'` tells you which one is loaded).
|
|
99
87
|
|
|
100
88
|
---
|
|
101
89
|
|
|
102
|
-
##
|
|
103
|
-
|
|
104
|
-
### Standard WebViewer Initialization
|
|
105
|
-
|
|
106
|
-
Drop the SDK into any container element with a single function call:
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
import { WebViewer } from 'teamsync-pdf-viewer';
|
|
110
|
-
import 'teamsync-pdf-viewer/style.css';
|
|
111
|
-
|
|
112
|
-
WebViewer({
|
|
113
|
-
initialDoc: '/sample.pdf',
|
|
114
|
-
initialScale: 1.0, // 100% natural size
|
|
115
|
-
enableAnnotations: true,
|
|
116
|
-
permissions: {
|
|
117
|
-
canRedact: true,
|
|
118
|
-
canAddAnnotations: true
|
|
119
|
-
},
|
|
120
|
-
watermark: {
|
|
121
|
-
text: 'CONFIDENTIAL',
|
|
122
|
-
mode: 'single',
|
|
123
|
-
size: 48,
|
|
124
|
-
opacity: 0.1,
|
|
125
|
-
color: '#dc2626'
|
|
126
|
-
}
|
|
127
|
-
}, document.getElementById('viewer-container')).then((instance) => {
|
|
128
|
-
console.log('TeamSync PDF Viewer is ready!', instance);
|
|
129
|
-
|
|
130
|
-
// Export annotated PDF buffer
|
|
131
|
-
instance.Core.documentViewer.getDocument().getFileData().then((pdfBytes) => {
|
|
132
|
-
console.log('Exported PDF byte length:', pdfBytes.length);
|
|
133
|
-
});
|
|
134
|
-
});
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
### Native React Component Usage
|
|
90
|
+
## Usage
|
|
138
91
|
|
|
139
|
-
|
|
92
|
+
### React component
|
|
140
93
|
|
|
141
94
|
```tsx
|
|
142
|
-
|
|
95
|
+
'use client'; // Next.js App Router: the viewer is client-only
|
|
96
|
+
|
|
97
|
+
import { TeamSyncViewer, type WebViewerInstance } from 'teamsync-pdf-viewer';
|
|
143
98
|
import 'teamsync-pdf-viewer/style.css';
|
|
144
99
|
|
|
145
|
-
function
|
|
100
|
+
export function ContractViewer({ url }: { url: string }) {
|
|
146
101
|
return (
|
|
147
|
-
<div style={{
|
|
148
|
-
<
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
102
|
+
<div style={{ height: '80vh' }}>
|
|
103
|
+
<TeamSyncViewer
|
|
104
|
+
fileUrl={url}
|
|
105
|
+
fileName="contract.pdf"
|
|
106
|
+
assets={{ workerSrc: '/pdfjs/pdf.worker.min.mjs', cMapUrl: '/pdfjs/cmaps/' }}
|
|
107
|
+
currentUser={{ id: 'u-42', name: 'Jane Doe' }}
|
|
108
|
+
initialScale="fit-width"
|
|
109
|
+
watermark={{ text: 'CONFIDENTIAL', mode: 'tiled', opacity: 0.08 }}
|
|
110
|
+
onReady={(instance: WebViewerInstance) => console.log('ready', instance)}
|
|
111
|
+
onDocumentLoadError={(error, retry) => {
|
|
112
|
+
// e.g. mint a fresh presigned URL and retry
|
|
113
|
+
retry(/* newUrl */);
|
|
114
|
+
}}
|
|
153
115
|
/>
|
|
154
116
|
</div>
|
|
155
117
|
);
|
|
156
118
|
}
|
|
157
119
|
```
|
|
158
120
|
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
## 🛠️ Local Development Quick Start
|
|
121
|
+
In Next.js, load it with `next/dynamic(() => import('./ContractViewer'), { ssr: false })` or keep
|
|
122
|
+
it inside a client component — the package itself never touches `window` at import time.
|
|
162
123
|
|
|
163
|
-
###
|
|
124
|
+
### Imperative API
|
|
164
125
|
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
npm install
|
|
169
|
-
```
|
|
126
|
+
```ts
|
|
127
|
+
import { createWebViewer } from 'teamsync-pdf-viewer';
|
|
128
|
+
import 'teamsync-pdf-viewer/style.css';
|
|
170
129
|
|
|
171
|
-
|
|
130
|
+
const instance = await createWebViewer(
|
|
131
|
+
{ initialDoc: '/sample.pdf', fileName: 'sample.pdf', permissions: { canRedact: true } },
|
|
132
|
+
document.getElementById('viewer-container')!
|
|
133
|
+
);
|
|
172
134
|
|
|
173
|
-
|
|
174
|
-
|
|
135
|
+
instance.on('documentLoaded', ({ numPages }) => console.log(numPages, 'pages'));
|
|
136
|
+
const pdfBytes = await instance.getFileData(); // annotated / redacted / watermarked Uint8Array
|
|
137
|
+
instance.destroy(); // unmounts and releases every listener
|
|
175
138
|
```
|
|
176
139
|
|
|
177
|
-
|
|
140
|
+
`WebViewer()` remains available as a deprecated alias of `createWebViewer()`.
|
|
178
141
|
|
|
179
142
|
---
|
|
180
143
|
|
|
181
|
-
##
|
|
144
|
+
## API overview
|
|
145
|
+
|
|
146
|
+
### `<TeamSyncViewer>` props / `WebViewerOptions`
|
|
147
|
+
|
|
148
|
+
| Prop | Type | Default | Description |
|
|
149
|
+
| :--- | :--- | :--- | :--- |
|
|
150
|
+
| `fileUrl` (`initialDoc`) | `string` | — | URL of the PDF. Fetched by pdf.js (CORS + Range supported). |
|
|
151
|
+
| `fileName` | `string` | `annotated_document.pdf` | Name used for downloads. |
|
|
152
|
+
| `assets` | `PdfAssetPaths` | — | Worker / CMap / font / wasm locations (or call `configurePdfAssets`). |
|
|
153
|
+
| `withCredentials` | `boolean` | `false` | Send cookies with the document request. |
|
|
154
|
+
| `initialScale` | `number \| 'fit-width' \| 'fit-page'` | `1` | Initial zoom. |
|
|
155
|
+
| `initialPage` | `number` | `1` | 1-based page to open. |
|
|
156
|
+
| `readOnly` | `boolean` | `false` | Disables all annotation / redaction editing. |
|
|
157
|
+
| `permissions` | `SDKPermissions` | all `true` | `canAddAnnotations`, `canEditAnnotations`, `canDeleteAnnotations`, `canRedact`. |
|
|
158
|
+
| `currentUser` | `{ id, name }` | — | Author of annotations created in this viewer. |
|
|
159
|
+
| `watermark` | `WatermarkOptions` | — | `{ text, mode: 'single' \| 'tiled', size, opacity, color }`. |
|
|
160
|
+
| `redactions`, `regexRedactions` | `Redaction[]`, `RegExp[]` | `[]` | Pre-set and pattern-driven redactions. |
|
|
161
|
+
| `toolbar`, `sidebars`, `leftPanelOpen` | `boolean` | `true` | Chrome toggles. |
|
|
162
|
+
| `autoFocus` | `boolean` | `false` | Focus the viewer on mount (keyboard shortcuts). |
|
|
163
|
+
| `plugins` | `ViewerPlugin[]` | `[]` | Extension plugins. |
|
|
164
|
+
|
|
165
|
+
Callbacks: `onReady(instance)`, `onDocumentLoaded({ url, numPages })`,
|
|
166
|
+
`onDocumentLoadError(error, retry(newUrl?), { url, passwordRequired })`, `onFirstPageRendered`,
|
|
167
|
+
`onPasswordRequired`, `onPageChange(page, numPages)`, `onAnnotationsChange(annotations)`.
|
|
168
|
+
|
|
169
|
+
### `WebViewerInstance`
|
|
170
|
+
|
|
171
|
+
- `on(type, listener)` / `off` — typed events: `documentLoaded`, `documentLoadError`,
|
|
172
|
+
`firstPageRendered`, `pageChanged`, `annotationsChanged`, `toolChanged`, `destroy`.
|
|
173
|
+
- `loadDocument(url)` — load or reload (resolves on load, rejects on error).
|
|
174
|
+
- `getFileData({ explicitAnnotations? })` — export the document as `Uint8Array`.
|
|
175
|
+
- `getAnnotations()`, `getCurrentPage()`, `getPageCount()`, `getPdfDocument()`.
|
|
176
|
+
- `destroy()` — unmount (imperative API) and release every listener.
|
|
177
|
+
- `UI.*` / `Core.*` — legacy facades (`UI.openElements`, `UI.fitWidth`,
|
|
178
|
+
`Core.annotationManager.exportAnnotations()`, `Core.documentViewer.getDocument().getFileData()`).
|
|
179
|
+
|
|
180
|
+
Full reference: [docs/wiki/API-Reference-&-Options.md](docs/wiki/API-Reference-&-Options.md).
|
|
182
181
|
|
|
183
|
-
|
|
182
|
+
---
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
┌───────────────────────────▼─────────────────────────────┐
|
|
192
|
-
│ Custom Extension │
|
|
193
|
-
│ (Custom Modals, Action Buttons, Export Hooks) │
|
|
194
|
-
└─────────────────────────────────────────────────────────┘
|
|
195
|
-
```
|
|
184
|
+
## Documentation
|
|
185
|
+
|
|
186
|
+
- [Getting Started](docs/wiki/Getting-Started.md) · [API Reference & Options](docs/wiki/API-Reference-&-Options.md)
|
|
187
|
+
- [Annotations & Markup](docs/wiki/Annotations-&-Markup-Guide.md) · [Redactions & PII Sanitization](docs/wiki/Redactions-&-PII-Sanitization.md)
|
|
188
|
+
- [Forensic Watermarking](docs/wiki/Forensic-Watermarking.md) · [Plugin Architecture](docs/wiki/Plugin-Architecture.md)
|
|
189
|
+
- [Changelog](CHANGELOG.md)
|
|
196
190
|
|
|
197
191
|
---
|
|
198
192
|
|
|
199
|
-
##
|
|
193
|
+
## Development
|
|
200
194
|
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
195
|
+
```bash
|
|
196
|
+
git clone https://github.com/angelbot-ai/TeamSync-PDF-Viewer.git
|
|
197
|
+
cd TeamSync-PDF-Viewer
|
|
198
|
+
npm install
|
|
199
|
+
npm run dev # demo application at http://localhost:5173
|
|
200
|
+
npm test # unit tests (vitest)
|
|
201
|
+
npm run build # library -> dist/
|
|
202
|
+
npm run verify:package # publint + arethetypeswrong + artifact guards
|
|
203
|
+
npm run build:app # demo / iframe package build (Vercel)
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
Layout:
|
|
204
207
|
|
|
205
208
|
```
|
|
206
|
-
|
|
207
|
-
├──
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
│ └── App.tsx # Demo Application Shell
|
|
215
|
-
├── public/ # Static PDF assets & PDF.js workers
|
|
216
|
-
└── docs/images/ # High-res UI documentation screenshots
|
|
209
|
+
src/
|
|
210
|
+
├── index.ts # public entry (side-effect free)
|
|
211
|
+
├── core/ # createWebViewer, WebViewerInstance, event bus, pdf.js assets, export
|
|
212
|
+
├── components/ # TeamSyncViewer + internal UI (DocumentViewer, Header, sidebars, modals)
|
|
213
|
+
├── annotations/ # annotation data model
|
|
214
|
+
├── hooks/, utils/ # search, shortcuts, rotation helpers, regex redaction
|
|
215
|
+
├── plugins/ # plugin interfaces
|
|
216
|
+
└── demo/ # demo & iframe-package bootstrap (not published)
|
|
217
217
|
```
|
|
218
218
|
|
|
219
|
+
### Iframe package (script-tag hosts)
|
|
220
|
+
|
|
221
|
+
`npm run build:app` produces a self-contained viewer; `public/webviewer.js` wraps it in an iframe
|
|
222
|
+
with a `postMessage` bridge and exposes a `WebViewer(options, element)` function for non-React hosts.
|
|
223
|
+
|
|
219
224
|
---
|
|
220
225
|
|
|
221
|
-
##
|
|
226
|
+
## TypeScript notes
|
|
222
227
|
|
|
223
|
-
|
|
224
|
-
|
|
228
|
+
Declarations ship in `dist/src/`. They resolve under `moduleResolution: "bundler"` (Next.js, Vite,
|
|
229
|
+
webpack) and `node10`; `node16`/`nodenext` resolution is not supported yet because the emitted
|
|
230
|
+
declarations use extension-less relative imports.
|
|
225
231
|
|
|
226
|
-
|
|
227
|
-
<div align="center">
|
|
228
|
-
<b>AngelBot AI • TeamSync • </b> <a href="https://www.teamsync.com" target="_blank" rel="noopener noreferrer">https://www.teamsync.com</a>
|
|
229
|
-
</div>
|
|
232
|
+
## License
|
|
230
233
|
|
|
231
|
-
|
|
232
|
-
<b>TeamSync PDF Viewer Engine</b> • Engineered with ❤️ for the Open Web.
|
|
233
|
-
</div>
|
|
234
|
+
[CPAL-1.0](LICENSE) — Copyright © 2026 AngelBot Ai Pvt Ltd.
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
* Annotation data model.
|
|
4
|
+
*
|
|
5
|
+
* Coordinates are in "base page space": the pdf.js viewport at scale 1 with the page's intrinsic
|
|
6
|
+
* /Rotate applied (top-left origin, PDF points). UI rotation applied by the viewer is composed on
|
|
7
|
+
* top of this space at render time, so stored annotations are independent of the current view.
|
|
8
|
+
*/
|
|
9
|
+
export type AnnotationType = 'rectangle' | 'ellipse' | 'line' | 'arrow' | 'freehand' | 'text' | 'note' | 'callout' | 'signature' | 'highlight' | 'digital_signature_placeholder' | 'link';
|
|
10
|
+
export interface AnnotationPoint {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
}
|
|
14
|
+
export interface Annotation {
|
|
15
|
+
id: string;
|
|
16
|
+
/** 1-based page number */
|
|
17
|
+
pageIndex: number;
|
|
18
|
+
type: AnnotationType;
|
|
19
|
+
x: number;
|
|
20
|
+
y: number;
|
|
21
|
+
width: number;
|
|
22
|
+
height: number;
|
|
23
|
+
text?: string;
|
|
24
|
+
points?: AnnotationPoint[];
|
|
25
|
+
rects?: {
|
|
26
|
+
x: number;
|
|
27
|
+
y: number;
|
|
28
|
+
width: number;
|
|
29
|
+
height: number;
|
|
30
|
+
}[];
|
|
31
|
+
color: string;
|
|
32
|
+
strokeWidth: number;
|
|
33
|
+
opacity: number;
|
|
34
|
+
imageUrl?: string;
|
|
35
|
+
timestamp?: number;
|
|
36
|
+
signer?: string;
|
|
37
|
+
signType?: 'advanced' | 'simple';
|
|
38
|
+
linkUrl?: string;
|
|
39
|
+
/** Display name of the author (set from `currentUser` when created in-viewer). */
|
|
40
|
+
author?: string;
|
|
41
|
+
/** Stable author identifier (opaque to the viewer). */
|
|
42
|
+
authorId?: string;
|
|
43
|
+
/** When true the annotation cannot be moved, edited or deleted in the UI. */
|
|
44
|
+
readOnly?: boolean;
|
|
45
|
+
}
|