react-native-pdf 6.5.0 → 6.6.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.
package/README.md CHANGED
@@ -169,12 +169,18 @@ react-native run-ios
169
169
  <details>
170
170
  <summary>ChangeLog details</summary>
171
171
 
172
+ v6.6.0
173
+ 1. Fixed: Migrate to ViewPropTypes exported from 'deprecated-react-native-prop-types'
174
+ 2. Added: Decode File Path for iOS
175
+ 3. Improved: prefer current page for calculating scale factor on fit
176
+ 4. Improved: Typescript version source
177
+
172
178
  v6.5.0
173
- 1. Fix: replace mavenCentral with maven
179
+ 1. Fixed: replace mavenCentral with maven
174
180
  2. Breaking Change(Android): replace deprecated repository: jcenter()
175
- 3. Fix: loading progress
176
- 4. Add: Typed "source" prop
177
- 5. Remove: dependency to fbjs
181
+ 3. Fixed: loading progress
182
+ 4. Added: Typed "source" prop
183
+ 5. Removed: dependency to fbjs
178
184
 
179
185
  v6.4.0
180
186
  1. Remove sample for reducing NPM package size
@@ -50,7 +50,17 @@ RCT_EXPORT_METHOD(loadFile:(NSString *)path
50
50
 
51
51
  if (path != nil && path.length != 0) {
52
52
 
53
- NSURL *pdfURL = [NSURL fileURLWithPath:path];
53
+ NSString *decodedPath = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)path, CFSTR(""));
54
+
55
+ NSString *finalPath = NULL;
56
+ if (decodedPath == NULL) {
57
+ // use orignal provided path
58
+ finalPath = path;
59
+ } else {
60
+ finalPath = decodedPath;
61
+ }
62
+
63
+ NSURL *pdfURL = [NSURL fileURLWithPath:finalPath];
54
64
  CGPDFDocumentRef pdfRef = CGPDFDocumentCreateWithURL((__bridge CFURLRef) pdfURL);
55
65
 
56
66
  if (pdfRef == NULL) {
@@ -132,6 +132,9 @@ const float MIN_SCALE = 1.0f;
132
132
  _pdfDocument = [[PDFDocument alloc] initWithData:blobData];
133
133
  }
134
134
  } else {
135
+
136
+ // decode file path
137
+ _path = (__bridge_transfer NSString *)CFURLCreateStringByReplacingPercentEscapes(NULL, (CFStringRef)_path, CFSTR(""));
135
138
  NSURL *fileURL = [NSURL fileURLWithPath:_path];
136
139
  _pdfDocument = [[PDFDocument alloc] initWithURL:fileURL];
137
140
  }
@@ -200,7 +203,7 @@ const float MIN_SCALE = 1.0f;
200
203
 
