@react-native-ohos/clipboard 1.13.3-rc.1 → 1.16.3-rc.2

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.
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "@react-native-clipboard/clipboard",
4
+ "License": "MIT License",
5
+ "License File": " LICENSE ",
6
+ "Version Number": "1.16.2",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/react-native-clipboard/clipboard",
9
+ "Description": "React Native Clipboard API for both iOS and Android."
10
+ }
11
+ ]
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @react-native-ohos/clipboard
2
2
 
3
- This project is based on [@react-native-clipboard/clipboard](https://github.com/react-native-clipboard/clipboard)@1.16.3
3
+ This project is based on [@react-native-clipboard/clipboard@v1.16.2](https://github.com/react-native-clipboard/clipboard/tree/v1.16.2)
4
4
 
5
5
  ## Documentation
6
6
 
@@ -0,0 +1,37 @@
1
+ require 'json'
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
4
+
5
+ fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
6
+
7
+ Pod::Spec.new do |s|
8
+ s.name = "RNCClipboard"
9
+ s.version = package['version']
10
+ s.summary = package['description']
11
+ s.license = package['license']
12
+
13
+ s.authors = package['author']
14
+ s.homepage = package['homepage']
15
+
16
+ s.source = { :git => "https://github.com/react-native-clipboard/clipboard", :tag => "v#{s.version}" }
17
+ s.ios.source_files = "ios/**/*.{h,m,mm}"
18
+ s.osx.source_files = "macos/**/*.{h,m,mm}"
19
+ s.visionos.source_files = "ios/**/*.{h,m,mm}"
20
+
21
+ if fabric_enabled
22
+ folly_compiler_flags = '-DFOLLY_NO_CONFIG -DFOLLY_MOBILE=1 -DFOLLY_USE_LIBCPP=1 -Wno-comma -Wno-shorten-64-to-32'
23
+
24
+ s.pod_target_xcconfig = {
25
+ 'HEADER_SEARCH_PATHS' => '"$(PODS_ROOT)/boost" "$(PODS_ROOT)/boost-for-react-native" "$(PODS_ROOT)/RCT-Folly"',
26
+ 'CLANG_CXX_LANGUAGE_STANDARD' => 'c++17',
27
+ }
28
+ s.platforms = { ios: '11.0', tvos: '11.0', :osx => "10.14", :visionos => "1.0" }
29
+ s.compiler_flags = folly_compiler_flags + ' -DRCT_NEW_ARCH_ENABLED'
30
+
31
+ install_modules_dependencies(s)
32
+ else
33
+ s.platforms = { :ios => "9.0", :tvos => "9.0", :osx => "10.14", :visionos => "1.0" }
34
+
35
+ s.dependency "React-Core"
36
+ end
37
+ end
@@ -1,4 +1,4 @@
1
- import { EmitterSubscription } from 'react-native';
1
+ import { type EmitterSubscription } from "react-native";
2
2
  /**
3
3
  * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
4
4
  */
@@ -52,7 +52,7 @@ export declare const Clipboard: {
52
52
  */
53
53
  setImage(content: string): void;
54
54
  /**
55
- * (Android Only)
55
+ * (iOS and Android Only)
56
56
  * Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
57
57
  * ```javascript
58
58
  * async _getContent() {
package/dist/Clipboard.js CHANGED
@@ -24,8 +24,8 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.Clipboard = void 0;
27
- var react_native_1 = require("react-native");
28
- var NativeClipboardModule_1 = __importStar(require("@react-native-clipboard/clipboard/src/NativeClipboardModule"));
27
+ const react_native_1 = require("react-native");
28
+ const NativeClipboardModule_1 = __importStar(require("@react-native-clipboard/clipboard/src/NativeClipboardModule"));
29
29
  /**
30
30
  * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
31
31
  */
@@ -38,7 +38,7 @@ exports.Clipboard = {
38
38
  * }
39
39
  * ```
40
40
  */
41
- getString: function () {
41
+ getString() {
42
42
  return NativeClipboardModule_1.default.getString();
43
43
  },
44
44
  /**
@@ -50,7 +50,7 @@ exports.Clipboard = {
50
50
  * }
51
51
  * ```
52
52
  */
53
- getStrings: function () {
53
+ getStrings() {
54
54
  return NativeClipboardModule_1.default.getStrings();
55
55
  },
56
56
  /**
@@ -61,7 +61,7 @@ exports.Clipboard = {
61
61
  * }
62
62
  * ```
63
63
  */
64
- getImagePNG: function () {
64
+ getImagePNG() {
65
65
  return NativeClipboardModule_1.default.getImagePNG();
66
66
  },
67
67
  /**
@@ -72,7 +72,7 @@ exports.Clipboard = {
72
72
  * }
73
73
  * ```
74
74
  */
75
- getImageJPG: function () {
75
+ getImageJPG() {
76
76
  return NativeClipboardModule_1.default.getImageJPG();
77
77
  },
78
78
  /**
@@ -85,7 +85,7 @@ exports.Clipboard = {
85
85
  * ```
86
86
  * @param the content to be stored in the clipboard.
87
87
  */
88
- setImage: function (content) {
88
+ setImage(content) {
89
89
  // @ts-ignore
90
90
  if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
91
91
  NativeClipboardModule_1.default.setImage(content);
@@ -93,7 +93,7 @@ exports.Clipboard = {
93
93
  return;
94
94
  },
95
95
  /**
96
- * (Android Only)
96
+ * (iOS and Android Only)
97
97
  * Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
98
98
  * ```javascript
99
99
  * async _getContent() {
@@ -101,7 +101,7 @@ exports.Clipboard = {
101
101
  * }
102
102
  * ```
103
103
  */
104
- getImage: function () {
104
+ getImage() {
105
105
  return NativeClipboardModule_1.default.getImage();
106
106
  },
107
107
  /**
@@ -113,7 +113,7 @@ exports.Clipboard = {
113
113
  * ```
114
114
  * @param the content to be stored in the clipboard.
115
115
  */
116
- setString: function (content) {
116
+ setString(content) {
117
117
  NativeClipboardModule_1.default.setString(content);
118
118
  },
119
119
  /**
@@ -125,7 +125,7 @@ exports.Clipboard = {
125
125
  * ```
126
126
  * @param the content to be stored in the clipboard.
127
127
  */
128
- setStrings: function (content) {
128
+ setStrings(content) {
129
129
  NativeClipboardModule_1.default.setStrings(content);
130
130
  },
131
131
  /**
@@ -137,7 +137,7 @@ exports.Clipboard = {
137
137
  * }
138
138
  * ```
139
139
  */
140
- hasString: function () {
140
+ hasString() {
141
141
  return NativeClipboardModule_1.default.hasString();
142
142
  },
143
143
  /**
@@ -149,7 +149,7 @@ exports.Clipboard = {
149
149
  * }
150
150
  * ```
151
151
  */
152
- hasImage: function () {
152
+ hasImage() {
153
153
  return NativeClipboardModule_1.default.hasImage();
154
154
  },
155
155
  /**
@@ -163,7 +163,7 @@ exports.Clipboard = {
163
163
  * }
164
164
  * ```
165
165
  */
166
- hasURL: function () {
166
+ hasURL() {
167
167
  // @ts-ignore
168
168
  if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
169
169
  return NativeClipboardModule_1.default.hasURL();
@@ -181,7 +181,7 @@ exports.Clipboard = {
181
181
  * }
182
182
  * ```
183
183
  */
184
- hasNumber: function () {
184
+ hasNumber() {
185
185
  // @ts-ignore
186
186
  if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
187
187
  return NativeClipboardModule_1.default.hasNumber();
@@ -199,7 +199,7 @@ exports.Clipboard = {
199
199
  * }
200
200
  * ```
201
201
  */
202
- hasWebURL: function () {
202
+ hasWebURL() {
203
203
  // @ts-ignore
204
204
  if (react_native_1.Platform.OS == 'ios' || react_native_1.Platform.OS == 'harmony') {
205
205
  return NativeClipboardModule_1.default.hasWebURL();
@@ -216,7 +216,7 @@ exports.Clipboard = {
216
216
  * Clipboard.addListener(listener);
217
217
  * ```
218
218
  */
219
- addListener: function (callback) {
219
+ addListener(callback) {
220
220
  return (0, NativeClipboardModule_1.addListener)(callback);
221
221
  },
222
222
  /**
@@ -226,7 +226,7 @@ exports.Clipboard = {
226
226
  * Clipboard.removeAllListeners();
227
227
  * ```
228
228
  */
229
- removeAllListeners: function () {
229
+ removeAllListeners() {
230
230
  (0, NativeClipboardModule_1.removeAllListeners)();
231
231
  },
232
232
  };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import { Clipboard } from './Clipboard';
2
- export { useClipboard } from '@react-native-clipboard/clipboard/src/useClipboard';
1
+ import { Clipboard } from "./Clipboard";
2
+ export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
3
3
  export default Clipboard;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useClipboard = void 0;
4
- var Clipboard_1 = require("./Clipboard");
4
+ const Clipboard_1 = require("./Clipboard");
5
5
  var useClipboard_1 = require("@react-native-clipboard/clipboard/src/useClipboard");
6
6
  Object.defineProperty(exports, "useClipboard", { enumerable: true, get: function () { return useClipboard_1.useClipboard; } });
7
7
  exports.default = Clipboard_1.Clipboard;
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2015-present, Facebook, Inc.
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.
@@ -0,0 +1,33 @@
1
+ OPEN SOURCE SOFTWARE NOTICE
2
+
3
+ Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders.
4
+
5
+ Warranty Disclaimer
6
+ THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS.
7
+
8
+ Copyright Notice and License Texts
9
+
10
+ ----------------------------------------------------------------------
11
+ Software: @react-native-clipboard/clipboard V1.16.2
12
+
13
+ MIT License
14
+
15
+ Copyright (c) 2015-present, Facebook, Inc.
16
+
17
+ Permission is hereby granted, free of charge, to any person obtaining a copy
18
+ of this software and associated documentation files (the "Software"), to deal
19
+ in the Software without restriction, including without limitation the rights
20
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
21
+ copies of the Software, and to permit persons to whom the Software is
22
+ furnished to do so, subject to the following conditions:
23
+
24
+ The above copyright notice and this permission notice shall be included in all
25
+ copies or substantial portions of the Software.
26
+
27
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
30
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
31
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
32
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
33
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <configuration>
3
+ <oatconfig>
4
+ <licensefile>LICENSE</licensefile>
5
+ <filefilterlist>
6
+ <filefilter name="copyrightPolicyFilter" desc="Filters for compatibility,license header policies">
7
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加版权头"/>
8
+ <filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加版权头"/>
9
+ <filteritem type="filename" name="*.proto" desc="资源文件,不需要添加版权头"/>
10
+ <filteritem type="filename" name="*.json" desc="资源文件,不需要添加版权头"/>
11
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
12
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
13
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
14
+ <filteritem type="filename" name="LICENSE" desc="工程文件,不修改版权头"/>
15
+ </filefilter>
16
+ <filefilter name="defaultPolicyFilter" desc="Filters for compatibility,license header policies">
17
+ <filteritem type="filename" name="hvigorfile.ts" desc="hvigor构建脚本,DevEco Studio自动生成,不需要添加许可证头"/>
18
+ <filteritem type="filename" name="*.json5" desc="hvigor工程配置文件,DevEco Studio自动生成,不需要添加许可证头"/>
19
+ <filteritem type="filename" name="LICENSE" desc="原三方库证书文件无需更改,因此添加过滤"/>
20
+ <filteritem type="filename" name="*.proto" desc="资源文件,不需要添加许可证头"/>
21
+ <filteritem type="filename" name="*.json" desc="资源文件,不需要添加许可证头"/>
22
+ <filteritem type="filepath" name="hvigorw" desc="工程模板,不修改版权头,以防有修改版权风险"/>
23
+ <filteritem type="filepath" name="hvigorw.bat" desc="工程模板,不修改版权头,以防有修改版权风险"/>
24
+ <filteritem type="filepath" name="hvigor/hvigor-wrapper.js" desc="工程模板,不修改版权头,以防有修改版权风险"/>
25
+ </filefilter>
26
+ <filefilter name="binaryFileTypePolicyFilter" desc="Filters for resources files policies">
27
+ <filteritem type="filename" name="icon.png" desc="应用图标"/>
28
+ <filteritem type="filename" name="app_icon.png" desc="应用图标"/>
29
+ <filteritem type="filename" name="warn.png" desc="页面展示图标"/>
30
+ </filefilter>
31
+ </filefilterlist>
32
+ <policylist>
33
+ <policy name="projectPolicy" desc="">
34
+ <policyitem type="license" name="MIT" path="*.*" desc="license under the MIT"/>
35
+ </policy>
36
+ </policylist>
37
+ </oatconfig>
38
+ </configuration>
@@ -0,0 +1,11 @@
1
+ [
2
+ {
3
+ "Name": "@react-native-clipboard/clipboard",
4
+ "License": "MIT License",
5
+ "License File": " LICENSE ",
6
+ "Version Number": "1.16.2",
7
+ "Owner" : "xiafeng@huawei.com",
8
+ "Upstream URL": "https://github.com/react-native-clipboard/clipboard",
9
+ "Description": "React Native Clipboard API for both iOS and Android."
10
+ }
11
+ ]
@@ -0,0 +1,307 @@
1
+ > 模板版本:v0.2.2
2
+
3
+ <p align="center">
4
+ <h1 align="center"> <code>@react-native-clipboard/clipboard</code> </h1>
5
+ </p>
6
+ <p align="center">
7
+ <a href="https://github.com/react-native-clipboard/clipboard">
8
+ <img src="https://img.shields.io/badge/platforms-android%20|%20ios%20|%20macos%20|%20windows%20|%20harmony%20-lightgrey.svg" alt="Supported platforms" />
9
+ </a>
10
+ <a href="https://github.com/react-native-clipboard/clipboard/blob/master/LICENSE">
11
+ <img src="https://img.shields.io/badge/license-MIT-green.svg" alt="License" />
12
+ </a>
13
+ </p>
14
+
15
+ > [!TIP] [Github 地址](https://github.com/react-native-oh-library/clipboard/tree/sig)
16
+
17
+ ## 安装与使用
18
+
19
+ 请到三方库的 Releases 发布地址查看配套的版本信息:[@react-native-ohos/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases) 。对于未发布到npm的旧版本,请参考[安装指南](/zh-cn/tgz-usage.md)安装tgz包。
20
+
21
+ 进入到工程目录并输入以下命令:
22
+
23
+ <!-- tabs:start -->
24
+
25
+ #### **npm**
26
+
27
+ ```bash
28
+ npm install @react-native-ohos/clipboard
29
+ ```
30
+
31
+ #### **yarn**
32
+
33
+ ```bash
34
+ yarn add @react-native-ohos/clipboard
35
+ ```
36
+
37
+ <!-- tabs:end -->
38
+
39
+ 下面的代码展示了这个库的基本使用场景:
40
+
41
+ > [!WARNING] 使用时 import 的库名不变。
42
+
43
+ ```js
44
+ import React, { useState } from 'react';
45
+ import { StyleSheet, Text, TouchableOpacity, View } from 'react-native';
46
+ import Clipboard from "@react-native-clipboard/clipboard";
47
+
48
+ const App = () => {
49
+ const [copiedText, setCopiedText] = useState("");
50
+
51
+ const copyToClipboard = () => {
52
+ Clipboard.setString("hello world");
53
+ };
54
+
55
+ const fetchCopiedText = async () => {
56
+ const text = await Clipboard.getString();
57
+ setCopiedText(text);
58
+ };
59
+
60
+ return (
61
+ <View style={styles.container}>
62
+ <TouchableOpacity onPress={copyToClipboard}>
63
+ <Text>Click here to copy to Clipboard</Text>
64
+ </TouchableOpacity>
65
+ <TouchableOpacity onPress={fetchCopiedText}>
66
+ <Text>View copied text</Text>
67
+ </TouchableOpacity>
68
+
69
+ <Text style={styles.copiedText}>{copiedText}</Text>
70
+ </View>
71
+ );
72
+ };
73
+
74
+ const styles = StyleSheet.create({
75
+ container: {
76
+ flex: 1,
77
+ justifyContent: "center",
78
+ alignItems: "center",
79
+ padding: 20,
80
+ },
81
+ copiedText: {
82
+ marginTop: 20,
83
+ fontSize: 18,
84
+ },
85
+ });
86
+
87
+ export default App;
88
+ ```
89
+
90
+ ## Link
91
+
92
+ 目前 HarmonyOS 暂不支持 AutoLink,所以 Link 步骤需要手动配置。
93
+
94
+ 首先需要使用 DevEco Studio 打开项目里的 HarmonyOS 工程 `harmony`
95
+
96
+ ### 1.在工程根目录的 `oh-package.json5` 添加 overrides 字段
97
+
98
+ ```json
99
+ {
100
+ ...
101
+ "overrides": {
102
+ "@rnoh/react-native-openharmony" : "./react_native_openharmony"
103
+ }
104
+ }
105
+ ```
106
+
107
+ ### 2.引入原生端代码
108
+
109
+ 目前有两种方法:
110
+
111
+ 1. 通过 har 包引入(在 IDE 完善相关功能后该方法会被遗弃,目前首选此方法);
112
+ 2. 直接链接源码。
113
+
114
+ 方法一:通过 har 包引入
115
+
116
+ > [!TIP] har 包位于三方库安装路径的 `harmony` 文件夹下。
117
+
118
+ 打开 `entry/oh-package.json5`,添加以下依赖
119
+
120
+ ```json
121
+ "dependencies": {
122
+ "@rnoh/react-native-openharmony": "file:../react_native_openharmony",
123
+
124
+ "@react-native-ohos/clipboard": "file:../../node_modules/@react-native-ohos/clipboard/harmony/clipboard.har"
125
+ }
126
+ ```
127
+
128
+ 点击右上角的 `sync` 按钮
129
+
130
+ 或者在终端执行:
131
+
132
+ ```bash
133
+ cd entry
134
+ ohpm install
135
+ ```
136
+
137
+ 方法二:直接链接源码
138
+
139
+ > [!TIP] 如需使用直接链接源码,请参考[直接链接源码说明](/zh-cn/link-source-code.md)
140
+
141
+ ### 3.配置 CMakeLists 和引入 ClipboardPackage
142
+
143
+ 打开 `entry/src/main/cpp/CMakeLists.txt`,添加:
144
+
145
+ ```diff
146
+ project(rnapp)
147
+ cmake_minimum_required(VERSION 3.4.1)
148
+ set(CMAKE_SKIP_BUILD_RPATH TRUE)
149
+ set(RNOH_APP_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
150
+ set(NODE_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../node_modules")
151
+ + set(OH_MODULES "${CMAKE_CURRENT_SOURCE_DIR}/../../../oh_modules")
152
+ set(RNOH_CPP_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../../../../../../react-native-harmony/harmony/cpp")
153
+ set(LOG_VERBOSITY_LEVEL 1)
154
+ set(CMAKE_ASM_FLAGS "-Wno-error=unused-command-line-argument -Qunused-arguments")
155
+ set(CMAKE_CXX_FLAGS "-fstack-protector-strong -Wl,-z,relro,-z,now,-z,noexecstack -s -fPIE -pie")
156
+ set(WITH_HITRACE_SYSTRACE 1) # for other CMakeLists.txt files to use
157
+ add_compile_definitions(WITH_HITRACE_SYSTRACE)
158
+
159
+ add_subdirectory("${RNOH_CPP_DIR}" ./rn)
160
+
161
+ # RNOH_BEGIN: manual_package_linking_1
162
+ add_subdirectory("../../../../sample_package/src/main/cpp" ./sample-package)
163
+ + add_subdirectory("${OH_MODULES}/@react-native-ohos/clipboard/src/main/cpp" ./clipboard)
164
+ # RNOH_END: manual_package_linking_1
165
+
166
+ file(GLOB GENERATED_CPP_FILES "./generated/*.cpp")
167
+
168
+ add_library(rnoh_app SHARED
169
+ ${GENERATED_CPP_FILES}
170
+ "./PackageProvider.cpp"
171
+ "${RNOH_CPP_DIR}/RNOHAppNapiBridge.cpp"
172
+ )
173
+ target_link_libraries(rnoh_app PUBLIC rnoh)
174
+
175
+ # RNOH_BEGIN: manual_package_linking_2
176
+ target_link_libraries(rnoh_app PUBLIC rnoh_sample_package)
177
+ + target_link_libraries(rnoh_app PUBLIC rnoh_clipboard)
178
+ # RNOH_END: manual_package_linking_2
179
+ ```
180
+
181
+ 打开 `entry/src/main/cpp/PackageProvider.cpp`,添加:
182
+
183
+ ```diff
184
+ #include "RNOH/PackageProvider.h"
185
+ #include "generated/RNOHGeneratedPackage.h"
186
+ #include "SamplePackage.h"
187
+ + #include "ClipboardPackage.h"
188
+
189
+ using namespace rnoh;
190
+
191
+ std::vector<std::shared_ptr<Package>> PackageProvider::getPackages(Package::Context ctx) {
192
+ return {
193
+ std::make_shared<RNOHGeneratedPackage>(ctx),
194
+ std::make_shared<SamplePackage>(ctx),
195
+ + std::make_shared<ClipboardPackage>(ctx),
196
+ };
197
+ }
198
+ ```
199
+
200
+ ### 4.在 ArkTs 侧引入 ClipboardPackage
201
+
202
+ 打开 `entry/src/main/ets/RNPackagesFactory.ts`,添加:
203
+
204
+ ```diff
205
+ import type {RNPackageContext, RNPackage} from 'rnoh/ts';
206
+ import {SamplePackage} from 'rnoh-sample-package/ts';
207
+ + import {ClipboardPackage} from '@react-native-ohos/clipboard/ts';
208
+
209
+ export function createRNPackages(ctx: RNPackageContext): RNPackage[] {
210
+ return [
211
+ new SamplePackage(ctx),
212
+ + new ClipboardPackage(ctx)
213
+ ];
214
+ }
215
+
216
+ ```
217
+
218
+ ### 5.运行
219
+
220
+ 点击右上角的 `sync` 按钮
221
+
222
+ 或者在终端执行:
223
+
224
+ ```bash
225
+ cd entry
226
+ ohpm install
227
+ ```
228
+
229
+ 然后编译、运行即可。
230
+
231
+ ## 约束与限制
232
+
233
+ ### 兼容性
234
+
235
+ 要使用此库,需要使用正确的 React-Native 和 RNOH 版本。另外,还需要使用配套的 DevEco Studio 和 手机 ROM。
236
+
237
+ 请到三方库相应的 Releases 发布地址查看 Release 配套的版本信息:[@react-native-ohos/clipboard Releases](https://github.com/react-native-oh-library/clipboard/releases)
238
+
239
+ ### 权限要求
240
+
241
+ > [!TIP] "ohos.permission.READ_PASTEBOARD"权限等级为<B>system_basic</B>,授权方式为<B>user_grant</B>,[使用 ACL 签名的配置指导](https://developer.harmonyos.com/cn/docs/documentation/doc-guides-V3/signing-0000001587684945-V3#section157591551175916)
242
+
243
+ #### 在 entry 目录下的module.json5中添加权限
244
+
245
+ 打开 `entry/src/main/module.json5`,添加:
246
+
247
+ ```diff
248
+ ...
249
+ "requestPermissions": [
250
+ + {
251
+ + "name": "ohos.permission.READ_PASTEBOARD",
252
+ + "reason": "$string:Access_clipboard",
253
+ + "usedScene": {
254
+ + "abilities": [
255
+ + "EntryAbility"
256
+ + ],
257
+ + "when":"always"
258
+ + }
259
+ + },
260
+ ]
261
+ ```
262
+
263
+ #### 在 entry 目录下添加申请剪切板权限的原因
264
+
265
+ 打开 `entry/src/main/resources/base/element/string.json`,添加:
266
+
267
+ ```diff
268
+ ...
269
+ {
270
+ "string": [
271
+ + {
272
+ + "name": "Access_clipboard",
273
+ + "value": "access clipboard"
274
+ + }
275
+ ]
276
+ }
277
+ ```
278
+
279
+ ## 属性
280
+
281
+ > [!TIP] "Platform"列表示该属性在原三方库上支持的平台。
282
+
283
+ > [!TIP] "HarmonyOS Support"列为 yes 表示 HarmonyOS 平台支持该属性;no 则表示不支持;partially 表示部分支持。使用方法跨平台一致,效果对标 iOS 或 Android 的效果。
284
+
285
+ | Name | Description | Type | Required | Platform | HarmonyOS Support |
286
+ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | -------- | ----------- | ----------------- |
287
+ | getString | Get content of string type, this method returns a Promise, so you can use following code to get clipboard content | function | NO | iOS,Android | yes |
288
+ | setString | Set content of string type. You can use following code to set clipboard content | function | NO | iOS,Android | yes |
289
+ | hasString | Returns whether the clipboard has content or is empty. | function | NO | iOS,Android | yes |
290
+ | getImage | Get content of image in base64 string type, this method returns a Promise, so you can use following code to get clipboard content (iOS and Android only) | function | NO | iOS,Android | no |
291
+ | getStrings | (iOS only) Get contents of string array type, this method returns a Promise, so you can use following code to get clipboard content | function | NO | iOS | yes |
292
+ | setStrings | (iOS only) Set content of string array type. You can use following code to set clipboard content | function | NO | iOS | yes |
293
+ | hasNumber | (iOS 14+ only) Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | iOS | yes |
294
+ | hasImage | Returns whether the clipboard has a Image | function | NO | iOS | yes |
295
+ | hasUrl | (iOS only) Returns whether the clipboard has a URL content. Can check if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | iOS | yes |
296
+ | hasWebUrl | (iOS 14+ only) Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+ | function | NO | iOS | yes |
297
+ | setImage | Set content of Image type.(base64 string) | function | NO | iOS | yes |
298
+ | getImageJPG | get base64 string of JPG Image | function | NO | iOS | yes |
299
+ | getImagePNG | get base64 string of PNG Image | function | NO | iOS | yes |
300
+
301
+ ## 遗留问题
302
+
303
+ ## 其他
304
+
305
+ ## 开源协议
306
+
307
+ 本项目基于 [The MIT License (MIT)](https://github.com/react-native-clipboard/clipboard/blob/master/LICENSE) ,请自由地享受和参与开源。
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -21,6 +21,5 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { ClipboardPackage } from './src/main/ets/ClipboardPackage.ets'
25
- export * from './ts.ets'
26
- export default ClipboardPackage
24
+
25
+ export * from './ts'
@@ -3,10 +3,10 @@
3
3
  "types": "",
4
4
  "devDependencies": {},
5
5
  "name": "@react-native-ohos/clipboard",
6
- "version": "1.13.3-rc.1",
6
+ "version": "1.16.3-rc.2",
7
7
  "description": "",
8
8
  "main": "index.ets",
9
9
  "dependencies": {
10
- "@rnoh/react-native-openharmony": "file:../react_native_openharmony"
10
+ "@rnoh/react-native-openharmony": "file:../../example/node_modules/react-native-harmony/harmony/react_native_openharmony.har"
11
11
  }
12
12
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -153,6 +153,24 @@ static jsi::Value _hostFunction_RNCClipboardTurboModule_hasWebURL(
153
153
  return jsi::Value(static_cast<ArkTSTurboModule &> (turboModule).callAsync(rt, "hasWebURL", args, count));
154
154
  }
155
155
 
156
+ static jsi::Value _hostFunction_RNCClipboardTurboModule_addListener(
157
+ jsi::Runtime &rt,
158
+ react::TurboModule & turboModule,
159
+ const jsi::Value* args,
160
+ size_t count)
161
+ {
162
+ return jsi::Value(static_cast<ArkTSTurboModule &> (turboModule).call(rt, "addListener", args, count));
163
+ }
164
+
165
+ static jsi::Value _hostFunction_RNCClipboardTurboModule_removeListeners(
166
+ jsi::Runtime &rt,
167
+ react::TurboModule & turboModule,
168
+ const jsi::Value* args,
169
+ size_t count)
170
+ {
171
+ return jsi::Value(static_cast<ArkTSTurboModule &> (turboModule).call(rt, "removeListeners", args, count));
172
+ }
173
+
156
174
  RNCClipboardTurboModule::RNCClipboardTurboModule(const ArkTSTurboModule::Context ctx, const std::string name)
157
175
  : ArkTSTurboModule(ctx, name)
158
176
  {
@@ -174,4 +192,7 @@ RNCClipboardTurboModule::RNCClipboardTurboModule(const ArkTSTurboModule::Context
174
192
  methodMap_["hasImage"]= MethodMetadata{0, _hostFunction_RNCClipboardTurboModule_hasImage};
175
193
  methodMap_["hasURL"]= MethodMetadata{0, _hostFunction_RNCClipboardTurboModule_hasURL};
176
194
  methodMap_["hasWebURL"]= MethodMetadata{0, _hostFunction_RNCClipboardTurboModule_hasWebURL};
195
+
196
+ methodMap_["addListener"]= MethodMetadata{1, _hostFunction_RNCClipboardTurboModule_addListener};
197
+ methodMap_["removeListeners"]= MethodMetadata{1, _hostFunction_RNCClipboardTurboModule_removeListeners};
177
198
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -25,7 +25,6 @@
25
25
  import { RNPackage, TurboModulesFactory } from '@rnoh/react-native-openharmony/ts';
26
26
  import type { TurboModule, TurboModuleContext } from '@rnoh/react-native-openharmony/ts';
27
27
  import { RNCClipboardTurboModule } from './RNCClipboardTurboModule';
28
- import {RNOHPackage} from "@rnoh/react-native-openharmony";
29
28
 
30
29
  class ClipboardTurboModulesFactory extends TurboModulesFactory {
31
30
  createTurboModule(name: string): TurboModule | null {
@@ -40,7 +39,7 @@ class ClipboardTurboModulesFactory extends TurboModulesFactory {
40
39
  }
41
40
  }
42
41
 
43
- export class ClipboardPackage extends RNOHPackage {
42
+ export class ClipboardPackage extends RNPackage {
44
43
  createTurboModulesFactory(ctx: TurboModuleContext): TurboModulesFactory {
45
44
  return new ClipboardTurboModulesFactory(ctx);
46
45
  }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
@@ -321,7 +321,7 @@ export class RNCClipboardTurboModule extends TurboModule {
321
321
  let systemPasteboard = pasteboard.getSystemPasteboard();
322
322
  systemPasteboard.clear().then(() => {
323
323
  systemPasteboard.getData().then((pasteData) => {
324
- while(content.length > 0) {
324
+ while (content.length > 0) {
325
325
  pasteData.addRecord(pasteboard.MIMETYPE_TEXT_PLAIN, content.pop())
326
326
  }
327
327
 
@@ -475,4 +475,7 @@ export class RNCClipboardTurboModule extends TurboModule {
475
475
  })
476
476
  });
477
477
  }
478
- }
478
+
479
+ addListener(eventName: string): void {}
480
+ removeListeners(count: number): void {}
481
+ }
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * MIT License
3
3
  *
4
- * Copyright (C) 2023 Huawei Device Co., Ltd.
4
+ * Copyright (C) 2025 Huawei Device Co., Ltd.
5
5
  *
6
6
  * Permission is hereby granted, free of charge, to any person obtaining a copy
7
7
  * of this software and associated documentation files (the "Software"), to deal
Binary file
package/package.json CHANGED
@@ -1,15 +1,9 @@
1
1
  {
2
2
  "name": "@react-native-ohos/clipboard",
3
- "version": "1.13.3-rc.1",
3
+ "version": "1.16.3-rc.2",
4
4
  "description": "React Native Clipboard API",
5
5
  "harmony": {
6
- "alias": "react-native-clipboard/clipboard",
7
- "autolinking": {
8
- "etsPackageClassName": "ClipboardPackage",
9
- "cppPackageClassName": "ClipboardPackage",
10
- "cmakeLibraryTargetName": "rnoh_clipboard",
11
- "ohPackageName": "@react-native-ohos/clipboard"
12
- }
6
+ "alias": "@react-native-clipboard/clipboard"
13
7
  },
14
8
  "keywords": [
15
9
  "Clipboard",
@@ -17,7 +11,7 @@
17
11
  "react-native",
18
12
  "setString"
19
13
  ],
20
- "homepage": "https://gitcode.com/openharmony-sig/rntpc_clipboard#readme",
14
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_clipboard/tree/br_rnoh0.77#readme",
21
15
  "bugs": {
22
16
  "url": "https://gitcode.com/openharmony-sig/rntpc_clipboard/issues"
23
17
  },
@@ -42,7 +36,8 @@
42
36
  "windows": "cd example && react-native run-windows",
43
37
  "start": "react-native start",
44
38
  "build": "tsc",
45
- "lint": "eslint src --ext .ts,.tsx --cache",
39
+ "format": "biome format --write .",
40
+ "lint": "biome lint --write .",
46
41
  "prepare": "npm run build",
47
42
  "test": "jest",
48
43
  "type-check": "tsc --noEmit"
@@ -52,30 +47,44 @@
52
47
  },
53
48
  "devDependencies": {
54
49
  "@babel/core": "^7.12.9",
55
- "@react-native-community/eslint-config": "^2.0.0",
56
- "@types/react-native": "^0.70.0",
50
+ "@biomejs/biome": "1.9.4",
51
+ "@callstack/react-native-visionos": "^0.76.0",
52
+ "@react-native/babel-preset": "^0.75.0",
53
+ "@react-native/metro-config": "^0.75.0",
54
+ "@rnx-kit/align-deps": "^2.4.1",
55
+ "@rnx-kit/metro-config": "^2.0.0",
56
+ "@types/react": "^18.2.0",
57
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
57
58
  "babel-jest": "^26.1.0",
58
- "eslint": "^7.32.0",
59
- "eslint-plugin-prettier": "^3.1.2",
60
- "jest": "^26.1.0",
61
- "metro-react-native-babel-preset": "^0.64.0",
62
- "prettier": "^2.4.1",
63
- "react": "17.0.1",
64
- "react-native": "0.68.0",
65
- "react-native-macos": "^0.62.0-0",
66
- "react-native-windows": "^0.64.0",
67
- "react-test-renderer": "16.9.0",
59
+ "jest": "^29.2.1",
60
+ "react": "^18.3.1",
61
+ "react-native": "^0.77.1",
62
+ "react-native-macos": "0.76.0",
63
+ "react-native-test-app": "^4.0.5",
64
+ "react-native-windows": "^0.75.0",
65
+ "react-test-renderer": "^18.2.0",
68
66
  "typescript": "^4.4.3"
69
67
  },
70
68
  "dependencies": {
71
- "@react-native-clipboard/clipboard": "1.13.2"
69
+ "@react-native-clipboard/clipboard": "1.16.2"
72
70
  },
73
71
  "peerDependencies": {
74
- "react": ">=16.0",
75
- "react-native": ">=0.57.0"
72
+ "react": ">= 16.9.0",
73
+ "react-native": ">= 0.61.5",
74
+ "react-native-macos": ">= 0.61.0",
75
+ "react-native-windows": ">= 0.61.0"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "react-native-macos": {
79
+ "optional": true
80
+ },
81
+ "react-native-windows": {
82
+ "optional": true
83
+ }
76
84
  },
77
85
  "publishConfig": {
78
86
  "registry": "https://registry.npmjs.org/",
79
87
  "access": "public"
80
- }
81
- }
88
+ },
89
+ "packageManager": "yarn@4.1.1"
90
+ }
package/src/Clipboard.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {EmitterSubscription, Platform} from 'react-native';
1
+ import { type EmitterSubscription, Platform } from "react-native";
2
2
  import NativeClipboard, {
3
3
  addListener,
4
4
  removeAllListeners,
@@ -71,7 +71,7 @@ export const Clipboard = {
71
71
  return;
72
72
  },
73
73
  /**
74
- * (Android Only)
74
+ * (iOS and Android Only)
75
75
  * Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
76
76
  * ```javascript
77
77
  * async _getContent() {
package/src/index.ts CHANGED
@@ -1,3 +1,3 @@
1
- import {Clipboard} from './Clipboard';
2
- export {useClipboard} from '@react-native-clipboard/clipboard/src/useClipboard';
1
+ import { Clipboard } from "./Clipboard";
2
+ export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
3
3
  export default Clipboard;