react-native-pdf-sdk 0.1.1 → 0.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 (105) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +19 -13
  3. package/nitrogen/generated/android/PdfSdk+autolinking.cmake +1 -1
  4. package/nitrogen/generated/android/PdfSdk+autolinking.gradle +1 -1
  5. package/nitrogen/generated/android/PdfSdkOnLoad.cpp +1 -1
  6. package/nitrogen/generated/android/PdfSdkOnLoad.hpp +1 -1
  7. package/nitrogen/generated/android/c++/JFunc_void_PdfErrorEvent.hpp +1 -1
  8. package/nitrogen/generated/android/c++/JFunc_void_PdfLoadEvent.hpp +1 -1
  9. package/nitrogen/generated/android/c++/JFunc_void_PdfPageEvent.hpp +1 -1
  10. package/nitrogen/generated/android/c++/JFunc_void_PdfTapEvent.hpp +1 -1
  11. package/nitrogen/generated/android/c++/JFunc_void_PdfZoomEvent.hpp +1 -1
  12. package/nitrogen/generated/android/c++/JHybridNativePdfViewSpec.cpp +1 -1
  13. package/nitrogen/generated/android/c++/JHybridNativePdfViewSpec.hpp +1 -1
  14. package/nitrogen/generated/android/c++/JHybridPdfDocumentSpec.cpp +1 -1
  15. package/nitrogen/generated/android/c++/JHybridPdfDocumentSpec.hpp +1 -1
  16. package/nitrogen/generated/android/c++/JHybridPdfSdkSpec.cpp +1 -1
  17. package/nitrogen/generated/android/c++/JHybridPdfSdkSpec.hpp +1 -1
  18. package/nitrogen/generated/android/c++/JPdfErrorCode.hpp +2 -2
  19. package/nitrogen/generated/android/c++/JPdfErrorEvent.hpp +2 -2
  20. package/nitrogen/generated/android/c++/JPdfFit.hpp +2 -2
  21. package/nitrogen/generated/android/c++/JPdfLoadEvent.hpp +2 -2
  22. package/nitrogen/generated/android/c++/JPdfPageEvent.hpp +2 -2
  23. package/nitrogen/generated/android/c++/JPdfPageSize.hpp +2 -2
  24. package/nitrogen/generated/android/c++/JPdfRenderRequest.hpp +2 -2
  25. package/nitrogen/generated/android/c++/JPdfTapEvent.hpp +2 -2
  26. package/nitrogen/generated/android/c++/JPdfViewSource.hpp +2 -2
  27. package/nitrogen/generated/android/c++/JPdfZoomEvent.hpp +2 -2
  28. package/nitrogen/generated/android/c++/views/JHybridNativePdfViewStateUpdater.cpp +103 -72
  29. package/nitrogen/generated/android/c++/views/JHybridNativePdfViewStateUpdater.hpp +7 -2
  30. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/Func_void_PdfErrorEvent.kt +1 -3
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/Func_void_PdfLoadEvent.kt +1 -3
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/Func_void_PdfPageEvent.kt +1 -3
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/Func_void_PdfTapEvent.kt +1 -3
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/Func_void_PdfZoomEvent.kt +1 -3
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/HybridNativePdfViewSpec.kt +3 -1
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/HybridPdfDocumentSpec.kt +3 -1
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/HybridPdfSdkSpec.kt +3 -1
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfErrorCode.kt +1 -1
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfErrorEvent.kt +2 -2
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfFit.kt +1 -1
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfLoadEvent.kt +2 -2
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfPageEvent.kt +2 -2
  43. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfPageSize.kt +2 -2
  44. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfRenderRequest.kt +2 -2
  45. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfSdkOnLoad.kt +1 -1
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfTapEvent.kt +2 -2
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfViewSource.kt +2 -2
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/PdfZoomEvent.kt +2 -2
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/views/HybridNativePdfViewManager.kt +30 -14
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfsdk/views/HybridNativePdfViewStateUpdater.kt +3 -3
  51. package/nitrogen/generated/ios/PdfSdk+autolinking.rb +1 -1
  52. package/nitrogen/generated/ios/PdfSdk-Swift-Cxx-Bridge.cpp +1 -1
  53. package/nitrogen/generated/ios/PdfSdk-Swift-Cxx-Bridge.hpp +1 -1
  54. package/nitrogen/generated/ios/PdfSdk-Swift-Cxx-Umbrella.hpp +1 -1
  55. package/nitrogen/generated/ios/PdfSdkAutolinking.mm +1 -1
  56. package/nitrogen/generated/ios/PdfSdkAutolinking.swift +1 -5
  57. package/nitrogen/generated/ios/c++/HybridNativePdfViewSpecSwift.cpp +1 -1
  58. package/nitrogen/generated/ios/c++/HybridNativePdfViewSpecSwift.hpp +1 -1
  59. package/nitrogen/generated/ios/c++/HybridPdfDocumentSpecSwift.cpp +1 -1
  60. package/nitrogen/generated/ios/c++/HybridPdfDocumentSpecSwift.hpp +1 -1
  61. package/nitrogen/generated/ios/c++/HybridPdfSdkSpecSwift.cpp +1 -1
  62. package/nitrogen/generated/ios/c++/HybridPdfSdkSpecSwift.hpp +1 -1
  63. package/nitrogen/generated/ios/c++/views/HybridNativePdfViewComponent.mm +123 -88
  64. package/nitrogen/generated/ios/swift/Func_void_PdfErrorEvent.swift +1 -1
  65. package/nitrogen/generated/ios/swift/Func_void_PdfLoadEvent.swift +1 -1
  66. package/nitrogen/generated/ios/swift/Func_void_PdfPageEvent.swift +1 -1
  67. package/nitrogen/generated/ios/swift/Func_void_PdfTapEvent.swift +1 -1
  68. package/nitrogen/generated/ios/swift/Func_void_PdfZoomEvent.swift +1 -1
  69. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +1 -1
  70. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +1 -1
  71. package/nitrogen/generated/ios/swift/HybridNativePdfViewSpec.swift +1 -1
  72. package/nitrogen/generated/ios/swift/HybridNativePdfViewSpec_cxx.swift +3 -3
  73. package/nitrogen/generated/ios/swift/HybridPdfDocumentSpec.swift +1 -1
  74. package/nitrogen/generated/ios/swift/HybridPdfDocumentSpec_cxx.swift +3 -3
  75. package/nitrogen/generated/ios/swift/HybridPdfSdkSpec.swift +1 -1
  76. package/nitrogen/generated/ios/swift/HybridPdfSdkSpec_cxx.swift +3 -3
  77. package/nitrogen/generated/ios/swift/PdfErrorCode.swift +1 -1
  78. package/nitrogen/generated/ios/swift/PdfErrorEvent.swift +1 -1
  79. package/nitrogen/generated/ios/swift/PdfFit.swift +1 -1
  80. package/nitrogen/generated/ios/swift/PdfLoadEvent.swift +1 -1
  81. package/nitrogen/generated/ios/swift/PdfPageEvent.swift +1 -1
  82. package/nitrogen/generated/ios/swift/PdfPageSize.swift +1 -1
  83. package/nitrogen/generated/ios/swift/PdfRenderRequest.swift +1 -1
  84. package/nitrogen/generated/ios/swift/PdfTapEvent.swift +1 -1
  85. package/nitrogen/generated/ios/swift/PdfViewSource.swift +1 -1
  86. package/nitrogen/generated/ios/swift/PdfZoomEvent.swift +1 -1
  87. package/nitrogen/generated/shared/c++/HybridNativePdfViewSpec.cpp +1 -1
  88. package/nitrogen/generated/shared/c++/HybridNativePdfViewSpec.hpp +1 -1
  89. package/nitrogen/generated/shared/c++/HybridPdfDocumentSpec.cpp +1 -1
  90. package/nitrogen/generated/shared/c++/HybridPdfDocumentSpec.hpp +1 -1
  91. package/nitrogen/generated/shared/c++/HybridPdfSdkSpec.cpp +1 -1
  92. package/nitrogen/generated/shared/c++/HybridPdfSdkSpec.hpp +1 -1
  93. package/nitrogen/generated/shared/c++/PdfErrorCode.hpp +1 -1
  94. package/nitrogen/generated/shared/c++/PdfErrorEvent.hpp +1 -1
  95. package/nitrogen/generated/shared/c++/PdfFit.hpp +1 -1
  96. package/nitrogen/generated/shared/c++/PdfLoadEvent.hpp +1 -1
  97. package/nitrogen/generated/shared/c++/PdfPageEvent.hpp +1 -1
  98. package/nitrogen/generated/shared/c++/PdfPageSize.hpp +1 -1
  99. package/nitrogen/generated/shared/c++/PdfRenderRequest.hpp +1 -1
  100. package/nitrogen/generated/shared/c++/PdfTapEvent.hpp +1 -1
  101. package/nitrogen/generated/shared/c++/PdfViewSource.hpp +1 -1
  102. package/nitrogen/generated/shared/c++/PdfZoomEvent.hpp +1 -1
  103. package/nitrogen/generated/shared/c++/views/HybridNativePdfViewComponent.cpp +25 -186
  104. package/nitrogen/generated/shared/c++/views/HybridNativePdfViewComponent.hpp +63 -63
  105. package/package.json +11 -6
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfLoadEvent.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfPageEvent.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfPageSize.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfRenderRequest.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfTapEvent.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfViewSource.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// PdfZoomEvent.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,181 +1,45 @@
1
1
  ///