201
204
  if (_pdfDocument && ([changedProps containsObject:@"path"] || [changedProps containsObject:@"fitPolicy"] || [changedProps containsObject:@"minScale"] || [changedProps containsObject:@"maxScale"])) {
202
205
 
203
- PDFPage *pdfPage = [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
206
+ PDFPage *pdfPage = _pdfView.currentPage ? _pdfView.currentPage : [_pdfDocument pageAtIndex:_pdfDocument.pageCount-1];
204
207
  CGRect pdfPageRect = [pdfPage boundsForBox:kPDFDisplayBoxCropBox];
205
208
 
206
209
  // some pdf with rotation, then adjust it
package/package.json CHANGED
@@ -1,10 +1,9 @@
1
1
  {
2
2
  "name": "react-native-pdf",
3
- "version": "6.5.0",
3
+ "version": "6.6.0",
4
4
  "summary": "A react native PDF view component",
5
5
  "description": "A react native PDF view component, support ios and android platform",
6
- "main": "index.js",
7
- "typings": "./index.d.ts",
6
+ "main": "dist/index.js",
8
7
  "repository": {
9
8
  "type": "git",
10
9
  "url": "git+https://github.com/wonday/react-native-pdf.git"
@@ -28,24 +27,22 @@
28
27
  "url": "https://github.com/wonday/react-native-pdf/issues"
29
28
  },
30
29
  "dependencies": {
31
- "crypto-js": "^3.2.0"
30
+ "crypto-js": "^3.2.0",
31
+ "deprecated-react-native-prop-types": "^2.3.0"
32
32
  },
33
33
  "devDependencies": {
34
- "prop-types": "^15.7.2"
34
+ "@types/react-native": "^0.68.0",
35
+ "react-native": "^0.68.0",
36
+ "typescript": "^4.7.4"
35
37
  },
36
38
  "files": [
37
39
  "android/",
38
40
  "ios/",
39
41
  "windows/",
40
- "DoubleTapView.js",
41
- "index.d.ts",
42
- "index.js",
43
- "index.js.flow",
44
- "PdfManager.js",
45
- "PdfPageView.js",
46
- "PdfView.js",
47
- "PdfViewFlatList.js",
48
- "PinchZoomView.js",
42
+ "dist/",
49
43
  "react-native-pdf.podspec"
50
- ]
44
+ ],
45
+ "scripts": {
46
+ "build": "rm -rf dist/ && tsc"
47
+ }
51
48
  }
package/DoubleTapView.js DELETED
@@ -1,126 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Wonday (@wonday.org)
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the MIT-style license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- 'use strict';
10
- import React, {Component} from 'react';
11
- import {
12
- View,
13
- PanResponder,
14
- ViewPropTypes,
15
- } from 'react-native';
16
- import PropTypes from 'prop-types';
17
-
18
- export default class DoubleTapView extends Component {
19
-
20
- static propTypes = {
21
- ...ViewPropTypes,
22
- delay: PropTypes.number,
23
- radius: PropTypes.number,
24
- onSingleTap: PropTypes.func,
25
- onDoubleTap: PropTypes.func,
26
- };
27
-
28
- static defaultProps = {
29
- delay: 300,
30
- radius: 50,
31
- onSingleTap: () => {
32
- },
33
- onDoubleTap: () => {
34
- },
35
- };
36
-
37
- constructor() {
38
- super();
39
-
40
- this.gestureHandlers = PanResponder.create({
41
- onStartShouldSetPanResponder: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
42
- onStartShouldSetResponderCapture: (evt, gestureState) => (gestureState.numberActiveTouches === 1),
43
- onMoveShouldSetPanResponder: (evt, gestureState) => (false),
44
- onMoveShouldSetResponderCapture: (evt, gestureState) => (false),
45
- onPanResponderTerminationRequest: (evt, gestureState) => false,
46
- onPanResponderRelease: this.handlePanResponderRelease,
47
-
48
- });
49
-
50
- this.prevTouchInfo = {
51
- prevTouchX: 0,
52
- prevTouchY: 0,
53
- prevTouchTimeStamp: 0,
54
- };
55
-
56
- this.timer = null;
57
-
58
- }
59
-
60
-
61
- distance = (x0, y0, x1, y1) => {
62
- return Math.sqrt(Math.pow((x1 - x0), 2) + Math.pow((y1 - y0), 2)).toFixed(1);
63
- };
64
-
65
- isDoubleTap = (currentTouchTimeStamp, {x0, y0}) => {
66
- const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
67
- const dt = currentTouchTimeStamp - prevTouchTimeStamp;
68
- const {delay, radius} = this.props;
69
-
70
- return (prevTouchTimeStamp > 0 && dt < delay && this.distance(prevTouchX, prevTouchY, x0, y0) < radius);
71
- };
72
-
73
- handlePanResponderRelease = (evt, gestureState) => {
74
-
75
- const currentTouchTimeStamp = Date.now();
76
- const x = evt.nativeEvent.locationX;
77
- const y = evt.nativeEvent.locationY;
78
-
79
- if (this.timer) {
80
-
81
- if (this.isDoubleTap(currentTouchTimeStamp, gestureState)) {
82
-
83
- clearTimeout(this.timer);
84
- this.timer = null;
85
- this.props.onDoubleTap();
86
-
87
- } else {
88
-
89
- const {prevTouchX, prevTouchY, prevTouchTimeStamp} = this.prevTouchInfo;
90
- const {radius} = this.props;
91
-
92
- // if not in radius, it's a move
93
- if (this.distance(prevTouchX, prevTouchY, gestureState.x0, gestureState.y0) < radius) {
94
- this.timer = null;
95
- this.props.onSingleTap(x, y);
96
- }
97
-
98
- }
99
- } else {
100
- // do not count scroll gestures as taps
101
- if (this.distance(0, gestureState.dx, 0, gestureState.dy) < 10) {
102
-
103
- this.timer = setTimeout(() => {
104
- this.props.onSingleTap(x, y);
105
- this.timer = null;
106
- }, this.props.delay);
107
- }
108
- }
109
-
110
-
111
- this.prevTouchInfo = {
112
- prevTouchX: gestureState.x0,
113
- prevTouchY: gestureState.y0,
114
- prevTouchTimeStamp: currentTouchTimeStamp,
115
- };
116
-
117
- };
118
-
119
- render() {
120
- return (
121
- <View {...this.props} {...this.gestureHandlers.panHandlers}>
122
- {this.props.children}
123
- </View>
124
- );
125
- }
126
- }
package/PdfManager.js DELETED
@@ -1,26 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Wonday (@wonday.org)
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the MIT-style license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
- 'use strict';
10
-
11
- const PdfManagerNative = require('react-native').NativeModules.PdfManager;
12
-
13
- export default class PdfManager {
14
-
15
- static loadFile(path, password) {
16
- if (typeof path !== 'string') {
17
- throw new TypeError('path must be a valid string.');
18
- }
19
-
20
- if (password === undefined) {
21
- password = "";
22
- }
23
-
24
- return PdfManagerNative.loadFile(path, password);
25
- }
26
- }
package/PdfPageView.js DELETED
@@ -1,54 +0,0 @@
1
- /**
2
- * Copyright (c) 2017-present, Wonday (@wonday.org)
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the MIT-style license found in the
6
- * LICENSE file in the root directory of this source tree.
7
- */
8
-
9
-
10
- 'use strict';
11
- import React, {PureComponent} from 'react';
12
- import PropTypes from 'prop-types';
13
- import {
14
- ViewPropTypes,
15
- requireNativeComponent,
16
- } from 'react-native';
17
-
18
- export default class PdfPageView extends PureComponent {
19
- _getStylePropsProps = () => {
20
- const {width, height} = this.props;
21
- if (width || height) {
22
- return {width, height};
23
- }
24
- return {};
25
- };
26
-
27
- render() {
28
- const {
29
- style,
30
- ...restProps
31
- } = this.props;
32
- return (
33
- <PdfPageViewCustom
34
- {...restProps}
35
- style={[style, this._getStylePropsProps()]}
36
- />
37
- );
38
-
39
- }
40
- }
41
-
42
- PdfPageView.propTypes = {
43
- ...ViewPropTypes,
44
- fileNo: PropTypes.number,
45
- page: PropTypes.number,
46
- width: PropTypes.number,
47
- height: PropTypes.number
48
- };
49
-
50
- PdfPageView.defaultProps = {
51
- style: {}
52
- };
53
-
54
- let PdfPageViewCustom = requireNativeComponent('RCTPdfPageView', PdfPageView, {nativeOnly: {}});