teamsync-pdf-viewer 1.0.3 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/CHANGELOG.md +82 -0
  2. package/LICENSE +96 -1
  3. package/README.md +186 -165
  4. package/dist/src/annotations/AnnotationManager.d.ts +90 -0
  5. package/dist/src/annotations/geometry.d.ts +51 -0
  6. package/dist/src/annotations/ids.d.ts +6 -0
  7. package/dist/src/annotations/types.d.ts +72 -0
  8. package/dist/src/annotations/xfdf.d.ts +18 -0
  9. package/dist/src/components/AboutModal.d.ts +6 -0
  10. package/dist/src/components/AnnotationContextMenu.d.ts +17 -0
  11. package/dist/src/components/DocumentViewer.d.ts +50 -0
  12. package/dist/src/components/Header.d.ts +36 -0
  13. package/dist/src/components/InsertLinkModal.d.ts +10 -0
  14. package/dist/src/components/LeftSidebar.d.ts +10 -0
  15. package/dist/src/components/PageContextMenu.d.ts +20 -0
  16. package/dist/src/components/PageRenderer.d.ts +40 -0
  17. package/dist/src/components/SettingsModal.d.ts +8 -0
  18. package/dist/src/components/Sidebar.d.ts +18 -0
  19. package/dist/src/components/TeamSyncViewer.d.ts +35 -0
  20. package/dist/src/components/TextSelectionMenu.d.ts +18 -0
  21. package/dist/src/core/ViewerInstance.d.ts +94 -0
  22. package/dist/src/core/busContext.d.ts +3 -0
  23. package/dist/src/core/createWebViewer.d.ts +5 -0
  24. package/dist/src/core/eventBus.d.ts +25 -0
  25. package/dist/src/core/export.d.ts +23 -0
  26. package/dist/src/core/pdfAssets.d.ts +27 -0
  27. package/dist/src/core/print.d.ts +12 -0
  28. package/dist/src/core/types.d.ts +108 -0
  29. package/dist/src/hooks/usePdfSearch.d.ts +23 -0
  30. package/dist/src/hooks/useShortcuts.d.ts +13 -0
  31. package/dist/src/hooks/useViewerBus.d.ts +7 -0
  32. package/dist/src/index.d.ts +29 -0
  33. package/dist/src/plugins/index.d.ts +1 -0
  34. package/dist/src/plugins/types.d.ts +26 -0
  35. package/dist/src/utils/findRegexRedactions.d.ts +6 -0
  36. package/dist/src/utils/rotationUtils.d.ts +32 -0
  37. package/dist/style.css +2 -0
  38. package/dist/teamsync-pdf-viewer.js +6177 -0
  39. package/dist/teamsync-pdf-viewer.js.map +1 -0
  40. package/package.json +48 -15
  41. package/dist/TeamSync.pdf +0 -0
  42. package/dist/ThirdPartyNotices.txt +0 -639
  43. package/dist/favicon.svg +0 -16
  44. package/dist/icons.svg +0 -24
  45. package/dist/index.d.ts +0 -1
  46. package/dist/teamsync-pdf-viewer.css +0 -2
  47. package/dist/teamsync-pdf-viewer.es.js +0 -51524
  48. package/dist/teamsync-pdf-viewer.umd.cjs +0 -327
  49. package/dist/webviewer.js +0 -92