2
2
  /// HybridNativePdfViewComponent.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #include "HybridNativePdfViewComponent.hpp"
9
9
 
10
- #include <string>
11
- #include <exception>
12
- #include <utility>
13
- #include <NitroModules/NitroDefines.hpp>
14
- #include <NitroModules/JSIConverter.hpp>
15
- #include <NitroModules/PropNameIDCache.hpp>
16
- #include <react/renderer/core/RawValue.h>
17
- #include <react/renderer/core/ShadowNode.h>
18
- #include <react/renderer/core/ComponentDescriptor.h>
19
- #include <react/renderer/components/view/ViewProps.h>
10
+ #include <NitroModules/NitroHash.hpp>
11
+ #include <NitroModules/RawPropsCompat.hpp>
12
+ #include <NitroModules/ReactProp.hpp>
20
13
 
21
14
  namespace margelo::nitro::pdfsdk::views {
22
15
 
16
+ using namespace facebook;
17
+
23
18
  extern const char HybridNativePdfViewComponentName[] = "NativePdfView";
24
19
 
25
20
  HybridNativePdfViewProps::HybridNativePdfViewProps(const react::PropsParserContext& context,
26
21
  const HybridNativePdfViewProps& sourceProps,
27
22
  const react::RawProps& rawProps):
28
23
  react::ViewProps(context, sourceProps, rawProps, filterObjectKeys),
29
- source([&]() -> CachedProp<PdfViewSource> {
30
- try {
31
- const react::RawValue* rawValue = rawProps.at("source", nullptr, nullptr);
32
- if (rawValue == nullptr) return sourceProps.source;
33
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
34
- return CachedProp<PdfViewSource>::fromRawValue(*runtime, value, sourceProps.source);
35
- } catch (const std::exception& exc) {
36
- throw std::runtime_error(std::string("NativePdfView.source: ") + exc.what());
37
- }
38
- }()),
39
- page([&]() -> CachedProp<double> {
40
- try {
41
- const react::RawValue* rawValue = rawProps.at("page", nullptr, nullptr);
42
- if (rawValue == nullptr) return sourceProps.page;
43
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
44
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.page);
45
- } catch (const std::exception& exc) {
46
- throw std::runtime_error(std::string("NativePdfView.page: ") + exc.what());
47
- }
48
- }()),
49
- fit([&]() -> CachedProp<PdfFit> {
50
- try {
51
- const react::RawValue* rawValue = rawProps.at("fit", nullptr, nullptr);
52
- if (rawValue == nullptr) return sourceProps.fit;
53
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
54
- return CachedProp<PdfFit>::fromRawValue(*runtime, value, sourceProps.fit);
55
- } catch (const std::exception& exc) {
56
- throw std::runtime_error(std::string("NativePdfView.fit: ") + exc.what());
57
- }
58
- }()),
59
- minZoom([&]() -> CachedProp<double> {
60
- try {
61
- const react::RawValue* rawValue = rawProps.at("minZoom", nullptr, nullptr);
62
- if (rawValue == nullptr) return sourceProps.minZoom;
63
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
64
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.minZoom);
65
- } catch (const std::exception& exc) {
66
- throw std::runtime_error(std::string("NativePdfView.minZoom: ") + exc.what());
67
- }
68
- }()),
69
- maxZoom([&]() -> CachedProp<double> {
70
- try {
71
- const react::RawValue* rawValue = rawProps.at("maxZoom", nullptr, nullptr);
72
- if (rawValue == nullptr) return sourceProps.maxZoom;
73
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
74
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.maxZoom);
75
- } catch (const std::exception& exc) {
76
- throw std::runtime_error(std::string("NativePdfView.maxZoom: ") + exc.what());
77
- }
78
- }()),
79
- doubleTapZoom([&]() -> CachedProp<double> {
80
- try {
81
- const react::RawValue* rawValue = rawProps.at("doubleTapZoom", nullptr, nullptr);
82
- if (rawValue == nullptr) return sourceProps.doubleTapZoom;
83
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
84
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.doubleTapZoom);
85
- } catch (const std::exception& exc) {
86
- throw std::runtime_error(std::string("NativePdfView.doubleTapZoom: ") + exc.what());
87
- }
88
- }()),
89
- pageGap([&]() -> CachedProp<double> {
90
- try {
91
- const react::RawValue* rawValue = rawProps.at("pageGap", nullptr, nullptr);
92
- if (rawValue == nullptr) return sourceProps.pageGap;
93
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
94
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.pageGap);
95
- } catch (const std::exception& exc) {
96
- throw std::runtime_error(std::string("NativePdfView.pageGap: ") + exc.what());
97
- }
98
- }()),
99
- backdropColor([&]() -> CachedProp<double> {
100
- try {
101
- const react::RawValue* rawValue = rawProps.at("backdropColor", nullptr, nullptr);
102
- if (rawValue == nullptr) return sourceProps.backdropColor;
103
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
104
- return CachedProp<double>::fromRawValue(*runtime, value, sourceProps.backdropColor);
105
- } catch (const std::exception& exc) {
106
- throw std::runtime_error(std::string("NativePdfView.backdropColor: ") + exc.what());
107
- }
108
- }()),
109
- scrollIndicators([&]() -> CachedProp<bool> {
110
- try {
111
- const react::RawValue* rawValue = rawProps.at("scrollIndicators", nullptr, nullptr);
112
- if (rawValue == nullptr) return sourceProps.scrollIndicators;
113
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
114
- return CachedProp<bool>::fromRawValue(*runtime, value, sourceProps.scrollIndicators);
115
- } catch (const std::exception& exc) {
116
- throw std::runtime_error(std::string("NativePdfView.scrollIndicators: ") + exc.what());
117
- }
118
- }()),
119
- onLoad([&]() -> CachedProp<std::optional<std::function<void(const PdfLoadEvent& /* event */)>>> {
120
- try {
121
- const react::RawValue* rawValue = rawProps.at("onLoad", nullptr, nullptr);
122
- if (rawValue == nullptr) return sourceProps.onLoad;
123
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
124
- return CachedProp<std::optional<std::function<void(const PdfLoadEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onLoad);
125
- } catch (const std::exception& exc) {
126
- throw std::runtime_error(std::string("NativePdfView.onLoad: ") + exc.what());
127
- }
128
- }()),
129
- onPageChange([&]() -> CachedProp<std::optional<std::function<void(const PdfPageEvent& /* event */)>>> {
130
- try {
131
- const react::RawValue* rawValue = rawProps.at("onPageChange", nullptr, nullptr);
132
- if (rawValue == nullptr) return sourceProps.onPageChange;
133
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
134
- return CachedProp<std::optional<std::function<void(const PdfPageEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onPageChange);
135
- } catch (const std::exception& exc) {
136
- throw std::runtime_error(std::string("NativePdfView.onPageChange: ") + exc.what());
137
- }
138
- }()),
139
- onZoom([&]() -> CachedProp<std::optional<std::function<void(const PdfZoomEvent& /* event */)>>> {
140
- try {
141
- const react::RawValue* rawValue = rawProps.at("onZoom", nullptr, nullptr);
142
- if (rawValue == nullptr) return sourceProps.onZoom;
143
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
144
- return CachedProp<std::optional<std::function<void(const PdfZoomEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onZoom);
145
- } catch (const std::exception& exc) {
146
- throw std::runtime_error(std::string("NativePdfView.onZoom: ") + exc.what());
147
- }
148
- }()),
149
- onError([&]() -> CachedProp<std::optional<std::function<void(const PdfErrorEvent& /* event */)>>> {
150
- try {
151
- const react::RawValue* rawValue = rawProps.at("onError", nullptr, nullptr);
152
- if (rawValue == nullptr) return sourceProps.onError;
153
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
154
- return CachedProp<std::optional<std::function<void(const PdfErrorEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onError);
155
- } catch (const std::exception& exc) {
156
- throw std::runtime_error(std::string("NativePdfView.onError: ") + exc.what());
157
- }
158
- }()),
159
- onTap([&]() -> CachedProp<std::optional<std::function<void(const PdfTapEvent& /* event */)>>> {
160
- try {
161
- const react::RawValue* rawValue = rawProps.at("onTap", nullptr, nullptr);
162
- if (rawValue == nullptr) return sourceProps.onTap;
163
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
164
- return CachedProp<std::optional<std::function<void(const PdfTapEvent& /* event */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.onTap);
165
- } catch (const std::exception& exc) {
166
- throw std::runtime_error(std::string("NativePdfView.onTap: ") + exc.what());
167
- }
168
- }()),
169
- hybridRef([&]() -> CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNativePdfViewSpec>& /* ref */)>>> {
170
- try {
171
- const react::RawValue* rawValue = rawProps.at("hybridRef", nullptr, nullptr);
172
- if (rawValue == nullptr) return sourceProps.hybridRef;
173
- const auto& [runtime, value] = (std::pair<jsi::Runtime*, jsi::Value>)*rawValue;
174
- return CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNativePdfViewSpec>& /* ref */)>>>::fromRawValue(*runtime, value.asObject(*runtime).getProperty(*runtime, PropNameIDCache::get(*runtime, "f")), sourceProps.hybridRef);
175
- } catch (const std::exception& exc) {
176
- throw std::runtime_error(std::string("NativePdfView.hybridRef: ") + exc.what());
177
- }
178
- }()) { }
24
+ source(nitro::ReactProp<PdfViewSource>::fromRawValue("NativePdfView", "source", rawProps, sourceProps.source)),
25
+ page(nitro::ReactProp<double>::fromRawValue("NativePdfView", "page", rawProps, sourceProps.page)),
26
+ fit(nitro::ReactProp<PdfFit>::fromRawValue("NativePdfView", "fit", rawProps, sourceProps.fit)),
27
+ minZoom(nitro::ReactProp<double>::fromRawValue("NativePdfView", "minZoom", rawProps, sourceProps.minZoom)),
28
+ maxZoom(nitro::ReactProp<double>::fromRawValue("NativePdfView", "maxZoom", rawProps, sourceProps.maxZoom)),
29
+ doubleTapZoom(nitro::ReactProp<double>::fromRawValue("NativePdfView", "doubleTapZoom", rawProps, sourceProps.doubleTapZoom)),
30
+ pageGap(nitro::ReactProp<double>::fromRawValue("NativePdfView", "pageGap", rawProps, sourceProps.pageGap)),
31
+ backdropColor(nitro::ReactProp<double>::fromRawValue("NativePdfView", "backdropColor", rawProps, sourceProps.backdropColor)),
32
+ scrollIndicators(nitro::ReactProp<bool>::fromRawValue("NativePdfView", "scrollIndicators", rawProps, sourceProps.scrollIndicators)),
33
+ onLoad(nitro::ReactProp<std::optional<std::function<void(const PdfLoadEvent& /* event */)>>>::fromRawValue("NativePdfView", "onLoad", rawProps, sourceProps.onLoad)),
34
+ onPageChange(nitro::ReactProp<std::optional<std::function<void(const PdfPageEvent& /* event */)>>>::fromRawValue("NativePdfView", "onPageChange", rawProps, sourceProps.onPageChange)),
35
+ onZoom(nitro::ReactProp<std::optional<std::function<void(const PdfZoomEvent& /* event */)>>>::fromRawValue("NativePdfView", "onZoom", rawProps, sourceProps.onZoom)),
36
+ onError(nitro::ReactProp<std::optional<std::function<void(const PdfErrorEvent& /* event */)>>>::fromRawValue("NativePdfView", "onError", rawProps, sourceProps.onError)),
37
+ onTap(nitro::ReactProp<std::optional<std::function<void(const PdfTapEvent& /* event */)>>>::fromRawValue("NativePdfView", "onTap", rawProps, sourceProps.onTap)),
38
+ hybridRef(nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativePdfViewSpec>& /* ref */)>>>::fromRawValue("NativePdfView", "hybridRef", rawProps, sourceProps.hybridRef)) {
39
+ #ifdef ANDROID
40
+ nitro::RawPropsCompat::initializeDynamicProps(*this, sourceProps, rawProps, filterObjectKeys);
41
+ #endif
42
+ }
179
43
 
