react-native-pdf-renderer 1.2.0 → 1.3.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/DEPENDENTS.md ADDED
@@ -0,0 +1,28 @@
1
+ # Dependents stats for douglasjunior/react-native-pdf-renderer
2
+
3
+ [![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by&message=17&color=informational&logo=slickpic)](https://github.com/douglasjunior/react-native-pdf-renderer/network/dependents)
4
+ [![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by%20(public)&message=17&color=informational&logo=slickpic)](https://github.com/douglasjunior/react-native-pdf-renderer/network/dependents)
5
+ [![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by%20(private)&message=-17&color=informational&logo=slickpic)](https://github.com/douglasjunior/react-native-pdf-renderer/network/dependents)
6
+ [![Generated by github-dependents-info](https://img.shields.io/static/v1?label=Used%20by%20(stars)&message=262&color=informational&logo=slickpic)](https://github.com/douglasjunior/react-native-pdf-renderer/network/dependents)
7
+
8
+ | Repository | Stars |
9
+ | :-------- | -----: |
10
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/114444115?s=40&v=4" width="20" height="20" alt=""> &nbsp; [PapillonApp](https://github.com/PapillonApp) / [Papillon](https://github.com/PapillonApp/Papillon) | 136 |
11
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/1512341?s=40&v=4" width="20" height="20" alt=""> &nbsp; [douglasjunior](https://github.com/douglasjunior) / [react-native-pdf-renderer](https://github.com/douglasjunior/react-native-pdf-renderer) | 123 |
12
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/92865629?s=40&v=4" width="20" height="20" alt=""> &nbsp; [jayasuryard31](https://github.com/jayasuryard31) / [AyurScan](https://github.com/jayasuryard31/AyurScan) | 1 |
13
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/79224590?s=40&v=4" width="20" height="20" alt=""> &nbsp; [LeMaitre4523](https://github.com/LeMaitre4523) / [Renard-archive](https://github.com/LeMaitre4523/Renard-archive) | 1 |
14
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/1499012?s=40&v=4" width="20" height="20" alt=""> &nbsp; [lukasa1993](https://github.com/lukasa1993) / [react-native-presigned-s3](https://github.com/lukasa1993/react-native-presigned-s3) | 1 |
15
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/43969012?s=40&v=4" width="20" height="20" alt=""> &nbsp; [Filahan](https://github.com/Filahan) / [promapp](https://github.com/Filahan/promapp) | 0 |
16
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/141116673?s=40&v=4" width="20" height="20" alt=""> &nbsp; [kuldip-trentium](https://github.com/kuldip-trentium) / [expo-crm](https://github.com/kuldip-trentium/expo-crm) | 0 |
17
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/161857344?s=40&v=4" width="20" height="20" alt=""> &nbsp; [uzziel-humanly](https://github.com/uzziel-humanly) / [APP-QUEJAS-AGUA-PUEBLA](https://github.com/uzziel-humanly/APP-QUEJAS-AGUA-PUEBLA) | 0 |
18
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/26320684?s=40&v=4" width="20" height="20" alt=""> &nbsp; [dariiioz](https://github.com/dariiioz) / [triphub-front](https://github.com/dariiioz/triphub-front) | 0 |
19
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/31977125?s=40&v=4" width="20" height="20" alt=""> &nbsp; [hendradedis](https://github.com/hendradedis) / [BacAku](https://github.com/hendradedis/BacAku) | 0 |
20
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/150951943?s=40&v=4" width="20" height="20" alt=""> &nbsp; [LoreneMntp](https://github.com/LoreneMntp) / [Triphub-front](https://github.com/LoreneMntp/Triphub-front) | 0 |
21
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/139728411?s=40&v=4" width="20" height="20" alt=""> &nbsp; [TPLCarloTaleon](https://github.com/TPLCarloTaleon) / [encrypt-decrypt-pdf](https://github.com/TPLCarloTaleon/encrypt-decrypt-pdf) | 0 |
22
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/92579981?s=40&v=4" width="20" height="20" alt=""> &nbsp; [janani-gopi](https://github.com/janani-gopi) / [PDFviewer](https://github.com/janani-gopi/PDFviewer) | 0 |
23
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/104327603?s=40&v=4" width="20" height="20" alt=""> &nbsp; [florvillalba21](https://github.com/florvillalba21) / [alfresco-testing](https://github.com/florvillalba21/alfresco-testing) | 0 |
24
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/127974191?s=40&v=4" width="20" height="20" alt=""> &nbsp; [typark1234](https://github.com/typark1234) / [nucampsite](https://github.com/typark1234/nucampsite) | 0 |
25
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/22235844?s=40&v=4" width="20" height="20" alt=""> &nbsp; [thanhttb](https://github.com/thanhttb) / [vee-app](https://github.com/thanhttb/vee-app) | 0 |
26
+ |<img class="avatar mr-2" src="https://avatars.githubusercontent.com/u/6248392?s=40&v=4" width="20" height="20" alt=""> &nbsp; [pangyujie](https://github.com/pangyujie) / [react-native-pdf-renderer](https://github.com/pangyujie/react-native-pdf-renderer) | 0 |
27
+
28
+ _Generated using [github-dependents-info](https://github.com/nvuillam/github-dependents-info), by [Nicolas Vuillamy](https://github.com/nvuillam)_
package/README.md CHANGED
@@ -12,6 +12,14 @@ It uses [PdfRenderer](https://developer.android.com/reference/android/graphics/p
12
12
  |-|-|
13
13
  |<img src="https://github.com/douglasjunior/react-native-pdf-renderer/raw/main/screenshots/android.gif" width="240"/>|<img src="https://github.com/douglasjunior/react-native-pdf-renderer/raw/main/screenshots/ios.gif" width="240"/>
14
14
 
15
+ ## Why another PDF renderer?
16
+
17
+ The main reason why I create this library is to avoid using third party native dependencies, like `com.github.TalbotGooday:AndroidPdfViewer`, `com.github.mhiew:android-pdf-viewer`, `react-native-blob-util` or even `react-native-webview`.
18
+
19
+ But why?
20
+
21
+ Every React Native developer knows (or will discover soon) [the pain of updating the React Native ecosystem](https://x.com/flexbox_/status/1806786055057674337) when a new version of Android or iOS comes out, so here we want to avoid this pain as much as possible.
22
+
15
23
  ## Requirements
16
24
 
17
25
  - React Native >= 0.60.0
@@ -65,14 +73,14 @@ For more details, see the [Sample Project](https://github.com/douglasjunior/reac
65
73
 
66
74
  ## PdfRendererView props
67
75
 
68
- |Name|Value|Default|Description|
76
+ |Name|Type|Default|Description|
69
77
  |-|-|-|-|
70
78
  |source|`string`||Path to a file stored on device.|
71
79
  |distanceBetweenPages|`number`|`16`|Distance in `DPI` between pages.|
72
80
  |maxZoom|`number`|`5`|Max zoom scale.|
73
81
  |singlePage|`boolean`|`false`|(Experimental) Renders only the first page without scroll. (useful for display thumbnail)|
74
82
  |onPageChange|`(current: number, total: number) => void`||Invoked on pages scroll.|
75
- |style|`StyleProp<ViewStyle>`||Styles to be applied to the View |
83
+ |style|`StyleProp<ViewStyle>`||Styles to be applied to the native [view](https://reactnative.dev/docs/view-style-props).|
76
84
 
77
85
  ## Limitations
78
86
 
@@ -82,7 +90,7 @@ The `PdfRendererView` is `flex: 1` by default, so you need to make sure that you
82
90
 
83
91
  ### Border radius
84
92
 
85
- The `borderRadius` style is ignored by React Native custom view in Android and crash on iOS. (read more #1)
93
+ The `borderRadius` style is ignored by React Native custom view in Android and crash on iOS. (read more [#1](https://github.com/douglasjunior/react-native-pdf-renderer/issues/1#issuecomment-1483395465))
86
94
 
87
95
  If you need `borderRadius`, the best option is to wrap the `PdfRendererView` in another `View`.
88
96
 
@@ -94,6 +102,12 @@ If you need `borderRadius`, the best option is to wrap the `PdfRendererView` in
94
102
  </View>
95
103
  ```
96
104
 
105
+ ## Mock with jest
106
+
107
+ ```js
108
+ jest.mock('react-native-pdf-renderer', () => require('react-native-pdf-renderer/dist/mock'));
109
+ ```
110
+
97
111
  ## Contribute
98
112
 
99
113
  New features, bug fixes and improvements are welcome! For questions and suggestions use the [issues](https://github.com/douglasjunior/react-native-pdf-renderer/issues).
@@ -108,7 +122,7 @@ This lib is only possible thanks to the community help:
108
122
  - RecyclerView `notifyDataSetChanged()` not working on React Native: https://stackoverflow.com/a/49381907/2826279
109
123
  - Add pinch to zoom on RecyclerView: https://stackoverflow.com/a/37895783/2826279
110
124
  - Using `Matrix` to handle zoom in a View: https://stackoverflow.com/a/55299327/2826279
111
- - **Daniel Felipe Sartório** for the help with Android native code
125
+ - [Daniel Felipe Sartório](https://github.com/danielfelipesartorio) for the help with Android native code
112
126
 
113
127
  ## Star History
114
128
 
@@ -30,7 +30,6 @@ import com.facebook.react.bridge.ReactApplicationContext;
30
30
  import com.facebook.react.uimanager.ViewManager;
31
31
  import com.github.douglasjunior.reactNativePdfRenderer.modules.PdfRendererViewManager;
32
32
 
33
- import java.util.Arrays;
34
33
  import java.util.Collections;
35
34
  import java.util.List;
36
35
 
@@ -44,7 +43,7 @@ public class PdfRendererPackage implements ReactPackage {
44
43
  @NonNull
45
44
  @Override
46
45
  public List<ViewManager> createViewManagers(@NonNull ReactApplicationContext reactApplicationContext) {
47
- return Arrays.asList(
46
+ return Collections.singletonList(
48
47
  new PdfRendererViewManager(reactApplicationContext)
49
48
  );
50
49
  }
@@ -0,0 +1,63 @@
1
+ // MIT License
2
+
3
+ // Copyright (c) 2023 Douglas Nassif Roma Junior
4
+
5
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ // of this software and associated documentation files (the "Software"), to deal
7
+ // in the Software without restriction, including without limitation the rights
8
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ // copies of the Software, and to permit persons to whom the Software is
10
+ // furnished to do so, subject to the following conditions:
11
+
12
+ // The above copyright notice and this permission notice shall be included in all
13
+ // copies or substantial portions of the Software.
14
+
15
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ // SOFTWARE.
22
+
23
+ package com.github.douglasjunior.reactNativePdfRenderer.modules;
24
+
25
+ import java.util.HashSet;
26
+ import java.util.Set;
27
+
28
+ public class ObservableZoom {
29
+ private final Set<ZoomChangeListener> listeners = new HashSet<>();
30
+ private float zoom;
31
+
32
+ public ObservableZoom(int initialZoom) {
33
+ this.zoom = initialZoom;
34
+ }
35
+
36
+ public void addListener(ZoomChangeListener listener) {
37
+ this.listeners.add(listener);
38
+ }
39
+
40
+ public void removeListener(ZoomChangeListener zoomListener) {
41
+ this.listeners.remove(zoomListener);
42
+ }
43
+
44
+ private void notifyListeners() {
45
+ for (ZoomChangeListener listener : listeners) {
46
+ listener.onZoomChange(this.zoom);
47
+ }
48
+ }
49
+
50
+ public float getZoom() {
51
+ return zoom;
52
+ }
53
+
54
+ public void setZoom(float newZoom) {
55
+ if (newZoom == this.zoom) return;
56
+ this.zoom = newZoom;
57
+ notifyListeners();
58
+ }
59
+
60
+ public interface ZoomChangeListener {
61
+ void onZoomChange(float newZoom);
62
+ }
63
+ }
@@ -31,6 +31,8 @@ import android.graphics.Color;
31
31
  import android.graphics.Matrix;
32
32
  import android.graphics.pdf.PdfRenderer;
33
33
  import android.os.ParcelFileDescriptor;
34
+ import android.text.TextUtils;
35
+ import android.util.Log;
34
36
  import android.util.TypedValue;
35
37
  import android.view.GestureDetector;
36
38
  import android.view.MotionEvent;
@@ -45,38 +47,47 @@ import androidx.recyclerview.widget.RecyclerView;
45
47
 
46
48
  import com.facebook.react.bridge.Arguments;
47
49
  import com.facebook.react.bridge.ReactApplicationContext;
48
- import com.facebook.react.bridge.WritableMap;
49
50
  import com.facebook.react.uimanager.events.RCTEventEmitter;
50
51
 
51
52
  import java.io.File;
52
53
  import java.io.IOException;
53
54
 
55
+ @SuppressLint({"ViewConstructor", "NotifyDataSetChanged"})
54
56
  public class PdfRendererRecyclerView extends RecyclerView {
55
57
  private final ViewGroup mParent;
56
58
  private final GestureDetector mGestureDetector;
59
+ private final int mMinZoom = 1;
60
+ private final ReactApplicationContext mReactApplicationContext;
61
+ private final ScaleGestureDetector mScaleDetector;
62
+ private final Matrix mMatrix;
63
+ private final ObservableZoom mZoomObserver;
64
+ private final LayoutManager mLayoutManager;
57
65
  private boolean mRequestedLayout = false;
58
- private float mMinZoom = 1;
59
66
  private float mMaxZoom = 5;
60
67
  private float mDistanceBetweenPages = 0;
61
68
  private int mWidth;
62
69
  private int mHeight;
63
70
  private int mCurrentItemPosition = -1;
64
- private ReactApplicationContext mReactApplicationContext;
65
- private ScaleGestureDetector mScaleDetector;
66
- private Matrix mMatrix;
67
71
  private boolean mSinglePage;
68
72
 
69
73
  public PdfRendererRecyclerView(@NonNull ReactApplicationContext context, ViewGroup parent) {
70
74
  super(context);
71
75
 
72
- LayoutManager lm = new LayoutManager(context);
73
- lm.setOrientation(LinearLayoutManager.VERTICAL);
76
+ mZoomObserver = new ObservableZoom(mMinZoom);
74
77
 
75
- PdfRendererAdapter adapter = new PdfRendererAdapter();
78
+ mLayoutManager = new LayoutManager(context);
79
+ mLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
76
80
 
77
- this.setLayoutManager(lm);
81
+ var adapter = new PdfRendererAdapter();
82
+
83
+ this.setLayoutManager(mLayoutManager);
78
84
  this.setAdapter(adapter);
79
- this.addOnScrollListener(new ScrollListener());
85
+ this.addOnScrollListener(new OnScrollListener() {
86
+ @Override
87
+ public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
88
+ dispatchPageChangeEvent();
89
+ }
90
+ });
80
91
 
81
92
  mReactApplicationContext = context;
82
93
  mParent = parent;
@@ -99,37 +110,37 @@ public class PdfRendererRecyclerView extends RecyclerView {
99
110
 
100
111
  public void closeAdapter() {
101
112
  try {
102
- PdfRendererAdapter adapter = (PdfRendererAdapter) getAdapter();
113
+ var adapter = (PdfRendererAdapter) getAdapter();
114
+ assert adapter != null;
103
115
  adapter.close();
104
116
  adapter.notifyDataSetChanged();
105
117
  } catch (Exception ex) {
106
- ex.printStackTrace();
107
- // do nothing
118
+ Log.e("PdfRendererRecyclerView", "Error closing adapter", ex);
108
119
  }
109
120
  }
110
121
 
111
122
  public void updateSource(String source) throws IOException {
112
123
  mCurrentItemPosition = -1;
113
- PdfRendererAdapter adapter = (PdfRendererAdapter) getAdapter();
124
+ var adapter = (PdfRendererAdapter) getAdapter();
125
+ if (adapter == null) return;
126
+ adapter.close();
114
127
  adapter.updateSource(source);
115
128
  adapter.notifyDataSetChanged();
116
- dispatchPageChangeEvent();
129
+ post(this::dispatchPageChangeEvent);
117
130
  }
118
131
 
119
132
  private void dispatchPageChangeEvent() {
120
- int position = ((LinearLayoutManager) getLayoutManager()).findLastCompletelyVisibleItemPosition();
133
+ var newPosition = mLayoutManager.findLastCompletelyVisibleItemPosition();
134
+ if (newPosition < 0) newPosition = mLayoutManager.findLastVisibleItemPosition();
121
135
 
122
- if (position < 0) {
123
- position = ((LinearLayoutManager) getLayoutManager()).findLastVisibleItemPosition();
124
- }
136
+ if (newPosition != mCurrentItemPosition) {
137
+ mCurrentItemPosition = newPosition;
125
138
 
126
- if (position != mCurrentItemPosition) {
127
- mCurrentItemPosition = position;
139
+ var adapter = (PdfRendererAdapter) getAdapter();
140
+ if (adapter == null) return;
128
141
 
129
- PdfRendererAdapter adapter = (PdfRendererAdapter) getAdapter();
130
-
131
- WritableMap event = Arguments.createMap();
132
- event.putInt("position", position);
142
+ var event = Arguments.createMap();
143
+ event.putInt("position", newPosition);
133
144
  event.putInt("total", adapter.getPageCount());
134
145
 
135
146
  mReactApplicationContext
@@ -156,7 +167,7 @@ public class PdfRendererRecyclerView extends RecyclerView {
156
167
  @Override
157
168
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
158
169
  super.onSizeChanged(w, h, oldw, oldh);
159
- float scale = mWidth > 0 && mHeight > 0
170
+ var scale = mWidth > 0 && mHeight > 0
160
171
  ? Math.max(w / mWidth, h / mHeight)
161
172
  : 1;
162
173
  mMatrix.setScale(scale, scale);
@@ -164,13 +175,13 @@ public class PdfRendererRecyclerView extends RecyclerView {
164
175
  }
165
176
 
166
177
  private boolean isScrollingInsideZoomedArea() {
167
- float[] values = new float[9];
178
+ var values = new float[9];
168
179
  mMatrix.getValues(values);
169
180
 
170
- float scaleY = Math.min(Math.max(values[Matrix.MSCALE_Y], mMinZoom), mMaxZoom);
171
- float posY = values[Matrix.MTRANS_Y];
181
+ var scaleY = Math.min(Math.max(values[Matrix.MSCALE_Y], mMinZoom), mMaxZoom);
182
+ var posY = values[Matrix.MTRANS_Y];
172
183
 
173
- float maxPosY = mHeight - mHeight * scaleY;
184
+ var maxPosY = mHeight - mHeight * scaleY;
174
185
 
175
186
  return posY < 0 && posY > maxPosY;
176
187
  }
@@ -197,7 +208,7 @@ public class PdfRendererRecyclerView extends RecyclerView {
197
208
  try {
198
209
  return super.onInterceptTouchEvent(ev);
199
210
  } catch (IllegalArgumentException ex) {
200
- ex.printStackTrace();
211
+ Log.e("PdfRendererRecyclerView", "Error intercepting touch event", ex);
201
212
  }
202
213
  return false;
203
214
  }
@@ -208,17 +219,17 @@ public class PdfRendererRecyclerView extends RecyclerView {
208
219
  }
209
220
 
210
221
  private void validateMatrixLimits() {
211
- float[] values = new float[9];
222
+ var values = new float[9];
212
223
  mMatrix.getValues(values);
213
224
 
214
- float scaleX = Math.min(Math.max(values[Matrix.MSCALE_X], mMinZoom), mMaxZoom);
215
- float posX = values[Matrix.MTRANS_X];
225
+ var scaleX = Math.min(Math.max(values[Matrix.MSCALE_X], mMinZoom), mMaxZoom);
226
+ var posX = values[Matrix.MTRANS_X];
216
227
 
217
- float scaleY = Math.min(Math.max(values[Matrix.MSCALE_Y], mMinZoom), mMaxZoom);
218
- float posY = values[Matrix.MTRANS_Y];
228
+ var scaleY = Math.min(Math.max(values[Matrix.MSCALE_Y], mMinZoom), mMaxZoom);
229
+ var posY = values[Matrix.MTRANS_Y];
219
230
 
220
- float maxPosX = mWidth - mWidth * scaleX;
221
- float maxPosY = mHeight - mHeight * scaleY;
231
+ var maxPosX = mWidth - mWidth * scaleX;
232
+ var maxPosY = mHeight - mHeight * scaleY;
222
233
 
223
234
  if (posX > 0.0f)
224
235
  posX = 0.0f;
@@ -261,11 +272,11 @@ public class PdfRendererRecyclerView extends RecyclerView {
261
272
  private class ScaleListener extends ScaleGestureDetector.SimpleOnScaleGestureListener {
262
273
  @Override
263
274
  public boolean onScale(ScaleGestureDetector detector) {
264
- float[] values = new float[9];
275
+ var values = new float[9];
265
276
  mMatrix.getValues(values);
266
277
 
267
- float zoom = values[Matrix.MSCALE_X];
268
- float factor = detector.getScaleFactor();
278
+ var zoom = values[Matrix.MSCALE_X];
279
+ var factor = detector.getScaleFactor();
269
280
 
270
281
  if (zoom >= mMaxZoom && factor > 1) {
271
282
  return false;
@@ -274,8 +285,20 @@ public class PdfRendererRecyclerView extends RecyclerView {
274
285
  mMatrix.postScale(factor, factor, getWidth() / 2f, getHeight() / 2f);
275
286
  validateMatrixLimits();
276
287
  ViewCompat.postInvalidateOnAnimation(PdfRendererRecyclerView.this);
288
+
277
289
  return true;
278
290
  }
291
+
292
+ @Override
293
+ public void onScaleEnd(@NonNull ScaleGestureDetector detector) {
294
+ super.onScaleEnd(detector);
295
+
296
+ var values = new float[9];
297
+ mMatrix.getValues(values);
298
+ var zoom = values[Matrix.MSCALE_X];
299
+
300
+ mZoomObserver.setZoom(zoom);
301
+ }
279
302
  }
280
303
 
281
304
  private class GestureListener extends GestureDetector.SimpleOnGestureListener {
@@ -293,13 +316,13 @@ public class PdfRendererRecyclerView extends RecyclerView {
293
316
  return false;
294
317
  }
295
318
 
296
- float[] values = new float[9];
319
+ var values = new float[9];
297
320
  mMatrix.getValues(values);
298
321
 
299
- float currentZoom = values[Matrix.MSCALE_X];
300
- float newZoom = currentZoom > mMinZoom ? mMinZoom : mMaxZoom;
301
- float centerX = getWidth() / 2f;
302
- float centerY = getHeight() / 2f;
322
+ var currentZoom = values[Matrix.MSCALE_X];
323
+ var newZoom = currentZoom > mMinZoom ? mMinZoom : mMaxZoom;
324
+ var centerX = getWidth() / 2f;
325
+ var centerY = getHeight() / 2f;
303
326
 
304
327
  mMatrix.setScale(newZoom, newZoom, centerX, centerY);
305
328
  mMatrix.postTranslate(centerX - e.getX(), centerY - e.getY());
@@ -307,6 +330,8 @@ public class PdfRendererRecyclerView extends RecyclerView {
307
330
  validateMatrixLimits();
308
331
 
309
332
  ViewCompat.postInvalidateOnAnimation(PdfRendererRecyclerView.this);
333
+
334
+ mZoomObserver.setZoom(newZoom);
310
335
  return true;
311
336
  }
312
337
  }
@@ -317,15 +342,15 @@ public class PdfRendererRecyclerView extends RecyclerView {
317
342
  private PdfRenderer mPdfRenderer;
318
343
 
319
344
  public void updateSource(String source) throws IOException {
320
- if (source == null || source.isEmpty()) return;
321
- File file = new File(source.replace("file://", ""));
345
+ if (TextUtils.isEmpty(source)) return;
346
+ var file = new File(source.replace("file://", ""));
322
347
  mFileDescriptor = ParcelFileDescriptor.open(file, ParcelFileDescriptor.MODE_READ_ONLY);
323
348
  mPdfRenderer = new PdfRenderer(mFileDescriptor);
324
349
  }
325
350
 
326
351
  public void close() throws IOException {
327
- mPdfRenderer.close();
328
- mFileDescriptor.close();
352
+ if (mPdfRenderer != null) mPdfRenderer.close();
353
+ if (mFileDescriptor != null) mFileDescriptor.close();
329
354
  mPdfRenderer = null;
330
355
  mFileDescriptor = null;
331
356
  }
@@ -333,40 +358,30 @@ public class PdfRendererRecyclerView extends RecyclerView {
333
358
  @NonNull
334
359
  @Override
335
360
  public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
336
- ImageView imageView = new ImageView(parent.getContext());
361
+ var imageView = new ImageView(parent.getContext());
337
362
  imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
338
363
  imageView.setBackgroundColor(Color.WHITE);
339
- LayoutParams params = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
364
+ var params = new LayoutParams(LayoutParams.MATCH_PARENT, 0);
340
365
  imageView.setLayoutParams(params);
341
- ViewHolder viewHolder = new ViewHolder(parent, imageView);
342
- return viewHolder;
366
+ return new ViewHolder(imageView);
343
367
  }
344
368
 
345
369
  @Override
346
- public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
347
- if (mPdfRenderer == null) return;
348
-
349
- PdfRenderer.Page page = mPdfRenderer.openPage(position);
350
- Bitmap bitmap = Bitmap.createBitmap(page.getWidth(), page.getHeight(), Bitmap.Config.ARGB_4444);
351
- page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
352
-
353
- ImageView imageView = holder.getImageView();
354
- imageView.setImageBitmap(bitmap);
355
-
356
- LayoutParams lp = (LayoutParams) imageView.getLayoutParams();
357
- lp.width = LayoutParams.MATCH_PARENT;
358
-
359
- if (mSinglePage) {
360
- lp.height = LayoutParams.MATCH_PARENT;
361
- lp.setMargins(0, 0, 0, 0);
362
- } else {
363
- lp.height = Math.round(((float) mWidth / (float) page.getWidth()) * (float) page.getHeight());
364
- lp.setMargins(0, 0, 0, (int) mDistanceBetweenPages);
365
- }
370
+ public void onViewDetachedFromWindow(@NonNull ViewHolder holder) {
371
+ super.onViewDetachedFromWindow(holder);
372
+ holder.detachFromWindow();
373
+ }
366
374
 
367
- imageView.setLayoutParams(lp);
375
+ @Override
376
+ public void onViewAttachedToWindow(@NonNull ViewHolder holder) {
377
+ super.onViewAttachedToWindow(holder);
378
+ holder.attachFromWindow();
379
+ }
368
380
 
369
- page.close();
381
+ @Override
382
+ public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
383
+ if (mPdfRenderer == null) return;
384
+ holder.update(position, mZoomObserver.getZoom());
370
385
  }
371
386
 
372
387
  @Override
@@ -384,29 +399,61 @@ public class PdfRendererRecyclerView extends RecyclerView {
384
399
  }
385
400
 
386
401
  public class ViewHolder extends RecyclerView.ViewHolder {
402
+ private ObservableZoom.ZoomChangeListener zoomListener;
387
403
 
388
- private final ViewGroup mParentView;
389
-
390
- public ViewHolder(ViewGroup parentView, ImageView imageView) {
404
+ public ViewHolder(ImageView imageView) {
391
405
  super(imageView);
392
- mParentView = parentView;
393
- }
394
-
395
- public ViewGroup getParentView() {
396
- return mParentView;
397
406
  }
398
407
 
399
408
  public ImageView getImageView() {
400
409
  return (ImageView) this.itemView;
401
410
  }
402
- }
403
- }
404
411
 
405
- class ScrollListener extends OnScrollListener {
412
+ public void update(int position, float newZoom) {
413
+ var page = mPdfRenderer.openPage(position);
414
+ var bitmap = Bitmap.createBitmap(
415
+ Math.round(page.getWidth() * newZoom),
416
+ Math.round(page.getHeight() * newZoom),
417
+ Bitmap.Config.ARGB_4444
418
+ );
419
+ page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY);
420
+
421
+ var imageView = getImageView();
422
+ imageView.setImageBitmap(bitmap);
423
+
424
+ var lp = (LayoutParams) imageView.getLayoutParams();
425
+ lp.width = LayoutParams.MATCH_PARENT;
426
+
427
+ if (mSinglePage) {
428
+ lp.height = LayoutParams.MATCH_PARENT;
429
+ lp.setMargins(0, 0, 0, 0);
430
+ } else {
431
+ lp.height = Math.round(((float) mWidth / (float) page.getWidth()) * (float) page.getHeight());
432
+ lp.setMargins(0, 0, 0, (int) mDistanceBetweenPages);
433
+ }
434
+ imageView.setLayoutParams(lp);
435
+
436
+ page.close();
437
+ }
406
438
 
407
- @Override
408
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
409
- dispatchPageChangeEvent();
439
+ public void detachFromWindow() {
440
+ if (zoomListener != null) {
441
+ mZoomObserver.removeListener(zoomListener);
442
+ zoomListener = null;
443
+ }
444
+ }
445
+
446
+ public void attachFromWindow() {
447
+ detachFromWindow();
448
+ zoomListener = newZoom -> {
449
+ var position = getLayoutPosition();
450
+ if (position == NO_POSITION) return;
451
+ if (position < mLayoutManager.findFirstVisibleItemPosition()
452
+ || position > mLayoutManager.findLastVisibleItemPosition()) return;
453
+ update(position, newZoom);
454
+ };
455
+ mZoomObserver.addListener(zoomListener);
456
+ }
410
457
  }
411
458
  }
412
459
 
@@ -422,12 +469,11 @@ public class PdfRendererRecyclerView extends RecyclerView {
422
469
  * https://github.com/douglasjunior/react-native-pdf-renderer/issues/3
423
470
  */
424
471
 
425
- float[] values = new float[9];
472
+ var values = new float[9];
426
473
  mMatrix.getValues(values);
427
474
 
428
- float scaleY = values[Matrix.MSCALE_Y];
429
-
430
- int dyWithScale = Math.round(dy / scaleY);
475
+ var scaleY = values[Matrix.MSCALE_Y];
476
+ var dyWithScale = Math.round(dy / scaleY);
431
477
 
432
478
  return super.scrollVerticallyBy(dyWithScale, recycler, state);
433
479
  }
@@ -28,7 +28,6 @@ import android.widget.LinearLayout;
28
28
 
29
29
  import androidx.annotation.NonNull;
30
30
  import androidx.annotation.Nullable;
31
- import androidx.recyclerview.widget.RecyclerView;
32
31
 
33
32
  import com.facebook.react.bridge.ReactApplicationContext;
34
33
  import com.facebook.react.bridge.ReadableMap;
@@ -41,8 +40,7 @@ import java.io.IOException;
41
40
  import java.util.Map;
42
41
 
43
42
  public class PdfRendererViewManager extends SimpleViewManager<ViewGroup> {
44
-
45
- private ReactApplicationContext mReactApplicationContext;
43
+ private final ReactApplicationContext mReactApplicationContext;
46
44
 
47
45
  public PdfRendererViewManager(ReactApplicationContext reactApplicationContext) {
48
46
  this.mReactApplicationContext = reactApplicationContext;
@@ -57,16 +55,15 @@ public class PdfRendererViewManager extends SimpleViewManager<ViewGroup> {
57
55
  @NonNull
58
56
  @Override
59
57
  protected ViewGroup createViewInstance(@NonNull ThemedReactContext themedReactContext) {
60
- LinearLayout layout = new LinearLayout(themedReactContext);
58
+ var layout = new LinearLayout(themedReactContext);
61
59
  layout.setOrientation(LinearLayout.VERTICAL);
62
60
 
63
- LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
61
+ var params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
64
62
 
65
- PdfRendererRecyclerView recyclerView = new PdfRendererRecyclerView(mReactApplicationContext, layout);
63
+ var recyclerView = new PdfRendererRecyclerView(mReactApplicationContext, layout);
66
64
  recyclerView.setLayoutParams(params);
67
65
 
68
66
  layout.addView(recyclerView);
69
-
70
67
  layout.setClipToOutline(true);
71
68
 
72
69
  return layout;
@@ -75,7 +72,8 @@ public class PdfRendererViewManager extends SimpleViewManager<ViewGroup> {
75
72
  @Nullable
76
73
  @Override
77
74
  public Map<String, Object> getExportedCustomBubblingEventTypeConstants() {
78
- Map map = super.getExportedCustomBubblingEventTypeConstants();
75
+ var map = super.getExportedCustomBubblingEventTypeConstants();
76
+ if (map == null) map = MapBuilder.of();
79
77
  map.put("pageChange", MapBuilder.of(
80
78
  "phasedRegistrationNames",
81
79
  MapBuilder.of("bubbled", "onPageChange")
@@ -85,11 +83,13 @@ public class PdfRendererViewManager extends SimpleViewManager<ViewGroup> {
85
83
 
86
84
  @ReactProp(name = "params")
87
85
  public void setParams(ViewGroup layout, @Nullable ReadableMap params) throws IOException {
88
- PdfRendererRecyclerView recyclerView = (PdfRendererRecyclerView) layout.getChildAt(0);
86
+ if (params == null) return;
89
87
 
90
- String source = params.getString("source");
91
- Boolean singlePage = params.hasKey("singlePage") ? params.getBoolean("singlePage") : false;
92
- float maxZoom = params.hasKey("maxZoom") ? Double.valueOf(params.getDouble("maxZoom")).floatValue() : 5;
88
+ var recyclerView = (PdfRendererRecyclerView) layout.getChildAt(0);
89
+
90
+ var source = params.getString("source");
91
+ var singlePage = params.hasKey("singlePage") && params.getBoolean("singlePage");
92
+ var maxZoom = params.hasKey("maxZoom") ? Double.valueOf(params.getDouble("maxZoom")).floatValue() : 5;
93
93
 
94
94
  if (source != null) {
95
95
  recyclerView.updateSource(source);
@@ -106,8 +106,7 @@ public class PdfRendererViewManager extends SimpleViewManager<ViewGroup> {
106
106
 
107
107
  @ReactProp(name = "distanceBetweenPages")
108
108
  public void setDistanceBetweenPages(ViewGroup layout, @Nullable float distanceBetweenPages) {
109
- PdfRendererRecyclerView recyclerView = (PdfRendererRecyclerView) layout.getChildAt(0);
109
+ var recyclerView = (PdfRendererRecyclerView) layout.getChildAt(0);
110
110
  recyclerView.setDistanceBetweenPages(distanceBetweenPages);
111
111
  }
112
-
113
112
  }
@@ -1,18 +1,45 @@
1
1
  import { ViewProps } from 'react-native';
2
- export declare type PdfRendererViewPropsType = {
2
+ export type PdfRendererViewPropsType = {
3
+ testID?: string;
4
+ /**
5
+ * Styles to be applied to the View.
6
+ *
7
+ * Note: Border radius is not supported.
8
+ */
3
9
  style?: ViewProps['style'];
10
+ /**
11
+ * Path to a file stored on device.
12
+ *
13
+ * Ex.: `file:///path/to/file.pdf`
14
+ */
4
15
  source?: string;
5
- distanceBetweenPages: number;
6
- maxZoom: number;
7
- singlePage: boolean;
16
+ /**
17
+ * Distance in `DPI` between pages.
18
+ *
19
+ * Default: 16
20
+ */
21
+ distanceBetweenPages?: number;
22
+ /**
23
+ * Max zoom scale.
24
+ *
25
+ * Default: 5
26
+ */
27
+ maxZoom?: number;
28
+ /**
29
+ * (Experimental)
30
+ *
31
+ * Renders only the first page without scroll. (useful for display thumbnail).
32
+ *
33
+ * Default: false
34
+ */
35
+ singlePage?: boolean;
36
+ /**
37
+ * Invoked on pages scroll.
38
+ *
39
+ * @param page current page number
40
+ * @param totalPages total pages number
41
+ */
8
42
  onPageChange?: (page: number, totalPages: number) => void;
9
43
  };
10
- declare const PdfRendererView: {
11
- (props: PdfRendererViewPropsType): JSX.Element;
12
- defaultProps: {
13
- maxZoom: number;
14
- distanceBetweenPages: number;
15
- singlePage: boolean;
16
- };
17
- };
44
+ declare const PdfRendererView: ({ testID, onPageChange, style, source, singlePage, distanceBetweenPages, maxZoom, }: PdfRendererViewPropsType) => JSX.Element;
18
45
  export default PdfRendererView;
@@ -1,29 +1,4 @@
1
- "use strict";
2
1
  // MIT License
3
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
- if (k2 === undefined) k2 = k;
5
- var desc = Object.getOwnPropertyDescriptor(m, k);
6
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
- desc = { enumerable: true, get: function() { return m[k]; } };
8
- }
9
- Object.defineProperty(o, k2, desc);
10
- }) : (function(o, m, k, k2) {
11
- if (k2 === undefined) k2 = k;
12
- o[k2] = m[k];
13
- }));
14
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
- Object.defineProperty(o, "default", { enumerable: true, value: v });
16
- }) : function(o, v) {
17
- o["default"] = v;
18
- });
19
- var __importStar = (this && this.__importStar) || function (mod) {
20
- if (mod && mod.__esModule) return mod;
21
- var result = {};
22
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
23
- __setModuleDefault(result, mod);
24
- return result;
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
2
  // Copyright (c) 2023 Douglas Nassif Roma Junior
28
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy
29
4
  // of this software and associated documentation files (the "Software"), to deal
@@ -40,35 +15,33 @@ Object.defineProperty(exports, "__esModule", { value: true });
40
15
  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
41
16
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
42
17
  // SOFTWARE.
43
- const react_1 = __importStar(require("react"));
44
- const react_native_1 = require("react-native");
45
- const PdfRendererNative = (0, react_native_1.requireNativeComponent)('RNPdfRendererView');
46
- const styles = react_native_1.StyleSheet.create({
18
+ import React, { useCallback, useMemo } from 'react';
19
+ import { requireNativeComponent, StyleSheet, } from 'react-native';
20
+ const PdfRendererNative = requireNativeComponent('RNPdfRendererView');
21
+ const styles = StyleSheet.create({
47
22
  default: {
48
23
  backgroundColor: 'gray',
49
24
  flex: 1,
50
25
  },
51
26
  });
52
- const PdfRendererView = (props) => {
53
- const { onPageChange, style, source, singlePage, maxZoom, ...others } = props;
54
- const viewStyles = (0, react_1.useMemo)(() => [styles.default, style, {
27
+ const PdfRendererView = ({ testID = undefined, onPageChange, style, source, singlePage = false, distanceBetweenPages = 16, maxZoom = 5, }) => {
28
+ const viewStyles = useMemo(() => [
29
+ styles.default,
30
+ style,
31
+ {
55
32
  // See https://github.com/douglasjunior/react-native-pdf-renderer#limitations
56
33
  borderRadius: null,
57
- }], [style]);
58
- const handlePageChange = (0, react_1.useCallback)((event) => {
34
+ },
35
+ ], [style]);
36
+ const handlePageChange = useCallback((event) => {
59
37
  onPageChange?.(event.nativeEvent.position, event.nativeEvent.total);
60
38
  }, [onPageChange]);
61
- const params = (0, react_1.useMemo)(() => ({
39
+ const params = useMemo(() => ({
62
40
  source,
63
41
  singlePage,
64
42
  maxZoom,
65
43
  }), [source, singlePage, maxZoom]);
66
- return (react_1.default.createElement(PdfRendererNative, { ...others, style: viewStyles, params: params, onPageChange: handlePageChange }));
67
- };
68
- PdfRendererView.defaultProps = {
69
- maxZoom: 5,
70
- distanceBetweenPages: 16,
71
- singlePage: false,
44
+ return (React.createElement(PdfRendererNative, { testID: testID, distanceBetweenPages: distanceBetweenPages, style: viewStyles, params: params, onPageChange: handlePageChange }));
72
45
  };
73
- exports.default = PdfRendererView;
46
+ export default PdfRendererView;
74
47
  //# sourceMappingURL=PdfRendererView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PdfRendererView.js","sourceRoot":"","sources":["../src/PdfRendererView.tsx"],"names":[],"mappings":";AAAA,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,+CAAkD;AAClD,+CAKsB;AAgBtB,MAAM,iBAAiB,GAAG,IAAA,qCAAsB,EAAC,mBAAmB,CAAQ,CAAC;AAE7E,MAAM,MAAM,GAAG,yBAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,KAA+B,EAAe,EAAE;IACvE,MAAM,EAAC,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,MAAM,EAAC,GAAG,KAAK,CAAC;IAE5E,MAAM,UAAU,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE;YACvD,6EAA6E;YAC7E,YAAY,EAAE,IAAI;SACnB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC;IAEb,MAAM,gBAAgB,GAAG,IAAA,mBAAW,EAClC,CAAC,KAAkD,EAAE,EAAE;QACrD,YAAY,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,MAAM,MAAM,GAAG,IAAA,eAAO,EACpB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,UAAU;QACV,OAAO;KACR,CAAC,EACF,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,8BAAC,iBAAiB,OACZ,MAAM,EACV,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,CAAC,YAAY,GAAG;IAC7B,OAAO,EAAE,CAAC;IACV,oBAAoB,EAAE,EAAE;IACxB,UAAU,EAAE,KAAK;CAClB,CAAC;AAEF,kBAAe,eAAe,CAAC"}
1
+ {"version":3,"file":"PdfRendererView.js","sourceRoot":"","sources":["../src/PdfRendererView.tsx"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,KAAK,EAAE,EAAC,WAAW,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AAClD,OAAO,EAEL,sBAAsB,EACtB,UAAU,GAEX,MAAM,cAAc,CAAC;AAkDtB,MAAM,iBAAiB,GAAG,sBAAsB,CAAC,mBAAmB,CAAQ,CAAC;AAE7E,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,OAAO,EAAE;QACP,eAAe,EAAE,MAAM;QACvB,IAAI,EAAE,CAAC;KACR;CACF,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,CAAC,EACvB,MAAM,GAAG,SAAS,EAClB,YAAY,EACZ,KAAK,EACL,MAAM,EACN,UAAU,GAAG,KAAK,EAClB,oBAAoB,GAAG,EAAE,EACzB,OAAO,GAAG,CAAC,GACc,EAAe,EAAE;IAC1C,MAAM,UAAU,GAAG,OAAO,CACxB,GAAG,EAAE,CAAC;QACJ,MAAM,CAAC,OAAO;QACd,KAAK;QACL;YACE,6EAA6E;YAC7E,YAAY,EAAE,IAAI;SACnB;KACF,EACD,CAAC,KAAK,CAAC,CACR,CAAC;IAEF,MAAM,gBAAgB,GAAG,WAAW,CAClC,CAAC,KAAkD,EAAE,EAAE;QACrD,YAAY,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACtE,CAAC,EACD,CAAC,YAAY,CAAC,CACf,CAAC;IAEF,MAAM,MAAM,GAAG,OAAO,CACpB,GAAG,EAAE,CAAC,CAAC;QACL,MAAM;QACN,UAAU;QACV,OAAO;KACR,CAAC,EACF,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,CAAC,CAC9B,CAAC;IAEF,OAAO,CACL,oBAAC,iBAAiB,IAChB,MAAM,EAAE,MAAM,EACd,oBAAoB,EAAE,oBAAoB,EAC1C,KAAK,EAAE,UAAU,EACjB,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,gBAAgB,GAC9B,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,10 +1,4 @@
1
- "use strict";
2
1
  // MIT License
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.default = void 0;
8
2
  // Copyright (c) 2023 Douglas Nassif Roma Junior
9
3
  // Permission is hereby granted, free of charge, to any person obtaining a copy
10
4
  // of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +15,5 @@ exports.default = void 0;
21
15
  // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
16
  // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
17
  // SOFTWARE.
24
- var PdfRendererView_1 = require("./PdfRendererView");
25
- Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(PdfRendererView_1).default; } });
18
+ export { default } from './PdfRendererView';
26
19
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;;;;;;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,qDAA0C;AAAlC,2HAAA,OAAO,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,gDAAgD;AAEhD,+EAA+E;AAC/E,gFAAgF;AAChF,+EAA+E;AAC/E,4EAA4E;AAC5E,wEAAwE;AACxE,2DAA2D;AAE3D,iFAAiF;AACjF,kDAAkD;AAElD,6EAA6E;AAC7E,2EAA2E;AAC3E,8EAA8E;AAC9E,yEAAyE;AACzE,gFAAgF;AAChF,gFAAgF;AAChF,YAAY;AAEZ,OAAO,EAAC,OAAO,EAAC,MAAM,mBAAmB,CAAC"}
package/dist/mock.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { PdfRendererViewPropsType } from './PdfRendererView';
3
+ declare const PdfRendererViewMock: (props: PdfRendererViewPropsType) => React.JSX.Element;
4
+ export default PdfRendererViewMock;
package/dist/mock.js ADDED
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ const PdfRendererViewMock = (props) => {
4
+ return React.createElement(View, { testID: props.testID, style: props.style });
5
+ };
6
+ export default PdfRendererViewMock;
7
+ //# sourceMappingURL=mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mock.js","sourceRoot":"","sources":["../src/mock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAC;AAGlC,MAAM,mBAAmB,GAAG,CAAC,KAA+B,EAAE,EAAE;IAC9D,OAAO,oBAAC,IAAI,IAAC,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,GAAI,CAAC;AAC5D,CAAC,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,11 +1,10 @@
1
1
  {
2
2
  "name": "react-native-pdf-renderer",
3
3
  "displayName": "React-Native Pdf Renderer",
4
- "version": "1.2.0",
4
+ "version": "1.3.1",
5
5
  "description": "⚛ A zoomable, blazing fast, zero dependencies, pure native, typed PDF Renderer for Android and iOS.",
6
6
  "main": "dist",
7
7
  "license": "MIT",
8
- "private": false,
9
8
  "repository": {
10
9
  "type": "git",
11
10
  "url": "https://github.com/douglasjunior/react-native-pdf-renderer.git"
@@ -35,23 +34,23 @@
35
34
  "react-native": ">=0.60"
36
35
  },
37
36
  "devDependencies": {
37
+ "react": "18.2.0",
38
+ "react-native": "0.74.1",
38
39
  "@babel/core": "^7.20.0",
39
40
  "@babel/preset-env": "^7.20.0",
40
41
  "@babel/runtime": "^7.20.0",
41
- "@react-native-community/eslint-config": "^3.2.0",
42
- "@tsconfig/react-native": "^2.0.2",
43
- "@types/jest": "^29.2.1",
44
- "@types/react": "^18.0.24",
42
+ "@react-native/babel-preset": "0.74.83",
43
+ "@react-native/eslint-config": "0.74.83",
44
+ "@react-native/metro-config": "0.74.83",
45
+ "@react-native/typescript-config": "0.74.83",
46
+ "@types/react": "^18.2.6",
45
47
  "@types/react-test-renderer": "^18.0.0",
46
- "babel-jest": "^29.2.1",
48
+ "babel-jest": "^29.6.3",
47
49
  "eslint": "^8.19.0",
48
- "jest": "^29.2.1",
49
- "metro-react-native-babel-preset": "0.73.8",
50
- "prettier": "^2.4.1",
51
- "react": "18.2.0",
52
- "react-native": "0.71.4",
50
+ "jest": "^29.6.3",
51
+ "prettier": "2.8.8",
53
52
  "react-test-renderer": "18.2.0",
54
- "typescript": "4.8.4"
53
+ "typescript": "5.0.4"
55
54
  },
56
55
  "types": "dist"
57
56
  }