@thatkid02/react-native-pdf-viewer 0.0.1

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 (95) hide show
  1. package/LICENSE +20 -0
  2. package/PdfViewer.podspec +28 -0
  3. package/README.md +290 -0
  4. package/android/CMakeLists.txt +24 -0
  5. package/android/build.gradle +121 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/cpp/cpp-adapter.cpp +6 -0
  8. package/android/src/main/java/com/margelo/nitro/pdfviewer/HybridPdfViewer.kt +169 -0
  9. package/android/src/main/java/com/margelo/nitro/pdfviewer/PdfViewer.kt +996 -0
  10. package/android/src/main/java/com/margelo/nitro/pdfviewer/PdfViewerPackage.kt +26 -0
  11. package/ios/PdfViewer.swift +696 -0
  12. package/lib/module/PdfViewer.nitro.js +4 -0
  13. package/lib/module/PdfViewer.nitro.js.map +1 -0
  14. package/lib/module/index.js +13 -0
  15. package/lib/module/index.js.map +1 -0
  16. package/lib/module/package.json +1 -0
  17. package/lib/typescript/package.json +1 -0
  18. package/lib/typescript/src/PdfViewer.nitro.d.ts +67 -0
  19. package/lib/typescript/src/PdfViewer.nitro.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +8 -0
  21. package/lib/typescript/src/index.d.ts.map +1 -0
  22. package/nitro.json +17 -0
  23. package/nitrogen/generated/android/c++/JErrorEvent.hpp +57 -0
  24. package/nitrogen/generated/android/c++/JFunc_void_ErrorEvent.hpp +77 -0
  25. package/nitrogen/generated/android/c++/JFunc_void_LoadCompleteEvent.hpp +76 -0
  26. package/nitrogen/generated/android/c++/JFunc_void_LoadingChangeEvent.hpp +76 -0
  27. package/nitrogen/generated/android/c++/JFunc_void_PageChangeEvent.hpp +76 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_ScaleChangeEvent.hpp +76 -0
  29. package/nitrogen/generated/android/c++/JFunc_void_ThumbnailGeneratedEvent.hpp +77 -0
  30. package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.cpp +273 -0
  31. package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.hpp +94 -0
  32. package/nitrogen/generated/android/c++/JLoadCompleteEvent.hpp +61 -0
  33. package/nitrogen/generated/android/c++/JLoadingChangeEvent.hpp +53 -0
  34. package/nitrogen/generated/android/c++/JPageChangeEvent.hpp +57 -0
  35. package/nitrogen/generated/android/c++/JScaleChangeEvent.hpp +53 -0
  36. package/nitrogen/generated/android/c++/JThumbnailGeneratedEvent.hpp +57 -0
  37. package/nitrogen/generated/android/c++/views/JHybridPdfViewerStateUpdater.cpp +108 -0
  38. package/nitrogen/generated/android/c++/views/JHybridPdfViewerStateUpdater.hpp +49 -0
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ErrorEvent.kt +32 -0
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ErrorEvent.kt +81 -0
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_LoadCompleteEvent.kt +81 -0
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_LoadingChangeEvent.kt +81 -0
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_PageChangeEvent.kt +81 -0
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ScaleChangeEvent.kt +81 -0
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ThumbnailGeneratedEvent.kt +81 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/HybridPdfViewerSpec.kt +195 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/LoadCompleteEvent.kt +35 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/LoadingChangeEvent.kt +29 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/PageChangeEvent.kt +32 -0
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ScaleChangeEvent.kt +29 -0
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ThumbnailGeneratedEvent.kt +32 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/pdfviewerOnLoad.kt +35 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/views/HybridPdfViewerManager.kt +50 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/views/HybridPdfViewerStateUpdater.kt +23 -0
  55. package/nitrogen/generated/android/pdfviewer+autolinking.cmake +83 -0
  56. package/nitrogen/generated/android/pdfviewer+autolinking.gradle +27 -0
  57. package/nitrogen/generated/android/pdfviewerOnLoad.cpp +58 -0
  58. package/nitrogen/generated/android/pdfviewerOnLoad.hpp +25 -0
  59. package/nitrogen/generated/ios/PdfViewer+autolinking.rb +60 -0
  60. package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Bridge.cpp +80 -0
  61. package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Bridge.hpp +339 -0
  62. package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Umbrella.hpp +64 -0
  63. package/nitrogen/generated/ios/PdfViewerAutolinking.mm +33 -0
  64. package/nitrogen/generated/ios/PdfViewerAutolinking.swift +25 -0
  65. package/nitrogen/generated/ios/c++/HybridPdfViewerSpecSwift.cpp +11 -0
  66. package/nitrogen/generated/ios/c++/HybridPdfViewerSpecSwift.hpp +205 -0
  67. package/nitrogen/generated/ios/c++/views/HybridPdfViewerComponent.mm +161 -0
  68. package/nitrogen/generated/ios/swift/ErrorEvent.swift +46 -0
  69. package/nitrogen/generated/ios/swift/Func_void_ErrorEvent.swift +47 -0
  70. package/nitrogen/generated/ios/swift/Func_void_LoadCompleteEvent.swift +47 -0
  71. package/nitrogen/generated/ios/swift/Func_void_LoadingChangeEvent.swift +47 -0
  72. package/nitrogen/generated/ios/swift/Func_void_PageChangeEvent.swift +47 -0
  73. package/nitrogen/generated/ios/swift/Func_void_ScaleChangeEvent.swift +47 -0
  74. package/nitrogen/generated/ios/swift/Func_void_ThumbnailGeneratedEvent.swift +47 -0
  75. package/nitrogen/generated/ios/swift/HybridPdfViewerSpec.swift +65 -0
  76. package/nitrogen/generated/ios/swift/HybridPdfViewerSpec_cxx.swift +500 -0
  77. package/nitrogen/generated/ios/swift/LoadCompleteEvent.swift +57 -0
  78. package/nitrogen/generated/ios/swift/LoadingChangeEvent.swift +35 -0
  79. package/nitrogen/generated/ios/swift/PageChangeEvent.swift +46 -0
  80. package/nitrogen/generated/ios/swift/ScaleChangeEvent.swift +35 -0
  81. package/nitrogen/generated/ios/swift/ThumbnailGeneratedEvent.swift +46 -0
  82. package/nitrogen/generated/shared/c++/ErrorEvent.hpp +71 -0
  83. package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.cpp +52 -0
  84. package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.hpp +111 -0
  85. package/nitrogen/generated/shared/c++/LoadCompleteEvent.hpp +75 -0
  86. package/nitrogen/generated/shared/c++/LoadingChangeEvent.hpp +67 -0
  87. package/nitrogen/generated/shared/c++/PageChangeEvent.hpp +71 -0
  88. package/nitrogen/generated/shared/c++/ScaleChangeEvent.hpp +67 -0
  89. package/nitrogen/generated/shared/c++/ThumbnailGeneratedEvent.hpp +71 -0
  90. package/nitrogen/generated/shared/c++/views/HybridPdfViewerComponent.cpp +243 -0
  91. package/nitrogen/generated/shared/c++/views/HybridPdfViewerComponent.hpp +127 -0
  92. package/nitrogen/generated/shared/json/PdfViewerConfig.json +23 -0
  93. package/package.json +175 -0
  94. package/src/PdfViewer.nitro.ts +97 -0
  95. package/src/index.tsx +27 -0