180
44
  bool HybridNativePdfViewProps::filterObjectKeys(const std::string& propName) {
181
45
  switch (hashString(propName)) {
@@ -198,29 +62,4 @@ namespace margelo::nitro::pdfsdk::views {
198
62
  }
199
63
  }
200
64
 
201
- HybridNativePdfViewComponentDescriptor::HybridNativePdfViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters)
202
- : ConcreteComponentDescriptor(parameters,
203
- react::RawPropsParser(/* enableJsiParser */ true)) {}
204
-
205
- std::shared_ptr<const react::Props> HybridNativePdfViewComponentDescriptor::cloneProps(const react::PropsParserContext& context,
206
- const std::shared_ptr<const react::Props>& props,
207
- react::RawProps rawProps) const {
208
- // 1. Prepare raw props parser
209
- rawProps.parse(rawPropsParser_);
210
- // 2. Copy props with Nitro's cached copy constructor
211
- return HybridNativePdfViewShadowNode::Props(context, /* & */ rawProps, props);
212
- }
213
-
214
- #ifdef ANDROID
215
- void HybridNativePdfViewComponentDescriptor::adopt(react::ShadowNode& shadowNode) const {
216
- // This is called immediately after `ShadowNode` is created, cloned or in progress.
217
- // On Android, we need to wrap props in our state, which gets routed through Java and later unwrapped in JNI/C++.
218
- auto& concreteShadowNode = static_cast<HybridNativePdfViewShadowNode&>(shadowNode);
219
- const std::shared_ptr<const HybridNativePdfViewProps>& constProps = concreteShadowNode.getConcreteSharedProps();
220
- const std::shared_ptr<HybridNativePdfViewProps>& props = std::const_pointer_cast<HybridNativePdfViewProps>(constProps);
221
- HybridNativePdfViewState state{props};
222
- concreteShadowNode.setStateData(std::move(state));
223
- }
224
- #endif
225
-
226
65
  } // namespace margelo::nitro::pdfsdk::views
