@tindtechnologies/pdfjs-viewer 5.4.624-tind.3 → 5.4.624-tind.4

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/build/pdf.mjs CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  /**
24
24
  * pdfjsVersion = 5.4.0
25
- * pdfjsBuild = ea39462
25
+ * pdfjsBuild = cf046ea
26
26
  */
27
27
  /******/ // The require scope
28
28
  /******/ var __webpack_require__ = {};
@@ -16121,7 +16121,7 @@ class InternalRenderTask {
16121
16121
  }
16122
16122
  }
16123
16123
  const version = "5.4.0";
16124
- const build = "ea39462";
16124
+ const build = "cf046ea";
16125
16125
 
16126
16126
  ;// ./src/display/editor/color_picker.js
16127
16127
 
@@ -22,7 +22,7 @@
22
22
 
23
23
  /**
24
24
  * pdfjsVersion = 5.4.0
25
- * pdfjsBuild = ea39462
25
+ * pdfjsBuild = cf046ea
26
26
  */
27
27
  /******/ // The require scope
28
28
  /******/ var __webpack_require__ = {};
@@ -22,7 +22,7 @@
22
22
 
23
23
  /**
24
24
  * pdfjsVersion = 5.4.0
25
- * pdfjsBuild = ea39462
25
+ * pdfjsBuild = cf046ea
26
26
  */
27
27
  /******/ // The require scope
28
28
  /******/ var __webpack_require__ = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tindtechnologies/pdfjs-viewer",
3
- "version": "5.4.624-tind.3",
3
+ "version": "5.4.624-tind.4",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tind/pdfjs-viewer"
@@ -1,7 +1,16 @@
1
+ const OPEN_PATCHED_FLAG = Symbol("tindPdfViewerApplicationOpenPatched");
2
+ const registeredDocuments = new WeakSet();
3
+
1
4
  function patchPDFViewerApplicationOpen(evt) {
2
- const win = evt?.detail?.source || window;
5
+ const sourceWindow = evt?.detail?.source;
6
+ if (sourceWindow && sourceWindow !== window) {
7
+ // Ignore events emitted by sibling iframe viewers sharing parent.document.
8
+ return;
9
+ }
10
+
11
+ const win = sourceWindow || window;
3
12
  const app = win.PDFViewerApplication;
4
- if (!app) {
13
+ if (!app || app[OPEN_PATCHED_FLAG]) {
5
14
  return;
6
15
  }
7
16
 
@@ -15,6 +24,25 @@ function patchPDFViewerApplicationOpen(evt) {
15
24
 
16
25
  const originalOpen = app.open.bind(app);
17
26
  app.open = (args) => originalOpen({ ...args, rangeChunkSize, disableStream });
27
+ app[OPEN_PATCHED_FLAG] = true;
18
28
  }
19
29
 
20
- document.addEventListener("webviewerloaded", patchPDFViewerApplicationOpen);
30
+ function addWebViewerLoadedListener(targetDocument) {
31
+ if (!targetDocument || registeredDocuments.has(targetDocument)) {
32
+ return;
33
+ }
34
+
35
+ targetDocument.addEventListener(
36
+ "webviewerloaded",
37
+ patchPDFViewerApplicationOpen,
38
+ );
39
+ registeredDocuments.add(targetDocument);
40
+ }
41
+
42
+ addWebViewerLoadedListener(document);
43
+
44
+ try {
45
+ addWebViewerLoadedListener(window.parent?.document);
46
+ } catch {
47
+ // Cross-origin or sandboxed iframe: parent.document is inaccessible.
48
+ }
package/web/viewer.mjs CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  /**
24
24
  * pdfjsVersion = 5.4.0
25
- * pdfjsBuild = ea39462
25
+ * pdfjsBuild = cf046ea
26
26
  */
27
27
  /******/ // The require scope
28
28
  /******/ var __webpack_require__ = {};