@@ -0,0 +1,71 @@
1
+ ///
2
+ /// ThumbnailGeneratedEvent.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
+ #include <string>
24
+
25
+ namespace margelo::nitro::pdfviewer {
26
+
27
+ /**
28
+ * A struct which can be represented as a JavaScript object (ThumbnailGeneratedEvent).
29
+ */
30
+ struct ThumbnailGeneratedEvent {
31
+ public:
32
+ double page SWIFT_PRIVATE;
33
+ std::string uri SWIFT_PRIVATE;
34
+
35
+ public:
36
+ ThumbnailGeneratedEvent() = default;
37
+ explicit ThumbnailGeneratedEvent(double page, std::string uri): page(page), uri(uri) {}
38
+ };
39
+
40
+ } // namespace margelo::nitro::pdfviewer
41
+
42
+ namespace margelo::nitro {
43
+
44
+ // C++ ThumbnailGeneratedEvent <> JS ThumbnailGeneratedEvent (object)
45
+ template <>
46
+ struct JSIConverter<margelo::nitro::pdfviewer::ThumbnailGeneratedEvent> final {
47
+ static inline margelo::nitro::pdfviewer::ThumbnailGeneratedEvent fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
48
+ jsi::Object obj = arg.asObject(runtime);
49
+ return margelo::nitro::pdfviewer::ThumbnailGeneratedEvent(
50
+ JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "page")),
51
+ JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "uri"))
52
+ );
53
+ }
54
+ static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::pdfviewer::ThumbnailGeneratedEvent& arg) {
55
+ jsi::Object obj(runtime);
56
+ obj.setProperty(runtime, "page", JSIConverter<double>::toJSI(runtime, arg.page));
57
+ obj.setProperty(runtime, "uri", JSIConverter<std::string>::toJSI(runtime, arg.uri));
58
+ return obj;
59
+ }
60
+ static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
61
+ if (!value.isObject()) {
62
+ return false;
63
+ }
64
+ jsi::Object obj = value.getObject(runtime);
65
+ if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "page"))) return false;
66
+ if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "uri"))) return false;
67
+ return true;
68
+ }
69
+ };
70
+
71
+ } // namespace margelo::nitro
@@ -0,0 +1,243 @@
1
+ ///
2
+ /// HybridPdfViewerComponent.cpp
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
+ #include "HybridPdfViewerComponent.hpp"
9
+
10
+ #include <string>
11
+ #include <exception>
12
+ #include <utility>
13
+ #include <NitroModules/NitroDefines.hpp>
14
+ #include <NitroModules/JSIConverter.hpp>
15
+ #include <react/renderer/core/RawValue.h>
16
+ #include <react/renderer/core/ShadowNode.h>
17
+ #include <react/renderer/core/ComponentDescriptor.h>
18
+ #include <react/renderer/components/view/ViewProps.h>
19
+
20
+ namespace margelo::nitro::pdfviewer::views {
21
+
22
+ extern const char HybridPdfViewerComponentName[] = "PdfViewer";
23
+
24
+ HybridPdfViewerProps::HybridPdfViewerProps(const react::PropsParserContext& context,
25
+ const HybridPdfViewerProps& sourceProps,
26
+ const react::RawProps& rawProps):
27
+ react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
28
+ source([&]() -> CachedProp<std::optional<std::string>> {
29
+ try {
30
+ const react::RawValue* rawValue = rawProps.at("source", nullptr, nullptr);
31
+ if (rawValue == nullptr) return sourceProps.source;
32
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
33
+ return CachedProp<std::optional<std::string>>::fromRawValue(*runtime, value, sourceProps.source);
34
+ } catch (const std::exception& exc) {
35
+ throw std::runtime_error(std::string("PdfViewer.source: ") + exc.what());
36
+ }
37
+ }()),
38
+ horizontal([&]() -> CachedProp<std::optional<bool>> {
39
+ try {
40
+ const react::RawValue* rawValue = rawProps.at("horizontal", nullptr, nullptr);
41
+ if (rawValue == nullptr) return sourceProps.horizontal;
42
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
43
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.horizontal);
44
+ } catch (const std::exception& exc) {
45
+ throw std::runtime_error(std::string("PdfViewer.horizontal: ") + exc.what());
46
+ }
47
+ }()),
48
+ enablePaging([&]() -> CachedProp<std::optional<bool>> {
49
+ try {
50
+ const react::RawValue* rawValue = rawProps.at("enablePaging", nullptr, nullptr);
51
+ if (rawValue == nullptr) return sourceProps.enablePaging;
52
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
53
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enablePaging);
54
+ } catch (const std::exception& exc) {
55
+ throw std::runtime_error(std::string("PdfViewer.enablePaging: ") + exc.what());
56
+ }
57
+ }()),
58
+ spacing([&]() -> CachedProp<std::optional<double>> {
59
+ try {
60
+ const react::RawValue* rawValue = rawProps.at("spacing", nullptr, nullptr);
61
+ if (rawValue == nullptr) return sourceProps.spacing;
62
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
63
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.spacing);
64
+ } catch (const std::exception& exc) {
65
+ throw std::runtime_error(std::string("PdfViewer.spacing: ") + exc.what());
66
+ }
67
+ }()),
68
+ enableZoom([&]() -> CachedProp<std::optional<bool>> {
69
+ try {
70
+ const react::RawValue* rawValue = rawProps.at("enableZoom", nullptr, nullptr);
71
+ if (rawValue == nullptr) return sourceProps.enableZoom;
72
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
73
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.enableZoom);
74
+ } catch (const std::exception& exc) {
75
+ throw std::runtime_error(std::string("PdfViewer.enableZoom: ") + exc.what());
76
+ }
77
+ }()),
78
+ minScale([&]() -> CachedProp<std::optional<double>> {
79
+ try {
80
+ const react::RawValue* rawValue = rawProps.at("minScale", nullptr, nullptr);
81
+ if (rawValue == nullptr) return sourceProps.minScale;
82
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
83
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.minScale);
84
+ } catch (const std::exception& exc) {
85
+ throw std::runtime_error(std::string("PdfViewer.minScale: ") + exc.what());
86
+ }
87
+ }()),
88
+ maxScale([&]() -> CachedProp<std::optional<double>> {
89
+ try {
90
+ const react::RawValue* rawValue = rawProps.at("maxScale", nullptr, nullptr);
91
+ if (rawValue == nullptr) return sourceProps.maxScale;
92
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
93
+ return CachedProp<std::optional<double>>::fromRawValue(*runtime, value, sourceProps.maxScale);
94
+ } catch (const std::exception& exc) {
95
+ throw std::runtime_error(std::string("PdfViewer.maxScale: ") + exc.what());
96
+ }
97
+ }()),
98
+ showsActivityIndicator([&]() -> CachedProp<std::optional<bool>> {
99
+ try {
100
+ const react::RawValue* rawValue = rawProps.at("showsActivityIndicator", nullptr, nullptr);
101
+ if (rawValue == nullptr) return sourceProps.showsActivityIndicator;
102
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
103
+ return CachedProp<std::optional<bool>>::fromRawValue(*runtime, value, sourceProps.showsActivityIndicator);
104
+ } catch (const std::exception& exc) {
105
+ throw std::runtime_error(std::string("PdfViewer.showsActivityIndicator: ") + exc.what());
106
+ }
107
+ }()),
108
+ onLoadComplete([&]() -> CachedProp<std::optional<std::function<void(const LoadCompleteEvent& /* event */)>>> {
109
+ try {
110
+ const react::RawValue* rawValue = rawProps.at("onLoadComplete", nullptr, nullptr);
111
+ if (rawValue == nullptr) return sourceProps.onLoadComplete;
112
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
113
+ return CachedProp<std::optional<std::function<void(const LoadCompleteEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onLoadComplete);
114
+ } catch (const std::exception& exc) {
115
+ throw std::runtime_error(std::string("PdfViewer.onLoadComplete: ") + exc.what());
116
+ }
117
+ }()),
118
+ onPageChange([&]() -> CachedProp<std::optional<std::function<void(const PageChangeEvent& /* event */)>>> {
119
+ try {
120
+ const react::RawValue* rawValue = rawProps.at("onPageChange", nullptr, nullptr);
121
+ if (rawValue == nullptr) return sourceProps.onPageChange;
122
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
123
+ return CachedProp<std::optional<std::function<void(const PageChangeEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onPageChange);
124
+ } catch (const std::exception& exc) {
125
+ throw std::runtime_error(std::string("PdfViewer.onPageChange: ") + exc.what());
126
+ }
127
+ }()),
128
+ onScaleChange([&]() -> CachedProp<std::optional<std::function<void(const ScaleChangeEvent& /* event */)>>> {
129
+ try {
130
+ const react::RawValue* rawValue = rawProps.at("onScaleChange", nullptr, nullptr);
131
+ if (rawValue == nullptr) return sourceProps.onScaleChange;
132
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
133
+ return CachedProp<std::optional<std::function<void(const ScaleChangeEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onScaleChange);
134
+ } catch (const std::exception& exc) {
135
+ throw std::runtime_error(std::string("PdfViewer.onScaleChange: ") + exc.what());
136
+ }
137
+ }()),
138
+ onError([&]() -> CachedProp<std::optional<std::function<void(const ErrorEvent& /* event */)>>> {
139
+ try {
140
+ const react::RawValue* rawValue = rawProps.at("onError", nullptr, nullptr);
141
+ if (rawValue == nullptr) return sourceProps.onError;
142
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
143
+ return CachedProp<std::optional<std::function<void(const ErrorEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onError);
144
+ } catch (const std::exception& exc) {
145
+ throw std::runtime_error(std::string("PdfViewer.onError: ") + exc.what());
146
+ }
147
+ }()),
148
+ onThumbnailGenerated([&]() -> CachedProp<std::optional<std::function<void(const ThumbnailGeneratedEvent& /* event */)>>> {
149
+ try {
150
+ const react::RawValue* rawValue = rawProps.at("onThumbnailGenerated", nullptr, nullptr);
151
+ if (rawValue == nullptr) return sourceProps.onThumbnailGenerated;
152
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
153
+ return CachedProp<std::optional<std::function<void(const ThumbnailGeneratedEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onThumbnailGenerated);
154
+ } catch (const std::exception& exc) {
155
+ throw std::runtime_error(std::string("PdfViewer.onThumbnailGenerated: ") + exc.what());
156
+ }
157
+ }()),
158
+ onLoadingChange([&]() -> CachedProp<std::optional<std::function<void(const LoadingChangeEvent& /* event */)>>> {
159
+ try {
160
+ const react::RawValue* rawValue = rawProps.at("onLoadingChange", nullptr, nullptr);
161
+ if (rawValue == nullptr) return sourceProps.onLoadingChange;
162
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
163
+ return CachedProp<std::optional<std::function<void(const LoadingChangeEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.onLoadingChange);
164
+ } catch (const std::exception& exc) {
165
+ throw std::runtime_error(std::string("PdfViewer.onLoadingChange: ") + exc.what());
166
+ }
167
+ }()),
168
+ hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPdfViewerSpec>& /* ref */)>>> {
169
+ try {
170
+ const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
171
+ if (rawValue == nullptr) return sourceProps.hybridRef;
172
+ const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
173
+ return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPdfViewerSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, "f"), sourceProps.hybridRef);
174
+ } catch (const std::exception& exc) {
175
+ throw std::runtime_error(std::string("PdfViewer.hybridRef: ") + exc.what());
176
+ }
177
+ }()) { }
178
+
179
+ HybridPdfViewerProps::HybridPdfViewerProps(const HybridPdfViewerProps& other):
180
+ react::ViewProps(),
181
+ source(other.source),
182
+ horizontal(other.horizontal),
183
+ enablePaging(other.enablePaging),
184
+ spacing(other.spacing),
185
+ enableZoom(other.enableZoom),
186
+ minScale(other.minScale),
187
+ maxScale(other.maxScale),
188
+ showsActivityIndicator(other.showsActivityIndicator),
189
+ onLoadComplete(other.onLoadComplete),
190
+ onPageChange(other.onPageChange),
191
+ onScaleChange(other.onScaleChange),
192
+ onError(other.onError),
193
+ onThumbnailGenerated(other.onThumbnailGenerated),
194
+ onLoadingChange(other.onLoadingChange),
195
+ hybridRef(other.hybridRef) { }
196
+
197
+ bool HybridPdfViewerProps::filterObjectKeys(const std::string& propName) {
198
+ switch (hashString(propName)) {
199
+ case hashString("source"): return true;
200
+ case hashString("horizontal"): return true;
201
+ case hashString("enablePaging"): return true;
202
+ case hashString("spacing"): return true;
203
+ case hashString("enableZoom"): return true;
204
+ case hashString("minScale"): return true;
205
+ case hashString("maxScale"): return true;
206
+ case hashString("showsActivityIndicator"): return true;
207
+ case hashString("onLoadComplete"): return true;
208
+ case hashString("onPageChange"): return true;
209
+ case hashString("onScaleChange"): return true;
210
+ case hashString("onError"): return true;
211
+ case hashString("onThumbnailGenerated"): return true;
212
+ case hashString("onLoadingChange"): return true;
213
+ case hashString("hybridRef"): return true;
214
+ default: return false;
215
+ }
216
+ }
217
+
218
+ HybridPdfViewerComponentDescriptor::HybridPdfViewerComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
219
+ : ConcreteComponentDescriptor(parameters,
220
+ react::RawPropsParser(/* enableJsiParser */ true)) {}
221
+
222
+ std::shared_ptr<const react::Props> HybridPdfViewerComponentDescriptor::cloneProps(const react::PropsParserContext& context,
223
+ const std::shared_ptr<const react::Props>& props,
224
+ react::RawProps rawProps) const {
225
+ // 1. Prepare raw props parser
226
+ rawProps.parse(rawPropsParser_);
227
+ // 2. Copy props with Nitro's cached copy constructor
228
+ return HybridPdfViewerShadowNode::Props(context, /* & */ rawProps, props);
229
+ }
230
+
231
+ #ifdef ANDROID
232
+ void HybridPdfViewerComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
233
+ // This is called immediately after `ShadowNode` is created, cloned or in progress.
234
+ // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
235
+ auto& concreteShadowNode = dynamic_cast<HybridPdfViewerShadowNode&>(shadowNode);
236
+ const HybridPdfViewerProps& props = concreteShadowNode.getConcreteProps();
237
+ HybridPdfViewerState state;
238
+ state.setProps(props);
239
+ concreteShadowNode.setStateData(std::move(state));
240
+ }
241
+ #endif
242
+
243
+ } // namespace margelo::nitro::pdfviewer::views
@@ -0,0 +1,127 @@
1
+ ///
2
+ /// HybridPdfViewerComponent.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
+ #include <optional>
11
+ #include <NitroModules/NitroDefines.hpp>
12
+ #include <NitroModules/NitroHash.hpp>
13
+ #include <NitroModules/CachedProp.hpp>
14
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <react/renderer/components/view/ViewProps.h>
18
+
19
+ #include <string>
20
+ #include <optional>
21
+ #include "LoadCompleteEvent.hpp"
22
+ #include <functional>
23
+ #include "PageChangeEvent.hpp"
24
+ #include "ScaleChangeEvent.hpp"
25
+ #include "ErrorEvent.hpp"
26
+ #include "ThumbnailGeneratedEvent.hpp"
27
+ #include "LoadingChangeEvent.hpp"
28
+ #include <memory>
29
+ #include "HybridPdfViewerSpec.hpp"
30
+
31
+ namespace margelo::nitro::pdfviewer::views {
32
+
33
+ using namespace facebook;
34
+
35
+ /**
36
+ * The name of the actual native View.
37
+ */
38
+ extern const char HybridPdfViewerComponentName[];
39
+
40
+ /**
41
+ * Props for the "PdfViewer" View.
42
+ */
43
+ class HybridPdfViewerProps final: public react::ViewProps {
44
+ public:
45
+ HybridPdfViewerProps() = default;
46
+ HybridPdfViewerProps(const HybridPdfViewerProps&);
47
+ HybridPdfViewerProps(const react::PropsParserContext& context,
48
+ const HybridPdfViewerProps& sourceProps,
49
+ const react::RawProps& rawProps);
50
+
51
+ public:
52
+ CachedProp<std::optional<std::string>> source;
53
+ CachedProp<std::optional<bool>> horizontal;
54
+ CachedProp<std::optional<bool>> enablePaging;
55
+ CachedProp<std::optional<double>> spacing;
56
+ CachedProp<std::optional<bool>> enableZoom;
57
+ CachedProp<std::optional<double>> minScale;
58
+ CachedProp<std::optional<double>> maxScale;
59
+ CachedProp<std::optional<bool>> showsActivityIndicator;
60
+ CachedProp<std::optional<std::function<void(const LoadCompleteEvent& /* event */)>>> onLoadComplete;
61
+ CachedProp<std::optional<std::function<void(const PageChangeEvent& /* event */)>>> onPageChange;
62
+ CachedProp<std::optional<std::function<void(const ScaleChangeEvent& /* event */)>>> onScaleChange;
63
+ CachedProp<std::optional<std::function<void(const ErrorEvent& /* event */)>>> onError;
64
+ CachedProp<std::optional<std::function<void(const ThumbnailGeneratedEvent& /* event */)>>> onThumbnailGenerated;
65
+ CachedProp<std::optional<std::function<void(const LoadingChangeEvent& /* event */)>>> onLoadingChange;
66
+ CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridPdfViewerSpec>& /* ref */)>>> hybridRef;
67
+
68
+ private:
69
+ static bool filterObjectKeys(const std::string& propName);
70
+ };
71
+
72
+ /**
73
+ * State for the "PdfViewer" View.
74
+ */
75
+ class HybridPdfViewerState final {
76
+ public:
77
+ HybridPdfViewerState() = default;
78
+
79
+ public:
80
+ void setProps(const HybridPdfViewerProps& props) { _props.emplace(props); }
81
+ const std::optional<HybridPdfViewerProps>& getProps() const { return _props; }
82
+
83
+ public:
84
+ #ifdef ANDROID
85
+ HybridPdfViewerState(const HybridPdfViewerState& /* previousState */, folly::dynamic /* data */) {}
86
+ folly::dynamic getDynamic() const {
87
+ throw std::runtime_error("HybridPdfViewerState does not support folly!");
88
+ }
89
+ react::MapBuffer getMapBuffer() const {
90
+ throw std::runtime_error("HybridPdfViewerState does not support MapBuffer!");
91
+ };
92
+ #endif
93
+
94
+ private:
95
+ std::optional<HybridPdfViewerProps> _props;
96
+ };
97
+
98
+ /**
99
+ * The Shadow Node for the "PdfViewer" View.
100
+ */
101
+ using HybridPdfViewerShadowNode = react::ConcreteViewShadowNode<HybridPdfViewerComponentName /* "HybridPdfViewer" */,
102
+ HybridPdfViewerProps /* custom props */,
103
+ react::ViewEventEmitter /* default */,
104
+ HybridPdfViewerState /* custom state */>;
105
+
106
+ /**
107
+ * The Component Descriptor for the "PdfViewer" View.
108
+ */
109
+ class HybridPdfViewerComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridPdfViewerShadowNode> {
110
+ public:
111
+ HybridPdfViewerComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
112
+
113
+ public:
114
+ /**
115
+ * A faster path for cloning props - reuses the caching logic from `HybridPdfViewerProps`.
116
+ */
117
+ std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
118
+ const std::shared_ptr<const react::Props>& props,
119
+ react::RawProps rawProps) const override;
120
+ #ifdef ANDROID
121
+ void adopt(react::ShadowNode& shadowNode) const override;
122
+ #endif
123
+ };
124
+
125
+ /* The actual view for "PdfViewer" needs to be implemented in platform-specific code. */
126
+
127
+ } // namespace margelo::nitro::pdfviewer::views
@@ -0,0 +1,23 @@
1
+ {
2
+ "uiViewClassName": "PdfViewer",
3
+ "supportsRawText": false,
4
+ "bubblingEventTypes": {},
5
+ "directEventTypes": {},
6
+ "validAttributes": {
7
+ "source": true,
8
+ "horizontal": true,
9
+ "enablePaging": true,
10
+ "spacing": true,
11
+ "enableZoom": true,
12
+ "minScale": true,
13
+ "maxScale": true,
14
+ "showsActivityIndicator": true,
15
+ "onLoadComplete": true,
16
+ "onPageChange": true,
17
+ "onScaleChange": true,
18
+ "onError": true,
19
+ "onThumbnailGenerated": true,
20
+ "onLoadingChange": true,
21
+ "hybridRef": true
22
+ }
23
+ }
package/package.json ADDED
@@ -0,0 +1,175 @@
1
+ {
2
+ "name": "@thatkid02/react-native-pdf-viewer",
3
+ "version": "0.0.1",
4
+ "description": "Pdf viewer with page thumbnailsthumbnails",
5
+ "main": "./lib/module/index.js",
6
+ "types": "./lib/typescript/src/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "source": "./src/index.tsx",
10
+ "types": "./lib/typescript/src/index.d.ts",
11
+ "default": "./lib/module/index.js"
12
+ },
13
+ "./package.json": "./package.json"
14
+ },
15
+ "files": [
16
+ "src",
17
+ "lib",
18
+ "android",
19
+ "ios",
20
+ "cpp",
21
+ "nitrogen",
22
+ "nitro.json",
23
+ "*.podspec",
24
+ "react-native.config.js",
25
+ "!ios/build",
26
+ "!android/build",
27
+ "!android/gradle",
28
+ "!android/gradlew",
29
+ "!android/gradlew.bat",
30
+ "!android/local.properties",
31
+ "!**/__tests__",
32
+ "!**/__fixtures__",
33
+ "!**/__mocks__",
34
+ "!**/.*"
35
+ ],
36
+ "scripts": {
37
+ "example": "yarn workspace react-native-pdf-viewer-example",
38
+ "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
39
+ "prepare": "bob build",
40
+ "nitrogen": "nitrogen",
41
+ "typecheck": "tsc",
42
+ "test": "jest",
43
+ "release": "release-it --only-version",
44
+ "lint": "eslint \"**/*.{js,ts,tsx}\""
45
+ },
46
+ "keywords": [
47
+ "react-native",
48
+ "ios",
49
+ "android"
50
+ ],
51
+ "repository": {
52
+ "type": "git",
53
+ "url": "git+https://github.com/thatkid02/react-native-pdf-viewer.git"
54
+ },
55
+ "author": "thatkid02 <nelsondsouza02@gmail.com> (https://github.com/thatkid02)",
56
+ "license": "MIT",
57
+ "bugs": {
58
+ "url": "https://github.com/thatkid02/react-native-pdf-viewer/issues"
59
+ },
60
+ "homepage": "https://github.com/thatkid02/react-native-pdf-viewer#readme",
61
+ "publishConfig": {
62
+ "access": "public",
63
+ "registry": "https://registry.npmjs.org/"
64
+ },
65
+ "devDependencies": {
66
+ "@commitlint/config-conventional": "^19.8.1",
67
+ "@eslint/compat": "^1.3.2",
68
+ "@eslint/eslintrc": "^3.3.1",
69
+ "@eslint/js": "^9.35.0",
70
+ "@react-native/babel-preset": "0.83.0",
71
+ "@react-native/eslint-config": "0.83.0",
72
+ "@release-it/conventional-changelog": "^10.0.1",
73
+ "@types/jest": "^29.5.14",
74
+ "@types/react": "^19.2.0",
75
+ "commitlint": "^19.8.1",
76
+ "del-cli": "^6.0.0",
77
+ "eslint": "^9.35.0",
78
+ "eslint-config-prettier": "^10.1.8",
79
+ "eslint-plugin-prettier": "^5.5.4",
80
+ "jest": "^29.7.0",
81
+ "lefthook": "^2.0.3",
82
+ "nitrogen": "^0.29.8",
83
+ "prettier": "^2.8.8",
84
+ "react": "19.2.0",
85
+ "react-native": "0.83.0",
86
+ "react-native-builder-bob": "^0.40.13",
87
+ "react-native-nitro-modules": "^0.29.8",
88
+ "release-it": "^19.0.4",
89
+ "turbo": "^2.5.6",
90
+ "typescript": "^5.9.2"
91
+ },
92
+ "peerDependencies": {
93
+ "react": "*",
94
+ "react-native": "*",
95
+ "react-native-nitro-modules": "^0.29.8"
96
+ },
97
+ "workspaces": [
98
+ "example"
99
+ ],
100
+ "packageManager": "yarn@4.11.0",
101
+ "react-native-builder-bob": {
102
+ "source": "src",
103
+ "output": "lib",
104
+ "targets": [
105
+ [
106
+ "custom",
107
+ {
108
+ "script": "nitrogen",
109
+ "clean": "nitrogen/"
110
+ }
111
+ ],
112
+ [
113
+ "module",
114
+ {
115
+ "esm": true
116
+ }
117
+ ],
118
+ [
119
+ "typescript",
120
+ {
121
+ "project": "tsconfig.build.json"
122
+ }
123
+ ]
124
+ ]
125
+ },
126
+ "jest": {
127
+ "preset": "react-native",
128
+ "modulePathIgnorePatterns": [
129
+ "<rootDir>/example/node_modules",
130
+ "<rootDir>/lib/"
131
+ ]
132
+ },
133
+ "commitlint": {
134
+ "extends": [
135
+ "@commitlint/config-conventional"
136
+ ]
137
+ },
138
+ "release-it": {
139
+ "git": {
140
+ "commitMessage": "chore: release ${version}",
141
+ "tagName": "v${version}"
142
+ },
143
+ "npm": {
144
+ "publish": true
145
+ },
146
+ "github": {
147
+ "release": true
148
+ },
149
+ "plugins": {
150
+ "@release-it/conventional-changelog": {
151
+ "preset": {
152
+ "name": "angular"
153
+ }
154
+ }
155
+ }
156
+ },
157
+ "prettier": {
158
+ "quoteProps": "consistent",
159
+ "singleQuote": true,
160
+ "tabWidth": 2,
161
+ "trailingComma": "es5",
162
+ "useTabs": false
163
+ },
164
+ "create-react-native-library": {
165
+ "type": "nitro-view",
166
+ "languages": "kotlin-swift",
167
+ "tools": [
168
+ "jest",
169
+ "lefthook",
170
+ "release-it",
171
+ "eslint"
172
+ ],
173
+ "version": "0.57.0"
174
+ }
175
+ }