teamsync-pdf-viewer 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +77 -0
- package/README.md +233 -0
- package/dist/TeamSync.pdf +0 -0
- package/dist/ThirdPartyNotices.txt +639 -0
- package/dist/favicon.svg +16 -0
- package/dist/icons.svg +24 -0
- package/dist/index.d.ts +1 -0
- package/dist/teamsync-pdf-viewer.css +2 -0
- package/dist/teamsync-pdf-viewer.es.js +51524 -0
- package/dist/teamsync-pdf-viewer.umd.cjs +327 -0
- package/dist/webviewer.js +92 -0
- package/package.json +56 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2026 AngelBot Ai Pvt Ltd. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Drop-in replacement for Legacy WebViewer wrapper.
|
|
6
|
+
*/
|
|
7
|
+
export default function WebViewer(options, viewerElement) {
|
|
8
|
+
return new Promise((resolve, reject) => {
|
|
9
|
+
// 1. Create the iframe
|
|
10
|
+
const iframe = document.createElement('iframe');
|
|
11
|
+
iframe.style.width = '100%';
|
|
12
|
+
iframe.style.height = '100%';
|
|
13
|
+
iframe.style.border = 'none';
|
|
14
|
+
|
|
15
|
+
// 2. Construct the URL to our built Vite app (index.html)
|
|
16
|
+
const basePath = options.path || '/lib';
|
|
17
|
+
iframe.src = `${basePath}/index.html`;
|
|
18
|
+
viewerElement.appendChild(iframe);
|
|
19
|
+
|
|
20
|
+
// 3. Establish the Mock Legacy Instance API
|
|
21
|
+
const instance = {
|
|
22
|
+
iframeWindow: iframe.contentWindow,
|
|
23
|
+
UI: {
|
|
24
|
+
setTheme: (theme) => iframe.contentWindow.postMessage({ type: 'UI_SET_THEME', theme }, '*'),
|
|
25
|
+
openElements: (elements) => iframe.contentWindow.postMessage({ type: 'UI_OPEN_ELEMENTS', elements }, '*'),
|
|
26
|
+
closeElements: (elements) => iframe.contentWindow.postMessage({ type: 'UI_CLOSE_ELEMENTS', elements }, '*'),
|
|
27
|
+
enableElements: (elements) => iframe.contentWindow.postMessage({ type: 'UI_OPEN_ELEMENTS', elements }, '*'),
|
|
28
|
+
disableElements: (elements) => iframe.contentWindow.postMessage({ type: 'UI_CLOSE_ELEMENTS', elements }, '*'),
|
|
29
|
+
setActiveLeftPanel: (panel) => iframe.contentWindow.postMessage({ type: 'UI_SET_ACTIVE_LEFT_PANEL', panel }, '*')
|
|
30
|
+
},
|
|
31
|
+
Core: {
|
|
32
|
+
annotationManager: {
|
|
33
|
+
exportAnnotations: () => {
|
|
34
|
+
return new Promise((res) => {
|
|
35
|
+
const listener = (event) => {
|
|
36
|
+
if (event.source !== iframe.contentWindow) return;
|
|
37
|
+
if (event.data.type === 'EXPORT_ANNOTATIONS_RESULT') {
|
|
38
|
+
window.removeEventListener('message', listener);
|
|
39
|
+
res(event.data.annotations);
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
window.addEventListener('message', listener);
|
|
43
|
+
iframe.contentWindow.postMessage({ type: 'CORE_EXPORT_ANNOTATIONS' }, '*');
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
documentViewer: {
|
|
48
|
+
getDocument: () => ({
|
|
49
|
+
getFileData: () => {
|
|
50
|
+
return new Promise((res) => {
|
|
51
|
+
const listener = (event) => {
|
|
52
|
+
if (event.source !== iframe.contentWindow) return;
|
|
53
|
+
if (event.data.type === 'GET_FILE_DATA_RESULT') {
|
|
54
|
+
window.removeEventListener('message', listener);
|
|
55
|
+
res(event.data.data);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
window.addEventListener('message', listener);
|
|
59
|
+
iframe.contentWindow.postMessage({ type: 'CORE_GET_FILE_DATA' }, '*');
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
// Wait for the React app inside the iframe to signal it is ready
|
|
68
|
+
const messageListener = (event) => {
|
|
69
|
+
if (event.source !== iframe.contentWindow) return;
|
|
70
|
+
|
|
71
|
+
if (event.data === 'VIEWER_READY') {
|
|
72
|
+
// Prepare options (stringify regexes since they can't be cloned directly via postMessage)
|
|
73
|
+
const serializedOptions = {
|
|
74
|
+
...options,
|
|
75
|
+
regexRedactions: options.regexRedactions
|
|
76
|
+
? options.regexRedactions.map(r => r.toString())
|
|
77
|
+
: []
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
iframe.contentWindow.postMessage({
|
|
81
|
+
type: 'INIT',
|
|
82
|
+
options: serializedOptions
|
|
83
|
+
}, '*');
|
|
84
|
+
} else if (event.data === 'VIEWER_INITIALIZED') {
|
|
85
|
+
window.removeEventListener('message', messageListener);
|
|
86
|
+
resolve(instance);
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
window.addEventListener('message', messageListener);
|
|
91
|
+
});
|
|
92
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "teamsync-pdf-viewer",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"license": "CPAL-1.0",
|
|
5
|
+
"description": "Enterprise PDF Viewer SDK - 100% Client-Side WebAssembly PDF Engine for React",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/teamsync-pdf-viewer.umd.cjs",
|
|
8
|
+
"module": "./dist/teamsync-pdf-viewer.es.js",
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/teamsync-pdf-viewer.es.js",
|
|
13
|
+
"require": "./dist/teamsync-pdf-viewer.umd.cjs",
|
|
14
|
+
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./style.css": "./dist/style.css"
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/angelbot-ai/TeamSync-PDF-Viewer.git"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/angelbot-ai/TeamSync-PDF-Viewer/issues"
|
|
27
|
+
},
|
|
28
|
+
"homepage": "https://github.com/angelbot-ai/TeamSync-PDF-Viewer#readme",
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"dev": "vite",
|
|
34
|
+
"build": "tsc -b && vite build",
|
|
35
|
+
"build:app": "tsc -b && vite build --config vite.config.app.ts",
|
|
36
|
+
"lint": "oxlint",
|
|
37
|
+
"preview": "vite preview"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"lucide-react": "^1.28.0",
|
|
41
|
+
"pdf-lib": "^1.17.1",
|
|
42
|
+
"pdfjs-dist": "^6.2.108",
|
|
43
|
+
"react": "^19.2.8",
|
|
44
|
+
"react-dom": "^19.2.8"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^24.13.3",
|
|
48
|
+
"@types/react": "^19.2.17",
|
|
49
|
+
"@types/react-dom": "^19.2.3",
|
|
50
|
+
"@vitejs/plugin-react": "^6.0.4",
|
|
51
|
+
"oxlint": "^1.75.0",
|
|
52
|
+
"typescript": "~6.0.2",
|
|
53
|
+
"vite": "^8.2.0",
|
|
54
|
+
"vite-plugin-dts": "^4.5.3"
|
|
55
|
+
}
|
|
56
|
+
}
|