@thatkid02/react-native-pdf-viewer 0.0.2 → 0.0.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.
@@ -0,0 +1,68 @@
1
+ ///
2
+ /// DocumentInfo.swift
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ import NitroModules
9
+
10
+ /**
11
+ * Represents an instance of `DocumentInfo`, backed by a C++ struct.
12
+ */
13
+ public typealias DocumentInfo = margelo.nitro.pdfviewer.DocumentInfo
14
+
15
+ public extension DocumentInfo {
16
+ private typealias bridge = margelo.nitro.pdfviewer.bridge.swift
17
+
18
+ /**
19
+ * Create a new instance of `DocumentInfo`.
20
+ */
21
+ init(pageCount: Double, pageWidth: Double, pageHeight: Double, currentPage: Double) {
22
+ self.init(pageCount, pageWidth, pageHeight, currentPage)
23
+ }
24
+
25
+ var pageCount: Double {
26
+ @inline(__always)
27
+ get {
28
+ return self.__pageCount
29
+ }
30
+ @inline(__always)
31
+ set {
32
+ self.__pageCount = newValue
33
+ }
34
+ }
35
+
36
+ var pageWidth: Double {
37
+ @inline(__always)
38
+ get {
39
+ return self.__pageWidth
40
+ }
41
+ @inline(__always)
42
+ set {
43
+ self.__pageWidth = newValue
44
+ }
45
+ }
46
+
47
+ var pageHeight: Double {
48
+ @inline(__always)
49
+ get {
50
+ return self.__pageHeight
51
+ }
52
+ @inline(__always)
53
+ set {
54
+ self.__pageHeight = newValue
55
+ }
56
+ }
57
+
58
+ var currentPage: Double {
59
+ @inline(__always)
60
+ get {
61
+ return self.__currentPage
62
+ }
63
+ @inline(__always)
64
+ set {
65
+ self.__currentPage = newValue
66
+ }
67
+ }
68
+ }
@@ -35,6 +35,7 @@ public protocol HybridPdfViewerSpec_protocol: HybridObject, HybridView {
35
35
  func setScale(scale: Double) throws -> Void
36
36
  func generateThumbnail(page: Double) throws -> Void
37
37
  func generateAllThumbnails() throws -> Void
38
+ func getDocumentInfo() throws -> DocumentInfo?
38
39
  }
39
40
 
40
41
  /// See ``HybridPdfViewerSpec``
@@ -554,6 +554,24 @@ open class HybridPdfViewerSpec_cxx {
554
554
  }
555
555
  }
556
556
 
557
+ @inline(__always)
558
+ public final func getDocumentInfo() -> bridge.Result_std__optional_DocumentInfo__ {
559
+ do {
560
+ let __result = try self.__implementation.getDocumentInfo()
561
+ let __resultCpp = { () -> bridge.std__optional_DocumentInfo_ in
562
+ if let __unwrappedValue = __result {
563
+ return bridge.create_std__optional_DocumentInfo_(__unwrappedValue)
564
+ } else {
565
+ return .init()
566
+ }
567
+ }()
568
+ return bridge.create_Result_std__optional_DocumentInfo__(__resultCpp)
569
+ } catch (let __error) {
570
+ let __exceptionPtr = __error.toCpp()
571
+ return bridge.create_Result_std__optional_DocumentInfo__(__exceptionPtr)
572
+ }
573
+ }
574
+
557
575
  public final func getView() -> UnsafeMutableRawPointer {
558
576
  return Unmanaged.passRetained(__implementation.view).toOpaque()
559
577
  }