@@ -1,20 +1,21 @@
1
1
  ///
2
2
  /// HybridNativePdfViewComponent.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
8
8
  #pragma once
9
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>
10
+ #include <NitroModules/ReactProp.hpp>
11
+ #include <NitroModules/ViewComponentDescriptor.hpp>
12
+ #include <NitroModules/ViewPropsHolderState.hpp>
16
13
  #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
14
  #include <react/renderer/components/view/ViewProps.h>
15
+ #include <react/renderer/core/PropsParserContext.h>
16
+ #include <react/renderer/core/RawProps.h>
17
+
18
+ #include <string>
18
19
 
19
20
  #include "PdfViewSource.hpp"
20
21
  #include "PdfFit.hpp"
@@ -48,21 +49,59 @@ namespace margelo::nitro::pdfsdk::views {
48
49
  const react::RawProps& rawProps);
49
50
 
50
51
  public:
51
- CachedProp<PdfViewSource> source;
52
- CachedProp<double> page;
53
- CachedProp<PdfFit> fit;
54
- CachedProp<double> minZoom;
55
- CachedProp<double> maxZoom;
56
- CachedProp<double> doubleTapZoom;
57
- CachedProp<double> pageGap;
58
- CachedProp<double> backdropColor;
59
- CachedProp<bool> scrollIndicators;
60
- CachedProp<std::optional<std::function<void(const PdfLoadEvent& /* event */)>>> onLoad;
61
- CachedProp<std::optional<std::function<void(const PdfPageEvent& /* event */)>>> onPageChange;
62
- CachedProp<std::optional<std::function<void(const PdfZoomEvent& /* event */)>>> onZoom;
63
- CachedProp<std::optional<std::function<void(const PdfErrorEvent& /* event */)>>> onError;
64
- CachedProp<std::optional<std::function<void(const PdfTapEvent& /* event */)>>> onTap;
65
- CachedProp<std::optional<std::function<void(const std::shared_ptr<HybridNativePdfViewSpec>& /* ref */)>>> hybridRef;
52
+ nitro::ReactProp<PdfViewSource> source;
53
+ nitro::ReactProp<double> page;
54
+ nitro::ReactProp<PdfFit> fit;
55
+ nitro::ReactProp<double> minZoom;
56
+ nitro::ReactProp<double> maxZoom;
57
+ nitro::ReactProp<double> doubleTapZoom;
58
+ nitro::ReactProp<double> pageGap;
59
+ nitro::ReactProp<double> backdropColor;
60
+ nitro::ReactProp<bool> scrollIndicators;
61
+ nitro::ReactProp<std::optional<std::function<void(const PdfLoadEvent& /* event */)>>> onLoad;
62
+ nitro::ReactProp<std::optional<std::function<void(const PdfPageEvent& /* event */)>>> onPageChange;
63
+ nitro::ReactProp<std::optional<std::function<void(const PdfZoomEvent& /* event */)>>> onZoom;
64
+ nitro::ReactProp<std::optional<std::function<void(const PdfErrorEvent& /* event */)>>> onError;
65
+ nitro::ReactProp<std::optional<std::function<void(const PdfTapEvent& /* event */)>>> onTap;
66
+ nitro::ReactProp<std::optional<std::function<void(const std::shared_ptr<HybridNativePdfViewSpec>& /* ref */)>>> hybridRef;
67
+
68
+ [[nodiscard]]
69
+ bool hasSameProps(const HybridNativePdfViewProps& other) const noexcept {
70
+ return source.hasSameValue(other.source) &&
71
+ page.hasSameValue(other.page) &&
72
+ fit.hasSameValue(other.fit) &&
73
+ minZoom.hasSameValue(other.minZoom) &&
74
+ maxZoom.hasSameValue(other.maxZoom) &&
75
+ doubleTapZoom.hasSameValue(other.doubleTapZoom) &&
76
+ pageGap.hasSameValue(other.pageGap) &&
77
+ backdropColor.hasSameValue(other.backdropColor) &&
78
+ scrollIndicators.hasSameValue(other.scrollIndicators) &&
79
+ onLoad.hasSameValue(other.onLoad) &&
80
+ onPageChange.hasSameValue(other.onPageChange) &&
81
+ onZoom.hasSameValue(other.onZoom) &&
82
+ onError.hasSameValue(other.onError) &&
83
+ onTap.hasSameValue(other.onTap) &&
84
+ hybridRef.hasSameValue(other.hybridRef);
85
+ }
86
+
87
+ [[nodiscard]]
88
+ bool hasAnyProvidedProps() const noexcept {
89
+ return source.isProvided() ||
90
+ page.isProvided() ||
91
+ fit.isProvided() ||
92
+ minZoom.isProvided() ||
93
+ maxZoom.isProvided() ||
94
+ doubleTapZoom.isProvided() ||
95
+ pageGap.isProvided() ||
96
+ backdropColor.isProvided() ||
97
+ scrollIndicators.isProvided() ||
98
+ onLoad.isProvided() ||
99
+ onPageChange.isProvided() ||
100
+ onZoom.isProvided() ||
101
+ onError.isProvided() ||
102
+ onTap.isProvided() ||
103
+ hybridRef.isProvided();
104
+ }
66
105
 
