@react-native-ohos/react-native-pdf 6.7.5-rc.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/DoubleTapView.js +125 -0
  2. package/LICENSE +21 -0
  3. package/PdfManager.js +26 -0
  4. package/PdfPageView.js +53 -0
  5. package/PdfView.js +416 -0
  6. package/PdfViewFlatList.js +30 -0
  7. package/PinchZoomView.js +125 -0
  8. package/README.OpenSource +11 -0
  9. package/README.md +13 -0
  10. package/fabric/RNPDFPdfNativeComponent.js +46 -0
  11. package/fabric/RTNPdfViewNativeComponent.tsx +56 -0
  12. package/harmony/pdfview/Index.ets +8 -0
  13. package/harmony/pdfview/build-profile.json5 +28 -0
  14. package/harmony/pdfview/consumer-rules.txt +0 -0
  15. package/harmony/pdfview/hvigorfile.ts +6 -0
  16. package/harmony/pdfview/obfuscation-rules.txt +18 -0
  17. package/harmony/pdfview/oh-package.json5 +11 -0
  18. package/harmony/pdfview/src/main/cpp/CMakeLists.txt +8 -0
  19. package/harmony/pdfview/src/main/cpp/ComponentDescriptors.h +39 -0
  20. package/harmony/pdfview/src/main/cpp/EventEmitters.cpp +40 -0
  21. package/harmony/pdfview/src/main/cpp/EventEmitters.h +50 -0
  22. package/harmony/pdfview/src/main/cpp/PdfEventEmitRequestHandler.h +53 -0
  23. package/harmony/pdfview/src/main/cpp/PdfViewJSIBinder.h +71 -0
  24. package/harmony/pdfview/src/main/cpp/PdfViewPackage.h +58 -0
  25. package/harmony/pdfview/src/main/cpp/Props.cpp +60 -0
  26. package/harmony/pdfview/src/main/cpp/Props.h +65 -0
  27. package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI-generated.cpp +30 -0
  28. package/harmony/pdfview/src/main/cpp/RTNPdfViewSpecsJSI.h +33 -0
  29. package/harmony/pdfview/src/main/cpp/ShadowNodes.cpp +33 -0
  30. package/harmony/pdfview/src/main/cpp/ShadowNodes.h +48 -0
  31. package/harmony/pdfview/src/main/cpp/States.cpp +30 -0
  32. package/harmony/pdfview/src/main/cpp/States.h +57 -0
  33. package/harmony/pdfview/src/main/ets/Logger.ets +64 -0
  34. package/harmony/pdfview/src/main/ets/PdfViewPackage.ets +34 -0
  35. package/harmony/pdfview/src/main/ets/components/mainpage/RTNPdfView.ets +521 -0
  36. package/harmony/pdfview/src/main/ets/components/mainpage/types.ts +15 -0
  37. package/harmony/pdfview/src/main/module.json5 +11 -0
  38. package/harmony/pdfview/src/main/resources/base/element/string.json +8 -0
  39. package/harmony/pdfview/src/main/resources/en_US/element/string.json +8 -0
  40. package/harmony/pdfview/src/main/resources/zh_CN/element/string.json +8 -0
  41. package/harmony/pdfview/src/test/List.test.ets +29 -0
  42. package/harmony/pdfview/src/test/LocalUnit.test.ets +57 -0
  43. package/harmony/pdfview.har +0 -0
  44. package/index.d.ts +64 -0
  45. package/index.js +475 -0
  46. package/index.js.flow +65 -0
  47. package/package.json +63 -0
  48. package/windows/RCTPdf/PropertySheet.props +16 -0
  49. package/windows/RCTPdf/RCTPdf.def +3 -0
  50. package/windows/RCTPdf/RCTPdf.vcxproj +180 -0
  51. package/windows/RCTPdf/RCTPdf.vcxproj.filters +38 -0
  52. package/windows/RCTPdf/RCTPdfControl.cpp +667 -0
  53. package/windows/RCTPdf/RCTPdfControl.h +119 -0
  54. package/windows/RCTPdf/RCTPdfControl.idl +10 -0
  55. package/windows/RCTPdf/RCTPdfControl.xaml +33 -0
  56. package/windows/RCTPdf/RCTPdfViewManager.cpp +69 -0
  57. package/windows/RCTPdf/RCTPdfViewManager.h +51 -0
  58. package/windows/RCTPdf/ReactPackageProvider.cpp +15 -0
  59. package/windows/RCTPdf/ReactPackageProvider.h +16 -0
  60. package/windows/RCTPdf/ReactPackageProvider.idl +9 -0
  61. package/windows/RCTPdf/packages.config +4 -0
  62. package/windows/RCTPdf/pch.cpp +1 -0
  63. package/windows/RCTPdf/pch.h +31 -0
  64. package/windows/README.md +21 -0