@@ -0,0 +1,79 @@
1
+ ///
2
+ /// DocumentInfo.hpp
3
+ /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
+ /// https://github.com/mrousavy/nitro
5
+ /// Copyright © 2026 Marc Rousavy @ Margelo
6
+ ///
7
+
8
+ #pragma once
9
+
10
+ #if __has_include(<NitroModules/JSIConverter.hpp>)
11
+ #include <NitroModules/JSIConverter.hpp>
12
+ #else
13
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
14
+ #endif
15
+ #if __has_include(<NitroModules/NitroDefines.hpp>)
16
+ #include <NitroModules/NitroDefines.hpp>
17
+ #else
18
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
+ #endif
20
+
21
+
22
+
23
+
24
+
25
+ namespace margelo::nitro::pdfviewer {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (DocumentInfo).
29
+ */
30
+ struct DocumentInfo {
31
+ public:
32
+ double pageCount SWIFT_PRIVATE;
33
+ double pageWidth SWIFT_PRIVATE;
34
+ double pageHeight SWIFT_PRIVATE;
35
+ double currentPage SWIFT_PRIVATE;
36
+
37
+ public:
38
+ DocumentInfo() = default;
39
+ explicit DocumentInfo(double pageCount, double pageWidth, double pageHeight, double currentPage): pageCount(pageCount), pageWidth(pageWidth), pageHeight(pageHeight), currentPage(currentPage) {}
40
+ };
41
+
42
+ } // namespace margelo::nitro::pdfviewer
43
+
44
+ namespace margelo::nitro {
45
+
46
+ // C++ DocumentInfo <> JS DocumentInfo (object)
47
+ template <>
48
+ struct JSIConverter<margelo::nitro::pdfviewer::DocumentInfo> final {
49
+ static inline margelo::nitro::pdfviewer::DocumentInfo fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
50
+ jsi::Object obj = arg.asObject(runtime);
51
+ return margelo::nitro::pdfviewer::DocumentInfo(
52
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pageCount")),
53
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pageWidth")),
54
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pageHeight")),
55
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "currentPage"))
56
+ );
57
+ }
58
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pdfviewer::DocumentInfo& arg) {
59
+ jsi::Object obj(runtime);
60
+ obj.setProperty(runtime, "pageCount", JSIConverter<double>::toJSI(runtime, arg.pageCount));
61
+ obj.setProperty(runtime, "pageWidth", JSIConverter<double>::toJSI(runtime, arg.pageWidth));
62
+ obj.setProperty(runtime, "pageHeight", JSIConverter<double>::toJSI(runtime, arg.pageHeight));
63
+ obj.setProperty(runtime, "currentPage", JSIConverter<double>::toJSI(runtime, arg.currentPage));
64
+ return obj;
65
+ }
66
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
67
+ if (!value.isObject()) {
68
+ return false;
69
+ }
70
+ jsi::Object obj = value.getObject(runtime);
71
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pageCount"))) return false;
72
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pageWidth"))) return false;
73
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pageHeight"))) return false;
74
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "currentPage"))) return false;
75
+ return true;
76
+ }
77
+ };
78
+
79
+ } // namespace margelo::nitro
@@ -54,6 +54,7 @@ namespace margelo::nitro::pdfviewer {
54
54
  prototype.registerHybridMethod("setScale", &HybridPdfViewerSpec::setScale);
55
55
  prototype.registerHybridMethod("generateThumbnail", &HybridPdfViewerSpec::generateThumbnail);
56
56
  prototype.registerHybridMethod("generateAllThumbnails", &HybridPdfViewerSpec::generateAllThumbnails);
57
+ prototype.registerHybridMethod("getDocumentInfo", &HybridPdfViewerSpec::getDocumentInfo);
57
58
  });
58
59
  }
59
60
 
@@ -25,6 +25,8 @@ namespace margelo::nitro::pdfviewer { struct ErrorEvent; }
25
25
  namespace margelo::nitro::pdfviewer { struct ThumbnailGeneratedEvent; }
26
26
  // Forward declaration of `LoadingChangeEvent` to properly resolve imports.
27
27
  namespace margelo::nitro::pdfviewer { struct LoadingChangeEvent; }
28
+ // Forward declaration of `DocumentInfo` to properly resolve imports.
29
+ namespace margelo::nitro::pdfviewer { struct DocumentInfo; }
28
30
 
29
31
  #include <string>
30
32
  #include <optional>
@@ -35,6 +37,7 @@ namespace margelo::nitro::pdfviewer { struct LoadingChangeEvent; }
35
37
  #include "ErrorEvent.hpp"
36
38
  #include "ThumbnailGeneratedEvent.hpp"
37
39
  #include "LoadingChangeEvent.hpp"
40
+ #include "DocumentInfo.hpp"
38
41
 
39
42
  namespace margelo::nitro::pdfviewer {
40
43
 
@@ -106,6 +109,7 @@ namespace margelo::nitro::pdfviewer {
106
109
  virtual void setScale(double scale) = 0;
107
110
  virtual void generateThumbnail(double page) = 0;
108
111
  virtual void generateAllThumbnails() = 0;
112
+ virtual std::optional<DocumentInfo> getDocumentInfo() = 0;
109
113
 
110
114
  protected:
111
115
  // Hybrid Setup
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thatkid02/react-native-pdf-viewer",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Pdf viewer with page thumbnailsthumbnails",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
@@ -10,6 +10,13 @@ export interface LoadCompleteEvent {
10
10
  pageHeight: number;
11
11
  }
12
12
 
13
+ export interface DocumentInfo {
14
+ pageCount: number;
15
+ pageWidth: number;
16
+ pageHeight: number;
17
+ currentPage: number; // 0-indexed
18
+ }
19
+
13
20
  export interface PageChangeEvent {
14
21
  page: number;
15
22
  pageCount: number;
@@ -113,6 +120,9 @@ export interface PdfViewerMethods extends HybridViewMethods {
113
120
 
114
121
  // Generate thumbnails for all pages
115
122
  generateAllThumbnails(): void;
123
+
124
+ // Get current document info (for querying cached PDFs)
125
+ getDocumentInfo(): DocumentInfo | null;
116
126
  }
117
127
 
118
128
  export type PdfViewer = HybridView<PdfViewerProps, PdfViewerMethods>;