67
106
  private:
68
107
  static bool filterObjectKeys(const std::string& propName);
@@ -71,32 +110,7 @@ namespace margelo::nitro::pdfsdk::views {
71
110
  /**
72
111
  * State for the "NativePdfView" View.
73
112
  */
74
- class HybridNativePdfViewState final {
75
- public:
76
- HybridNativePdfViewState() = default;
77
- explicit HybridNativePdfViewState(const std::shared_ptr<HybridNativePdfViewProps>& props):
78
- _props(props) {}
79
-
80
- public:
81
- [[nodiscard]]
82
- const std::shared_ptr<HybridNativePdfViewProps>& getProps() const {
83
- return _props;
84
- }
85
-
86
- public:
87
- #ifdef ANDROID
88
- HybridNativePdfViewState(const HybridNativePdfViewState& /* previousState */, folly::dynamic /* data */) {}
89
- folly::dynamic getDynamic() const {
90
- throw std::runtime_error("HybridNativePdfViewState does not support folly!");
91
- }
92
- react::MapBuffer getMapBuffer() const {
93
- throw std::runtime_error("HybridNativePdfViewState does not support MapBuffer!");
94
- };
95
- #endif
96
-
97
- private:
98
- std::shared_ptr<HybridNativePdfViewProps> _props;
99
- };
113
+ using HybridNativePdfViewState = nitro::ViewPropsHolderState<HybridNativePdfViewProps>;
100
114
 
101
115
  /**
102
116
  * The Shadow Node for the "NativePdfView" View.
@@ -109,21 +123,7 @@ namespace margelo::nitro::pdfsdk::views {
109
123
  /**
110
124
  * The Component Descriptor for the "NativePdfView" View.
111
125
  */
112
- class HybridNativePdfViewComponentDescriptor final: public react::ConcreteComponentDescriptor<HybridNativePdfViewShadowNode> {
113
- public:
114
- explicit HybridNativePdfViewComponentDescriptor(const react::ComponentDescriptorParameters& parameters);
115
-
116
- public:
117
- /**
118
- * A faster path for cloning props - reuses the caching logic from `HybridNativePdfViewProps`.
119
- */
120
- std::shared_ptr<const react::Props> cloneProps(const react::PropsParserContext& context,
121
- const std::shared_ptr<const react::Props>& props,
122
- react::RawProps rawProps) const override;
123
- #ifdef ANDROID
124
- void adopt(react::ShadowNode& shadowNode) const override;
125
- #endif
126
- };
126
+ using HybridNativePdfViewComponentDescriptor = nitro::ViewComponentDescriptor<HybridNativePdfViewShadowNode>;
127
127
 
128
128
  /* The actual view for "NativePdfView" needs to be implemented in platform-specific code. */
129
129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-pdf-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "A PDF SDK for React Native: a viewer that draws in tiles with the platform's own renderer, built for drawings metres wide.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -8,7 +8,7 @@
8
8
  "react-native": "src/index",
9
9
  "source": "src/index",
10
10
  "license": "MIT",
11
- "author": "Halil \u0130brahim Aky\u00fcz",
11
+ "author": "Halil İbrahim Akyüz",
12
12
  "homepage": "https://github.com/Halilibrahimakyz/react-native-pdf-sdk#readme",
13
13
  "repository": {
14
14
  "type": "git",
@@ -50,20 +50,25 @@
50
50
  "typecheck": "tsc --noEmit -p tsconfig.json",
51
51
  "pdfs": "cd example/pdfs && swift make.swift .",
52
52
  "test:ios": "sh ios/tests/run.sh",
53
- "test:android": "cd ../../android && ./gradlew :react-native-pdf-sdk:testDebugUnitTest",
53
+ "test:android": "cd example/android && ./gradlew :react-native-pdf-sdk:testDebugUnitTest",
54
54
  "verify": "npm run typecheck && npm run test:ios && npm run test:android",
55
55
  "build": "bob build",
56
- "prepublishOnly": "npm run verify && npm run build"
56
+ "prepublishOnly": "npm run verify && npm run build",
57
+ "example": "npm --prefix example run start"
57
58
  },
58
59
  "devDependencies": {
59
- "nitrogen": "0.35.5",
60
+ "@types/react": "^19.2.0",
61
+ "nitrogen": "0.37.2",
62
+ "react": "19.2.3",
63
+ "react-native": "0.85.2",
60
64
  "react-native-builder-bob": "^0.40.0",
65
+ "react-native-nitro-modules": "^0.37.2",
61
66
  "typescript": "^5.6.0"
62
67
  },
63
68
  "peerDependencies": {
64
69
  "react": "*",
65
70
  "react-native": "*",
66
- "react-native-nitro-modules": "*"
71
+ "react-native-nitro-modules": ">=0.37.2"
67
72
  },
68
73
  "react-native-builder-bob": {
69
74
  "source": "src",