@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.
- package/LICENSE +20 -0
- package/PdfViewer.podspec +28 -0
- package/README.md +290 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +121 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +6 -0
- package/android/src/main/java/com/margelo/nitro/pdfviewer/HybridPdfViewer.kt +169 -0
- package/android/src/main/java/com/margelo/nitro/pdfviewer/PdfViewer.kt +996 -0
- package/android/src/main/java/com/margelo/nitro/pdfviewer/PdfViewerPackage.kt +26 -0
- package/ios/PdfViewer.swift +696 -0
- package/lib/module/PdfViewer.nitro.js +4 -0
- package/lib/module/PdfViewer.nitro.js.map +1 -0
- package/lib/module/index.js +13 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/PdfViewer.nitro.d.ts +67 -0
- package/lib/typescript/src/PdfViewer.nitro.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +8 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +17 -0
- package/nitrogen/generated/android/c++/JErrorEvent.hpp +57 -0
- package/nitrogen/generated/android/c++/JFunc_void_ErrorEvent.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_LoadCompleteEvent.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_LoadingChangeEvent.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_PageChangeEvent.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_ScaleChangeEvent.hpp +76 -0
- package/nitrogen/generated/android/c++/JFunc_void_ThumbnailGeneratedEvent.hpp +77 -0
- package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.cpp +273 -0
- package/nitrogen/generated/android/c++/JHybridPdfViewerSpec.hpp +94 -0
- package/nitrogen/generated/android/c++/JLoadCompleteEvent.hpp +61 -0
- package/nitrogen/generated/android/c++/JLoadingChangeEvent.hpp +53 -0
- package/nitrogen/generated/android/c++/JPageChangeEvent.hpp +57 -0
- package/nitrogen/generated/android/c++/JScaleChangeEvent.hpp +53 -0
- package/nitrogen/generated/android/c++/JThumbnailGeneratedEvent.hpp +57 -0
- package/nitrogen/generated/android/c++/views/JHybridPdfViewerStateUpdater.cpp +108 -0
- package/nitrogen/generated/android/c++/views/JHybridPdfViewerStateUpdater.hpp +49 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ErrorEvent.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ErrorEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_LoadCompleteEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_LoadingChangeEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_PageChangeEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ScaleChangeEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/Func_void_ThumbnailGeneratedEvent.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/HybridPdfViewerSpec.kt +195 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/LoadCompleteEvent.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/LoadingChangeEvent.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/PageChangeEvent.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ScaleChangeEvent.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ThumbnailGeneratedEvent.kt +32 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/pdfviewerOnLoad.kt +35 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/views/HybridPdfViewerManager.kt +50 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/views/HybridPdfViewerStateUpdater.kt +23 -0
- package/nitrogen/generated/android/pdfviewer+autolinking.cmake +83 -0
- package/nitrogen/generated/android/pdfviewer+autolinking.gradle +27 -0
- package/nitrogen/generated/android/pdfviewerOnLoad.cpp +58 -0
- package/nitrogen/generated/android/pdfviewerOnLoad.hpp +25 -0
- package/nitrogen/generated/ios/PdfViewer+autolinking.rb +60 -0
- package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Bridge.cpp +80 -0
- package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Bridge.hpp +339 -0
- package/nitrogen/generated/ios/PdfViewer-Swift-Cxx-Umbrella.hpp +64 -0
- package/nitrogen/generated/ios/PdfViewerAutolinking.mm +33 -0
- package/nitrogen/generated/ios/PdfViewerAutolinking.swift +25 -0
- package/nitrogen/generated/ios/c++/HybridPdfViewerSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridPdfViewerSpecSwift.hpp +205 -0
- package/nitrogen/generated/ios/c++/views/HybridPdfViewerComponent.mm +161 -0
- package/nitrogen/generated/ios/swift/ErrorEvent.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ErrorEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_LoadCompleteEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_LoadingChangeEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_PageChangeEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_ScaleChangeEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/Func_void_ThumbnailGeneratedEvent.swift +47 -0
- package/nitrogen/generated/ios/swift/HybridPdfViewerSpec.swift +65 -0
- package/nitrogen/generated/ios/swift/HybridPdfViewerSpec_cxx.swift +500 -0
- package/nitrogen/generated/ios/swift/LoadCompleteEvent.swift +57 -0
- package/nitrogen/generated/ios/swift/LoadingChangeEvent.swift +35 -0
- package/nitrogen/generated/ios/swift/PageChangeEvent.swift +46 -0
- package/nitrogen/generated/ios/swift/ScaleChangeEvent.swift +35 -0
- package/nitrogen/generated/ios/swift/ThumbnailGeneratedEvent.swift +46 -0
- package/nitrogen/generated/shared/c++/ErrorEvent.hpp +71 -0
- package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.cpp +52 -0
- package/nitrogen/generated/shared/c++/HybridPdfViewerSpec.hpp +111 -0
- package/nitrogen/generated/shared/c++/LoadCompleteEvent.hpp +75 -0
- package/nitrogen/generated/shared/c++/LoadingChangeEvent.hpp +67 -0
- package/nitrogen/generated/shared/c++/PageChangeEvent.hpp +71 -0
- package/nitrogen/generated/shared/c++/ScaleChangeEvent.hpp +67 -0
- package/nitrogen/generated/shared/c++/ThumbnailGeneratedEvent.hpp +71 -0
- package/nitrogen/generated/shared/c++/views/HybridPdfViewerComponent.cpp +243 -0
- package/nitrogen/generated/shared/c++/views/HybridPdfViewerComponent.hpp +127 -0
- package/nitrogen/generated/shared/json/PdfViewerConfig.json +23 -0
- package/package.json +175 -0
- package/src/PdfViewer.nitro.ts +97 -0
- package/src/index.tsx +27 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPdfViewerSpec.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.jni.HybridData
|
|
12
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
13
|
+
import com.margelo.nitro.core.*
|
|
14
|
+
import com.margelo.nitro.views.*
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* A Kotlin class representing the PdfViewer HybridObject.
|
|
18
|
+
* Implement this abstract class to create Kotlin-based instances of PdfViewer.
|
|
19
|
+
*/
|
|
20
|
+
@DoNotStrip
|
|
21
|
+
@Keep
|
|
22
|
+
@Suppress(
|
|
23
|
+
"KotlinJniMissingFunction", "unused",
|
|
24
|
+
"RedundantSuppression", "RedundantUnitReturnType", "SimpleRedundantLet",
|
|
25
|
+
"LocalVariableName", "PropertyName", "PrivatePropertyName", "FunctionName"
|
|
26
|
+
)
|
|
27
|
+
abstract class HybridPdfViewerSpec: HybridView() {
|
|
28
|
+
@DoNotStrip
|
|
29
|
+
private var mHybridData: HybridData = initHybrid()
|
|
30
|
+
|
|
31
|
+
init {
|
|
32
|
+
super.updateNative(mHybridData)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun updateNative(hybridData: HybridData) {
|
|
36
|
+
mHybridData = hybridData
|
|
37
|
+
super.updateNative(hybridData)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Properties
|
|
41
|
+
@get:DoNotStrip
|
|
42
|
+
@get:Keep
|
|
43
|
+
@set:DoNotStrip
|
|
44
|
+
@set:Keep
|
|
45
|
+
abstract var source: String?
|
|
46
|
+
|
|
47
|
+
@get:DoNotStrip
|
|
48
|
+
@get:Keep
|
|
49
|
+
@set:DoNotStrip
|
|
50
|
+
@set:Keep
|
|
51
|
+
abstract var horizontal: Boolean?
|
|
52
|
+
|
|
53
|
+
@get:DoNotStrip
|
|
54
|
+
@get:Keep
|
|
55
|
+
@set:DoNotStrip
|
|
56
|
+
@set:Keep
|
|
57
|
+
abstract var enablePaging: Boolean?
|
|
58
|
+
|
|
59
|
+
@get:DoNotStrip
|
|
60
|
+
@get:Keep
|
|
61
|
+
@set:DoNotStrip
|
|
62
|
+
@set:Keep
|
|
63
|
+
abstract var spacing: Double?
|
|
64
|
+
|
|
65
|
+
@get:DoNotStrip
|
|
66
|
+
@get:Keep
|
|
67
|
+
@set:DoNotStrip
|
|
68
|
+
@set:Keep
|
|
69
|
+
abstract var enableZoom: Boolean?
|
|
70
|
+
|
|
71
|
+
@get:DoNotStrip
|
|
72
|
+
@get:Keep
|
|
73
|
+
@set:DoNotStrip
|
|
74
|
+
@set:Keep
|
|
75
|
+
abstract var minScale: Double?
|
|
76
|
+
|
|
77
|
+
@get:DoNotStrip
|
|
78
|
+
@get:Keep
|
|
79
|
+
@set:DoNotStrip
|
|
80
|
+
@set:Keep
|
|
81
|
+
abstract var maxScale: Double?
|
|
82
|
+
|
|
83
|
+
@get:DoNotStrip
|
|
84
|
+
@get:Keep
|
|
85
|
+
@set:DoNotStrip
|
|
86
|
+
@set:Keep
|
|
87
|
+
abstract var showsActivityIndicator: Boolean?
|
|
88
|
+
|
|
89
|
+
abstract var onLoadComplete: ((event: LoadCompleteEvent) -> Unit)?
|
|
90
|
+
|
|
91
|
+
private var onLoadComplete_cxx: Func_void_LoadCompleteEvent?
|
|
92
|
+
@Keep
|
|
93
|
+
@DoNotStrip
|
|
94
|
+
get() {
|
|
95
|
+
return onLoadComplete?.let { Func_void_LoadCompleteEvent_java(it) }
|
|
96
|
+
}
|
|
97
|
+
@Keep
|
|
98
|
+
@DoNotStrip
|
|
99
|
+
set(value) {
|
|
100
|
+
onLoadComplete = value?.let { it }
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
abstract var onPageChange: ((event: PageChangeEvent) -> Unit)?
|
|
104
|
+
|
|
105
|
+
private var onPageChange_cxx: Func_void_PageChangeEvent?
|
|
106
|
+
@Keep
|
|
107
|
+
@DoNotStrip
|
|
108
|
+
get() {
|
|
109
|
+
return onPageChange?.let { Func_void_PageChangeEvent_java(it) }
|
|
110
|
+
}
|
|
111
|
+
@Keep
|
|
112
|
+
@DoNotStrip
|
|
113
|
+
set(value) {
|
|
114
|
+
onPageChange = value?.let { it }
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
abstract var onScaleChange: ((event: ScaleChangeEvent) -> Unit)?
|
|
118
|
+
|
|
119
|
+
private var onScaleChange_cxx: Func_void_ScaleChangeEvent?
|
|
120
|
+
@Keep
|
|
121
|
+
@DoNotStrip
|
|
122
|
+
get() {
|
|
123
|
+
return onScaleChange?.let { Func_void_ScaleChangeEvent_java(it) }
|
|
124
|
+
}
|
|
125
|
+
@Keep
|
|
126
|
+
@DoNotStrip
|
|
127
|
+
set(value) {
|
|
128
|
+
onScaleChange = value?.let { it }
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
abstract var onError: ((event: ErrorEvent) -> Unit)?
|
|
132
|
+
|
|
133
|
+
private var onError_cxx: Func_void_ErrorEvent?
|
|
134
|
+
@Keep
|
|
135
|
+
@DoNotStrip
|
|
136
|
+
get() {
|
|
137
|
+
return onError?.let { Func_void_ErrorEvent_java(it) }
|
|
138
|
+
}
|
|
139
|
+
@Keep
|
|
140
|
+
@DoNotStrip
|
|
141
|
+
set(value) {
|
|
142
|
+
onError = value?.let { it }
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
abstract var onThumbnailGenerated: ((event: ThumbnailGeneratedEvent) -> Unit)?
|
|
146
|
+
|
|
147
|
+
private var onThumbnailGenerated_cxx: Func_void_ThumbnailGeneratedEvent?
|
|
148
|
+
@Keep
|
|
149
|
+
@DoNotStrip
|
|
150
|
+
get() {
|
|
151
|
+
return onThumbnailGenerated?.let { Func_void_ThumbnailGeneratedEvent_java(it) }
|
|
152
|
+
}
|
|
153
|
+
@Keep
|
|
154
|
+
@DoNotStrip
|
|
155
|
+
set(value) {
|
|
156
|
+
onThumbnailGenerated = value?.let { it }
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
abstract var onLoadingChange: ((event: LoadingChangeEvent) -> Unit)?
|
|
160
|
+
|
|
161
|
+
private var onLoadingChange_cxx: Func_void_LoadingChangeEvent?
|
|
162
|
+
@Keep
|
|
163
|
+
@DoNotStrip
|
|
164
|
+
get() {
|
|
165
|
+
return onLoadingChange?.let { Func_void_LoadingChangeEvent_java(it) }
|
|
166
|
+
}
|
|
167
|
+
@Keep
|
|
168
|
+
@DoNotStrip
|
|
169
|
+
set(value) {
|
|
170
|
+
onLoadingChange = value?.let { it }
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Methods
|
|
174
|
+
@DoNotStrip
|
|
175
|
+
@Keep
|
|
176
|
+
abstract fun goToPage(page: Double): Unit
|
|
177
|
+
|
|
178
|
+
@DoNotStrip
|
|
179
|
+
@Keep
|
|
180
|
+
abstract fun setScale(scale: Double): Unit
|
|
181
|
+
|
|
182
|
+
@DoNotStrip
|
|
183
|
+
@Keep
|
|
184
|
+
abstract fun generateThumbnail(page: Double): Unit
|
|
185
|
+
|
|
186
|
+
@DoNotStrip
|
|
187
|
+
@Keep
|
|
188
|
+
abstract fun generateAllThumbnails(): Unit
|
|
189
|
+
|
|
190
|
+
private external fun initHybrid(): HybridData
|
|
191
|
+
|
|
192
|
+
companion object {
|
|
193
|
+
private const val TAG = "HybridPdfViewerSpec"
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LoadCompleteEvent.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "LoadCompleteEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class LoadCompleteEvent
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val pageCount: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val pageWidth: Double,
|
|
30
|
+
@DoNotStrip
|
|
31
|
+
@Keep
|
|
32
|
+
val pageHeight: Double
|
|
33
|
+
) {
|
|
34
|
+
/* main constructor */
|
|
35
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// LoadingChangeEvent.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "LoadingChangeEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class LoadingChangeEvent
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val isLoading: Boolean
|
|
27
|
+
) {
|
|
28
|
+
/* main constructor */
|
|
29
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// PageChangeEvent.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "PageChangeEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class PageChangeEvent
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val page: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val pageCount: Double
|
|
30
|
+
) {
|
|
31
|
+
/* main constructor */
|
|
32
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ScaleChangeEvent.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "ScaleChangeEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class ScaleChangeEvent
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val scale: Double
|
|
27
|
+
) {
|
|
28
|
+
/* main constructor */
|
|
29
|
+
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/pdfviewer/ThumbnailGeneratedEvent.kt
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ThumbnailGeneratedEvent.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import androidx.annotation.Keep
|
|
11
|
+
import com.facebook.proguard.annotations.DoNotStrip
|
|
12
|
+
import com.margelo.nitro.core.*
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Represents the JavaScript object/struct "ThumbnailGeneratedEvent".
|
|
17
|
+
*/
|
|
18
|
+
@DoNotStrip
|
|
19
|
+
@Keep
|
|
20
|
+
data class ThumbnailGeneratedEvent
|
|
21
|
+
@DoNotStrip
|
|
22
|
+
@Keep
|
|
23
|
+
constructor(
|
|
24
|
+
@DoNotStrip
|
|
25
|
+
@Keep
|
|
26
|
+
val page: Double,
|
|
27
|
+
@DoNotStrip
|
|
28
|
+
@Keep
|
|
29
|
+
val uri: String
|
|
30
|
+
) {
|
|
31
|
+
/* main constructor */
|
|
32
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// pdfviewerOnLoad.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer
|
|
9
|
+
|
|
10
|
+
import android.util.Log
|
|
11
|
+
|
|
12
|
+
internal class pdfviewerOnLoad {
|
|
13
|
+
companion object {
|
|
14
|
+
private const val TAG = "pdfviewerOnLoad"
|
|
15
|
+
private var didLoad = false
|
|
16
|
+
/**
|
|
17
|
+
* Initializes the native part of "pdfviewer".
|
|
18
|
+
* This method is idempotent and can be called more than once.
|
|
19
|
+
*/
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun initializeNative() {
|
|
22
|
+
if (didLoad) return
|
|
23
|
+
try {
|
|
24
|
+
Log.i(TAG, "Loading pdfviewer C++ library...")
|
|
25
|
+
System.loadLibrary("pdfviewer")
|
|
26
|
+
Log.i(TAG, "Successfully loaded pdfviewer C++ library!")
|
|
27
|
+
didLoad = true
|
|
28
|
+
} catch (e: Error) {
|
|
29
|
+
Log.e(TAG, "Failed to load pdfviewer C++ library! Is it properly installed and linked? " +
|
|
30
|
+
"Is the name correct? (see `CMakeLists.txt`, at `add_library(...)`)", e)
|
|
31
|
+
throw e
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPdfViewerManager.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer.views
|
|
9
|
+
|
|
10
|
+
import android.view.View
|
|
11
|
+
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
12
|
+
import com.facebook.react.uimanager.SimpleViewManager
|
|
13
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
14
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
15
|
+
import com.margelo.nitro.pdfviewer.*
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Represents the React Native `ViewManager` for the "PdfViewer" Nitro HybridView.
|
|
19
|
+
*/
|
|
20
|
+
open class HybridPdfViewerManager: SimpleViewManager<View>() {
|
|
21
|
+
private val views = hashMapOf<View, HybridPdfViewer>()
|
|
22
|
+
|
|
23
|
+
override fun getName(): String {
|
|
24
|
+
return "PdfViewer"
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
override fun createViewInstance(reactContext: ThemedReactContext): View {
|
|
28
|
+
val hybridView = HybridPdfViewer(reactContext)
|
|
29
|
+
val view = hybridView.view
|
|
30
|
+
views[view] = hybridView
|
|
31
|
+
return view
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
override fun onDropViewInstance(view: View) {
|
|
35
|
+
super.onDropViewInstance(view)
|
|
36
|
+
views.remove(view)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? {
|
|
40
|
+
val hybridView = views[view] ?: throw Error("Couldn't find view $view in local views table!")
|
|
41
|
+
|
|
42
|
+
// 1. Update each prop individually
|
|
43
|
+
hybridView.beforeUpdate()
|
|
44
|
+
HybridPdfViewerStateUpdater.updateViewProps(hybridView, stateWrapper)
|
|
45
|
+
hybridView.afterUpdate()
|
|
46
|
+
|
|
47
|
+
// 2. Continue in base View props
|
|
48
|
+
return super.updateState(view, props, stateWrapper)
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// HybridPdfViewerStateUpdater.kt
|
|
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
|
+
package com.margelo.nitro.pdfviewer.views
|
|
9
|
+
|
|
10
|
+
import com.facebook.react.uimanager.StateWrapper
|
|
11
|
+
import com.margelo.nitro.pdfviewer.*
|
|
12
|
+
|
|
13
|
+
internal class HybridPdfViewerStateUpdater {
|
|
14
|
+
companion object {
|
|
15
|
+
/**
|
|
16
|
+
* Updates the props for [view] through C++.
|
|
17
|
+
* The [state] prop is expected to contain [view]'s props as wrapped Fabric state.
|
|
18
|
+
*/
|
|
19
|
+
@Suppress("KotlinJniMissingFunction")
|
|
20
|
+
@JvmStatic
|
|
21
|
+
external fun updateViewProps(view: HybridPdfViewerSpec, state: StateWrapper)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#
|
|
2
|
+
# pdfviewer+autolinking.cmake
|
|
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
|
+
# This is a CMake file that adds all files generated by Nitrogen
|
|
9
|
+
# to the current CMake project.
|
|
10
|
+
#
|
|
11
|
+
# To use it, add this to your CMakeLists.txt:
|
|
12
|
+
# ```cmake
|
|
13
|
+
# include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/pdfviewer+autolinking.cmake)
|
|
14
|
+
# ```
|
|
15
|
+
|
|
16
|
+
# Define a flag to check if we are building properly
|
|
17
|
+
add_definitions(-DBUILDING_PDFVIEWER_WITH_GENERATED_CMAKE_PROJECT)
|
|
18
|
+
|
|
19
|
+
# Enable Raw Props parsing in react-native (for Nitro Views)
|
|
20
|
+
add_definitions(-DRN_SERIALIZABLE_STATE)
|
|
21
|
+
|
|
22
|
+
# Add all headers that were generated by Nitrogen
|
|
23
|
+
include_directories(
|
|
24
|
+
"../nitrogen/generated/shared/c++"
|
|
25
|
+
"../nitrogen/generated/android/c++"
|
|
26
|
+
"../nitrogen/generated/android/"
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
# Add all .cpp sources that were generated by Nitrogen
|
|
30
|
+
target_sources(
|
|
31
|
+
# CMake project name (Android C++ library name)
|
|
32
|
+
pdfviewer PRIVATE
|
|
33
|
+
# Autolinking Setup
|
|
34
|
+
../nitrogen/generated/android/pdfviewerOnLoad.cpp
|
|
35
|
+
# Shared Nitrogen C++ sources
|
|
36
|
+
../nitrogen/generated/shared/c++/HybridPdfViewerSpec.cpp
|
|
37
|
+
../nitrogen/generated/shared/c++/views/HybridPdfViewerComponent.cpp
|
|
38
|
+
# Android-specific Nitrogen C++ sources
|
|
39
|
+
../nitrogen/generated/android/c++/JHybridPdfViewerSpec.cpp
|
|
40
|
+
../nitrogen/generated/android/c++/views/JHybridPdfViewerStateUpdater.cpp
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
# From node_modules/react-native/ReactAndroid/cmake-utils/folly-flags.cmake
|
|
44
|
+
# Used in node_modules/react-native/ReactAndroid/cmake-utils/ReactNative-application.cmake
|
|
45
|
+
target_compile_definitions(
|
|
46
|
+
pdfviewer PRIVATE
|
|
47
|
+
-DFOLLY_NO_CONFIG=1
|
|
48
|
+
-DFOLLY_HAVE_CLOCK_GETTIME=1
|
|
49
|
+
-DFOLLY_USE_LIBCPP=1
|
|
50
|
+
-DFOLLY_CFG_NO_COROUTINES=1
|
|
51
|
+
-DFOLLY_MOBILE=1
|
|
52
|
+
-DFOLLY_HAVE_RECVMMSG=1
|
|
53
|
+
-DFOLLY_HAVE_PTHREAD=1
|
|
54
|
+
# Once we target android-23 above, we can comment
|
|
55
|
+
# the following line. NDK uses GNU style stderror_r() after API 23.
|
|
56
|
+
-DFOLLY_HAVE_XSI_STRERROR_R=1
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
# Add all libraries required by the generated specs
|
|
60
|
+
find_package(fbjni REQUIRED) # <-- Used for communication between Java <-> C++
|
|
61
|
+
find_package(ReactAndroid REQUIRED) # <-- Used to set up React Native bindings (e.g. CallInvoker/TurboModule)
|
|
62
|
+
find_package(react-native-nitro-modules REQUIRED) # <-- Used to create all HybridObjects and use the Nitro core library
|
|
63
|
+
|
|
64
|
+
# Link all libraries together
|
|
65
|
+
target_link_libraries(
|
|
66
|
+
pdfviewer
|
|
67
|
+
fbjni::fbjni # <-- Facebook C++ JNI helpers
|
|
68
|
+
ReactAndroid::jsi # <-- RN: JSI
|
|
69
|
+
react-native-nitro-modules::NitroModules # <-- NitroModules Core :)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
# Link react-native (different prefab between RN 0.75 and RN 0.76)
|
|
73
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 76)
|
|
74
|
+
target_link_libraries(
|
|
75
|
+
pdfviewer
|
|
76
|
+
ReactAndroid::reactnative # <-- RN: Native Modules umbrella prefab
|
|
77
|
+
)
|
|
78
|
+
else()
|
|
79
|
+
target_link_libraries(
|
|
80
|
+
pdfviewer
|
|
81
|
+
ReactAndroid::react_nativemodule_core # <-- RN: TurboModules Core
|
|
82
|
+
)
|
|
83
|
+
endif()
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// pdfviewer+autolinking.gradle
|
|
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
|
+
/// This is a Gradle file that adds all files generated by Nitrogen
|
|
9
|
+
/// to the current Gradle project.
|
|
10
|
+
///
|
|
11
|
+
/// To use it, add this to your build.gradle:
|
|
12
|
+
/// ```gradle
|
|
13
|
+
/// apply from: '../nitrogen/generated/android/pdfviewer+autolinking.gradle'
|
|
14
|
+
/// ```
|
|
15
|
+
|
|
16
|
+
logger.warn("[NitroModules] 🔥 pdfviewer is boosted by nitro!")
|
|
17
|
+
|
|
18
|
+
android {
|
|
19
|
+
sourceSets {
|
|
20
|
+
main {
|
|
21
|
+
java.srcDirs += [
|
|
22
|
+
// Nitrogen files
|
|
23
|
+
"${project.projectDir}/../nitrogen/generated/android/kotlin"
|
|
24
|
+
]
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// pdfviewerOnLoad.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
|
+
#ifndef BUILDING_PDFVIEWER_WITH_GENERATED_CMAKE_PROJECT
|
|
9
|
+
#error pdfviewerOnLoad.cpp is not being built with the autogenerated CMakeLists.txt project. Is a different CMakeLists.txt building this?
|
|
10
|
+
#endif
|
|
11
|
+
|
|
12
|
+
#include "pdfviewerOnLoad.hpp"
|
|
13
|
+
|
|
14
|
+
#include <jni.h>
|
|
15
|
+
#include <fbjni/fbjni.h>
|
|
16
|
+
#include <NitroModules/HybridObjectRegistry.hpp>
|
|
17
|
+
|
|
18
|
+
#include "JHybridPdfViewerSpec.hpp"
|
|
19
|
+
#include "JFunc_void_LoadCompleteEvent.hpp"
|
|
20
|
+
#include "JFunc_void_PageChangeEvent.hpp"
|
|
21
|
+
#include "JFunc_void_ScaleChangeEvent.hpp"
|
|
22
|
+
#include "JFunc_void_ErrorEvent.hpp"
|
|
23
|
+
#include "JFunc_void_ThumbnailGeneratedEvent.hpp"
|
|
24
|
+
#include "JFunc_void_LoadingChangeEvent.hpp"
|
|
25
|
+
#include "views/JHybridPdfViewerStateUpdater.hpp"
|
|
26
|
+
#include <NitroModules/DefaultConstructableObject.hpp>
|
|
27
|
+
|
|
28
|
+
namespace margelo::nitro::pdfviewer {
|
|
29
|
+
|
|
30
|
+
int initialize(JavaVM* vm) {
|
|
31
|
+
using namespace margelo::nitro;
|
|
32
|
+
using namespace margelo::nitro::pdfviewer;
|
|
33
|
+
using namespace facebook;
|
|
34
|
+
|
|
35
|
+
return facebook::jni::initialize(vm, [] {
|
|
36
|
+
// Register native JNI methods
|
|
37
|
+
margelo::nitro::pdfviewer::JHybridPdfViewerSpec::registerNatives();
|
|
38
|
+
margelo::nitro::pdfviewer::JFunc_void_LoadCompleteEvent_cxx::registerNatives();
|
|
39
|
+
margelo::nitro::pdfviewer::JFunc_void_PageChangeEvent_cxx::registerNatives();
|
|
40
|
+
margelo::nitro::pdfviewer::JFunc_void_ScaleChangeEvent_cxx::registerNatives();
|
|
41
|
+
margelo::nitro::pdfviewer::JFunc_void_ErrorEvent_cxx::registerNatives();
|
|
42
|
+
margelo::nitro::pdfviewer::JFunc_void_ThumbnailGeneratedEvent_cxx::registerNatives();
|
|
43
|
+
margelo::nitro::pdfviewer::JFunc_void_LoadingChangeEvent_cxx::registerNatives();
|
|
44
|
+
margelo::nitro::pdfviewer::views::JHybridPdfViewerStateUpdater::registerNatives();
|
|
45
|
+
|
|
46
|
+
// Register Nitro Hybrid Objects
|
|
47
|
+
HybridObjectRegistry::registerHybridObjectConstructor(
|
|
48
|
+
"PdfViewer",
|
|
49
|
+
[]() -> std::shared_ptr<HybridObject> {
|
|
50
|
+
static DefaultConstructableObject<JHybridPdfViewerSpec::javaobject> object("com/margelo/nitro/pdfviewer/HybridPdfViewer");
|
|
51
|
+
auto instance = object.create();
|
|
52
|
+
return instance->cthis()->shared();
|
|
53
|
+
}
|
|
54
|
+
);
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
} // namespace margelo::nitro::pdfviewer
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// pdfviewerOnLoad.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
|
+
#include <jni.h>
|
|
9
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
10
|
+
|
|
11
|
+
namespace margelo::nitro::pdfviewer {
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Initializes the native (C++) part of pdfviewer, and autolinks all Hybrid Objects.
|
|
15
|
+
* Call this in your `JNI_OnLoad` function (probably inside `cpp-adapter.cpp`).
|
|
16
|
+
* Example:
|
|
17
|
+
* ```cpp (cpp-adapter.cpp)
|
|
18
|
+
* JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
|
|
19
|
+
* return margelo::nitro::pdfviewer::initialize(vm);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
int initialize(JavaVM* vm);
|
|
24
|
+
|
|
25
|
+
} // namespace margelo::nitro::pdfviewer
|