package/CHANGELOG.md ADDED
@@ -0,0 +1,82 @@
1
+ # Changelog
2
+
3
+ All notable changes to `teamsync-pdf-viewer` are documented here.
4
+
5
+ ## [1.2.0] — 2026-08-31
6
+
7
+ ### Added
8
+ - **`AnnotationManager`** (`instance.annotationManager`, also `instance.Core.annotationManager`):
9
+ the canonical annotation list with undo/redo, granular `annotationChanged` events
10
+ (`add` | `modify` | `delete`, with an `imported` flag), authorship stamping
11
+ (`currentUser`), edit permissions (read-only viewer, read-only annotation, other authors —
12
+ `permissions.canEditOthers`) and programmatic `addAnnotations` / `updateAnnotation` /
13
+ `deleteAnnotations` / `getAnnotationById`.
14
+ - **Native XFDF**: `annotationManager.importAnnotations(xfdf)` and
15
+ `exportAnnotations({ annotList?, useDisplayAuthor? })` (bare fragments per annotation, or a full
16
+ document). Reads Acrobat/Apryse XFDF (square, circle, line/arrow, ink, highlight quads, freetext,
17
+ callout, sticky note, stamp with image data, link) and keeps everything else as read-only
18
+ `opaque` annotations that re-export verbatim; unknown attributes/children (e.g. Apryse
19
+ `trn-custom-data`) are preserved across a round-trip. Stable UUID ids double as the XFDF `name`.
20
+ - **Page geometry module** (`createPageGeometry`, `rectToPdf`, `quadPointsToRects`, …): the single
21
+ authority for base-page-space ↔ PDF-user-space conversion, mirroring pdf.js's viewport transform.
22
+ - **Print** (menu item enabled, `instance.print()`): the exported document is printed through the
23
+ browser's PDF viewer in a hidden frame.
24
+ - `instance.on('annotationChanged', …)` typed event; `Annotation.author/authorId/createdAt/
25
+ modifiedAt/readOnly/strokes/rects` fields; multi-stroke ink and multi-rect highlights render.
26
+
27
+ ### Fixed
28
+ - Export geometry: annotations are baked exactly where they were drawn (any page size, CropBox
29
+ offset or intrinsic /Rotate) — replaces the hard-coded `scale = 1.5` conversion.
30
+ - Mixed page sizes: layout, scrolling, hit-testing and fit-to-width/page now use per-page
31
+ dimensions instead of page 1's.
32
+ - Annotation ids were timestamps (collision-prone); now `crypto.randomUUID()`.
33
+
34
+ ## [1.1.0] — 2026-08-31
35
+
36
+ ### Breaking
37
+ - The npm entry point is now **side-effect free**: importing the package no longer touches `window`,
38
+ never auto-mounts a demo viewer into `#root`, and no longer installs the iframe `postMessage` bridge.
39
+ Those behaviours live in the demo/iframe application build only (`src/demo/main.tsx`,
40
+ `npm run build:app`, `public/webviewer.js`).
41
+ - `react`, `react-dom` and `pdfjs-dist` are **peer dependencies** (previously `react` was a hard
42
+ dependency, which could install a second React copy).
43
+ - The pdf.js **worker is no longer inlined** as a `data:` URL. Hosts must serve
44
+ `pdf.worker.min.mjs` (matching their installed `pdfjs-dist`) and call `configurePdfAssets({ workerSrc })`
45
+ or pass `assets={{ workerSrc }}` to `<TeamSyncViewer>`. This shrinks the bundle from 5.3 MB to
46
+ well under 1 MB and works under strict Content-Security-Policies.
47
+ - The UMD build was removed (`pdfjs-dist` v6 is ESM-only, so it never worked for real consumers).
48
+ Script-tag users are served by the iframe package.
49
+ - `DocumentViewer`, `Header`, `Sidebar` and `PageRenderer` are no longer exported — they are
50
+ internal components with unstable props. Use `<TeamSyncViewer>` / `createWebViewer()`.
51
+ - Library styles are scoped under `.tspdf-root`; the global `*`/`body` resets moved to the demo.
52
+
53
+ ### Added
54
+ - `<TeamSyncViewer>` — an embeddable, container-sized React component with a small, typed prop
55
+ surface (`fileUrl`, `readOnly`, `currentUser`, `assets`, `withCredentials`, `toolbar`, `sidebars`,
56
+ `initialScale: 'fit-width' | 'fit-page'`, `onReady`, `onDocumentLoaded`, `onDocumentLoadError(error, retry)`,
57
+ `onFirstPageRendered`, `onPasswordRequired`, `onPageChange`, `onAnnotationsChange`).
58
+ - `createWebViewer(options, element)` (the old `WebViewer()` remains as a deprecated alias) returning a
59
+ `WebViewerInstance` with `destroy()`, `loadDocument(url)`, typed `on()/off()` events
60
+ (`documentLoaded`, `documentLoadError`, `firstPageRendered`, `pageChanged`, `annotationsChanged`,
61
+ `toolChanged`, `destroy`), `getFileData()`, `getAnnotations()` and the legacy `UI`/`Core` facades.
62
+ - Per-instance event bus: several viewers can be mounted on one page without cross-talk; keyboard
63
+ shortcuts apply to the focused viewer only.
64
+ - `configurePdfAssets()` for worker / CMap / standard-font / wasm locations.
65
+ - Real TypeScript declarations (`dist/index.d.ts`), `teamsync-pdf-viewer/style.css`, `"use client"`
66
+ banner for React Server Components bundlers, `sideEffects` metadata, source maps.
67
+ - CI workflow (lint, typecheck, unit tests, library + demo builds, `publint` + `arethetypeswrong`
68
+ package guards) and a first vitest suite.
69
+
70
+ ### Fixed
71
+ - `package.json` `types` condition ordering and the non-existent `dist/style.css` export.
72
+ - Export (`getFileData`) no longer issues a `HEAD` probe nor re-downloads the document; it uses the
73
+ bytes of the already-loaded document, so presigned/expiring URLs work.
74
+ - Pages with an intrinsic `/Rotate` render correctly; UI rotation now composes on top of it
75
+ (search highlights and redactions were previously misplaced on such pages).
76
+ - Hard-coded signer email removed from digital-signature placeholders (uses `currentUser.name`).
77
+ - Watermark text no longer defaults to `user@example.com - Confidential` in embedded usage.
78
+ - Loading errors (including password-protected documents) are surfaced instead of being logged only.
79
+ - Truncated `LICENSE` replaced with the full CPAL-1.0 text; stale docs and package name fixed.
80
+
81
+ ## [1.0.4] — 2026-08-15
82
+ - 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 Modificati
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,254 @@
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
  ![TeamSync PDF Viewer UI](https://raw.githubusercontent.com/angelbot-ai/TeamSync-PDF-Viewer/main/docs/images/viewer_ui.png)
6
9
 
7
- ### **100% Open Source. 100% Client-Side. Enterprise PDF Engine.**
8
-
9
10
  [![License: CPAL-1.0](https://img.shields.io/badge/License-CPAL--1.0-blue.svg)](LICENSE)
10
11
  [![Live Demo](https://img.shields.io/badge/Live%20Demo-pdfviewer.teamsync.com-000000.svg)](https://pdfviewer.teamsync.com/)
11
- [![NPM Version](https://img.shields.io/badge/npm-%40angelbot--ai%2Fteamsync--pdf--viewer-blue.svg)](https://www.npmjs.com/package/teamsync-pdf-viewer)
12
- [![React 19](https://img.shields.io/badge/React-19-61dafb.svg)](https://reactjs.org/)
13
- [![Vite 8](https://img.shields.io/badge/Vite-8.2-646cff.svg)](https://vitejs.dev/)
14
- [![TypeScript](https://img.shields.io/badge/TypeScript-6.0-blue.svg)](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
+ [![npm](https://img.shields.io/npm/v/teamsync-pdf-viewer.svg)](https://www.npmjs.com/package/teamsync-pdf-viewer)
13
+ [![React 18/19](https://img.shields.io/badge/React-18%20%7C%2019-61dafb.svg)](https://react.dev/)
14
+ [![TypeScript](https://img.shields.io/badge/TypeScript-types%20included-blue.svg)](https://www.typescriptlang.org/)
18
15
 
19
16
  </div>
20
17
 
21
18
  ---
22
19
 
23
- ## 🚀 Why TeamSync PDF Viewer?
24
-
25
- Traditional commercial PDF viewers force developers into expensive per-domain licenses, opaque sales calls, and heavy server-side processing dependencies. **TeamSync PDF Viewer** is built from the ground up to solve these pain points.
26
-
27
- - 💰 **Zero-Cost, Transparent Licensing**: Uncapped usage, no per-server fees, and no commercial paywalls. 100% free and open-source under CPAL 1.0.
28
- - ⚡ **100% Client-Side WebAssembly**: Documents never leave the browser sandbox. Process, redact, and render PDFs entirely on the client—guaranteeing instant **HIPAA**, **GDPR**, and **FINRA** compliance.
29
- - 🔌 **Universal WebViewer API**: Clean, intuitive `WebViewer({...})` API interface that makes integrating into your web applications effortless.
30
- - 🎨 **Headless & Customizable**: Built for modern React 19 SPA lifecycles. No bloated iFrames to fight—customize toolbars, sidebars, context menus, and controls natively.
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
+ - **Annotation API** — `instance.annotationManager`: undo/redo, granular `annotationChanged`
38
+ events, authorship + edit permissions, programmatic add/update/delete and **native XFDF**
39
+ import/export (Acrobat/Apryse-compatible; unknown markup is preserved as read-only pass-through).
40
+ - **Print** — via the menu or `instance.print()`.
41
+
42
+ Not yet supported: AcroForm filling, rendering of annotations already embedded in the PDF (only
43
+ XFDF-imported ones), document outline/bookmarks, password prompts (password-protected files raise
44
+ `onPasswordRequired`).
31
45
 
32
46
  ---
33
47
 
34
- ## 📦 Installation via NPM
35
-
36
- Install the package into your React / TypeScript project:
48
+ ## Installation
37
49
 
38
50
  ```bash
39
- # Using npm
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
51
+ npm install teamsync-pdf-viewer pdfjs-dist
47
52
  ```
48
53
 
49
- ### Installing from GitHub Packages (Alternative)
50
-
51
- If installing from GitHub Packages registry:
54
+ `react`, `react-dom` (18 or 19) and `pdfjs-dist` (6.x) are **peer dependencies**. `pdf-lib` and
55
+ `lucide-react` are installed automatically.
52
56
 
53
- 1. Create or update your `.npmrc` file:
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
- ---
57
+ ### Serve the pdf.js assets
63
58
 
64
- ## 📖 Official Documentation & Wiki
59
+ The library never bundles the pdf.js worker (bundling it produced a 5 MB package with a `data:`
60
+ URL worker that strict Content-Security-Policies reject). Serve the worker — and, for full font /
61
+ CJK / JPEG 2000 support, the CMaps, standard fonts and wasm decoders — from your own origin and tell
62
+ the viewer where they are.
65
63
 
66
- Explore detailed SDK guides, parameter options, code snippets, and architecture deep dives:
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
- ---
64
+ **Vite / Rollup**
77
65
 
78
- ## ✨ Uncompromised Feature Set
66
+ ```ts
67
+ import workerSrc from 'pdfjs-dist/build/pdf.worker.min.mjs?url';
68
+ import { configurePdfAssets } from 'teamsync-pdf-viewer';
79
69
 
80
- Everything you need to build collaborative, secure document workflows.
70
+ configurePdfAssets({ workerSrc });
71
+ ```
81
72
 
82
- ### 🎨 Smart Markup & Annotations
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.
73
+ **Next.js (or any static host)** — copy the files at build time and reference them by URL:
86
74
 
87
- ### 🛡️ Military-Grade Secure Redaction
88
- - **Binary-Level Data Obliteration**: We don't just place black boxes over text—redactions are permanently rasterized and burned into the underlying PDF vector structure.
89
- - **Text Layer Sanitization**: Redacted text is automatically stripped from the DOM `textLayer` and PDF content streams, preventing copy/paste extraction and search indexing.
90
- - **Automatic Regex Redactions**: Programmatically locate and redact sensitive PII (Aadhaar numbers, SSNs, credit cards, dates of birth) in a single click.
91
- - **Discard Unapplied Redactions**: Easily discard individual pending redactions or bulk-discard all unapplied redaction marks before committing.
75
+ ```bash
76
+ # e.g. in a prebuild script
77
+ cp node_modules/pdfjs-dist/build/pdf.worker.min.mjs public/pdfjs/
78
+ cp -r node_modules/pdfjs-dist/cmaps node_modules/pdfjs-dist/standard_fonts node_modules/pdfjs-dist/wasm public/pdfjs/
79
+ ```
92
80
 
93
- ### 🔍 High-DPI Canvas Rendering & Search
94
- - **Retina 60 FPS Zoom & Pan**: High-DPI `devicePixelRatio` scaling eliminates blurred text. Micro-debounced rendering enables buttery-smooth 60 FPS trackpad pinching and 360° mouse drag panning.
95
- - **Contextual Document Search**: Instant client-side text search with real-time match highlighting, result jumping, and match counting.
81
+ ```ts
82
+ configurePdfAssets({
83
+ workerSrc: '/pdfjs/pdf.worker.min.mjs',
84
+ cMapUrl: '/pdfjs/cmaps/',
85
+ standardFontDataUrl: '/pdfjs/standard_fonts/',
86
+ wasmUrl: '/pdfjs/wasm/',
87
+ });
88
+ ```
96
89
 
97
- ### 💧 Dynamic Forensic Watermarking
98
- - Programmatic, non-destructive watermarks rendered on the fly (single centered or full-page tiled) with customizable text, color, opacity, font size, and rotation.
90
+ The worker **must** come from the same `pdfjs-dist` version the viewer runs against
91
+ (`import { pdfjsVersion } from 'teamsync-pdf-viewer'` tells you which one is loaded).
99
92
 
100
93
  ---
101
94
 
102
- ## 💻 Developer SDK Usage
103
-
104
- ### Standard WebViewer Initialization
105
-
106
- Drop the SDK into any container element with a single function call:
95
+ ## Usage
107
96
 
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
138
-
139
- For native React integration, use the `<DocumentViewer />` component:
97
+ ### React component
140
98
 
141
99
  ```tsx
142
- import { DocumentViewer } from 'teamsync-pdf-viewer';
100
+ 'use client'; // Next.js App Router: the viewer is client-only
101
+
102
+ import { TeamSyncViewer, type WebViewerInstance } from 'teamsync-pdf-viewer';
143
103
  import 'teamsync-pdf-viewer/style.css';
144
104
 
145
- function App() {
105
+ export function ContractViewer({ url }: { url: string }) {
146
106
  return (
147
- <div style={{ width: '100vw', height: '100vh' }}>
148
- <DocumentViewer
149
- initialDoc="/contract.pdf"
150
- scale={1.0}
151
- enableAnnotations={true}
152
- permissions={{ canRedact: true }}
107
+ <div style={{ height: '80vh' }}>
108
+ <TeamSyncViewer
109
+ fileUrl={url}
110
+ fileName="contract.pdf"
111
+ assets={{ workerSrc: '/pdfjs/pdf.worker.min.mjs', cMapUrl: '/pdfjs/cmaps/' }}
112
+ currentUser={{ id: 'u-42', name: 'Jane Doe' }}
113
+ initialScale="fit-width"
114
+ watermark={{ text: 'CONFIDENTIAL', mode: 'tiled', opacity: 0.08 }}
115
+ onReady={(instance: WebViewerInstance) => console.log('ready', instance)}
116
+ onDocumentLoadError={(error, retry) => {
117
+ // e.g. mint a fresh presigned URL and retry
118
+ retry(/* newUrl */);
119
+ }}
153
120
  />
154
121
  </div>
155
122
  );
156
123
  }
157
124
  ```
158
125
 
159
- ---
160
-
161
- ## 🛠️ Local Development Quick Start
126
+ In Next.js, load it with `next/dynamic(() => import('./ContractViewer'), { ssr: false })` or keep
127
+ it inside a client component — the package itself never touches `window` at import time.
162
128
 
163
- ### 1. Clone & Install
129
+ ### Imperative API
164
130
 
165
- ```bash
166
- git clone https://github.com/angelbot-ai/TeamSync-PDF-Viewer.git
167
- cd TeamSync-PDF-Viewer
168
- npm install
169
- ```
131
+ ```ts
132
+ import { createWebViewer } from 'teamsync-pdf-viewer';
133
+ import 'teamsync-pdf-viewer/style.css';
170
134
 
171
- ### 2. Launch Dev Server
135
+ const instance = await createWebViewer(
136
+ { initialDoc: '/sample.pdf', fileName: 'sample.pdf', permissions: { canRedact: true } },
137
+ document.getElementById('viewer-container')!
138
+ );
172
139
 
173
- ```bash
174
- npm run dev
140
+ instance.on('documentLoaded', ({ numPages }) => console.log(numPages, 'pages'));
141
+ const pdfBytes = await instance.getFileData(); // annotated / redacted / watermarked Uint8Array
142
+ instance.destroy(); // unmounts and releases every listener
175
143
  ```
176
144
 
177
- Open `http://localhost:5173` in your browser to launch the live SDK viewer.
145
+ `WebViewer()` remains available as a deprecated alias of `createWebViewer()`.
178
146
 
179
147
  ---
180
148
 
181
- ## 🔌 Extensible Plugin Architecture
149
+ ## API overview
150
+
151
+ ### `<TeamSyncViewer>` props / `WebViewerOptions`
152
+
153
+ | Prop | Type | Default | Description |
154
+ | :--- | :--- | :--- | :--- |
155
+ | `fileUrl` (`initialDoc`) | `string` | — | URL of the PDF. Fetched by pdf.js (CORS + Range supported). |
156
+ | `fileName` | `string` | `annotated_document.pdf` | Name used for downloads. |
157
+ | `assets` | `PdfAssetPaths` | — | Worker / CMap / font / wasm locations (or call `configurePdfAssets`). |
158
+ | `withCredentials` | `boolean` | `false` | Send cookies with the document request. |
159
+ | `initialScale` | `number \| 'fit-width' \| 'fit-page'` | `1` | Initial zoom. |
160
+ | `initialPage` | `number` | `1` | 1-based page to open. |
161
+ | `readOnly` | `boolean` | `false` | Disables all annotation / redaction editing. |
162
+ | `permissions` | `SDKPermissions` | all `true` | `canAddAnnotations`, `canEditAnnotations`, `canDeleteAnnotations`, `canRedact`. |
163
+ | `currentUser` | `{ id, name }` | — | Author of annotations created in this viewer. |
164
+ | `watermark` | `WatermarkOptions` | — | `{ text, mode: 'single' \| 'tiled', size, opacity, color }`. |
165
+ | `redactions`, `regexRedactions` | `Redaction[]`, `RegExp[]` | `[]` | Pre-set and pattern-driven redactions. |
166
+ | `toolbar`, `sidebars`, `leftPanelOpen` | `boolean` | `true` | Chrome toggles. |
167
+ | `autoFocus` | `boolean` | `false` | Focus the viewer on mount (keyboard shortcuts). |
168
+ | `plugins` | `ViewerPlugin[]` | `[]` | Extension plugins. |
169
+
170
+ `permissions.canEditOthers` (default `false`) lets a user edit or delete annotations authored by
171
+ someone else; annotations carry `author`/`authorId` from `currentUser`.
172
+
173
+ Callbacks: `onReady(instance)`, `onDocumentLoaded({ url, numPages })`,
174
+ `onDocumentLoadError(error, retry(newUrl?), { url, passwordRequired })`, `onFirstPageRendered`,
175
+ `onPasswordRequired`, `onPageChange(page, numPages)`, `onAnnotationsChange(annotations)`.
176
+
177
+ ### `WebViewerInstance`
178
+
179
+ - `on(type, listener)` / `off` — typed events: `documentLoaded`, `documentLoadError`,
180
+ `firstPageRendered`, `pageChanged`, `annotationsChanged`, `toolChanged`, `destroy`.
181
+ - `loadDocument(url)` — load or reload (resolves on load, rejects on error).
182
+ - `getFileData({ explicitAnnotations? })` — export the document as `Uint8Array`.
183
+ - `getAnnotations()`, `getCurrentPage()`, `getPageCount()`, `getPdfDocument()`, `print()`.
184
+ - `annotationManager` — `getAnnotationsList()`, `getAnnotationById(id)`, `addAnnotations(list)`,
185
+ `updateAnnotation(id, patch)`, `deleteAnnotations(ids, { force })`, `undo()`/`redo()`,
186
+ `importAnnotations(xfdf)`, `exportAnnotations({ annotList?, useDisplayAuthor? })`,
187
+ `setCurrentUser(name, id?)`, `setReadOnly(bool)`, `canEdit(annotation)`,
188
+ `addEventListener('annotationChanged', ({ annotations, action, imported }) => …)`.
189
+ - `destroy()` — unmount (imperative API) and release every listener.
190
+ - `UI.*` / `Core.*` — legacy facades (`UI.openElements`, `UI.fitWidth`,
191
+ `Core.annotationManager.exportAnnotations()`, `Core.documentViewer.getDocument().getFileData()`).
192
+
193
+ Full reference: [docs/wiki/API-Reference-&-Options.md](docs/wiki/API-Reference-&-Options.md).
182
194
 
183
- TeamSync PDF Viewer features a decoupled **Plugin Architecture**. Core PDF rendering, smart annotations, redaction engines, and search remain lightweight and modular in the main engine, while enterprise extensions plug in as independent modules.
195
+ ---
184
196
 
185
- ```
186
- ┌─────────────────────────────────────────────────────────┐
187
- │ TeamSync PDF Viewer Core │
188
- │ (Page Rendering, Annotations, Redactions, Search) │
189
- └───────────────────────────┬─────────────────────────────┘
190
- │ Plugins Registry API
191
- ┌───────────────────────────▼─────────────────────────────┐
192
- │ Custom Extension │
193
- │ (Custom Modals, Action Buttons, Export Hooks) │
194
- └─────────────────────────────────────────────────────────┘
195
- ```
197
+ ## Documentation
198
+
199
+ - [Getting Started](docs/wiki/Getting-Started.md) · [API Reference & Options](docs/wiki/API-Reference-&-Options.md)
200
+ - [Annotations & Markup](docs/wiki/Annotations-&-Markup-Guide.md) · [Redactions & PII Sanitization](docs/wiki/Redactions-&-PII-Sanitization.md)
201
+ - [Forensic Watermarking](docs/wiki/Forensic-Watermarking.md) · [Plugin Architecture](docs/wiki/Plugin-Architecture.md)
202
+ - [Changelog](CHANGELOG.md)
196
203
 
197
204
  ---
198
205
 
199
- ## 🏛️ Architecture & Tech Stack
206
+ ## Development
207
+
208
+ ```bash
209
+ git clone https://github.com/angelbot-ai/TeamSync-PDF-Viewer.git
210
+ cd TeamSync-PDF-Viewer
211
+ npm install
212
+ npm run dev # demo application at http://localhost:5173
213
+ npm test # unit tests (vitest)
214
+ npm run build # library -> dist/
215
+ npm run verify:package # publint + arethetypeswrong + artifact guards
216
+ npm run build:app # demo / iframe package build (Vercel)
217
+ ```
200
218
 
201
- - **Core Engine**: HTML5, TypeScript, WebAssembly (PDF.js + pdf-lib)
202
- - **UI & State**: React 19, Lucide Icons, Pure CSS Modules
203
- - **Build System**: Vite 8 & Oxlint (Sub-500ms tree-shakable builds)
219
+ Layout:
204
220
 
205
221
  ```
206
- TeamSync-PDF-Viewer/
207
- ├── src/
208
- │ ├── components/ # Native React UI (Header, DocumentViewer, Sidebars, Modals)
209
- │ ├── hooks/ # Search & Keyboard shortcut hooks
210
- │ ├── utils/ # Redaction algorithms & vector helpers
211
- │ ├── plugins/ # Plugin API interfaces & registry
212
- │ ├── index.ts # Main SDK package exports
213
- │ ├── main.tsx # WebViewer SDK entry point & public API bridge
214
- │ └── App.tsx # Demo Application Shell
215
- ├── public/ # Static PDF assets & PDF.js workers
216
- └── docs/images/ # High-res UI documentation screenshots
222
+ src/
223
+ ├── index.ts # public entry (side-effect free)
224
+ ├── core/ # createWebViewer, WebViewerInstance, event bus, pdf.js assets, export
225
+ ├── components/ # TeamSyncViewer + internal UI (DocumentViewer, Header, sidebars, modals)
226
+ ├── annotations/ # annotation data model
227
+ ├── hooks/, utils/ # search, shortcuts, rotation helpers, regex redaction
228
+ ├── plugins/ # plugin interfaces
229
+ └── demo/ # demo & iframe-package bootstrap (not published)
217
230
  ```
218
231
 
219
- ---
232
+ ### Releasing
233
+
234
+ 1. Bump `version` in `package.json` + add a `CHANGELOG.md` entry, merge to `main`.
235
+ 2. Either push a tag `vX.Y.Z` on that commit, or run the **Publish to npm** workflow manually
236
+ with the ref to publish. The workflow re-runs the full verification chain, checks the version
237
+ is not already on the registry, and publishes with provenance (needs the `NPM_TOKEN` secret).
220
238
 
221
- ## 📄 License
239
+ ### Iframe package (script-tag hosts)
222
240
 
223
- Distributed under the **CPAL 1.0 (Common Public Attribution License)**.
224
- 100% Free and Open Source for personal and commercial usage.
241
+ `npm run build:app` produces a self-contained viewer; `public/webviewer.js` wraps it in an iframe
242
+ with a `postMessage` bridge and exposes a `WebViewer(options, element)` function for non-React hosts.
225
243
 
226
244
  ---
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>
230
245
 
231
- <div align="center">
232
- <b>TeamSync PDF Viewer Engine</b> • Engineered with ❤️ for the Open Web.
233
- </div>
246
+ ## TypeScript notes
247
+
248
+ Declarations ship in `dist/src/`. They resolve under `moduleResolution: "bundler"` (Next.js, Vite,
249
+ webpack) and `node10`; `node16`/`nodenext` resolution is not supported yet because the emitted
250
+ declarations use extension-less relative imports.
251
+
252
+ ## License
253
+
254
+ [CPAL-1.0](LICENSE) — Copyright © 2026 AngelBot Ai Pvt Ltd.