@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
@@ -0,0 +1,125 @@
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
+ StyleSheet,
15
+ PanResponder
16
+ } from 'react-native';
17
+ import {ViewPropTypes} from 'deprecated-react-native-prop-types';
18
+ export default class PinchZoomView extends Component {
19
+
20
+ static propTypes = {
21
+ ...ViewPropTypes,
22
+ scalable: PropTypes.bool,
23
+ onScaleChanged: PropTypes.func,
24
+ };
25
+
26
+ static defaultProps = {
27
+ scalable: true,
28
+ onScaleChanged: (scale) => {
29
+ },
30
+ };
31
+
32
+ constructor(props) {
33
+
34
+ super(props);
35
+ this.state = {};
36
+ this.distant = 0;
37
+ this.gestureHandlers = PanResponder.create({
38
+ onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
39
+ onMoveShouldSetResponderCapture: (evt, gestureState) => (true),
40
+ onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
41
+ onPanResponderGrant: this._handlePanResponderGrant,
42
+ onPanResponderMove: this._handlePanResponderMove,
43
+ onPanResponderRelease: this._handlePanResponderEnd,
44
+ onPanResponderTerminationRequest: evt => false,
45
+ onPanResponderTerminate: this._handlePanResponderTerminate,
46
+ onShouldBlockNativeResponder: evt => true
47
+ });
48
+
49
+ }
50
+
51
+ _handleStartShouldSetPanResponder = (e, gestureState) => {
52
+
53
+ // don't respond to single touch to avoid shielding click on child components
54
+ return false;
55
+
56
+ };
57
+
58
+ _handleMoveShouldSetPanResponder = (e, gestureState) => {
59
+
60
+ return this.props.scalable && (e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2);
61
+
62
+ };
63
+
64
+ _handlePanResponderGrant = (e, gestureState) => {
65
+
66
+ if (e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2) {
67
+ let dx = Math.abs(e.nativeEvent.touches[0].pageX - e.nativeEvent.touches[1].pageX);
68
+ let dy = Math.abs(e.nativeEvent.touches[0].pageY - e.nativeEvent.touches[1].pageY);
69
+ this.distant = Math.sqrt(dx * dx + dy * dy);
70
+ }
71
+
72
+ };
73
+
74
+ _handlePanResponderEnd = (e, gestureState) => {
75
+
76
+ this.distant = 0;
77
+
78
+ };
79
+
80
+ _handlePanResponderTerminate = (e, gestureState) => {
81
+
82
+ this.distant = 0;
83
+
84
+ };
85
+
86
+ _handlePanResponderMove = (e, gestureState) => {
87
+
88
+ if ((e.nativeEvent.changedTouches.length >= 2 || gestureState.numberActiveTouches >= 2) && this.distant > 100) {
89
+
90
+ let dx = Math.abs(e.nativeEvent.touches[0].pageX - e.nativeEvent.touches[1].pageX);
91
+ let dy = Math.abs(e.nativeEvent.touches[0].pageY - e.nativeEvent.touches[1].pageY);
92
+ let distant = Math.sqrt(dx * dx + dy * dy);
93
+ let scale = (distant / this.distant);
94
+ let pageX = (e.nativeEvent.touches[0].pageX + e.nativeEvent.touches[1].pageX) / 2;
95
+ let pageY = (e.nativeEvent.touches[0].pageY + e.nativeEvent.touches[1].pageY) / 2;
96
+ let pinchInfo = {scale: scale, pageX: pageX, pageY: pageY};
97
+
98
+ this.props.onScaleChanged(pinchInfo);
99
+ this.distant = distant;
100
+
101
+ }
102
+
103
+ };
104
+
105
+ render() {
106
+
107
+ return (
108
+ <View
109
+ {...this.props}
110
+ {...this.gestureHandlers?.panHandlers}
111
+ style={[styles.container, this.props.style]}>
112
+ {this.props.children}
113
+ </View>
114
+ );
115
+
116
+ }
117
+ }
118
+
119
+ const styles = StyleSheet.create({
120
+ container: {
121
+ flex: 1,
122
+ justifyContent: 'center',
123
+ alignItems: 'center'
124
+ }
125
+ });
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "react-native-pdf",
4
+ "License": "MIT License",
5
+ "License File": "https://github.com/wonday/react-native-pdf/blob/master/LICENSE",
6
+ "Version Number": "6.7.4",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/wonday/react-native-pdf",
9
+ "Description": "A react native PDF view component, support ios and android platform"
10
+ }
11
+ ]
package/README.md ADDED
@@ -0,0 +1,13 @@
1
+ # @react-native-ohos/react-native-pdf
2
+
3
+ This project is based on [react-native-pdf](https://github.com/wonday/react-native-pdf)@7.0.0
4
+
5
+ ## Documentation
6
+
7
+ - [中文](https://gitee.com/react-native-oh-library/usage-docs/blob/master/zh-cn/react-native-pdf.md)
8
+
9
+ - [English](https://gitee.com/react-native-oh-library/usage-docs/blob/master/en/react-native-pdf.md)
10
+
11
+ ## License
12
+
13
+ This library is licensed under [The MIT License (MIT)](https://github.com/wonday/react-native-pdf/blob/master/LICENSE)
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @flow
3
+ * @format
4
+ */
5
+ 'use strict';
6
+
7
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
8
+ import codegenNativeCommands from 'react-native/Libraries/Utilities/codegenNativeCommands';
9
+
10
+ type ChangeEvent = $ReadOnly<{|
11
+ message: ?string,
12
+ |}>;
13
+
14
+ export type NativeProps = $ReadOnly<{|
15
+ ...ViewProps,
16
+ path: ?string,
17
+ page: ?Int32,
18
+ scale: ?Float,
19
+ minScale: ?Float,
20
+ maxScale: ?Float,
21
+ horizontal: ?boolean,
22
+ enablePaging: ?boolean,
23
+ enableRTL: ?boolean,
24
+ enableAnnotationRendering: ?boolean,
25
+ showsHorizontalScrollIndicator: ?boolean,
26
+ showsVerticalScrollIndicator: ?boolean,
27
+ enableAntialiasing: ?boolean,
28
+ fitPolicy: ?Int32,
29
+ spacing: ?Int32,
30
+ password: ?string,
31
+ onChange: ?BubblingEventHandler<ChangeEvent>,
32
+ singlePage: ?boolean,
33
+ |}>;
34
+
35
+ interface NativeCommands {
36
+ +setNativePage: (
37
+ viewRef: React.ElementRef<ComponentType>,
38
+ page: Int32,
39
+ ) => void;
40
+ }
41
+
42
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
43
+ supportedCommands: ['setNativePage'],
44
+ });
45
+
46
+ export default codegenNativeComponent<NativeProps>('RNPDFPdfView');
@@ -0,0 +1,56 @@
1
+ import { ComponentType } from "react";
2
+ import type { HostComponent,ViewProps } from "react-native";
3
+ import { BubblingEventHandler, Float, Int32 } from "react-native/Libraries/Types/CodegenTypes";
4
+ import codegenNativeCommands from "react-native/Libraries/Utilities/codegenNativeCommands";
5
+ import codegenNativeComponent from "react-native/Libraries/Utilities/codegenNativeComponent";
6
+
7
+ type ChangeEvent = {
8
+ message: string,
9
+ };
10
+
11
+ type Source = {
12
+ uri: string;
13
+ headers?: {
14
+ [key: string]: string;
15
+ };
16
+ cache?: boolean;
17
+ cacheFileName?: string;
18
+ expiration?: number;
19
+ method?: string;
20
+ };
21
+
22
+ export interface NativeProps extends ViewProps {
23
+ source: Source,
24
+ path?: string,
25
+ page?: Int32,
26
+ scale?: Float,
27
+ minScale?: Float,
28
+ maxScale?: Float,
29
+ horizontal?: boolean,
30
+ enablePaging?: boolean,
31
+ enableRTL?: boolean,
32
+ enableAnnotationRendering?: boolean,
33
+ showsHorizontalScrollIndicator?: boolean,
34
+ showsVerticalScrollIndicator?: boolean,
35
+ enableAntialiasing?: boolean,
36
+ fitPolicy?: Int32,
37
+ spacing?: Int32,
38
+ password?: string,
39
+ onChange?: BubblingEventHandler<ChangeEvent>,
40
+ singlePage?: boolean,
41
+ }
42
+
43
+ interface NativeCommands {
44
+ setNativePage: (
45
+ viewRef: React.ElementRef<ComponentType>,
46
+ page: Int32,
47
+ ) => void;
48
+ }
49
+
50
+ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
51
+ supportedCommands: ['setNativePage'],
52
+ });
53
+
54
+ export default codegenNativeComponent<NativeProps>(
55
+ "RTNPdfView"
56
+ ) as HostComponent<NativeProps>;
@@ -0,0 +1,8 @@
1
+ /*
2
+ * Copyright (c) 2024 Huawei Device Co., Ltd. All rights reserved
3
+ * Use of this source code is governed by a MIT license that can be
4
+ * found in the LICENSE file.
5
+ */
6
+ import { PdfViewPackage } from './src/main/ets/PdfViewPackage'
7
+ export default PdfViewPackage
8
+ export * from './src/main/ets/components/mainpage/RTNPdfView'
@@ -0,0 +1,28 @@
1
+ {
2
+ "apiType": "stageMode",
3
+ "buildOption": {
4
+ },
5
+ "buildOptionSet": [
6
+ {
7
+ "name": "release",
8
+ "arkOptions": {
9
+ "obfuscation": {
10
+ "ruleOptions": {
11
+ "enable": true,
12
+ "files": [
13
+ "./obfuscation-rules.txt"
14
+ ]
15
+ },
16
+ "consumerFiles": [
17
+ "./consumer-rules.txt"
18
+ ]
19
+ }
20
+ },
21
+ },
22
+ ],
23
+ "targets": [
24
+ {
25
+ "name": "default"
26
+ }
27
+ ]
28
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ import { harTasks } from '@ohos/hvigor-ohos-plugin';
2
+
3
+ export default {
4
+ system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */
5
+ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */
6
+ }
@@ -0,0 +1,18 @@
1
+ # Define project specific obfuscation rules here.
2
+ # You can include the obfuscation configuration files in the current module's build-profile.json5.
3
+ #
4
+ # For more details, see
5
+ # https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md
6
+
7
+ # Obfuscation options:
8
+ # -disable-obfuscation: disable all obfuscations
9
+ # -enable-property-obfuscation: obfuscate the property names
10
+ # -enable-toplevel-obfuscation: obfuscate the names in the global scope
11
+ # -compact: remove unnecessary blank spaces and all line feeds
12
+ # -remove-log: remove all console.* statements
13
+ # -print-namecache: print the name cache that contains the mapping from the old names to new names
14
+ # -apply-namecache: reuse the given cache file
15
+
16
+ # Keep options:
17
+ # -keep-property-name: specifies property names that you want to keep
18
+ # -keep-global-name: specifies names that you want to keep in the global scope
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "@react-native-ohos/react-native-pdf",
3
+ "version": "6.7.5-rc.1",
4
+ "description": "Please describe the basic information.",
5
+ "main": "Index.ets",
6
+ "author": "",
7
+ "license": "Apache-2.0",
8
+ "dependencies": {
9
+ "@rnoh/react-native-openharmony": 'file:../../../libs/react_native_openharmony-5.0.0.802.har'
10
+ }
11
+ }
@@ -0,0 +1,8 @@
1
+ cmake_minimum_required(VERSION 3.4.1)
2
+ set(CMAKE_VERBOSE_MAKEFILE on)
3
+
4
+ file(GLOB rnoh_pdf_view_SRC CONFIGURE_DEPENDS *.cpp)
5
+ add_library(rnoh_pdf_view SHARED ${rnoh_pdf_view_SRC})
6
+ target_include_directories(rnoh_pdf_view PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
7
+ target_link_libraries(rnoh_pdf_view PUBLIC rnoh)
8
+
@@ -0,0 +1,39 @@
1
+ #ifndef COMPONENTDESCRIPTORS_H
2
+ #define COMPONENTDESCRIPTORS_H
3
+ /**
4
+ * MIT License
5
+ *
6
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ #pragma once
28
+
29
+ #include "ShadowNodes.h"
30
+ #include <react/renderer/core/ConcreteComponentDescriptor.h>
31
+
32
+ namespace facebook {
33
+ namespace react {
34
+
35
+ using RNPDFPdfViewComponentDescriptor = ConcreteComponentDescriptor<RNPDFPdfViewShadowNode>;
36
+
37
+ } // namespace react
38
+ } // namespace facebook
39
+ #endif
@@ -0,0 +1,40 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #include "EventEmitters.h"
26
+
27
+ namespace facebook {
28
+ namespace react {
29
+
30
+ void RNPDFPdfViewEventEmitter::onChange(OnChange event) const
31
+ {
32
+ dispatchEvent("change", [event = std::move(event)](jsi::Runtime &runtime) {
33
+ auto payload = jsi::Object(runtime);
34
+ payload.setProperty(runtime, "message", event.message);
35
+ return payload;
36
+ });
37
+ }
38
+
39
+ } // namespace react
40
+ } // namespace facebook
@@ -0,0 +1,50 @@
1
+ #ifndef EVENTEMITTERS_H
2
+ #define EVENTEMITTERS_H
3
+ /**
4
+ * MIT License
5
+ *
6
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ #pragma once
28
+
29
+ #include <react/renderer/components/view/ViewEventEmitter.h>
30
+ #include <jsi/jsi.h>
31
+
32
+ namespace facebook {
33
+ namespace react {
34
+
35
+ class JSI_EXPORT RNPDFPdfViewEventEmitter : public ViewEventEmitter {
36
+ public:
37
+ using ViewEventEmitter::ViewEventEmitter;
38
+
39
+ struct OnChange {
40
+ std::string message;
41
+ };
42
+
43
+ void onChange(OnChange value) const;
44
+
45
+
46
+ };
47
+
48
+ } // namespace react
49
+ } // namespace facebook
50
+ #endif
@@ -0,0 +1,53 @@
1
+ #ifndef PDFEVENTEMITREQUESTHANDLER_H
2
+ #define PDFEVENTEMITREQUESTHANDLER_H
3
+ /**
4
+ * MIT License
5
+ *
6
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
7
+ *
8
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ * of this software and associated documentation files (the "Software"), to deal
10
+ * in the Software without restriction, including without limitation the rights
11
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ * copies of the Software, and to permit persons to whom the Software is
13
+ * furnished to do so, subject to the following conditions:
14
+ *
15
+ * The above copyright notice and this permission notice shall be included in all
16
+ * copies or substantial portions of the Software.
17
+ *
18
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
24
+ * SOFTWARE.
25
+ */
26
+
27
+ #pragma once
28
+ #include "RNOH/ArkJS.h"
29
+ #include "RNOH/EventEmitRequestHandler.h"
30
+ #include "EventEmitters.h"
31
+
32
+ using namespace facebook;
33
+ namespace rnoh {
34
+
35
+ class PdfEventEmitRequestHandler : public EventEmitRequestHandler {
36
+ public:
37
+ void handleEvent(EventEmitRequestHandler::Context const &ctx) override
38
+ {
39
+ if (ctx.eventName != "RTNPdfView") {
40
+ return;
41
+ }
42
+ ArkJS arkJs(ctx.env);
43
+ auto eventEmitter = ctx.shadowViewRegistry->getEventEmitter<react::RNPDFPdfViewEventEmitter>(ctx.tag);
44
+ if (eventEmitter == nullptr) {
45
+ return;
46
+ }
47
+ auto message = arkJs.getString(arkJs.getObjectProperty(ctx.payload, "message"));
48
+ react::RNPDFPdfViewEventEmitter::OnChange event = {message};
49
+ eventEmitter->onChange(event);
50
+ };
51
+ };
52
+ }
53
+ #endif
@@ -0,0 +1,71 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #ifndef HARMONY_PDFVIEWJSIBINDER_H
26
+ #define HARMONY_PDFVIEWJSIBINDER_H
27
+
28
+ #include "RNOHCorePackage/ComponentBinders/ViewComponentJSIBinder.h"
29
+
30
+ namespace rnoh {
31
+
32
+ class PdfViewJSIBinder : public ViewComponentJSIBinder {
33
+ facebook::jsi::Object createNativeProps(facebook::jsi::Runtime &rt) override
34
+ {
35
+ auto object = ViewComponentJSIBinder::createNativeProps(rt);
36
+ object.setProperty(rt, "source", "Source");
37
+ object.setProperty(rt, "path", "string");
38
+ object.setProperty(rt, "page", "int");
39
+ object.setProperty(rt, "scale", "float");
40
+ object.setProperty(rt, "minScale", "float");
41
+ object.setProperty(rt, "maxScale", "float");
42
+ object.setProperty(rt, "horizontal", "boolean");
43
+ object.setProperty(rt, "enablePaging", "boolean");
44
+ object.setProperty(rt, "enableRTL", "boolean");
45
+ object.setProperty(rt, "enableAnnotationRendering", "boolean");
46
+ object.setProperty(rt, "showsHorizontalScrollIndicator", "boolean");
47
+ object.setProperty(rt, "showsVerticalScrollIndicator", "boolean");
48
+ object.setProperty(rt, "enableAntialiasing", "boolean");
49
+ object.setProperty(rt, "fitPolicy", "int");
50
+ object.setProperty(rt, "spacing", "int");
51
+ object.setProperty(rt, "password", "string");
52
+ object.setProperty(rt, "singlePage", "boolean");
53
+ return object;
54
+ }
55
+
56
+ facebook::jsi::Object createBubblingEventTypes(facebook::jsi::Runtime &rt) override
57
+ {
58
+ return facebook::jsi::Object(rt);
59
+ }
60
+
61
+ facebook::jsi::Object createDirectEventTypes(facebook::jsi::Runtime &rt) override
62
+ {
63
+ facebook::jsi::Object events(rt);
64
+ events.setProperty(rt, "topChange", createDirectEvent(rt, "onChange"));
65
+ return events;
66
+ }
67
+ };
68
+ } // namespace rnoh
69
+
70
+
71
+ #endif //HARMONY_PDFVIEWJSIBINDER_H
@@ -0,0 +1,58 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2024 Huawei Device Co., Ltd.
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ * of this software and associated documentation files (the "Software"), to deal
8
+ * in the Software without restriction, including without limitation the rights
9
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ * copies of the Software, and to permit persons to whom the Software is
11
+ * furnished to do so, subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ * SOFTWARE.
23
+ */
24
+
25
+ #ifndef HARMONY_PDFVIEWPACKAGE_H
26
+ #define HARMONY_PDFVIEWPACKAGE_H
27
+
28
+ #include "RNOH/Package.h"
29
+ #include "ComponentDescriptors.h"
30
+ #include "PdfViewJSIBinder.h"
31
+ #include "PdfEventEmitRequestHandler.h"
32
+
33
+ namespace rnoh {
34
+
35
+ class PdfViewPackage : public Package {
36
+ public:
37
+ PdfViewPackage(Package::Context ctx) : Package(ctx) {}
38
+
39
+ std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override
40
+ {
41
+ return {facebook::react::concreteComponentDescriptorProvider<
42
+ facebook::react::RNPDFPdfViewComponentDescriptor>()};
43
+ }
44
+
45
+ ComponentJSIBinderByString createComponentJSIBinderByName() override
46
+ {
47
+ return {{"RTNPdfView", std::make_shared<PdfViewJSIBinder>()}};
48
+ }
49
+
50
+ EventEmitRequestHandlers createEventEmitRequestHandlers() override
51
+ {
52
+ return { std::make_shared<PdfEventEmitRequestHandler>() };
53
+ }
54
+ };
55
+ } // namespace rnoh
56
+
57
+
58
+ #endif //HARMONY_CENTEREDTEXTPACKAGE_H