@react-native-ohos/clipboard 1.2.0-beta.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 (33) hide show
  1. package/LICENSE +21 -0
  2. package/README.OpenSource +11 -0
  3. package/README.md +13 -0
  4. package/RNCClipboard.podspec +37 -0
  5. package/dist/Clipboard.d.ts +159 -0
  6. package/dist/Clipboard.js +232 -0
  7. package/dist/index.d.ts +3 -0
  8. package/dist/index.js +7 -0
  9. package/harmony/clipboard/LICENSE +21 -0
  10. package/harmony/clipboard/NOTICE +33 -0
  11. package/harmony/clipboard/OAT.xml +38 -0
  12. package/harmony/clipboard/README.OpenSource +11 -0
  13. package/harmony/clipboard/README.md +307 -0
  14. package/harmony/clipboard/build-profile.json5 +8 -0
  15. package/harmony/clipboard/hvigorfile.ts +1 -0
  16. package/harmony/clipboard/index.ets +27 -0
  17. package/harmony/clipboard/oh-package.json5 +12 -0
  18. package/harmony/clipboard/src/main/cpp/CMakeLists.txt +7 -0
  19. package/harmony/clipboard/src/main/cpp/ClipboardPackage.h +58 -0
  20. package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.cpp +198 -0
  21. package/harmony/clipboard/src/main/cpp/RNCClipboardTurboModule.h +39 -0
  22. package/harmony/clipboard/src/main/ets/ClipboardPackage.ets +46 -0
  23. package/harmony/clipboard/src/main/ets/Logger.ts +64 -0
  24. package/harmony/clipboard/src/main/ets/RNCClipboardTurboModule.ts +759 -0
  25. package/harmony/clipboard/src/main/module.json5 +7 -0
  26. package/harmony/clipboard/src/main/resources/base/element/string.json +8 -0
  27. package/harmony/clipboard/src/main/resources/en_US/element/string.json +8 -0
  28. package/harmony/clipboard/src/main/resources/zh_CN/element/string.json +8 -0
  29. package/harmony/clipboard/ts.ets +26 -0
  30. package/harmony/clipboard.har +0 -0
  31. package/package.json +96 -0
  32. package/src/Clipboard.ts +211 -0
  33. package/src/index.ts +3 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "module": {
3
+ "name": "clipboard",
4
+ "type": "har",
5
+ "deviceTypes": ['default'],
6
+ }
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from npm package"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from npm package"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "string": [
3
+ {
4
+ "name": "page_show",
5
+ "value": "page from npm package"
6
+ }
7
+ ]
8
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * MIT License
3
+ *
4
+ * Copyright (C) 2025 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
+ export * from './src/main/ets/ClipboardPackage'
26
+ export * from './src/main/ets/RNCClipboardTurboModule'
Binary file
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "@react-native-ohos/clipboard",
3
+ "version": "1.2.0-beta.1",
4
+ "description": "React Native Clipboard API",
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
+ }
13
+ },
14
+ "keywords": [
15
+ "Clipboard",
16
+ "getString",
17
+ "react-native",
18
+ "setString"
19
+ ],
20
+ "homepage": "https://gitcode.com/openharmony-sig/rntpc_clipboard/tree/br_rnoh0.77#readme",
21
+ "bugs": {
22
+ "url": "https://gitcode.com/openharmony-sig/rntpc_clipboard/issues"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "https://gitcode.com/openharmony-sig/rntpc_clipboard.git"
27
+ },
28
+ "license": "MIT",
29
+ "author": "M.Haris Baig <harisbaig100@gmail.com>",
30
+ "main": "dist/index.js",
31
+ "types": "dist/index.d.ts",
32
+ "files": [
33
+ "dist",
34
+ "RNCClipboard.podspec",
35
+ "harmony",
36
+ "src",
37
+ "!harmony/oh_modules",
38
+ "!harmony/**/build",
39
+ "!harmony/**/oh_modules"
40
+ ],
41
+ "scripts": {
42
+ "windows": "cd example && react-native run-windows",
43
+ "start": "react-native start",
44
+ "build": "tsc",
45
+ "format": "biome format --write .",
46
+ "lint": "biome lint --write .",
47
+ "prepare": "npm run build",
48
+ "test": "jest",
49
+ "type-check": "tsc --noEmit"
50
+ },
51
+ "jest": {
52
+ "preset": "react-native"
53
+ },
54
+ "devDependencies": {
55
+ "@babel/core": "^7.12.9",
56
+ "@biomejs/biome": "1.9.4",
57
+ "@callstack/react-native-visionos": "^0.76.0",
58
+ "@react-native/babel-preset": "^0.75.0",
59
+ "@react-native/metro-config": "^0.75.0",
60
+ "@rnx-kit/align-deps": "^2.4.1",
61
+ "@rnx-kit/metro-config": "^2.0.0",
62
+ "@types/react": "^18.2.0",
63
+ "@typescript-eslint/eslint-plugin": "^8.16.0",
64
+ "babel-jest": "^26.1.0",
65
+ "jest": "^29.2.1",
66
+ "react": "^18.3.1",
67
+ "react-native": "^0.82.1",
68
+ "react-native-macos": "0.81.0",
69
+ "react-native-test-app": "^4.0.5",
70
+ "react-native-windows": "^0.75.0",
71
+ "react-test-renderer": "^18.2.0",
72
+ "typescript": "^4.4.3"
73
+ },
74
+ "dependencies": {
75
+ "@react-native-clipboard/clipboard": "1.16.3"
76
+ },
77
+ "peerDependencies": {
78
+ "react": ">= 16.9.0",
79
+ "react-native": ">= 0.61.5",
80
+ "react-native-macos": ">= 0.61.0",
81
+ "react-native-windows": ">= 0.61.0"
82
+ },
83
+ "peerDependenciesMeta": {
84
+ "react-native-macos": {
85
+ "optional": true
86
+ },
87
+ "react-native-windows": {
88
+ "optional": true
89
+ }
90
+ },
91
+ "publishConfig": {
92
+ "registry": "https://registry.npmjs.org/",
93
+ "access": "public"
94
+ },
95
+ "packageManager": "yarn@4.1.1"
96
+ }
@@ -0,0 +1,211 @@
1
+ import { type EmitterSubscription, Platform } from "react-native";
2
+ import NativeClipboard, {
3
+ addListener,
4
+ removeAllListeners,
5
+ } from '@react-native-clipboard/clipboard/src/NativeClipboardModule';
6
+
7
+ /**
8
+ * `Clipboard` gives you an interface for setting and getting content from Clipboard on both iOS and Android
9
+ */
10
+ export const Clipboard = {
11
+ /**
12
+ * Get content of string type, this method returns a `Promise`, so you can use following code to get clipboard content
13
+ * ```javascript
14
+ * async _getContent() {
15
+ * var content = await Clipboard.getString();
16
+ * }
17
+ * ```
18
+ */
19
+ getString(): Promise<string> {
20
+ return NativeClipboard.getString();
21
+ },
22
+ /**
23
+ * (iOS Only)
24
+ * Get contents of string array type, this method returns a `Promise`, so you can use following code to get clipboard content
25
+ * ```javascript
26
+ * async _getContent() {
27
+ * var content = await Clipboard.getStrings();
28
+ * }
29
+ * ```
30
+ */
31
+ getStrings(): Promise<string[]> {
32
+ return NativeClipboard.getStrings();
33
+ },
34
+ /**
35
+ * Get clipboard image as PNG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
36
+ * ```javascript
37
+ * async _getContent() {
38
+ * var content = await Clipboard.getImagePNG();
39
+ * }
40
+ * ```
41
+ */
42
+ getImagePNG(): Promise<string> {
43
+ return NativeClipboard.getImagePNG();
44
+ },
45
+ /**
46
+ * Get clipboard image as JPG in base64, this method returns a `Promise`, so you can use following code to get clipboard content
47
+ * ```javascript
48
+ * async _getContent() {
49
+ * var content = await Clipboard.getImageJPG();
50
+ * }
51
+ * ```
52
+ */
53
+ getImageJPG(): Promise<string> {
54
+ return NativeClipboard.getImageJPG();
55
+ },
56
+ /**
57
+ * (iOS Only)
58
+ * Set content of base64 image type. You can use following code to set clipboard content
59
+ * ```javascript
60
+ * _setContent() {
61
+ * Clipboard.setImage(...);
62
+ * }
63
+ * ```
64
+ * @param the content to be stored in the clipboard.
65
+ */
66
+ setImage(content: string) {
67
+ // @ts-ignore
68
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
69
+ NativeClipboard.setImage(content);
70
+ }
71
+ return;
72
+ },
73
+ /**
74
+ * (iOS and Android Only)
75
+ * Get clipboard image in base64, this method returns a `Promise`, so you can use following code to get clipboard content
76
+ * ```javascript
77
+ * async _getContent() {
78
+ * var content = await Clipboard.getImage();
79
+ * }
80
+ * ```
81
+ */
82
+ getImage(): Promise<string> {
83
+ return NativeClipboard.getImage();
84
+ },
85
+ /**
86
+ * Set content of string type. You can use following code to set clipboard content
87
+ * ```javascript
88
+ * _setContent() {
89
+ * Clipboard.setString('hello world');
90
+ * }
91
+ * ```
92
+ * @param the content to be stored in the clipboard.
93
+ */
94
+ setString(content: string) {
95
+ NativeClipboard.setString(content);
96
+ },
97
+ /**
98
+ * Set content of string array type. You can use following code to set clipboard content
99
+ * ```javascript
100
+ * _setContent() {
101
+ * Clipboard.setStrings(['hello world', 'second string']);
102
+ * }
103
+ * ```
104
+ * @param the content to be stored in the clipboard.
105
+ */
106
+ setStrings(content: string[]) {
107
+ NativeClipboard.setStrings(content);
108
+ },
109
+ /**
110
+ * Returns whether the clipboard has content or is empty.
111
+ * This method returns a `Promise`, so you can use following code to get clipboard content
112
+ * ```javascript
113
+ * async _hasContent() {
114
+ * var hasContent = await Clipboard.hasString();
115
+ * }
116
+ * ```
117
+ */
118
+ hasString() {
119
+ return NativeClipboard.hasString();
120
+ },
121
+ /**
122
+ * Returns whether the clipboard has an image or is empty.
123
+ * This method returns a `Promise`, so you can use following code to check clipboard content
124
+ * ```javascript
125
+ * async _hasContent() {
126
+ * var hasContent = await Clipboard.hasImage();
127
+ * }
128
+ * ```
129
+ */
130
+ hasImage() {
131
+ return NativeClipboard.hasImage();
132
+ },
133
+ /**
134
+ * (iOS Only)
135
+ * Returns whether the clipboard has a URL content. Can check
136
+ * if there is a URL content in clipboard without triggering PasteBoard notification for iOS 14+
137
+ * This method returns a `Promise`, so you can use following code to check for url content in clipboard.
138
+ * ```javascript
139
+ * async _hasURL() {
140
+ * var hasURL = await Clipboard.hasURL();
141
+ * }
142
+ * ```
143
+ */
144
+ hasURL() {
145
+ // @ts-ignore
146
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
147
+ return NativeClipboard.hasURL();
148
+ }
149
+ return;
150
+ },
151
+ /**
152
+ * (iOS 14+ Only)
153
+ * Returns whether the clipboard has a Number(UIPasteboardDetectionPatternNumber) content. Can check
154
+ * if there is a Number content in clipboard without triggering PasteBoard notification for iOS 14+
155
+ * This method returns a `Promise`, so you can use following code to check for Number content in clipboard.
156
+ * ```javascript
157
+ * async _hasNumber() {
158
+ * var hasNumber = await Clipboard.hasNumber();
159
+ * }
160
+ * ```
161
+ */
162
+ hasNumber() {
163
+ // @ts-ignore
164
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
165
+ return NativeClipboard.hasNumber();
166
+ }
167
+ return;
168
+ },
169
+ /**
170
+ * (iOS 14+ Only)
171
+ * Returns whether the clipboard has a WebURL(UIPasteboardDetectionPatternProbableWebURL) content. Can check
172
+ * if there is a WebURL content in clipboard without triggering PasteBoard notification for iOS 14+
173
+ * This method returns a `Promise`, so you can use following code to check for WebURL content in clipboard.
174
+ * ```javascript
175
+ * async _hasWebURL() {
176
+ * var hasWebURL = await Clipboard.hasWebURL();
177
+ * }
178
+ * ```
179
+ */
180
+ hasWebURL() {
181
+ // @ts-ignore
182
+ if (Platform.OS == 'ios' || Platform.OS == 'harmony') {
183
+ return NativeClipboard.hasWebURL();
184
+ }
185
+ return;
186
+ },
187
+ /**
188
+ * (iOS and Android Only)
189
+ * Adds a listener to get notifications when the clipboard has changed.
190
+ * If this is the first listener, turns on clipboard notifications on the native side.
191
+ * It returns EmitterSubscription where you can call "remove" to remove listener
192
+ * ```javascript
193
+ * const listener = () => console.log("changed!");
194
+ * Clipboard.addListener(listener);
195
+ * ```
196
+ */
197
+ addListener(callback: () => void): EmitterSubscription {
198
+ return addListener(callback);
199
+ },
200
+
201
+ /**
202
+ * (iOS and Android Only)
203
+ * Removes all previously registered listeners and turns off notifications on the native side.
204
+ * ```javascript
205
+ * Clipboard.removeAllListeners();
206
+ * ```
207
+ */
208
+ removeAllListeners() {
209
+ removeAllListeners();
210
+ },
211
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { Clipboard } from "./Clipboard";
2
+ export { useClipboard } from "@react-native-clipboard/clipboard/src/useClipboard";
3
+ export default Clipboard;