package/index.d.ts ADDED
@@ -0,0 +1,64 @@
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
+ import * as React from 'react';
10
+ import * as ReactNative from 'react-native';
11
+
12
+ export type TableContent = {
13
+ children: TableContent[],
14
+ mNativePtr: number,
15
+ pageIdx: number,
16
+ title: string,
17
+ };
18
+
19
+ export type Source = {
20
+ uri?: string;
21
+ headers?: {
22
+ [key: string]: string;
23
+ };
24
+ cache?: boolean;
25
+ cacheFileName?: string;
26
+ expiration?: number;
27
+ method?: string;
28
+ };
29
+
30
+ export interface PdfProps {
31
+ style?: ReactNative.StyleProp<ReactNative.ViewStyle>,
32
+ source: Source | number,
33
+ page?: number,
34
+ scale?: number,
35
+ minScale?: number,
36
+ maxScale?: number,
37
+ horizontal?: boolean,
38
+ showsHorizontalScrollIndicator?: boolean,
39
+ showsVerticalScrollIndicator?: boolean,
40
+ spacing?: number,
41
+ password?: string,
42
+ renderActivityIndicator?: (progress: number) => React.ReactElement,
43
+ enableAntialiasing?: boolean,
44
+ enablePaging?: boolean,
45
+ enableRTL?: boolean,
46
+ enableAnnotationRendering?: boolean,
47
+ enableDoubleTapZoom?: boolean;
48
+ fitPolicy?: number,
49
+ trustAllCerts?: boolean,
50
+ singlePage?: boolean,
51
+ onLoadProgress?: (percent: number,) => void,
52
+ onLoadComplete?: (numberOfPages: number, path: string, size: {height: number, width: number}, tableContents?: TableContent[]) => void,
53
+ onPageChanged?: (page: number, numberOfPages: number) => void,
54
+ onError?: (error: object) => void,
55
+ onPageSingleTap?: (page: number, x: number, y: number) => void,
56
+ onScaleChanged?: (scale: number) => void,
57
+ onPressLink?: (url: string) => void,
58
+ }
59
+
60
+ declare class Pdf extends React.Component<PdfProps, any> {
61
+ setPage: (pageNumber: number) => void;
62
+ }
63
+
64
+ export default Pdf;
package/index.js ADDED
@@ -0,0 +1,475 @@
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 PropTypes from 'prop-types';
12
+ import {
13
+ View,
14
+ Platform,
15
+ StyleSheet,
16
+ Image,
17
+ Text,
18
+ requireNativeComponent
19
+ } from 'react-native';
20
+ import PdfViewNativeComponent, {
21
+ Commands as PdfViewCommands,
22
+ } from './fabric/RNPDFPdfNativeComponent';
23
+ // import ReactNativeBlobUtil from 'react-native-blob-util';
24
+ import RNPDFPdfView, { Commands as RNPDFCommands } from "./fabric/RTNPdfViewNativeComponent";
25
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
26
+ const SHA1 = require('crypto-js/sha1');
27
+ import PdfView from './PdfView';
28
+
29
+ export default class Pdf extends Component {
30
+
31
+ static propTypes = {
32
+ ...ViewPropTypes,
33
+ source: PropTypes.oneOfType([
34
+ PropTypes.shape({
35
+ uri: PropTypes.string,
36
+ cache: PropTypes.bool,
37
+ cacheFileName: PropTypes.string,
38
+ expiration: PropTypes.number,
39
+ }),
40
+ // Opaque type returned by require('./test.pdf')
41
+ PropTypes.number,
42
+ ]).isRequired,
43
+ page: PropTypes.number,
44
+ scale: PropTypes.number,
45
+ minScale: PropTypes.number,
46
+ maxScale: PropTypes.number,
47
+ horizontal: PropTypes.bool,
48
+ spacing: PropTypes.number,
49
+ password: PropTypes.string,
50
+ renderActivityIndicator: PropTypes.func,
51
+ enableAntialiasing: PropTypes.bool,
52
+ enableAnnotationRendering: PropTypes.bool,
53
+ showsHorizontalScrollIndicator: PropTypes.bool,
54
+ showsVerticalScrollIndicator: PropTypes.bool,
55
+ enablePaging: PropTypes.bool,
56
+ enableRTL: PropTypes.bool,
57
+ fitPolicy: PropTypes.number,
58
+ trustAllCerts: PropTypes.bool,
59
+ singlePage: PropTypes.bool,
60
+ onLoadComplete: PropTypes.func,
61
+ onPageChanged: PropTypes.func,
62
+ onError: PropTypes.func,
63
+ onPageSingleTap: PropTypes.func,
64
+ onScaleChanged: PropTypes.func,
65
+ onPressLink: PropTypes.func,
66
+
67
+ // Props that are not available in the earlier react native version, added to prevent crashed on android
68
+ accessibilityLabel: PropTypes.string,
69
+ importantForAccessibility: PropTypes.string,
70
+ renderToHardwareTextureAndroid: PropTypes.string,
71
+ testID: PropTypes.string,
72
+ onLayout: PropTypes.bool,
73
+ accessibilityLiveRegion: PropTypes.string,
74
+ accessibilityComponentType: PropTypes.string,
75
+ };
76
+
77
+ static defaultProps = {
78
+ password: "",
79
+ scale: 1,
80
+ minScale: 1,
81
+ maxScale: 3,
82
+ spacing: 10,
83
+ fitPolicy: 2, //fit both
84
+ horizontal: false,
85
+ page: 1,
86
+ enableAntialiasing: true,
87
+ enableAnnotationRendering: true,
88
+ showsHorizontalScrollIndicator: true,
89
+ showsVerticalScrollIndicator: true,
90
+ enablePaging: false,
91
+ enableRTL: false,
92
+ trustAllCerts: true,
93
+ usePDFKit: true,
94
+ singlePage: false,
95
+ onLoadProgress: (percent) => {
96
+ },
97
+ onLoadComplete: (numberOfPages, path) => {
98
+ },
99
+ onPageChanged: (page, numberOfPages) => {
100
+ },
101
+ onError: (error) => {
102
+ },
103
+ onPageSingleTap: (page, x, y) => {
104
+ },
105
+ onScaleChanged: (scale) => {
106
+ },
107
+ onPressLink: (url) => {
108
+ },
109
+ };
110
+
111
+ constructor(props) {
112
+
113
+ super(props);
114
+ this.state = {
115
+ path: '',
116
+ isDownloaded: false,
117
+ progress: 0,
118
+ };
119
+
120
+ this.lastRNBFTask = null;
121
+
122
+ }
123
+
124
+ componentDidUpdate(prevProps) {
125
+
126
+ const nextSource = Image.resolveAssetSource(this.props.source);
127
+ const curSource = Image.resolveAssetSource(prevProps.source);
128
+
129
+ if ((nextSource.uri !== curSource.uri)) {
130
+ // if has download task, then cancel it.
131
+ if (this.lastRNBFTask) {
132
+ this.lastRNBFTask.cancel(err => {
133
+ this._loadFromSource(this.props.source);
134
+ });
135
+ this.lastRNBFTask = null;
136
+ } else {
137
+ this._loadFromSource(this.props.source);
138
+ }
139
+ }
140
+ }
141
+
142
+ componentDidMount() {
143
+ this._mounted = true;
144
+ this._loadFromSource(this.props.source);
145
+ }
146
+
147
+ componentWillUnmount() {
148
+ this._mounted = false;
149
+ if (this.lastRNBFTask) {
150
+ this.lastRNBFTask.cancel(err => {
151
+ });
152
+ this.lastRNBFTask = null;
153
+ }
154
+
155
+ }
156
+
157
+ _loadFromSource = (newSource) => {
158
+
159
+ const source = Image.resolveAssetSource(newSource) || {};
160
+
161
+ let uri = source.uri || '';
162
+ // first set to initial state
163
+ if (this._mounted) {
164
+ this.setState({ isDownloaded: false, path: '', progress: 0 });
165
+ }
166
+ const filename = source.cacheFileName || SHA1(uri) + '.pdf';
167
+ console.log('=== _loadFromSource uri: ' + uri);
168
+ // const cacheFile = ReactNativeBlobUtil.fs.dirs.CacheDir + '/' + filename;
169
+
170
+ this.setState({ path: uri});
171
+
172
+ if (source.cache) {
173
+ // ReactNativeBlobUtil.fs
174
+ // .stat(cacheFile)
175
+ // .then(stats => {
176
+ // if (!Boolean(source.expiration) || (source.expiration * 1000 + stats.lastModified) > (new Date().getTime())) {
177
+ // if (this._mounted) {
178
+ // this.setState({ path: cacheFile, isDownloaded: true });
179
+ // }
180
+ // } else {
181
+ // // cache expirated then reload it
182
+ // this._prepareFile(source);
183
+ // }
184
+ // })
185
+ // .catch(() => {
186
+ // this._prepareFile(source);
187
+ // })
188
+
189
+ } else {
190
+ this._prepareFile(source);
191
+ }
192
+ };
193
+
194
+ _prepareFile = async (source) => {
195
+
196
+ try {
197
+ if (source.uri) {
198
+ let uri = source.uri || '';
199
+
200
+ const isNetwork = !!(uri && uri.match(/^https?:\/\//));
201
+ const isAsset = !!(uri && uri.match(/^bundle-assets:\/\//));
202
+ const isBase64 = !!(uri && uri.match(/^data:application\/pdf;base64/));
203
+
204
+ const filename = source.cacheFileName || SHA1(uri) + '.pdf';
205
+ console.log('=== _prepareFile filename: ' + filename);
206
+ const cacheFile = ''
207
+
208
+ // delete old cache file
209
+ this._unlinkFile(cacheFile);
210
+
211
+ if (isNetwork) {
212
+ this._downloadFile(source, cacheFile);
213
+ } else if (isAsset) {
214
+ } else if (isBase64) {
215
+ let data = uri.replace(/data:application\/pdf;base64,/i, '');
216
+ } else {
217
+ if (this._mounted) {
218
+ this.setState({
219
+ path: unescape(uri.replace(/file:\/\//i, '')),
220
+ isDownloaded: true,
221
+ });
222
+ }
223
+ }
224
+ } else {
225
+ this._onError(new Error('no pdf source!'));
226
+ }
227
+ } catch (e) {
228
+ this._onError(e)
229
+ }
230
+ };
231
+
232
+ _downloadFile = async (source, cacheFile) => {
233
+
234
+ if (this.lastRNBFTask) {
235
+ this.lastRNBFTask.cancel(err => {
236
+ });
237
+ this.lastRNBFTask = null;
238
+ }
239
+
240
+ const tempCacheFile = cacheFile + '.tmp';
241
+ this._unlinkFile(tempCacheFile);
242
+
243
+ // this.lastRNBFTask = ReactNativeBlobUtil.config({
244
+ // // response data will be saved to this path if it has access right.
245
+ // path: tempCacheFile,
246
+ // trusty: this.props.trustAllCerts,
247
+ // })
248
+ // .fetch(
249
+ // source.method ? source.method : 'GET',
250
+ // source.uri,
251
+ // source.headers ? source.headers : {},
252
+ // source.body ? source.body : ""
253
+ // )
254
+ // // listen to download progress event
255
+ // .progress((received, total) => {
256
+ // this.props.onLoadProgress && this.props.onLoadProgress(received / total);
257
+ // if (this._mounted) {
258
+ // this.setState({ progress: received / total });
259
+ // }
260
+ // })
261
+ // .catch(async (error) => {
262
+ // this._onError(error);
263
+ // });
264
+
265
+ // this.lastRNBFTask
266
+ // .then(async (res) => {
267
+
268
+ // this.lastRNBFTask = null;
269
+
270
+ // if (res && res.respInfo && res.respInfo.headers && !res.respInfo.headers["Content-Encoding"] && !res.respInfo.headers["Transfer-Encoding"] && res.respInfo.headers["Content-Length"]) {
271
+ // const expectedContentLength = res.respInfo.headers["Content-Length"];
272
+ // let actualContentLength;
273
+
274
+ // try {
275
+ // const fileStats = await ReactNativeBlobUtil.fs.stat(res.path());
276
+
277
+ // if (!fileStats || !fileStats.size) {
278
+ // throw new Error("FileNotFound:" + source.uri);
279
+ // }
280
+
281
+ // actualContentLength = fileStats.size;
282
+ // } catch (error) {
283
+ // throw new Error("DownloadFailed:" + source.uri);
284
+ // }
285
+
286
+ // if (expectedContentLength != actualContentLength) {
287
+ // throw new Error("DownloadFailed:" + source.uri);
288
+ // }
289
+ // }
290
+
291
+ // this._unlinkFile(cacheFile);
292
+ // ReactNativeBlobUtil.fs
293
+ // .cp(tempCacheFile, cacheFile)
294
+ // .then(() => {
295
+ // if (this._mounted) {
296
+ // this.setState({ path: cacheFile, isDownloaded: true, progress: 1 });
297
+ // }
298
+ // this._unlinkFile(tempCacheFile);
299
+ // })
300
+ // .catch(async (error) => {
301
+ // throw error;
302
+ // });
303
+ // })
304
+ // .catch(async (error) => {
305
+ // this._unlinkFile(tempCacheFile);
306
+ // this._unlinkFile(cacheFile);
307
+ // this._onError(error);
308
+ // });
309
+
310
+ };
311
+
312
+ _unlinkFile = async (file) => {
313
+ try {
314
+ // await ReactNativeBlobUtil.fs.unlink(file);
315
+ } catch (e) {
316
+
317
+ }
318
+ }
319
+
320
+ setNativeProps = nativeProps => {
321
+ if (this._root) {
322
+ this._root.setNativeProps(nativeProps);
323
+ }
324
+ };
325
+
326
+ setPage(pageNumber) {
327
+ if ((pageNumber === null) || (isNaN(pageNumber))) {
328
+ throw new Error('Specified pageNumber is not a number');
329
+ }
330
+ if (Platform.OS === 'harmony') {
331
+ if (this._root) {
332
+ RNPDFCommands.setNativePage(
333
+ this._root,
334
+ pageNumber,
335
+ );
336
+ }
337
+ } else if (!!global?.nativeFabricUIManager) {
338
+ if (this._root) {
339
+ PdfViewCommands.setNativePage(
340
+ this._root,
341
+ pageNumber,
342
+ );
343
+ }
344
+ } else {
345
+ this.setNativeProps({
346
+ page: pageNumber
347
+ });
348
+ }
349
+
350
+ }
351
+
352
+ _onChange = (event) => {
353
+
354
+ let message = event.nativeEvent.message.split('|');
355
+ //__DEV__ && console.log("onChange: " + message);
356
+ if (message.length > 0) {
357
+ if (message.length > 5) {
358
+ message[4] = message.splice(4).join('|');
359
+ }
360
+ if (message[0] === 'loadComplete') {
361
+ let tableContents;
362
+ try {
363
+ tableContents = message[4] && JSON.parse(message[4]);
364
+ } catch (e) {
365
+ tableContents = message[4];
366
+ }
367
+ this.props.onLoadComplete && this.props.onLoadComplete(Number(message[1]), this.state.path, {
368
+ width: Number(message[2]),
369
+ height: Number(message[3]),
370
+ },
371
+ tableContents
372
+ );
373
+ } else if (message[0] === 'loadProgress') {
374
+ this.props.onLoadProgress && this.props.onLoadProgress(Number(message[1]));
375
+ } else if (message[0] === 'pageChanged') {
376
+ this.props.onPageChanged && this.props.onPageChanged(Number(message[1]), Number(message[2]));
377
+ } else if (message[0] === 'error') {
378
+ this._onError(new Error(message[1]));
379
+ } else if (message[0] === 'pageSingleTap') {
380
+ this.props.onPageSingleTap && this.props.onPageSingleTap(Number(message[1]), Number(message[2]), Number(message[3]));
381
+ } else if (message[0] === 'scaleChanged') {
382
+ this.props.onScaleChanged && this.props.onScaleChanged(Number(message[1]));
383
+ } else if (message[0] === 'linkPressed') {
384
+ this.props.onPressLink && this.props.onPressLink(message[1]);
385
+ }
386
+ }
387
+
388
+ };
389
+
390
+ _onError = (error) => {
391
+
392
+ this.props.onError && this.props.onError(error);
393
+
394
+ };
395
+
396
+ render() {
397
+ if (Platform.OS === "android" || Platform.OS === "ios" || Platform.OS === "windows") {
398
+ return (
399
+ <View style={[this.props.style, { overflow: 'hidden' }]}>
400
+ {!this.state.isDownloaded ?
401
+ (<View
402
+ style={styles.progressContainer}
403
+ >
404
+ {this.props.renderActivityIndicator
405
+ ? this.props.renderActivityIndicator(this.state.progress)
406
+ : <Text>{`${(this.state.progress * 100).toFixed(2)}%`}</Text>}
407
+ </View>) : (
408
+ Platform.OS === "android" || Platform.OS === "windows" ? (
409
+ <PdfCustom
410
+ ref={component => (this._root = component)}
411
+ {...this.props}
412
+ style={[{ flex: 1, backgroundColor: '#EEE' }, this.props.style]}
413
+ path={this.state.path}
414
+ onChange={this._onChange}
415
+ />
416
+ ) : (
417
+ this.props.usePDFKit ? (
418
+ <PdfCustom
419
+ ref={component => (this._root = component)}
420
+ {...this.props}
421
+ style={[{ backgroundColor: '#EEE', overflow: 'hidden' }, this.props.style]}
422
+ path={this.state.path}
423
+ onChange={this._onChange}
424
+ />
425
+ ) : (<PdfView
426
+ {...this.props}
427
+ style={[{ backgroundColor: '#EEE', overflow: 'hidden' }, this.props.style]}
428
+ path={this.state.path}
429
+ onLoadComplete={this.props.onLoadComplete}
430
+ onPageChanged={this.props.onPageChanged}
431
+ onError={this._onError}
432
+ onPageSingleTap={this.props.onPageSingleTap}
433
+ onScaleChanged={this.props.onScaleChanged}
434
+ onPressLink={this.props.onPressLink}
435
+ />)
436
+ )
437
+ )}
438
+ </View>);
439
+ } else if (Platform.OS === "harmony") {
440
+ console.log("===react-native-pdf style: " + JSON.stringify(this.props.style));
441
+ return (
442
+ <View style={[{ overflow: 'hidden' }, this.props.style]}>
443
+ <RNPDFPdfView
444
+ ref={component => (this._root = component)}
445
+ {...this.props}
446
+ path={this.state.path}
447
+ onChange={this._onChange}
448
+ />
449
+ </View>
450
+ );
451
+ } else {
452
+ return (null);
453
+ }
454
+ }
455
+ }
456
+
457
+ if (Platform.OS === "android" || Platform.OS === "ios") {
458
+ var PdfCustom = PdfViewNativeComponent;
459
+ } else if (Platform.OS === "windows") {
460
+ var PdfCustom = requireNativeComponent('RCTPdf', Pdf, {
461
+ nativeOnly: { path: true, onChange: true },
462
+ })
463
+ }
464
+
465
+ const styles = StyleSheet.create({
466
+ progressContainer: {
467
+ flex: 1,
468
+ justifyContent: 'center',
469
+ alignItems: 'center'
470
+ },
471
+ progressBar: {
472
+ width: 200,
473
+ height: 2
474
+ }
475
+ });
package/index.js.flow ADDED
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @flow strict
3
+ */
4
+
5
+ import { Component } from 'react';
6
+
7
+ import type { Node } from 'react';
8
+ import type { FormField, Methods } from 'rn-fetch-blob';
9
+ import type { ViewStyleProp } from 'react-native/Libraries/StyleSheet/StyleSheet'
10
+
11
+ export type AssetId = number;
12
+
13
+ export type FitWidth = 0;
14
+ export type FitHeight = 1;
15
+ export type FitBoth = 2;
16
+
17
+ export type Source = {
18
+ body?: string | FormField[],
19
+ cache?: boolean,
20
+ cacheFileName?: string,
21
+ expiration?: number,
22
+ headers?: { [key: string]: string },
23
+ method?: Methods,
24
+ uri: string
25
+ };
26
+
27
+ export type TableContent = {
28
+ children: TableContent[],
29
+ mNativePtr: number,
30
+ pageIdx: number,
31
+ title: string,
32
+ };
33
+
34
+ export type Props = {
35
+ renderActivityIndicator?: (progress: number) => Node,
36
+ enableAnnotationRendering?: boolean,
37
+ enableAntialiasing?: boolean,
38
+ enablePaging?: boolean,
39
+ enableRTL?: boolean,
40
+ fitPolicy?: FitWidth | FitHeight | FitBoth,
41
+ horizontal?: boolean,
42
+ showsHorizontalScrollIndicator?: boolean,
43
+ showsVerticalScrollIndicator?: boolean,
44
+ maxScale?: number,
45
+ minScale?: number,
46
+ singlePage?: boolean,
47
+ onError?: (error: Error) => void,
48
+ onLoadComplete?: (numberOfPages: number, path: string, size: { height: number, width: number }, tableContents: ?TableContent[]) => void,
49
+ onLoadProgress?: (percent: number) => void,
50
+ onPageChanged?: (page: number, numberOfPages: number) => void,
51
+ onPageSingleTap?: (page: number, x: number, y: number) => void,
52
+ onScaleChanged?: (scale: number) => void,
53
+ onPressLink?: (url: string) => void,
54
+ page?: number,
55
+ password?: string,
56
+ scale?: number,
57
+ source: AssetId | Source,
58
+ spacing?: number,
59
+ style?: ViewStyleProp,
60
+ testID?: string
61
+ };
62
+
63
+ declare export default class Pdf extends Component<Props> {
64
+ setPage: (pageNumber: number) => void;
65
+ }
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-pdf",
3
+ "version": "6.7.5-rc.1",
4
+ "summary": "A react native PDF view component",
5
+ "description": "A react native PDF view component, support ios and android platform",
6
+ "main": "index.js",
7
+ "typings": "./index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-pdf.git"
11
+ },
12
+ "harmony": {
13
+ "alias": "react-native-pdf",
14
+ "autolinking": {
15
+ "etsPackageClassName":"PdfViewPackage",
16
+ "cppPackageClassName":"PdfViewPackage",
17
+ "cmakeLibraryTargetName": "rnoh_pdf_view",
18
+ "ohPackageName": "@react-native-ohos/react-native-pdf"
19
+ }
20
+ },
21
+ "keywords": [
22
+ "react-component",
23
+ "react-native",
24
+ "pdf",
25
+ "view",
26
+ "viewer"
27
+ ],
28
+ "license": "MIT",
29
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_react-native-pdf",
30
+ "bugs": {
31
+ "url": "https://gitcode.com/openharmony-sig/rntpc_react-native-pdf/issues"
32
+ },
33
+ "dependencies": {
34
+ "crypto-js": "4.2.0",
35
+ "deprecated-react-native-prop-types": "^2.3.0",
36
+ "react-native-pdf": "6.7.4"
37
+ },
38
+ "devDependencies": {
39
+ "@babel/core": "^7.20.2",
40
+ "@babel/runtime": "^7.20.1",
41
+ "prop-types": "^15.7.2"
42
+ },
43
+ "peerDependencies": {
44
+ "react": "*",
45
+ "react-native": "*",
46
+ "react-native-blob-util": ">=0.13.7"
47
+ },
48
+ "files": [
49
+ "harmony",
50
+ "windows/",
51
+ "DoubleTapView.js",
52
+ "index.d.ts",
53
+ "index.js",
54
+ "index.js.flow",
55
+ "PdfManager.js",
56
+ "PdfPageView.js",
57
+ "PdfView.js",
58
+ "PdfViewFlatList.js",
59
+ "PinchZoomView.js",
60
+ "react-native-pdf.podspec",
61
+ "fabric/"
62
+ ]
63
+ }
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ImportGroup Label="PropertySheets" />
4
+ <PropertyGroup Label="UserMacros" />
5
+ <!--
6
+ To customize common C++/WinRT project properties:
7
+ * right-click the project node
8
+ * expand the Common Properties item
9
+ * select the C++/WinRT property page
10
+
11
+ For more advanced scenarios, and complete documentation, please see:
12
+ https://github.com/Microsoft/xlang/tree/master/src/package/cppwinrt/nuget
13
+ -->
14
+ <PropertyGroup />
15
+ <ItemDefinitionGroup />
16
+ </Project>
@@ -0,0 +1,3 @@
1
+ EXPORTS
2
+ DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3
+ DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE